Updated on 2025-08-20 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.

URI

  • URI format

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

  • Parameter description
    Table 1 Parameters

    Parameter

    Mandatory

    Description

    project_id

    Yes

    Definition

    Project ID of a tenant in a region.

    To obtain the value, see Obtaining a Project ID.

    Constraints

    N/A

    Range

    N/A

    Default Value

    N/A

    instance_id

    Yes

    Definition

    Instance ID.

    Constraints

    N/A

    Range

    N/A

    Default Value

    N/A

Request

Table 2 Request parameters

Parameter

Mandatory

Type

Description

Array elements

No

Array of objects

Definition

Parameters to be modified.

For details, see Table 3.

Constraints

N/A

Table 3 Parameters

Parameter

Mandatory

Type

Description

type

Yes

String

Definition

Connection type.

Constraints

N/A

Range

Enumerated values: host, hostssl, and hostnossl

Default Value

N/A

database

Yes

String

Definition

Database name.

Constraints

N/A

Range

The value can be any name other than template0 and template1. Use commas (,) to separate multiple names.

Default Value

N/A

user

Yes

String

Definition

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

Constraints

N/A

Range

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

Default Value

N/A

address

Yes

String

Definition

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

Constraints

N/A

Range

N/A

Default Value

N/A

mask

No

String

Definition

Subnet mask.

Constraints

N/A

Range

N/A

Default Value

An empty string

method

Yes

String

Definition

Authentication mode.

Constraints

N/A

Range

Enumerated values: reject, md5, and scram-sha-256

Default Value

N/A

priority

Yes

Integer

Definition

Configuration priority.

Constraints

N/A

Range

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.

Default Value

N/A

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

    Definition

    Result code.

    Range

    N/A

    message

    String

    Definition

    Result description.

    Range

    N/A

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

Status Code

Error Code

For details, see Error Codes.