forked from docs/doc-exports
Reviewed-by: Hasko, Vladimir <vladimir.hasko@t-systems.com> Co-authored-by: Wang , Deng Ke <wangdengke2@huawei.com> Co-committed-by: Wang , Deng Ke <wangdengke2@huawei.com>
110 lines
6.3 KiB
HTML
110 lines
6.3 KiB
HTML
<a name="dds_api_0017"></a><a name="dds_api_0017"></a>
|
|
|
|
<h1 class="topictitle1">Example</h1>
|
|
<div id="body1559720153567"><p id="dds_api_0017__dds_api_0013_en-us_topic_0121682346_p51148444524">This section describes how to create a cluster instance by calling APIs.</p>
|
|
<div class="note" id="dds_api_0017__dds_api_0013_en-us_topic_0121682346_note44222521746"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="dds_api_0017__dds_api_0013_p1911091510238">The validity period of a token obtained from IAM is 24 hours. If you want to use a token for authentication, cache it to avoid frequent IAM API calling.</p>
|
|
</div></div>
|
|
<div class="section" id="dds_api_0017__dds_api_0013_en-us_topic_0121682346_section872994"><h4 class="sectiontitle">Involved APIs</h4><p class="litext" id="dds_api_0017__dds_api_0013_en-us_topic_0121682346_p23385131">If you use a token for authentication, you must obtain the user's token and add <strong id="dds_api_0017__dds_api_0013_b151471630441">X-Auth-Token</strong> to the request message header of the service API when making an API call.</p>
|
|
<ul id="dds_api_0017__dds_api_0013_en-us_topic_0121682346_ul15147458"><li id="dds_api_0017__dds_api_0013_en-us_topic_0121682346_li2109397">API for obtaining tokens from IAM</li><li id="dds_api_0017__dds_api_0013_en-us_topic_0121682346_li18984577">Creating a DDS DB instance using an open API</li></ul>
|
|
</div>
|
|
<div class="section" id="dds_api_0017__dds_api_0013_en-us_topic_0121682346_section7856948"><h4 class="sectiontitle">Procedure</h4><ol id="dds_api_0017__dds_api_0013_en-us_topic_0121682346_ol61355793"><li id="dds_api_0017__dds_api_0013_en-us_topic_0121682346_li1837051910476">Obtain the token by following instructions in section <a href="dds_api_0010.html">Authentication</a>.</li><li class="msonormal" id="dds_api_0017__dds_api_0013_en-us_topic_0121682346_li8863205171315">Send <strong id="dds_api_0017__dds_api_0013_b842352706111943">POST https://<em id="dds_api_0017__dds_api_0013_i757506785111944">DDS</em><em id="dds_api_0017__dds_api_0013_i1171559010111944"> endpoint</em>/v3/{<em id="dds_api_0017__dds_api_0013_i842352697111953">project_id</em>}/instances</strong>.</li><li class="msonormal" id="dds_api_0017__dds_api_0013_en-us_topic_0121682346_li108635517130">Add <strong id="dds_api_0017__dds_api_0013_b380022418518">X-Auth-Token</strong> to the request header.</li><li class="msonormal" id="dds_api_0017__dds_api_0013_en-us_topic_0121682346_li1586314581311">Specify the following parameters in the request body:<div class="note" id="dds_api_0017__dds_api_0013_note997910579171"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="dds_api_0017__dds_api_0013_p13980105715175">The values of <strong id="dds_api_0017__dds_api_0013_b1694932402910">region</strong> and <strong id="dds_api_0017__dds_api_0013_b4949152413299">availability_zone</strong> are used as examples.</p>
|
|
<p id="dds_api_0017__dds_api_0013_p16641171680">For details about the API used for creating DB instances, see <a href="dds_api_0020.html">Creating a DB Instance</a>.</p>
|
|
</div></div>
|
|
<pre class="codeblock" id="dds_api_0017__dds_api_0013_codeblock1044891812017">{
|
|
"name": "test-cluster", //DB instance name
|
|
"datastore": {
|
|
"type": "DDS-Community", // Database type and version
|
|
"version": "4.0", //Database version
|
|
"storage_engine": "wiredTiger" //Storage engine
|
|
},
|
|
"region": "aaa", //Region name
|
|
"availability_zone": "bbb", //AZ name
|
|
"vpc_id": "674e9b42-cd8d-4d25-a2e6-5abcc565b961", //VPC ID
|
|
"subnet_id": "f1df08c5-71d1-406a-aff0-de435a51007b", //Subnet ID
|
|
"security_group_id": "7aa51dbf-5b63-40db-9724-dad3c4828b58", //Security group ID
|
|
"password": "******", //Administrator password
|
|
"disk_encryption_id": "d4825f1b-5e47-4ff7-8ca9-0960da1770b1", //Key ID for encrypting disks
|
|
"mode": "Sharding", //Sharded-cluster instance type
|
|
"flavor": [
|
|
{
|
|
"type":"mongos", //mongos node
|
|
"num": 2, //Quantity
|
|
"spec_code": "dds.mongodb.s2.medium.4.mongos" //Node resource code
|
|
},
|
|
{
|
|
"type":"shard", //shard node
|
|
"num": 2, //Quantity
|
|
"storage": "ULTRAHIGH", //Disk type
|
|
"size": 20, //Disk size
|
|
"spec_code": "dds.mongodb.s2.medium.4.shard" //Node resource code
|
|
},
|
|
{
|
|
"type":"config", //config node
|
|
"num": 1, //Quantity
|
|
"storage": "ULTRAHIGH", //Disk type
|
|
"size": 20, //Disk size
|
|
"spec_code": "dds.mongodb.s2.large.2.config" //Node resource type
|
|
}
|
|
],
|
|
"backup_strategy": {
|
|
"start_time": "23:00-00:00", //Backup period
|
|
"keep_days": "8" //Retention days of backup files
|
|
},
|
|
"ssl_option":"1"
|
|
}</pre>
|
|
<p id="dds_api_0017__dds_api_0013_p177519401282">If the following information is displayed, the request is successful:</p>
|
|
<pre class="codeblock" id="dds_api_0017__dds_api_0013_codeblock13288144755510">{
|
|
"id": "46125c43ca4d424a9f5c97354223c4e0in02",
|
|
"name": "test-cluster",
|
|
"datastore": {
|
|
"type": "DDS-Community",
|
|
"version": "4.0",
|
|
"storage_engine": "wiredTiger"
|
|
},
|
|
"created": "2019-01-14 08:50:27",
|
|
"status": "creating",
|
|
"region": "aaa",
|
|
"availability_zone": "bbb",
|
|
"vpc_id": "674e9b42-cd8d-4d25-a2e6-5abcc565b961",
|
|
"subnet_id": "f1df08c5-71d1-406a-aff0-de435a51007b",
|
|
"security_group_id": "7aa51dbf-5b63-40db-9724-dad3c4828b58",
|
|
"disk_encryption_id": "d4825f1b-5e47-4ff7-8ca9-0960da1770b1",
|
|
"mode": "Sharding",
|
|
"flavor": [
|
|
{
|
|
"type": "mongos",
|
|
"num": 2,
|
|
"spec_code": "dds.mongodb.s2.medium.4.mongos"
|
|
},
|
|
{
|
|
"type": "shard",
|
|
"num": 2,
|
|
"size": 20,
|
|
"spec_code": "dds.mongodb.s2.medium.4.shard"
|
|
},
|
|
{
|
|
"type": "config",
|
|
"num": 1,
|
|
"size": 20,
|
|
"spec_code": "dds.mongodb.s2.large.2.config"
|
|
}
|
|
],
|
|
"backup_strategy": {
|
|
"start_time": "23:00-00:00",
|
|
"keep_days": "8"
|
|
},
|
|
"enterprise_project_id": "",
|
|
"ssl_option":"1",
|
|
"job_id": "c0c606b6-470a-48c7-97a2-6c7f146014d4"
|
|
}</pre>
|
|
<p id="dds_api_0017__dds_api_0013_p137584018285">If the request fails, an error code and error information are returned. For details, see section <a href="dds_error_code.html">Error Code</a>.</p>
|
|
</li></ol>
|
|
</div>
|
|
</div>
|
|
<div>
|
|
<div class="familylinks">
|
|
<div class="parentlink"><strong>Parent topic:</strong> <a href="dds_api_0014.html">API Calling</a></div>
|
|
</div>
|
|
</div>
|
|
|