Updated on 2024-08-28 GMT+08:00

Modifying or Adding One or More Records in pg_hba.conf

Function

This API is used to modify or add one or more records in the pg_hba.conf file.

  • Before calling an API, you need to understand the API in Authentication.

URI

  • URI format

    PUT /v3/{project_id}/instances/{instance_id}/hba-info

  • Parameter description
    Table 1 Parameters

    Parameter

    Mandatory

    Description

    project_id

    Yes

    Project ID of a tenant in a region.

    For details about how to obtain the project ID, see Obtaining a Project ID.

    instance_id

    Yes

    Instance ID.

Request

Table 2 Request parameters

Parameter

Mandatory

Type

Description

Array elements

No

Array of objects

Parameters to be modified.

For details, see Table 3.

Table 3 Parameters

Parameter

Mandatory

Type

Description

type

Yes

String

Connection type. Enumerated values: host, hostssl, and hostnossl

database

Yes

String

Database name other than template0 and template1. Use commas (,) to separate multiple names.

user

Yes

String

Name of a user other than rdsAdmin, rdsMetric, rdsBackup, rdsRepl, and rdsProxy.

  • all indicates all database users of the DB instance.
  • Use commas (,) to separate multiple user names.

address

Yes

String

Client IP address. 0.0.0.0/0 indicates that the user can access the database from any IP address.

mask

No

String

Subnet mask. The default value is an empty string.

method

Yes

String

Authentication mode. Enumerated values: reject, md5, and scram-sha-256

priority

Yes

Integer

Configuration priority.

The priority you specified determines whether to modify or add a record in the pg_hba.conf file.

  • If the priority you specified does not exist, a new record will be added to the pg_hba.conf file.
  • If the priority you specified already exists, the record will be modified in the pg_hba.conf file.

Example Request

PUT https://rds.ap-southeast-1.myhuaweicloud.com/v3/0483b6b16e954cb88930a360d2c4e663/instances/e28979107ed04d3b8b2f1b819b8d2be3in03/hba-info

[ { 
   "type" : "host", 
   "database" : "all", 
   "user" : "all", 
   "address" : "0.0.0.0/0", 
   "mask" : "", 
   "method" : "md5", 
   "priority" : 0 
 } ]

Response

  • Normal response
    Table 4 Parameters

    Parameter

    Type

    Description

    code

    String

    Result code.

    message

    String

    Result description.

    • Example normal response
    { 
      "code" : 0, 
      "message" : "" 
    }

Status Code

Error Code

For details, see Error Codes.