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

17 KiB
Raw Blame History

Querying Subscriptions of a Specified Topic

Description

  • API name

    ListSubscriptionsByTopic

  • Function

    Query the list of subscriptions of a specified topic by page. The list is sorted by the subscription adding time in ascending order. If no subscription has been added to the topic, an empty list is returned.

URI

  • URI format

    GET /v2/{project_id}/notifications/topics/{topic_urn}/subscriptions?offset={offset}&limit={limit}

  • Parameter description

    Parameter

    Mandatory

    Type

    Description

    project_id

    Yes

    String

    Project ID

    See Obtaining a Project ID.

    topic_urn

    Yes

    String

    Unique resource ID of a topic. You can obtain it according to Querying Topics.

    offset

    No

    int

    Offset

    If the value is an integer greater than 0 but less than the number of resources, all resources after this offset will be queried. The default value is 0.

    limit

    No

    int

    • Number of resources returned on each page
    • Value range: 1100

      Commonly used values are 10, 20, and 50.

      The default value is 100.

Request

Example request
GET https://{SMN_Endpoint}/v2/{project_id}/notifications/topics/urn:smn:regionId:762bdb3251034f268af0e395c53ea09b:test_topic_v1/subscriptions?offset=0&limit=100 

Response

  • Parameter description

    Parameter

    Type

    Description

    request_id

    String

    Request ID, which is unique

    subscription_count

    int

    Number of subscriptions

    subscriptions

    Subscription structure array

    For details, see Table 1.

    Table 1 Subscription structure

    Parameter

    Type

    Description

    topic_urn

    String

    Resource identifier of a topic, which is unique

    protocol

    String

    Subscription protocol (Different protocols indicate different types of endpoints to receive messages.)

    Currently, the following protocols are supported:

    • email: The endpoints are email address.
    • sms: The endpoints are phone numbers.
    • http and https: The endpoints are URLs.

    subscription_urn

    String

    Resource identifier of a subscription, which is unique

    owner

    String

    Project ID of the topic creator

    endpoint

    String

    Message receiving endpoint

    remark

    String

    Remarks

    status

    Int

    Subscription status

    • 0: unconfirmed
    • 1: confirmed
    • 3: canceled
  • Example response
    {
        "request_id": "4650b14bf221492fb819c231d167e6fe", 
        "subscription_count": 2, 
        "subscriptions": [
            {
                "topic_urn": "urn:smn:regionId:762bdb3251034f268af0e395c53ea09b:test_topic_v1", 
                "protocol": "sms", 
                "subscription_urn": "urn:smn:regionId:762bdb3251034f268af0e395c53ea09b:test_topic_v1:2e778e84408e44058e6cbc6d3c377837", 
                "owner": "762bdb3251034f268af0e395c53ea09b", 
                "endpoint": "xxxxxxxxxx", 
                "remark": "", 
                "status": 0
            }, 
            {
                "topic_urn": "urn:smn:regionId:762bdb3251034f268af0e395c53ea09b:test_topic_v1", 
                "protocol": "email", 
                "subscription_urn": "urn:smn:regionId:762bdb3251034f268af0e395c53ea09b:test_topic_v1:a2d52a9f5c3b47f48c3fafb177a58796", 
                "owner": "762bdb3251034f268af0e395c53ea09b", 
                "endpoint": "xx@xx.com", 
                "remark": "", 
                "status": 0
            }
    ] 
    }

Returned Value

See section Returned Value.

Error Code

See section Error Code.