forked from docs/doc-exports
Reviewed-by: Bobkova, Natalia <natalia.bobkova@t-systems.com> Co-authored-by: Zaoxu, Li <lizaoxu@huawei.com> Co-committed-by: Zaoxu, Li <lizaoxu@huawei.com>
149 lines
12 KiB
HTML
149 lines
12 KiB
HTML
<a name="smn_api_52003"></a><a name="smn_api_52003"></a>
|
|
|
|
<h1 class="topictitle1">Adding a Subscription</h1>
|
|
<div id="body65443729"><div class="section" id="smn_api_52003__section28602718"><h4 class="sectiontitle">Description</h4><ul id="smn_api_52003__ul33304380203733"><li id="smn_api_52003__li51147505203733">API name<p id="smn_api_52003__p38624841203741"><a name="smn_api_52003__li51147505203733"></a><a name="li51147505203733"></a>Subscribe</p>
|
|
</li></ul>
|
|
<ul id="smn_api_52003__ul20998054203745"><li id="smn_api_52003__li46884910203750">Function<p id="smn_api_52003__p18920255194414"><a name="smn_api_52003__li46884910203750"></a><a name="li46884910203750"></a>Add a subscription to a specified topic. If the status of the subscription is unconfirmed, a confirmation message is sent to the subscriber. After confirming the subscription, the subscriber can receive notification messages published to the topic.</p>
|
|
<p id="smn_api_52003__p199636587449">By default, 10,000 subscriptions can be added to a topic. However, in a high-concurrency scenario, which is rare, extra subscriptions may be added successfully.</p>
|
|
<p id="smn_api_52003__p18441719152118">The API is idempotent. If the added subscription already exists, a successful result and status code 200 are returned. Otherwise, the status code is 201.</p>
|
|
</li></ul>
|
|
</div>
|
|
<div class="section" id="smn_api_52003__section56097870"><h4 class="sectiontitle">URI</h4><ul id="smn_api_52003__ul13795340"><li id="smn_api_52003__li57049196">URI format<p id="smn_api_52003__p43680716"><a name="smn_api_52003__li57049196"></a><a name="li57049196"></a>POST /v2/{project_id}/notifications/topics/{topic_urn}/subscriptions</p>
|
|
</li></ul>
|
|
<ul id="smn_api_52003__ul57582125"><li id="smn_api_52003__li48477080">Parameter description
|
|
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="smn_api_52003__table33640543" frame="border" border="1" rules="all"><thead align="left"><tr id="smn_api_52003__row18743339"><th align="left" class="cellrowborder" valign="top" width="25%" id="mcps1.3.2.3.1.1.1.5.1.1"><p id="smn_api_52003__p41815528"><strong id="smn_api_52003__b842352706191030">Parameter</strong></p>
|
|
</th>
|
|
<th align="left" class="cellrowborder" valign="top" width="22.650000000000002%" id="mcps1.3.2.3.1.1.1.5.1.2"><p id="smn_api_52003__p31614597"><strong id="smn_api_52003__b593421527191713">Mandatory</strong></p>
|
|
</th>
|
|
<th align="left" class="cellrowborder" valign="top" width="21.709999999999997%" id="mcps1.3.2.3.1.1.1.5.1.3"><p id="smn_api_52003__p10645546"><strong id="smn_api_52003__b84235270619112">Type</strong></p>
|
|
</th>
|
|
<th align="left" class="cellrowborder" valign="top" width="30.64%" id="mcps1.3.2.3.1.1.1.5.1.4"><p id="smn_api_52003__p56982912"><strong id="smn_api_52003__b84235270619115">Description</strong></p>
|
|
</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody><tr id="smn_api_52003__row1408093"><td class="cellrowborder" valign="top" width="25%" headers="mcps1.3.2.3.1.1.1.5.1.1 "><p id="smn_api_52003__p46946741">project_id</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="22.650000000000002%" headers="mcps1.3.2.3.1.1.1.5.1.2 "><p id="smn_api_52003__p44589661">Yes</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="21.709999999999997%" headers="mcps1.3.2.3.1.1.1.5.1.3 "><p id="smn_api_52003__p54992765">String</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="30.64%" headers="mcps1.3.2.3.1.1.1.5.1.4 "><p id="smn_api_52003__p11652542155129">Project ID</p>
|
|
<p id="smn_api_52003__p25228990">See <a href="smn_api_66000.html">Obtaining a Project ID</a>.</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="smn_api_52003__row4105351"><td class="cellrowborder" valign="top" width="25%" headers="mcps1.3.2.3.1.1.1.5.1.1 "><p id="smn_api_52003__p64098000">topic_urn</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="22.650000000000002%" headers="mcps1.3.2.3.1.1.1.5.1.2 "><p id="smn_api_52003__p24555510">Yes</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="21.709999999999997%" headers="mcps1.3.2.3.1.1.1.5.1.3 "><p id="smn_api_52003__p42839264">String</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="30.64%" headers="mcps1.3.2.3.1.1.1.5.1.4 "><p id="smn_api_52003__p47428342">Unique resource ID of a topic. You can obtain it by referring to <a href="en-us_topic_0036016755.html">Querying Topics</a>.</p>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</li></ul>
|
|
</div>
|
|
<div class="section" id="smn_api_52003__section35118788"><h4 class="sectiontitle">Request</h4><ul id="smn_api_52003__ul9109783"><li id="smn_api_52003__li14879189">Parameter description
|
|
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="smn_api_52003__table66803845" frame="border" border="1" rules="all"><thead align="left"><tr id="smn_api_52003__row57367087"><th align="left" class="cellrowborder" valign="top" width="19.24807519248075%" id="mcps1.3.3.2.1.1.1.5.1.1"><p id="smn_api_52003__p16222495"><strong id="smn_api_52003__b843318798">Parameter</strong></p>
|
|
</th>
|
|
<th align="left" class="cellrowborder" valign="top" width="20.707929207079292%" id="mcps1.3.3.2.1.1.1.5.1.2"><p id="smn_api_52003__p38953736"><strong id="smn_api_52003__b86763093241">Mandatory</strong></p>
|
|
</th>
|
|
<th align="left" class="cellrowborder" valign="top" width="24.417558244175584%" id="mcps1.3.3.2.1.1.1.5.1.3"><p id="smn_api_52003__p1136017"><strong id="smn_api_52003__b656867056">Type</strong></p>
|
|
</th>
|
|
<th align="left" class="cellrowborder" valign="top" width="35.626437356264375%" id="mcps1.3.3.2.1.1.1.5.1.4"><p id="smn_api_52003__p24908514"><strong id="smn_api_52003__b1659088883">Description</strong></p>
|
|
</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody><tr id="smn_api_52003__row14679294"><td class="cellrowborder" valign="top" width="19.24807519248075%" headers="mcps1.3.3.2.1.1.1.5.1.1 "><p id="smn_api_52003__p48172185">endpoint</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="20.707929207079292%" headers="mcps1.3.3.2.1.1.1.5.1.2 "><p id="smn_api_52003__p9632925">Yes</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="24.417558244175584%" headers="mcps1.3.3.2.1.1.1.5.1.3 "><p id="smn_api_52003__p42069424">String</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="35.626437356264375%" headers="mcps1.3.3.2.1.1.1.5.1.4 "><p id="smn_api_52003__p52180221">Message endpoint</p>
|
|
<div class="note" id="smn_api_52003__note1190810251344"><span class="notetitle"> NOTE: </span><div class="notebody"><p id="smn_api_52003__p65848362">For an HTTP subscription, the endpoint starts with <strong id="smn_api_52003__b842352706152017">http://</strong>.</p>
|
|
<p id="smn_api_52003__p55764348">For an HTTPS subscription, the endpoint starts with <strong id="smn_api_52003__b842352706152039">https://</strong>.</p>
|
|
<p id="smn_api_52003__p32117087">For an email subscription, the endpoint is an email address.</p>
|
|
<p id="smn_api_52003__p20618333">For an SMS subscription, the endpoint is a phone number.</p>
|
|
</div></div>
|
|
</td>
|
|
</tr>
|
|
<tr id="smn_api_52003__row51347269"><td class="cellrowborder" valign="top" width="19.24807519248075%" headers="mcps1.3.3.2.1.1.1.5.1.1 "><p id="smn_api_52003__p65488131">protocol</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="20.707929207079292%" headers="mcps1.3.3.2.1.1.1.5.1.2 "><p id="smn_api_52003__p2938434">Yes</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="24.417558244175584%" headers="mcps1.3.3.2.1.1.1.5.1.3 "><p id="smn_api_52003__p36686634">String</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="35.626437356264375%" headers="mcps1.3.3.2.1.1.1.5.1.4 "><p id="smn_api_52003__p18827362">Subscription protocol (Different protocols indicate different types of endpoints to receive messages.)</p>
|
|
<p id="smn_api_52003__p1555972375816">The following protocols are supported:</p>
|
|
<ul id="smn_api_52003__ul1777124019573"><li id="smn_api_52003__smn_api_52001_li1915283525718"><strong id="smn_api_52003__smn_api_52001_b65901133114410">email</strong>: The endpoints are email address.</li><li id="smn_api_52003__smn_api_52001_li031203718574"><strong id="smn_api_52003__smn_api_52001_b99571741008">sms</strong>: The endpoints are phone numbers.</li><li id="smn_api_52003__smn_api_52001_li1682010496573"><strong id="smn_api_52003__smn_api_52001_b1099011287223">http</strong> and <strong id="smn_api_52003__smn_api_52001_b577715331224">https</strong>: The endpoints are URLs.</li></ul>
|
|
</td>
|
|
</tr>
|
|
<tr id="smn_api_52003__row34938791"><td class="cellrowborder" valign="top" width="19.24807519248075%" headers="mcps1.3.3.2.1.1.1.5.1.1 "><p id="smn_api_52003__p11469823">remark</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="20.707929207079292%" headers="mcps1.3.3.2.1.1.1.5.1.2 "><p id="smn_api_52003__p56640484">No</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="24.417558244175584%" headers="mcps1.3.3.2.1.1.1.5.1.3 "><p id="smn_api_52003__p24476477">String</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="35.626437356264375%" headers="mcps1.3.3.2.1.1.1.5.1.4 "><p id="smn_api_52003__p10287856125818">Description of the subscription</p>
|
|
<p id="smn_api_52003__p36437619">The remarks must be UTF-8-coded and can contain up to 128 bytes.</p>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</li></ul>
|
|
<ul id="smn_api_52003__ul25445523"><li id="smn_api_52003__li27683123">Example request<pre class="screen" id="smn_api_52003__screen17545349104950">POST https://{SMN_Endpoint}/v2/{project_id}/notifications/topics/urn:smn:regionId:762bdb3251034f268af0e395c53ea09b:test_topic_v1/subscriptions</pre>
|
|
<pre class="screen" id="smn_api_52003__screen2181856119303">{
|
|
"protocol": "email",
|
|
"endpoint": "xxx@xxx.com",
|
|
"remark": "O&M"
|
|
} </pre>
|
|
</li></ul>
|
|
</div>
|
|
<div class="section" id="smn_api_52003__section47633640"><h4 class="sectiontitle">Response</h4><ul id="smn_api_52003__ul18947112"><li id="smn_api_52003__li36306286">Parameter description
|
|
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="smn_api_52003__table58321122" frame="border" border="1" rules="all"><thead align="left"><tr id="smn_api_52003__row60828573"><th align="left" class="cellrowborder" valign="top" width="28.910000000000004%" id="mcps1.3.4.2.1.1.1.4.1.1"><p id="smn_api_52003__p28167350"><strong id="smn_api_52003__b1422083561">Parameter</strong></p>
|
|
</th>
|
|
<th align="left" class="cellrowborder" valign="top" width="28.910000000000004%" id="mcps1.3.4.2.1.1.1.4.1.2"><p id="smn_api_52003__p66962839"><strong id="smn_api_52003__b161209858">Type</strong></p>
|
|
</th>
|
|
<th align="left" class="cellrowborder" valign="top" width="42.18%" id="mcps1.3.4.2.1.1.1.4.1.3"><p id="smn_api_52003__p55280873"><strong id="smn_api_52003__b1131605665">Description</strong></p>
|
|
</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody><tr id="smn_api_52003__row41508862"><td class="cellrowborder" valign="top" width="28.910000000000004%" headers="mcps1.3.4.2.1.1.1.4.1.1 "><p id="smn_api_52003__p6774674">request_id</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="28.910000000000004%" headers="mcps1.3.4.2.1.1.1.4.1.2 "><p id="smn_api_52003__p11877685">String</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="42.18%" headers="mcps1.3.4.2.1.1.1.4.1.3 "><p id="smn_api_52003__p22568466">Request ID, which is unique</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="smn_api_52003__row10740297"><td class="cellrowborder" valign="top" width="28.910000000000004%" headers="mcps1.3.4.2.1.1.1.4.1.1 "><p id="smn_api_52003__p64657722">subscription_urn</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="28.910000000000004%" headers="mcps1.3.4.2.1.1.1.4.1.2 "><p id="smn_api_52003__p2784095">String</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="42.18%" headers="mcps1.3.4.2.1.1.1.4.1.3 "><p id="smn_api_52003__p24185120">Resource identifier of a subscription, which is unique</p>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</li><li id="smn_api_52003__li48430751">Example response<pre class="screen" id="smn_api_52003__screen9154679193031">{
|
|
"request_id": "fdbabe38ead6482b8574f82a3d1168e9",
|
|
"subscription_urn": "urn:smn:regionId:762bdb3251034f268af0e395c53ea09b:test_topic_v1:2e778e84408e44058e6cbc6d3c377837"
|
|
}</pre>
|
|
</li></ul>
|
|
</div>
|
|
<div class="section" id="smn_api_52003__section26049579"><h4 class="sectiontitle">Returned Value</h4><p id="smn_api_52003__p61765553">See <a href="smn_api_63002.html">Returned Value</a>.</p>
|
|
</div>
|
|
<div class="section" id="smn_api_52003__section73211020122511"><h4 class="sectiontitle">Error Codes</h4><p id="smn_api_52003__p9759142919265">See <a href="smn_api_64000.html">Error Codes</a>.</p>
|
|
</div>
|
|
</div>
|
|
<div>
|
|
<div class="familylinks">
|
|
<div class="parentlink"><strong>Parent topic:</strong> <a href="smn_api_52000.html">Subscription Operations</a></div>
|
|
</div>
|
|
</div>
|
|
|