百度智能云

All Product Document

          Cloud Database MONGODB

          Instance Related Interface

          Create a Replica Saet Instance

          Prerequisites

          The creation of an instance requires real-name authentication. Those who have not passed the real-name authentication can go to the real-name authentication under the security certification in the official website console of Baidu AI Cloud for authentication.

          Instruction

          • This interface is used to create a Baidu AI Cloud database DocDB for MongoDB instances with the same configuration and currently supports only one at a time.
          • The account cash balance is required to be greater than or equal to the instance fee so that you can create a prepaid instance.
          • The creation interface is asynchronous. And, you can check the instance state by querying specific instances.

          Request Structure

          POST /v{version}/instance?clientToken={clientToken} HTTP/1.1
          HOST: mongodb.bj.baidubce.com
          Authorization: authorization string
          
          {
              "billing":{
                  "paymentTiming": paymentTiming,
                  "reservation": {
                      "reservationLength": reservationLength
                  }
              },
              "engineVersion": dbVersion,
              "storageEngine": dbEngine,
              "dbInstanceCpuCount": dbCpu,
              "dbInstanceMemoryCapacity": dbMemory,
              "dbInstanceStorage": dbStorage,
              "dbInstanceName": dbName,
              "accountPassword": password,
              "vpcId": vpcId,
               "subnets":[
              {
                  "zoneName": zoneName,
                  "subnetId": subnetId
              }
              ]
          }

          Request Header Field

          There are no other special header fields except the common header field.

          Request Parameters

          Parameter Name Type Required Parameter Position Description
          version string Yes URL Parameters API Version Number
          clientToken string Yes Query parameter Idempotent Token is an ASCII character string with a length not exceeding 64 bits.
          billing billing Yes RequestBody parameter Order and billing-related parameters Structure and Value Reference
          purchaseCount int No RequestBody parameter A batch of instances is created with only one supported at a time by default.
          dbInstanceName string No RequestBody parameter Instance name is customized by the user, requirements:
          1) uppercase and lowercase letters, numbers, characters and special characters, such as "-", "_", "/", ".", are supported, and it must begin with a letter;
          2) The length limit is 1-65;
          3) It is not specified by default. If not specified, it is automatically generated at random.
          storageEngine string Yes RequestBody parameter Storage engine only supports value WiredTiger.
          engineVersion string Yes RequestBody parameter Database version only supports value 3.4.
          dbInstanceType string No RequestBody parameter Instance Types replicate:Instance of replica set Replicate by default
          dbInstanceCpuCount int Yes RequestBody parameter The number of CPU cores Value Reference
          dbInstanceMemoryCapacity int Yes RequestBody parameter Memory size in GB Value Reference
          dbInstanceStorage int Yes RequestBody parameter Storage space in GB. It increases by 1 GB. Value Reference
          accountPassword String No RequestBody parameter The password of the "root" account. If empty, it generates a random password. The password must meet 8 to 32 characters. English characters, numbers, and symbols must exist at the same time. Of which, symbols are limited to "!", "@", "#", "$", "%", "^", "*", "()". Passwords need to be encrypted and transmitted. All passwords are encrypted by AES 128-bit encryption algorithm. SK is used as the key, and the encrypted binary byte stream needs to be converted to hexadecimal and passed to the server as a string. Steps are as follows: byte[] bCiphertext= AES(plaintext,SK) String strHex = HexStr(bCiphertext).
          vpcId string No RequestBody parameter VPC, if not provided, belongs to the default VPC. Available VPC can be queried by calling the Query VPC List interface.
          subnets List SubnetMap No RequestBody parameter Means the subnetid of each availability zone in the vpc. If it is not the default vpc, you must specify a subnetid. You can query the subnet list by calling the Query Subnet List interface.

          SubnetMap

          Parameters’ Name Type Description
          zoneName String The list of availability zones can be queried by calling the Query List of Availability Zones interface. The ZoneName naming convention is "country-region-usable zone sequence", lowercase, for example, Beijing usable zone A is "cn-bj-a".
          subnetId String Subnet Id

          Return the Header Field

          There are no other special header fields except the common header field.

          Return parameters

          Parameter Name Type Description
          dbInstanceSimpleModels List DbInstanceSimpleModelInstance ID and link information
          **DbInstanceSimpleModel**
          Parameter Name Type Description
          dbInstanceId String Instance ID.
          connectionString StringDatabase Connection Address.
          port String Database Connection Port.
          **Request Example**
          POST /v1/instance?clientToken=be31b98c-5e41-4838-9830-9be700de5a20 HTTP/1.1
          HOST: mongodb.bj.baidubce.com
          ContentType: application/json    
          Authorization: bce-auth-v1/f81d3b34e48048fbb2634dc7882d7e21/2017-11-21T04:17:29Z/3600/host/74c506f68c65e26c633bfa104c863fffac5190fdec1ec24b7c03eb5d67d2e1de
          
          {
              "billing":{
                  "paymentTiming": "Prepaid",
                  "reservation": {
                      "reservationLength": 1
                  }
              },
              "engineVersion": "3.4",
              "storageEngine": "WiredTiger",
              "dbInstanceCpuCount": 1,
              "dbInstanceMemoryCapacity": 2,
              "dbInstanceStorage": 5,
              "dbInstanceName": "myInstance",
              "accountPassword": "be3A@12345",
              "vpcId": "vpc-jdni4sh8",
               "subnets":[
              {
                  "zoneName": "cn-bj-a",
                  "subnetId": "sbn-ien9ahe"
              }
              ]
          }

          Return Example

          {
              "dbInstanceSimpleModels" : [
                  {
                      "dbInstanceId": "mgo-1nsju5hd",
                      "connectionString: "",
                      "port": 3306
                  }
              ]
          }

          Get Instance List

          Instruction

          • The user can only view the instance list of their own ID.

          Request Structure

          GET /v{version}/instance?engineVersion={engineVersion}&storageEngine={storageEngine}&marker={marker}&maxKeys={maxKeys} HTTP/1.1
          HOST: mongodb.bj.baidubce.com
          Authorization: authorization string

          Request Header Field

          There are no other special header fields except the common header field.

          Request Parameter

          Parameter Name Type RequiredParameter PositionDescription
          versionstringYesURL parameters API Version Number
          marker stringNoQuery parameterQuery parameter It is at the start position of the query for getting list by batch, and is a character string generated by the system.
          maxKeys intNoQuery Query ParametersThe maximum number contained in each page (main instance) is usually no more than 1000, the default value is 1000.
          engineVersion stringNoQuery ParametersDatabase Version Number.
          storageEngine stringNoQuery ParametersStorage Engine。

          Return Header Field

          There are no other special header fields except the common header field.

          Return Parameter

          Parameter Name Type Description
          marker String The start position of query for the list is obtained by batch, which is a character string generated by the system.
          maxKeys int The maximum number contained in each page.
          isTruncated boolean "True" means there is still data behind, and "false" means it is already the last page.
          nextMarker String Gets the "marker" value to be passed on the next page. This field does not appear when "isTruncated" is "false".
          dbInstances List DBInstance An array composed of [DBInstance](MONGODB/API reference/Object description.md# DBInstance Object details) objects.

          Request Example

          GET /v1/instance?marker=mgo-ajdh7se3&maxKeys=1 HTTP/1.1
          HOST: mongodb.bj.baidubce.com
          ContentType: application/json    
          Authorization: bce-auth-v1/f81d3b34e48048fbb2634dc7882d7e21/2017-11-21T04:17:29Z/3600/host/74c506f68c65e26c633bfa104c863fffac5190fdec1ec24b7c03eb5d67d2e1de

          Return Example

          {
              "nextMarker": "m-xktdeMSf",
              "marker": "m-IyWRtII7",
              "maxKeys": 1,
              "isTruncated": true,
              "dbInstances":[{
                  "dbInstanceId": "mgo-ajdh7se3",
                  "dbInstanceName": "my",
                  "connectionString": "http://10.0.0.0",
                  "port": 3306,
                  "engineVersion": "3.4",
                  "storageEngine": "WiredTiger",
                  "dbInstanceClass": instanceClass,
                  "dbInstanceStorage": instanceStorage,
                  "dbInstanceType": "replicate",
                  "dbInstanceStatus": "RUNNING",
                  "paymentTiming": "Prepaid",      
                  “vpcId": "vpc-sheuq23nc",
                  "subnets": [{
                      "zoneName": "cn-bj-a",
                      "subnetId": "sbn-nfirhn3n1"
                  }],
                  "createTime": "2018-05-26T06:46:11Z"
              }]
          }

          Query Specified Instance Details

          Instruction

          • Query detailed information of specified instances

          Request Structure

          GET /v{version}/instance/{dbInstanceId} HTTP/1.1
          HOST: mongodb.bj.baidubce.com
          Authorization: authorization string

          Request Header Field

          There are no other special header fields except the common header field.

          Request Parameters

          Parameter Name Type Required?Parameter PositionDescription
          versionstringYesURL parameters API Version Number
          dbInstanceId stringYesURL Parameters Specified Instance Id
          **Return Header Field**

          There are no other special header fields except the common header field.

          Return Parameter

          Parameter Name Type Description
          dbInstanceId String Instance ID
          dbInstanceName String Instance name of database
          connectionString String Address for database connections
          port String The port of database
          storageEngine String Storage engine
          engineVersion String Database engine version
          dbInstanceType String Instance types, replicate: instances of replica set
          dbInstanceStatus String Instance state, refer to [Instance State List](MONGODB/API Reference/Appendix.md#Instance Status)
          dbInstanceCpuCount Int The number of CPU cores
          dbInstanceMemoryCapacity Int Instance memory in GB
          dbInstanceStorage Int Storage space in GB
          createTime Datetime Time of creating instance, the detailed regulations see Time and Date
          expireTime Datetime Expiring instances time, See Time and Date for standard
          vpcId String ID for VPC of instances
          subnets List SubnetMap Instance availability zone, subnet, [SubnetMap Object](MONGODB/API reference/Object. Md# SubnetMap Object details)
          paymentTiming String Payment mode, see Payment Mode.

          Request Example

          GET /v1/instance/mgo-nca3jn5j HTTP/1.1
          HOST: mongodb.bj.baidubce.com
          ContentType: application/json    
          Authorization: bce-auth-v1/f81d3b34e48048fbb2634dc7882d7e21/2017-11-21T04:17:29Z/3600/host/74c506f68c65e26c633bfa104c863fffac5190fdec1ec24b7c03eb5d67d2e1de

          Return Example

          HTTP/1.1 200 OK
          x-bce-request-id: 7869616F-7A68-6977-656E-406261696475
          Content-Type: application/json
          {
              "dbInstanceId": "mgo-mut9rhom8p3m",
              "dbInstanceName": "my",
              "connectionString": "http://10.0.0.0",
              "port": 3306,
              "storageEngine": "WiredTiger",
              "engineVersion": "3.4",
              "dbInstanceCpuCount":1,
              "dbInstanceMemoryCapacity": 2,
              "dbInstanceStorage": 5,
              "dbInstanceStatus": "RUNNING",
              "createTime": "2016-04-26T06:46:30Z",
              "expireTime": "2016-05-26T06:46:11Z",
              "dbInstanceType": "replicate",
              "vpcId": "v-kj3nc8fs",
               "paymentTiming"      : "Prepaid"
          }

          Release an Instance

          Release a single instance, after which all physical resources used by the instance are recovered, and all relevant data is lost and cannot be recovered.

          Instruction

          • Only Postpaid instances or Prepaid instances expired can be released.

          Request Structure

          DELETE /v{version}/instance/{dbInstanceId}?clientToken={clientToken} HTTP/1.1
          HOST: mongodb.bj.baidubce.com
          Authorization: authorization string

          Request Header Field

          There are no other special header fields except the common header field.

          Request Parameter

          Parameter Name Type Required?Parameter PositionDescription
          versionstringYesURL parameters API Version Number
          clientTokenstringYesQuery Parameter Idempotent Token is an ASCII character string with a length not exceeding 64 bits.
          dbInstanceId StringYesQuery ParametersInstance Id.
          **Return Header Field**

          There are no other special header fields except the common header field.

          Return Parameter

          No special return parameters

          Request Example

          DELETE /v1/instance/mgo-snfke3hs9?clientToken=be31b98c-5e41-4838-9830-9be700de5a20 HTTP/1.1
          HOST: mongodb.bj.baidubce.com
          ContentType: application/json    
          Authorization: bce-auth-v1/f81d3b34e48048fbb2634dc7882d7e21/2017-11-21T04:17:29Z/3600/host/74c506f68c65e26c633bfa104c863fffac5190fdec1ec24b7c03eb5d67d2e1de

          Return Instances

          HTTP/1.1 200 OK
          x-bce-request-id: 7869616F-7A68-6977-656E-406261696475
          Content-Type: application/json
          Content-Length: 0

          Restart the instance

          Instruction

          Only instances at the state of RUNNING can be restarted.

          Request Structure

          PUT /v{version}/instance/{dbInstanceId}?restart HTTP/1.1
          HOST: mongodb.bj.baidubce.com
          Authorization: authorization string

          Request Header Field

          There are no other special header fields except the common header field.

          Request Parameters

          Parameter Name Type Required?Parameter PositionDescription
          versionstringYesURL parameters API Version Number
          dbInstanceId stringYesURL Parameter specified instance Id
          **Return Header Field**

          There are no other special header fields except the common header field.

          Return Parameter

          No special return parameters

          Request Examples

          PUT /v1/instance/mgo-m1x9dhwe?restart HTTP/1.1
          HOST: mongodb.bj.baidubce.com
          ContentType: application/json    
          Authorization: bce-auth-v1/f81d3b34e48048fbb2634dc7882d7e21/2017-11-21T04:17:29Z/3600/host/74c506f68c65e26c633bfa104c863fffac5190fdec1ec24b7c03eb5d67d2e1de

          Return Example

          HTTP/1.1 200 OK
          x-bce-request-id: 7869616F-7A68-6977-656E-406261696475
          Content-Type: application/json
          Content-Length: 0

          Modify Instance Name

          Request Structure

          PUT /v{version}/instance/{dbInstanceId}?modifyName  HTTP/1.1
          HOST: mongodb.bj.baidubce.com
          Authorization: authorization string
          
          {
              "dbInstanceName": dbInstanceName
          }

          Request Header Field

          There are no other special header fields except the common header field.

          Request Parameter

          Parameter Name Type Required or not Parameter Position Description
          version string Yes URL Parameter API version number
          dbInstanceId string Yes URL Parameter Specified Instance Id
          dbInstanceName string Yes RequestBody parameter The requirements of instance name:
          1) uppercase and lowercase letters, numbers, characters and special characters like "-", "_", "/", "." are supported and it must begin with a letter;
          2) The length limit range from1-65.

          Return header field

          There are no other special header fields except the common header field.

          Return Parameter

          No special return parameters

          Request Example

          PUT /v1/instance/mgo-mkd4j3ns?modifyName HTTP/1.1
          HOST: mongodb.bj.baidubce.com
          ContentType: application/json    
          Authorization: bce-auth-v1/f81d3b34e48048fbb2634dc7882d7e21/2017-11-21T04:17:29Z/3600/host/74c506f68c65e26c633bfa104c863fffac5190fdec1ec24b7c03eb5d67d2e1de
          
          {
              "dbInstanceName":"myMongo"
          }

          Return Instance

          HTTP/1.1 200 OK
          x-bce-request-id: 7869616F-7A68-6977-656E-406261696475
          Content-Type: application/json
          Content-Length: 0

          Package Upgrade or Degrade

          It can expand or reduce the capacity of resources for specified instances. Memory and disk scaling operations are supported at present.

          Instruction

          • Example billing can be expanded and reduced flexibly when post-payment is adopted. Use prepaid, can not be reduced
          • Expanding or reducing capacity can be operated only when the instance is RUNNING.
          • The asynchronous interface can see if "dbInstanceStatus" recover by querying the instance details interface.

          Request Structure

          PUT /v{version}/instance/{dbInstanceId}?resize&clientToken={clientToken} HTTP/1.1
          HOST: mongodb.bj.baidubce.com
          Authorization: authorization string
          
          {
              "dbInstanceCpuCount"        : dbInstanceCpuCount,
              "dbInstanceMemoryCapacity"      : dbInstanceMemoryCapacity,
              "dbInstanceStorage"             : dbInstanceStorage
          }

          Request Header Field

          There are no other special header fields except the common header field.

          Request Parameter

          Parameter Name Type Required or not Parameter Position Description
          version string Yes URL Parameter API Version Number
          clientToken string Yes Query parameter Idempotent Token is an ASCII character string with a length not exceeding 64 bits.
          dbInstanceId string Yes URL Parameter Specified Instance Id
          dbInstanceCpuCount Int Yes RequestBody parameter The number of CPU cores Value Reference
          dbInstanceMemoryCapacity Int Yes RequestBody parameter Memory size in GB Value Reference
          dbInstanceStorage Int Yes RequestBody parameter Disk size in GB and it increases by 1 GB. Value Reference

          Return Header Field

          There are no other special header fields except the common header field.

          Return Parameter

          No special return parameters

          Request Example

          PUT /v1/instance/mgo-mdjei8sh?resize&clientToken=be31b98c-5e41-4838-9830-9be700de5a20 HTTP/1.1
          HOST: mongodb.bj.baidubce.com
          ContentType: application/json    
          Authorization: bce-auth-v1/f81d3b34e48048fbb2634dc7882d7e21/2017-11-21T04:17:29Z/3600/host/74c506f68c65e26c633bfa104c863fffac5190fdec1ec24b7c03eb5d67d2e1de
          
          {
              "dbInstanceCpuCount"        : 1,
              "dbInstanceMemoryCapacity"      : 2,
              "dbInstanceStorage"             : 5
          }

          Return Example

          HTTP/1.1 200 OK
          x-bce-request-id: 7869616F-7A68-6977-656E-406261696475
          Content-Type: application/json
          Content-Length: 0

          Modify the Account Password

          Instruction

          Change the password of the "root" account.

          Request Structure

          PUT /v{version}/instance/{dbInstanceId}?resetPassword  HTTP/1.1
          HOST: mongodb.bj.baidubce.com
          Authorization: authorization string
          
          {
              "accountPassword": accountPassword
          }

          Request Header Field

          There are no other special header fields except the common header field.

          Request Parameter

          Parameter Name Type Required or not Parameter Position Description
          version string Yes URL Parameter API Version Number
          dbInstanceId string Yes URL Parameter Specified Instance Id
          accountPassword string Yes RequestBody parameter Password of “root” account consists of 8-32 characters. English character(s), number(s) and symbol(s) must exist at the same time, symbols only "!", "@", "#", "$", "%", "^", "*", "()".
          Password needs to be encrypted and transmitted. All passwords are encrypted by the AES 128-bit encryption algorithm. SK is used as the key, and the encrypted binary byte stream needs to be converted to hexadecimal and passed to the server as a string. Steps are as follows:
          byte[] bCiphertext= AES(plaintext,SK) String strHex = HexStr(bCiphertext)

          Return Header Field

          There are no other special header fields except the common header field.

          Return Parameter

          No special return parameters

          Request Example

          PUT /v1/instance/mgo-mfjusndh?resetPassword HTTP/1.1
          HOST: mongodb.bj.baidubce.com
          Authorization: bce-auth-v1/rdsak/2016-07-03T06:13:13Z/1800/x-bce-date/{signature}
          
          {
              "accountPassword": "3869616F-7A68-6977-656E-4062BE16782"
          }

          Return Example

          HTTP/1.1 200 OK
          x-bce-request-id: 7869616F-7A68-6977-656E-406261696475
          Content-Type: application/json
          Content-Length: 0
          Previous
          Calling Instruction
          Next
          Billing Related Interfaces