Updated on 2025-08-20 GMT+08:00

Enabling Database Proxy

Function

This API is used to enable database proxy for a DB instance.

URI

  • URI format

    POST /v3/{project_id}/instances/{instance_id}/proxy/open

  • 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

    You can obtain the value of this parameter from the id field in Table 4.

    Default Value

    N/A

Request

Table 2 Parameters

Parameter

Mandatory

Type

Description

flavor_ref

Yes

String

Definition

Specification code of the database proxy.

Constraints

N/A

Range

  • When the site supports the database proxy in primary/standby mode, this parameter does not take effect.
  • When the site supports the database proxy in cluster mode, set this parameter to the value of code in the response body in Querying Database Proxy Specifications.

Default Value

N/A

node_num

Yes

Integer

Definition

Number of database proxy nodes.

Constraints

N/A

Range

  • When the site supports the database proxy in primary/standby mode, set this parameter to 2.
  • When the site supports the database proxy in cluster mode, the minimum value of this parameter is 2. For the maximum value, see the value of max_proxy_node_num in the response body in Querying Database Proxies.

Default Value

N/A

proxy_name

No

String

Definition

Name of the database proxy. Database proxies of the same type can have the same name under the same tenant.

Constraints

N/A

Range

The name must start with a letter and consist of 4 to 64 characters. Only letters, digits, hyphens (-), underscores (_), and periods (.) are allowed.

If this parameter is not specified or the site supports only the database proxy in primary/standby mode, a random name will be generated.

Default Value

N/A

proxy_mode

No

String

Definition

Read/write mode of the database proxy.

Constraints

N/A

Range

  • readwrite (default value): readable and writable
  • readonly: read-only

Default Value

N/A

route_mode

No

Integer

Definition

Routing policy of the database proxy.

Constraints

N/A

Range

  • 0: weighted
  • 1: load balancing (The primary node does not process read requests.)
  • 2: load balancing (The primary node processes read requests.)

Default Value

N/A

nodes_read_weight

Yes

Array of objects

Definition

Read weights of database nodes. For details, see Table 3.

Constraints

  • If proxy_mode is set to readonly, you need to configure a weight for at least one read replica.
  • If route_mode is set to a value greater than 0, the weight configured for the primary instance does not take effect.

subnet_id

No

String

Definition

Subnet ID in the VPC hosting the DB instance.

Constraints

To use this parameter, contact customer service.

Range

The value can be any subnet ID in the VPC to which the instance belongs. To obtain the subnet ID, go to the subnet details page on the VPC console.

Default Value

N/A

Table 3 nodes_read_weight field data structure description

Parameter

Mandatory

Type

Description

instance_id

Yes

String

Definition

Instance ID.

Constraints

N/A

Range

N/A

Default Value

N/A

weight

Yes

Integer

Definition

Read weight assigned.

Constraints

N/A

Range

N/A

Default Value

N/A

Example Request

Enable database proxy for a DB instance.

POST https://rds.ap-southeast-1.myhuaweicloud.com/v3/23a50154cf494ec9ad6883979a12db0a/instances/920ec36cef814a8b830a5bed50d9a088in01/proxy/open

{
    "flavor_ref": "rds.proxy.xlarge.2",
    "node_num": 2,
    "proxy_name": "proxy-test",
	"nodes_read_weight": [
        {
            "instance_id": "917c67424dd54af3addf537a069e5b20in01",
            "weight": 1
        }
    ]
}

Response

  • Normal response
    Table 4 Parameters

    Parameter

    Type

    Description

    job_id

    String

    Definition

    Task ID.

    Range

    N/A

  • Example normal response
    { 
       "job_id" : "09908118-8e32-4742-982a-7be194f59e1d" 
     }
  • Abnormal response

    For details, see Abnormal Request Results.

Status Code

Error Code

For details, see Error Codes.