doc-exports/docs/smn/api-ref/smn_api_56003.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

147 lines
12 KiB
HTML

<a name="smn_api_56003"></a><a name="smn_api_56003"></a>
<h1 class="topictitle1">Adding a Resource Tag</h1>
<div id="body1523350913840"><div class="section" id="smn_api_56003__section6275354111818"><h4 class="sectiontitle">Description</h4><ul id="smn_api_56003__ul33304380203733"><li id="smn_api_56003__li51147505203733">API name<p id="smn_api_56003__p38624841203741">CreateResourceTag</p>
</li></ul>
<ul id="smn_api_56003__ul20998054203745"><li id="smn_api_56003__li46884910203750">Function<p id="smn_api_56003__p12634105461810">You can add a maximum of 10 tags to a resource.</p>
<p id="smn_api_56003__p6634154131819">The API is idempotent. 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>
</li></ul>
</div>
<div class="section" id="smn_api_56003__section12757544187"><h4 class="sectiontitle">URI</h4><ul id="smn_api_56003__ul9634254141820"><li id="smn_api_56003__li96341154191814">URI format<p id="smn_api_56003__p1863405461812">POST /v2/{project_id}/{resource_type}/{resource_id}/tags</p>
</li><li id="smn_api_56003__li4634125417181">Parameter description
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="smn_api_56003__table1029119541182" frame="border" border="1" rules="all"><thead align="left"><tr id="smn_api_56003__row6634135420184"><th align="left" class="cellrowborder" valign="top" width="17.738226177382263%" id="mcps1.3.2.2.2.1.1.5.1.1"><p id="smn_api_56003__p0650125431810"><strong id="smn_api_56003__b842352706191030">Parameter</strong></p>
</th>
<th align="left" class="cellrowborder" valign="top" width="23.357664233576642%" id="mcps1.3.2.2.2.1.1.5.1.2"><p id="smn_api_56003__p1465005418189"><strong id="smn_api_56003__b593421527191713">Mandatory</strong></p>
</th>
<th align="left" class="cellrowborder" valign="top" width="26.027397260273972%" id="mcps1.3.2.2.2.1.1.5.1.3"><p id="smn_api_56003__p0650175419188"><strong id="smn_api_56003__b84235270619112">Type</strong></p>
</th>
<th align="left" class="cellrowborder" valign="top" width="32.87671232876712%" id="mcps1.3.2.2.2.1.1.5.1.4"><p id="smn_api_56003__p156507545182"><strong id="smn_api_56003__b84235270619115">Description</strong></p>
</th>
</tr>
</thead>
<tbody><tr id="smn_api_56003__row4650165421816"><td class="cellrowborder" valign="top" width="17.738226177382263%" headers="mcps1.3.2.2.2.1.1.5.1.1 "><p id="smn_api_56003__p3650854151810">project_id</p>
</td>
<td class="cellrowborder" valign="top" width="23.357664233576642%" headers="mcps1.3.2.2.2.1.1.5.1.2 "><p id="smn_api_56003__p1365025412188">Yes</p>
</td>
<td class="cellrowborder" valign="top" width="26.027397260273972%" headers="mcps1.3.2.2.2.1.1.5.1.3 "><p id="smn_api_56003__p186502054111811">String</p>
</td>
<td class="cellrowborder" valign="top" width="32.87671232876712%" headers="mcps1.3.2.2.2.1.1.5.1.4 "><p id="smn_api_56003__p1665018541188">Project ID</p>
<p id="smn_api_56003__p118812918506">See <a href="smn_api_66000.html">Obtaining a Project ID</a>.</p>
</td>
</tr>
<tr id="smn_api_56003__row19650165415182"><td class="cellrowborder" valign="top" width="17.738226177382263%" headers="mcps1.3.2.2.2.1.1.5.1.1 "><p id="smn_api_56003__p99531421797">resource_type</p>
</td>
<td class="cellrowborder" valign="top" width="23.357664233576642%" headers="mcps1.3.2.2.2.1.1.5.1.2 "><p id="smn_api_56003__p1495310421799">Yes</p>
</td>
<td class="cellrowborder" valign="top" width="26.027397260273972%" headers="mcps1.3.2.2.2.1.1.5.1.3 "><p id="smn_api_56003__p149531342296">String</p>
</td>
<td class="cellrowborder" valign="top" width="32.87671232876712%" headers="mcps1.3.2.2.2.1.1.5.1.4 "><p id="smn_api_56003__p52661238184213">Resource type</p>
<p id="smn_api_56003__p278251314214">The value can be the following:</p>
<p id="smn_api_56003__p14550953686"><strong id="smn_api_56003__b79113111105">smn_topic</strong>: topic</p>
<p id="smn_api_56003__p8682201993"></p>
<p id="smn_api_56003__p10462259131014"></p>
</td>
</tr>
<tr id="smn_api_56003__row0650054191817"><td class="cellrowborder" valign="top" width="17.738226177382263%" headers="mcps1.3.2.2.2.1.1.5.1.1 "><p id="smn_api_56003__p1363485413187">resource_id</p>
</td>
<td class="cellrowborder" valign="top" width="23.357664233576642%" headers="mcps1.3.2.2.2.1.1.5.1.2 "><p id="smn_api_56003__p463417547182">Yes</p>
</td>
<td class="cellrowborder" valign="top" width="26.027397260273972%" headers="mcps1.3.2.2.2.1.1.5.1.3 "><p id="smn_api_56003__p7634195417180">String</p>
</td>
<td class="cellrowborder" valign="top" width="32.87671232876712%" headers="mcps1.3.2.2.2.1.1.5.1.4 "><p id="smn_api_56003__p176341254201810">Resource ID</p>
<p id="smn_api_56003__p57491711103514">Obtain a resource ID:</p>
<ul id="smn_api_56003__ul111761720155610"><li id="smn_api_56003__smn_api_56002_li969342316131">Add <strong id="smn_api_56003__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_56003__smn_api_56002_li1669312233134">Call the <strong id="smn_api_56003__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_56003__section15306154161813"><h4 class="sectiontitle">Request</h4><ul id="smn_api_56003__ul365015417185"><li id="smn_api_56003__li116501654111816">Parameter description
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="smn_api_56003__table2306754131811" frame="border" border="1" rules="all"><thead align="left"><tr id="smn_api_56003__row10650115416183"><th align="left" class="cellrowborder" valign="top" width="16.13838616138386%" id="mcps1.3.3.2.1.1.1.5.1.1"><p id="smn_api_56003__p2650155410184"><strong id="smn_api_56003__b558166876">Parameter</strong></p>
</th>
<th align="left" class="cellrowborder" valign="top" width="21.837816218378165%" id="mcps1.3.3.2.1.1.1.5.1.2"><p id="smn_api_56003__p3650185481810"><strong id="smn_api_56003__b286245577">Mandatory</strong></p>
</th>
<th align="left" class="cellrowborder" valign="top" width="16.45835416458354%" id="mcps1.3.3.2.1.1.1.5.1.3"><p id="smn_api_56003__p16501254141811"><strong id="smn_api_56003__b117873465">Type</strong></p>
</th>
<th align="left" class="cellrowborder" valign="top" width="45.56544345565444%" id="mcps1.3.3.2.1.1.1.5.1.4"><p id="smn_api_56003__p1765017544189"><strong id="smn_api_56003__b1440922626">Description</strong></p>
</th>
</tr>
</thead>
<tbody><tr id="smn_api_56003__row465019548182"><td class="cellrowborder" valign="top" width="16.13838616138386%" headers="mcps1.3.3.2.1.1.1.5.1.1 "><p id="smn_api_56003__p26501954141814">tag</p>
</td>
<td class="cellrowborder" valign="top" width="21.837816218378165%" headers="mcps1.3.3.2.1.1.1.5.1.2 "><p id="smn_api_56003__p13650175411819">Yes</p>
</td>
<td class="cellrowborder" valign="top" width="16.45835416458354%" headers="mcps1.3.3.2.1.1.1.5.1.3 "><p id="smn_api_56003__p12650654151819">Resource tag structure</p>
</td>
<td class="cellrowborder" valign="top" width="45.56544345565444%" headers="mcps1.3.3.2.1.1.1.5.1.4 "><p id="smn_api_56003__p8650554201817">Resource tag to be added. For details, see <a href="#smn_api_56003__table1127111434346">Table 1</a>.</p>
</td>
</tr>
</tbody>
</table>
</div>
<div class="tablenoborder"><a name="smn_api_56003__table1127111434346"></a><a name="table1127111434346"></a><table cellpadding="4" cellspacing="0" summary="" id="smn_api_56003__table1127111434346" frame="border" border="1" rules="all"><caption><b>Table 1 </b>Resource_tag structure</caption><thead align="left"><tr id="smn_api_56003__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_56003__smn_api_56001_p993135161718"><strong id="smn_api_56003__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_56003__smn_api_56001_p19311451131719"><strong id="smn_api_56003__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_56003__smn_api_56001_p13931451141710"><strong id="smn_api_56003__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_56003__smn_api_56001_p393125141712"><strong id="smn_api_56003__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_56003__smn_api_56001_p1715443212610"><strong id="smn_api_56003__smn_api_56001_b134437429517">Constraint</strong></p>
</th>
</tr>
</thead>
<tbody><tr id="smn_api_56003__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_56003__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_56003__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_56003__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_56003__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_56003__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_56003__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_56003__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_56003__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_56003__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_56003__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_56003__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_56003__ul156505545181"><li id="smn_api_56003__li1765015471818">Request example<pre class="screen" id="smn_api_56003__screen2650135413180">POST https://{SMN_Endpoint}/v2/{project_id}/{resource_type}/{resource_id}/tags</pre>
</li></ul>
<ul id="smn_api_56003__ul465065410183"><li id="smn_api_56003__li1265095491813">Example request<pre class="screen" id="smn_api_56003__screen86502543186">{
"tag":
{
"key":"DEV",
"value":"DEV1"
}
}</pre>
</li></ul>
</div>
<div class="section" id="smn_api_56003__section12429402325"><h4 class="sectiontitle">Response</h4><p id="smn_api_56003__p454911110507">None</p>
</div>
<div class="section" id="smn_api_56003__section11338754191819"><h4 class="sectiontitle">Returned Value</h4><p id="smn_api_56003__p144041524121813">See <a href="smn_api_63002.html">Returned Value</a>.</p>
</div>
<div class="section" id="smn_api_56003__section73211020122511"><h4 class="sectiontitle">Error Code</h4><p id="smn_api_56003__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>