Example: Getting information about notification subscriptions

Getting a list of subscribers

The following example gets the list of all subscribers that are subscribed to notifications from a switch resource:

GET "https://192.0.2.5/rest/v1/system/notification_subscribers"

Example response body:

[
  "rest/v1/system/notification_subscribers/z6901beisjgf",
  "rest/v1/system/notification_subscribers/18l9g87erb42"
]

The response body is a list of URIs. The identifier at the end of the URI string is the subscriber name. You can use that identifier to get information about the subscriptions for that subscriber.

You can get more information about all the subscribers by using the depth parameter. For example, you can specify depth=1 to get a list of the subscriptions for each subscriber:

GET "https://192.0.2.5/rest/v1/system/notification_subscribers?depth=1"

Example response body:

[
  {
    "name": "z6901beisjgf",
    "notification_subscriptions": {
      "5mzo50lgoo": "rest/v1/system/notification_subscribers/z6901beisjgf/notification_subscriptions/5mzo50lgoo",
      "pouswxt9m9": "rest/v1/system/notification_subscribers/z6901beisjgf/notification_subscriptions/pouswxt9m9"
    },
    "type": "ws"
  },
  {
    "name": "18l9g87erb42",
    "notification_subscriptions": {
      "dz95lljqwk": "rest/v1/system/notification_subscribers/18l9g87erb42/notification_subscriptions/dz95lljqwk"
    },
    "type": "ws"
  }
]

You can specify depth=2 to further expand the list of subscription URIs for all the subscribers, or you can use the notifications_subscriptions resource to get information about subscriptions by subscription name.

Getting information about subscriptions

The following example gets the list of all the subscriptions of subscriber z6901beisjgf:

GET "https://192.0.2.5/rest/v1/system/notification_subscribers/z6901beisjgf/notification_subscriptions"

Example response body:

[
  "rest/v1/system/notification_subscribers/z6901beisjgf/notification_subscriptions/5mzo50lgoo",
  "rest/v1/system/notification_subscribers/z6901beisjgf/notification_subscriptions/pouswxt9m9"
]

The response body is a list of URIs. The identifier at the end of the URI string is the subscription name.

You can specify depth=1 to expand the URI of the subscriptions to get more information about all the subscriptions. For example:

GET "https://192.0.2.5/rest/v1/system/notification_subscribers/z6901beisjgf/notification_subscriptions?depth=1"

Example response body:

{
  "5mzo50lgoo": {
    "resource": [
      "/rest/v1/system/ports?attributes=admin,vlan_mode,vlan_tag,vlan_trunks,interfaces&depth=1"
    ]
  },
  "pouswxt9m9": {
    "resource": [
      "/rest/v1/system/interfaces?attributes=type,hw_intf_info,link_state,link_speed,error,other_config"
    ]
  }
}

You can also get information about a subscription by the subscription name for a specific subscriber. For example:

GET "https://192.0.2.5/rest/v1/system/notification_subscribers/z6901beisjgf/notification_subscriptions/pouswxt9m9"

Example response body:

{
  "5mzo50lgoo": {
    "resource": [
      "/rest/v1/system/ports?attributes=admin,vlan_mode,vlan_tag,vlan_trunks,interfaces&depth=1"
    ]
  }
}