Updated on 2024-09-11 GMT+08:00

Pre-Checking Resources

Function

This API is used to pre-check resources. Before calling this API:

URI

POST /v3/{project_id}/resource-check

Table 1 URI parameter

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.

Request Parameters

Table 2 Request header parameters

Parameter

Mandatory

Type

Description

X-Auth-Token

Yes

String

User token.

It can be obtained by calling the IAM API used to obtain a user token.

The value of X-Subject-Token in the response header is the token value.

Content-Type

Yes

String

Content type.

Value: application/json

X-Language

No

String

Request language type. The default value is en-us. Values:

  • en-us
  • zh-cn
Table 3 Request body parameters

Parameter

Mandatory

Type

Description

action

Yes

String

Verification type.

  • createInstance: pre-checking resources during instance creation
  • createReadonlyNode: pre-checking resources during read replica creation
  • resizeFlavor: pre-checking resources during instance specification change

resource

Yes

CheckResourceInfo object

Resource information.

Table 4 CheckResourceInfo

Parameter

Mandatory

Type

Description

enterprise_project_id

No

String

Enterprise project ID. This parameter is mandatory when action is set to createInstance.

instance_num

No

Integer

Number of instances. This parameter is mandatory when action is set to createInstance.

mode

No

String

Instance type. Its value is Cluster. This parameter is mandatory when action is set to createInstance.

availability_zone_mode

No

String

AZ type. The value can be single or multi. This parameter is mandatory when action is set to createInstance.

node_num

No

Integer

Number of nodes. This parameter is mandatory when action is set to createInstance or createReadonlyNode.

flavor_ref

No

String

Specification code. This parameter is mandatory when action is set to createInstance or resizeFlavor.

availability_zone

No

String

AZ code.

subnet_id

No

String

Subnet ID. This parameter is mandatory when action is set to createInstance.

instance_id

No

String

Instance ID. This parameter is mandatory when action is set to createReadonlyNode or resizeFlavor.

Response Parameters

Status code: 200

Table 5 Response body parameter

Parameter

Type

Description

result

Boolean

Returned result.

  • true: The check is passed.
  • false: The check fails.

Status code: 400

Table 6 Response body parameters

Parameter

Type

Description

error_code

String

Error code.

error_msg

String

Error message.

Status code: 500

Table 7 Response body parameters

Parameter

Type

Description

error_code

String

Error code.

error_msg

String

Error message.

Example Request

  • Pre-checking resources during instance creation
    POST https://{endpoint}/v3/97b026aa9cc4417888c14c84a1ad9860/resource-check
    
    {
      "action" : "createInstance",
      "resource" : {
        "enterprise_project_id" : 0,
        "instance_num" : 1,
        "mode" : "Cluster",
        "availability_zone_mode" : "single",
        "node_num" : 2,
        "flavor_ref" : "gaussdb.mysql.xlarge.x86.4",
        "availability_zone" : "cn-southwest-244b",
        "subnet_id" : "1e9f71dd-9192-4c0d-9739-161d8dcca68c"
      }
    }
  • Pre-checking resources during read replica creation
    POST https://{endpoint}/v3/97b026aa9cc4417888c14c84a1ad9860/resource-check
    
    {
      "action" : "createReadonlyNode",
      "resource" : {
        "instance_id" : "376e0847a2224e95afcd3e607eccd544in07",
        "node_num" : 1
      }
    }
  • Pre-checking resources during instance specification change
    POST https://{endpoint}/v3/97b026aa9cc4417888c14c84a1ad9860/resource-check
    
    {
      "action" : "resizeFlavor",
      "resource" : {
        "instance_id" : "376e0847a2224e95afcd3e607eccd544in07",
        "flavor_ref" : "gaussdb.mysql.xlarge.x86.4"
      }
    }

Example Response

Status code: 200

Success.

{
  "result" : true
}

Status Code

Status Code

Description

200

Success.

400

Client error.

500

Server error.

Error Code

For details, see Error Codes.