Help Center/ Distributed Database Middleware/ API Reference/ APIs (Recommended)/ DDM Instances/ Modifying the Read Policy of the Associated DB Instance
Updated on 2024-08-02 GMT+08:00

Modifying the Read Policy of the Associated DB Instance

Function

This API is used to modify the read policy of the DB instance associated with a DDM instance.

Constraints

Make sure that the associated RDS instances are available and not undergoing other operations.

URI

PUT /v2/{project_id}/instances/{instance_id}/action/read-write-strategy

Table 1 Path parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

Project ID of a tenant in a region

To obtain this value, see Obtaining a Project ID.

instance_id

Yes

String

DDM instance ID

Request Parameters

Table 2 Request header parameters

Parameter

Mandatory

Type

Description

X-Auth-Token

Yes

String

User token.

You can obtain the token by calling the IAM API used to obtain a user token.

Table 3 Request body parameters

Parameter

Mandatory

Type

Description

read_weight

Yes

Map<String, Integer>

Read weights of the primary DB instance and its read replicas

  • key: DB instance ID
  • value: read weight parameter

Response Parameters

Status code: 200

Table 4 Response body parameters

Parameter

Type

Description

success

Boolean

Whether the operation is successful

instance_id

String

DDM instance ID

Status code: 400

Table 5 Response body parameters

Parameter

Type

Description

errCode

String

Service error code

externalMessage

String

Error message

Status code: 500

Table 6 Response body parameters

Parameter

Type

Description

errCode

String

Service error code

externalMessage

String

Error message

Example Request

Modifying the read policy of the associated DB instance

PUT https://{endpoint}/v2/{project_id}/instances/{instance_id}/action/read-write-strategy

{
  "read_weight" : {
    "395298ae6fb9496d95939ed556474983in01" : 60,
    "38ef52c365a14b7caeb7333137900e96in01" : 50
  }
}

Example Response

Status code: 200

ok

{
  "success" : true,
  "instance_id" : "175f5aff-xxxx-xxxx-xxxx-d0858982bbec"
}

Status code: 400

bad request

{
  "externalMessage" : "Parameter error.",
  "errCode" : "DBS.280001"
}

Status code: 500

server error

{
  "externalMessage" : "Server failure.",
  "errCode" : "DBS.200412"
}

Status Codes

Status Code

Description

200

ok

400

bad request

500

server error

Error Codes

For details, see Error Codes.