doc-exports/docs/css/api-ref/css_03_0062.html
zhengxiu 6093788563 css api 20241120 version
Reviewed-by: Pruthi, Vineet <vineet.pruthi@t-systems.com>
Co-authored-by: zhengxiu <zhengxiu@huawei.com>
Co-committed-by: zhengxiu <zhengxiu@huawei.com>
2024-11-28 11:30:39 +00:00

79 lines
7.1 KiB
HTML

<a name="css_03_0062"></a><a name="css_03_0062"></a>
<h1 class="topictitle1">Creating a Pay-per-Use Elasticsearch Cluster</h1>
<div id="body8662426"><p id="css_03_0062__en-us_topic_0171541475_en-us_topic_0171174235_p51148444524">This section describes how to create a CSS cluster by using APIs. <a href="#css_03_0062__en-us_topic_0171541475_en-us_topic_0171174235_fig4812113917173">Figure 1</a> illustrates the API calling process.</p>
<div class="fignone" id="css_03_0062__en-us_topic_0171541475_en-us_topic_0171174235_fig4812113917173"><a name="css_03_0062__en-us_topic_0171541475_en-us_topic_0171174235_fig4812113917173"></a><a name="en-us_topic_0171541475_en-us_topic_0171174235_fig4812113917173"></a><span class="figcap"><b>Figure 1 </b>API calling process</span><br><span><img class="vsd" id="css_03_0062__en-us_topic_0171541475_image68441061565" src="en-us_image_0000002119117513.png"></span></div>
<div class="note" id="css_03_0062__en-us_topic_0171541475_en-us_topic_0171174235_en-us_topic_0111418639_note78851219195410"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="css_03_0062__en-us_topic_0171541475_en-us_topic_0171174235_en-us_topic_0111418639_p13885419115419">The token obtained on IAM is valid for only 24 hours. If you want to use one token for authentication, you can cache it to avoid frequent calling.</p>
</div></div>
<div class="section" id="css_03_0062__en-us_topic_0171541475_en-us_topic_0171174235_en-us_topic_0111418639_section101152312311"><h4 class="sectiontitle">Involved APIs</h4><p id="css_03_0062__en-us_topic_0171541475_en-us_topic_0171174235_en-us_topic_0111418639_p208391848152419">If you use a token for authentication, you must obtain the token and add <strong id="css_03_0062__en-us_topic_0171541475_en-us_topic_0171174235_en-us_topic_0111418639_b93839580536">X-Auth-Token</strong> to the request header of the API when making an API call.</p>
<ul id="css_03_0062__en-us_topic_0171541475_en-us_topic_0171174235_en-us_topic_0111418639_ul18839104814240"><li id="css_03_0062__en-us_topic_0171541475_en-us_topic_0171174235_en-us_topic_0111418639_li48397486241">API for obtaining tokens from IAM</li><li id="css_03_0062__en-us_topic_0171541475_en-us_topic_0171174235_en-us_topic_0111418639_li1583954822419">API for creating CSS clusters</li></ul>
</div>
<div class="section" id="css_03_0062__en-us_topic_0171541475_en-us_topic_0171174235_en-us_topic_0111418639_section84735913247"><h4 class="sectiontitle">Procedure</h4><ol id="css_03_0062__en-us_topic_0171541475_en-us_topic_0171174235_en-us_topic_0111418639_ol17437102653012"><li id="css_03_0062__en-us_topic_0171541475_en-us_topic_0171174235_li1265543762911"><a name="css_03_0062__en-us_topic_0171541475_en-us_topic_0171174235_li1265543762911"></a><a name="en-us_topic_0171541475_en-us_topic_0171174235_li1265543762911"></a>Obtain the token. Send <strong id="css_03_0062__en-us_topic_0171541475_b245372905916">POST https://</strong><strong id="css_03_0062__en-us_topic_0171541475_b73441112826">IAM</strong><strong id="css_03_0062__en-us_topic_0171541475_b545314299599"><em id="css_03_0062__en-us_topic_0171541475_i1334010121129"> endpoint</em></strong><strong id="css_03_0062__en-us_topic_0171541475_b245442935917">/v3/auth/tokens</strong>.<p id="css_03_0062__en-us_topic_0171541475_p175004152139">Obtain the token by following instructions in <a href="css_03_0079.html">Authentication</a>.</p>
<p id="css_03_0062__en-us_topic_0171541475_p67561824152">The value of <span class="parmname" id="css_03_0062__en-us_topic_0171541475_en-us_topic_0000001134543542_en-us_topic_0000001096804707_en-us_topic_0000001127381857_en-us_topic_0000001096804707_en-us_topic_0000001096752971_parmname33391418185012"><b>X-Subject-Token</b></span> in the response header is the user token.</p>
</li><li id="css_03_0062__en-us_topic_0171541475_en-us_topic_0171174235_en-us_topic_0111418639_li207811546133015">Add <strong id="css_03_0062__en-us_topic_0171541475_b982017561818">Content-type</strong> and <strong id="css_03_0062__en-us_topic_0171541475_b41544017912">X-Auth-Token</strong> to the request header.<ul id="css_03_0062__en-us_topic_0171541475_ul20175151465914"><li id="css_03_0062__en-us_topic_0171541475_en-us_topic_0168405763_li972916419595"><strong id="css_03_0062__b19462420204918">Content-Type</strong>: The request body type or format. Its default value is <span class="parmvalue" id="css_03_0062__parmvalue2046211200498"><b>application/json</b></span>.</li><li id="css_03_0062__en-us_topic_0171541475_en-us_topic_0168405763_li1642421012595"><strong id="css_03_0062__en-us_topic_0171541475_b3399819694">X-Auth-Token</strong>: Enter the user token obtained in <a href="#css_03_0062__en-us_topic_0171541475_en-us_topic_0171174235_li1265543762911">1</a>.</li></ul>
</li><li id="css_03_0062__en-us_topic_0171541475_en-us_topic_0171174235_en-us_topic_0111418639_li17564135310303">Send a cluster creation request and specify the following parameters in the request body:<p id="css_03_0062__p72921554331"><a name="css_03_0062__en-us_topic_0171541475_en-us_topic_0171174235_en-us_topic_0111418639_li17564135310303"></a><a name="en-us_topic_0171541475_en-us_topic_0171174235_en-us_topic_0111418639_li17564135310303"></a></p>
<pre class="screen" id="css_03_0062__screen20940175153419">POST /v1.0/6204a5bd270343b5885144cf9c8c158d/clusters
{
"cluster" : {
"instance" : {
"flavorRef" : "ess.spec-4u16g",
"volume" : {
"volume_type" : "COMMON",
"size" : 120
},
"nics" : {
"vpcId" : "{VPC ID}",
"netId" : "{NET ID}",
"securityGroupId" : "{Security group ID}"
},
"availability_zone" : "{AZ CODE}"
},
"datastore" : {
"version" : "{cluster-version}",
"type" : "elasticsearch"
},
"name" : "cluster-name",
"instanceNum" : 3,
"backupStrategy" : {
"period" : "16:00 GMT+08:00",
"prefix" : "snapshot",
"keepday" : 7,
"frequency" : "DAY",
"bucket" : "css-obs-backup",
"basePath" : "css_repository/obs-path",
"agency" : "css_obs_agency"
},
"httpsEnable" : true,
"authorityEnable" : true,
"adminPwd" : "{password}",
"enterprise_project_id" : "0",
"tags" : [ {
"key" : "k1",
"value" : "v1"
}, {
"key" : "k2",
"value" : "v2"
} ]
}
}</pre>
<p id="css_03_0062__p133011657163313"></p>
<div class="p" id="css_03_0062__en-us_topic_0171541475_p1480001531319">Check the response message. The following is an example response:<pre class="screen" id="css_03_0062__en-us_topic_0171541475_en-us_topic_0171174235_screen4345181711110">{
"cluster": {
"id": "ef683016-871e-48bc-bf93-74a29d60d214",
"name": "ES-Test"
}
}</pre>
</div>
<p id="css_03_0062__en-us_topic_0171541475_p7110922185113">If the request is successful, 200 OK is returned.</p>
<p id="css_03_0062__en-us_topic_0171541475_en-us_topic_0171174235_p250142016315">If the request fails, an error code and error information are returned. For details, see section <a href="css_03_0075.html">Status Codes</a>.</p>
</li></ol>
</div>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="en-us_topic_0000002083557490.html">Examples</a></div>
</div>
</div>