doc-exports/docs/smn/api-ref/smn_api_56002.html
guoyanyan feae604f17 SMN API 20220929 v1
Reviewed-by: gtema <artem.goncharov@gmail.com>
Co-authored-by: guoyanyan <guoyanyan3@huawei.com>
Co-committed-by: guoyanyan <guoyanyan3@huawei.com>
2022-11-10 09:15:21 +00:00

180 lines
14 KiB
HTML

<a name="smn_api_56002"></a><a name="smn_api_56002"></a>
<h1 class="topictitle1">Adding or Deleting Resource Tags in Batches</h1>
<div id="body1523350913840"><div class="section" id="smn_api_56002__section11166154101819"><h4 class="sectiontitle">Description</h4><ul id="smn_api_56002__ul4619132192719"><li id="smn_api_56002__li7619153252712">API name<p id="smn_api_56002__p1160318578274">BatchCreateOrDeleteResourceTags</p>
</li><li id="smn_api_56002__li13728183962718">Function<p id="smn_api_56002__p1063411548188">Add or delete tags for a specified resource in batches.</p>
<p id="smn_api_56002__p12634105461810">You can add a maximum of 10 tags to a resource.</p>
<div class="note" id="smn_api_56002__note38901949191911"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="smn_api_56002__p15634125481814">The API is idempotent. When you are to create tags, if there are duplicate keys in the request body, an error is reported.</p>
<p id="smn_api_56002__p96344545184">If a to-be-created tag has the same key as an existing tag, the tag will be created and overwrite the existing one.</p>
<p id="smn_api_56002__p287405491919">When tags are being deleted and some tags do not exist, the operation is considered successful by default. The character set of the tags will not be checked.</p>
</div></div>
</li></ul>
</div>
<div class="section" id="smn_api_56002__section171812054161811"><h4 class="sectiontitle">URI</h4><ul id="smn_api_56002__ul1463418547181"><li id="smn_api_56002__li063413540188">URI format<p id="smn_api_56002__p12634155481813">POST /v2/{project_id}/{resource_type}/{resource_id}/tags/action</p>
</li><li id="smn_api_56002__li1563445419187">Parameter description
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="smn_api_56002__table4181105410187" frame="border" border="1" rules="all"><thead align="left"><tr id="smn_api_56002__row9634205461818"><th align="left" class="cellrowborder" valign="top" width="22.972297229722972%" id="mcps1.3.2.2.2.1.1.5.1.1"><p id="smn_api_56002__p13634105451820"><strong id="smn_api_56002__b842352706191030">Parameter</strong></p>
</th>
<th align="left" class="cellrowborder" valign="top" width="22.972297229722972%" id="mcps1.3.2.2.2.1.1.5.1.2"><p id="smn_api_56002__p9634155461818"><strong id="smn_api_56002__b593421527191713">Mandatory</strong></p>
</th>
<th align="left" class="cellrowborder" valign="top" width="20.27202720272027%" id="mcps1.3.2.2.2.1.1.5.1.3"><p id="smn_api_56002__p176342054151820"><strong id="smn_api_56002__b84235270619112">Type</strong></p>
</th>
<th align="left" class="cellrowborder" valign="top" width="33.78337833783379%" id="mcps1.3.2.2.2.1.1.5.1.4"><p id="smn_api_56002__p8634185410184"><strong id="smn_api_56002__b84235270619115">Description</strong></p>
</th>
</tr>
</thead>
<tbody><tr id="smn_api_56002__row863485461812"><td class="cellrowborder" valign="top" width="22.972297229722972%" headers="mcps1.3.2.2.2.1.1.5.1.1 "><p id="smn_api_56002__p15634154191818">project_id</p>
</td>
<td class="cellrowborder" valign="top" width="22.972297229722972%" headers="mcps1.3.2.2.2.1.1.5.1.2 "><p id="smn_api_56002__p36341354151815">Yes</p>
</td>
<td class="cellrowborder" valign="top" width="20.27202720272027%" headers="mcps1.3.2.2.2.1.1.5.1.3 "><p id="smn_api_56002__p196341954171820">String</p>
</td>
<td class="cellrowborder" valign="top" width="33.78337833783379%" headers="mcps1.3.2.2.2.1.1.5.1.4 "><p id="smn_api_56002__p11634105415185">Project ID</p>
<p id="smn_api_56002__p118812918506">See <a href="smn_api_66000.html">Obtaining a Project ID</a>.</p>
</td>
</tr>
<tr id="smn_api_56002__row1563419545185"><td class="cellrowborder" valign="top" width="22.972297229722972%" headers="mcps1.3.2.2.2.1.1.5.1.1 "><p id="smn_api_56002__p99531421797">resource_type</p>
</td>
<td class="cellrowborder" valign="top" width="22.972297229722972%" headers="mcps1.3.2.2.2.1.1.5.1.2 "><p id="smn_api_56002__p1495310421799">Yes</p>
</td>
<td class="cellrowborder" valign="top" width="20.27202720272027%" headers="mcps1.3.2.2.2.1.1.5.1.3 "><p id="smn_api_56002__p149531342296">String</p>
</td>
<td class="cellrowborder" valign="top" width="33.78337833783379%" headers="mcps1.3.2.2.2.1.1.5.1.4 "><p id="smn_api_56002__p52661238184213">Resource type</p>
<p id="smn_api_56002__p278251314214">The value can be the following:</p>
<p id="smn_api_56002__p14550953686"><strong id="smn_api_56002__b55671313121318">smn_topic</strong>: topic</p>
<p id="smn_api_56002__p8682201993"></p>
<p id="smn_api_56002__p11902194391011"></p>
</td>
</tr>
<tr id="smn_api_56002__row6634254101816"><td class="cellrowborder" valign="top" width="22.972297229722972%" headers="mcps1.3.2.2.2.1.1.5.1.1 "><p id="smn_api_56002__p1363485413187">resource_id</p>
</td>
<td class="cellrowborder" valign="top" width="22.972297229722972%" headers="mcps1.3.2.2.2.1.1.5.1.2 "><p id="smn_api_56002__p463417547182">Yes</p>
</td>
<td class="cellrowborder" valign="top" width="20.27202720272027%" headers="mcps1.3.2.2.2.1.1.5.1.3 "><p id="smn_api_56002__p7634195417180">String</p>
</td>
<td class="cellrowborder" valign="top" width="33.78337833783379%" headers="mcps1.3.2.2.2.1.1.5.1.4 "><p id="smn_api_56002__p176341254201810">Resource ID</p>
<p id="smn_api_56002__p57491711103514">Obtain a resource ID:</p>
<ul id="smn_api_56002__ul969372310137"><li id="smn_api_56002__li969342316131">Add <strong id="smn_api_56002__b1046628401">X-SMN-RESOURCEID-TYPE=name</strong> in the request header and set the resource ID to the topic name.</li><li id="smn_api_56002__li1669312233134">Call the <strong id="smn_api_56002__b84235270694340">GetResourceInstances</strong> API to obtain the resource ID.</li></ul>
</td>
</tr>
</tbody>
</table>
</div>
</li></ul>
</div>
<div class="section" id="smn_api_56002__section2197105410186"><h4 class="sectiontitle">Request</h4><ul id="smn_api_56002__ul18634105451811"><li id="smn_api_56002__li1634125441812">Parameter description
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="smn_api_56002__table4213165415189" frame="border" border="1" rules="all"><thead align="left"><tr id="smn_api_56002__row16634145491814"><th align="left" class="cellrowborder" valign="top" width="16.88%" id="mcps1.3.3.2.1.1.1.5.1.1"><p id="smn_api_56002__p463435412187"><strong id="smn_api_56002__b492621386">Parameter</strong></p>
</th>
<th align="left" class="cellrowborder" valign="top" width="24.68%" id="mcps1.3.3.2.1.1.1.5.1.2"><p id="smn_api_56002__p16634054131814"><strong id="smn_api_56002__b1873939549">Mandatory</strong></p>
</th>
<th align="left" class="cellrowborder" valign="top" width="20.78%" id="mcps1.3.3.2.1.1.1.5.1.3"><p id="smn_api_56002__p9634155414185"><strong id="smn_api_56002__b207078290">Type</strong></p>
</th>
<th align="left" class="cellrowborder" valign="top" width="37.66%" id="mcps1.3.3.2.1.1.1.5.1.4"><p id="smn_api_56002__p2063413547181"><strong id="smn_api_56002__b674219474">Description</strong></p>
</th>
</tr>
</thead>
<tbody><tr id="smn_api_56002__row18634195431818"><td class="cellrowborder" valign="top" width="16.88%" headers="mcps1.3.3.2.1.1.1.5.1.1 "><p id="smn_api_56002__p156341354131810">tags</p>
</td>
<td class="cellrowborder" valign="top" width="24.68%" headers="mcps1.3.3.2.1.1.1.5.1.2 "><p id="smn_api_56002__p763418543186">Yes</p>
</td>
<td class="cellrowborder" valign="top" width="20.78%" headers="mcps1.3.3.2.1.1.1.5.1.3 "><p id="smn_api_56002__p563413548183">Resource_tag structure array</p>
</td>
<td class="cellrowborder" valign="top" width="37.66%" headers="mcps1.3.3.2.1.1.1.5.1.4 "><p id="smn_api_56002__p7634654141810">Tag list. For details, see <a href="#smn_api_56002__table1127111434346">Table 1</a>.</p>
<p id="smn_api_56002__p14459433554">When you delete tags, the tag structure cannot be missing, and the key cannot be left blank or be an empty string. The system does not check the character set when deleting a tag.</p>
</td>
</tr>
<tr id="smn_api_56002__row1263445419182"><td class="cellrowborder" valign="top" width="16.88%" headers="mcps1.3.3.2.1.1.1.5.1.1 "><p id="smn_api_56002__p16341754191812">action</p>
</td>
<td class="cellrowborder" valign="top" width="24.68%" headers="mcps1.3.3.2.1.1.1.5.1.2 "><p id="smn_api_56002__p363415545188">Yes</p>
</td>
<td class="cellrowborder" valign="top" width="20.78%" headers="mcps1.3.3.2.1.1.1.5.1.3 "><p id="smn_api_56002__p176349545181">String</p>
</td>
<td class="cellrowborder" valign="top" width="37.66%" headers="mcps1.3.3.2.1.1.1.5.1.4 "><p id="smn_api_56002__p186342054101815">Operation to be performed, which can be <strong id="smn_api_56002__b842352706101829">create</strong> or <strong id="smn_api_56002__b842352706101833">delete</strong></p>
</td>
</tr>
</tbody>
</table>
</div>
<div class="tablenoborder"><a name="smn_api_56002__table1127111434346"></a><a name="table1127111434346"></a><table cellpadding="4" cellspacing="0" summary="" id="smn_api_56002__table1127111434346" frame="border" border="1" rules="all"><caption><b>Table 1 </b>Resource_tag structure</caption><thead align="left"><tr id="smn_api_56002__smn_api_56001_row139311651171713"><th align="left" class="cellrowborder" valign="top" width="18.81188118811881%" id="mcps1.3.3.2.1.2.2.6.1.1"><p id="smn_api_56002__smn_api_56001_p993135161718"><strong id="smn_api_56002__smn_api_56001_b6377153915111">Parameter</strong></p>
</th>
<th align="left" class="cellrowborder" valign="top" width="15.841584158415841%" id="mcps1.3.3.2.1.2.2.6.1.2"><p id="smn_api_56002__smn_api_56001_p19311451131719"><strong id="smn_api_56002__smn_api_56001_b553769561">Mandatory</strong></p>
</th>
<th align="left" class="cellrowborder" valign="top" width="15.841584158415841%" id="mcps1.3.3.2.1.2.2.6.1.3"><p id="smn_api_56002__smn_api_56001_p13931451141710"><strong id="smn_api_56002__smn_api_56001_b1343797695">Type</strong></p>
</th>
<th align="left" class="cellrowborder" valign="top" width="12.871287128712872%" id="mcps1.3.3.2.1.2.2.6.1.4"><p id="smn_api_56002__smn_api_56001_p393125141712"><strong id="smn_api_56002__smn_api_56001_b36311841175120">Description</strong></p>
</th>
<th align="left" class="cellrowborder" valign="top" width="36.633663366336634%" id="mcps1.3.3.2.1.2.2.6.1.5"><p id="smn_api_56002__smn_api_56001_p1715443212610"><strong id="smn_api_56002__smn_api_56001_b134437429517">Constraint</strong></p>
</th>
</tr>
</thead>
<tbody><tr id="smn_api_56002__smn_api_56001_row3931105113173"><td class="cellrowborder" valign="top" width="18.81188118811881%" headers="mcps1.3.3.2.1.2.2.6.1.1 "><p id="smn_api_56002__smn_api_56001_p17931145131711">key</p>
</td>
<td class="cellrowborder" valign="top" width="15.841584158415841%" headers="mcps1.3.3.2.1.2.2.6.1.2 "><p id="smn_api_56002__smn_api_56001_p9931145120179">Yes</p>
</td>
<td class="cellrowborder" valign="top" width="15.841584158415841%" headers="mcps1.3.3.2.1.2.2.6.1.3 "><p id="smn_api_56002__smn_api_56001_p16931751111714">String</p>
</td>
<td class="cellrowborder" valign="top" width="12.871287128712872%" headers="mcps1.3.3.2.1.2.2.6.1.4 "><p id="smn_api_56002__smn_api_56001_p393175116171">Tag key</p>
</td>
<td class="cellrowborder" valign="top" width="36.633663366336634%" headers="mcps1.3.3.2.1.2.2.6.1.5 "><p id="smn_api_56002__smn_api_56001_p171314419267">The key contains 36 Unicode characters at most and cannot be blank or an empty string. It can contain only digits, letters, hyphens (-), and underscores (_) and must not start or end with a space.</p>
</td>
</tr>
<tr id="smn_api_56002__smn_api_56001_row39312515173"><td class="cellrowborder" valign="top" width="18.81188118811881%" headers="mcps1.3.3.2.1.2.2.6.1.1 "><p id="smn_api_56002__smn_api_56001_p09311651171711">value</p>
</td>
<td class="cellrowborder" valign="top" width="15.841584158415841%" headers="mcps1.3.3.2.1.2.2.6.1.2 "><p id="smn_api_56002__smn_api_56001_p1693155113179">Yes</p>
</td>
<td class="cellrowborder" valign="top" width="15.841584158415841%" headers="mcps1.3.3.2.1.2.2.6.1.3 "><p id="smn_api_56002__smn_api_56001_p14931751141720">String</p>
</td>
<td class="cellrowborder" valign="top" width="12.871287128712872%" headers="mcps1.3.3.2.1.2.2.6.1.4 "><p id="smn_api_56002__smn_api_56001_p159313515179">Tag value</p>
</td>
<td class="cellrowborder" valign="top" width="36.633663366336634%" headers="mcps1.3.3.2.1.2.2.6.1.5 "><p id="smn_api_56002__smn_api_56001_p344164632615">Each value contains 43 Unicode characters at most and can be an empty string. It can contain only digits, letters, hyphens (-), and underscores (_) and must not start or end with a space.</p>
</td>
</tr>
</tbody>
</table>
</div>
</li></ul>
<ul id="smn_api_56002__ul14634354201810"><li id="smn_api_56002__li10634254181820">Request example<pre class="screen" id="smn_api_56002__screen0634115471810">POST https://{SMN_Endpoint}/v2/{project_id}/{resource_type}/{resource_id}/tags/action</pre>
</li></ul>
<ul id="smn_api_56002__ul1634154191811"><li id="smn_api_56002__li263415471813">Request body<div class="p" id="smn_api_56002__p2877151762820">Request body when <strong id="smn_api_56002__b19982105913459">action</strong> is set to <strong id="smn_api_56002__b13989159194510">create</strong><pre class="screen" id="smn_api_56002__screen4299414122816">{
"action": "create",
"tags": [
{
"key": "key1",
"value": "value1"
},
{
"key": "key",
"value": "value3"
}
]
}</pre>
</div>
<p id="smn_api_56002__p15299181414286">Request body when <strong id="smn_api_56002__b249121214615">action</strong> is set to <strong id="smn_api_56002__b2511612104617">delete</strong></p>
<pre class="screen" id="smn_api_56002__screen16299314172819">{
"action": "delete",
"tags": [
{
"key": "key1"
},
{
"key": "key2",
"value": "value3"
}
]
}</pre>
</li></ul>
</div>
<div class="section" id="smn_api_56002__section112591544183"><h4 class="sectiontitle">Response</h4><p id="smn_api_56002__p0634115441814">None</p>
</div>
<div class="section" id="smn_api_56002__section10259185419185"><h4 class="sectiontitle">Returned Value</h4><p id="smn_api_56002__p144041524121813">See <a href="smn_api_63002.html">Returned Value</a>.</p>
</div>
<div class="section" id="smn_api_56002__section73211020122511"><h4 class="sectiontitle">Error Code</h4><p id="smn_api_56002__p9759142919265">See section <a href="smn_api_64000.html">Error Code</a>.</p>
</div>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="smn_api_56000.html">Resource Tag Operations</a></div>
</div>
</div>