Parts of a notification message
A notification message is the message sent to the subscriber when there is a change to a switch resource that is the topic of a subscription. The notification message is in JSON format.
The content of a notification message depends on the type of change that occurred.
Notification message examples
For the following examples, assume that the following subscribe message was used:
{
"topics": [
{
"name": "/rest/v1/system/bridge/vlans?depth=1&attributes=name"
}
],
"type": "subscribe"
}
The subscriber receives a notification when the name of any VLAN changes:
In the following example, VLAN7 has been added to the switch configuration:
{ "data": [ { "resources": [ { "operation": "inserted", "uri": "/rest/v1/system/bridge/vlans/VLAN7", "values": { "name": "VLAN7" } } ], "topicname": "/rest/v1/system/bridge/vlans?depth=1&attributes=name" } ], "type": "notification" }
In the following example, VLAN7 has been deleted from the configuration:
{ "data": [ { "resources": [ { "operation": "deleted", "uri": "/rest/v1/system/bridge/vlans/VLAN7", "values": {} } ], "topicname": "/rest/v1/system/bridge/vlans?depth=1&attributes=name" } ], "type": "notification" }
In the following example, the subscriber has subscribed to the following topic:
/rest/v1/system/interfaces/1%2F1%2F2?attributes=name,admin_state
If either the name or the administrative state of interface
1/1/2
changes, a notification message is sent. If attributes other than name or administrative state changes, no notification message is sent.
In the following example, the administrative state of the interface changed to
up
.
{
"data": [
{
"resources": [
{
"operation": "modified",
"uri": "/rest/v1/system/interfaces/1%2F1%2F2",
"values": {
"admin_state": "up"
}
}
],
"topicname": "/rest/v1/system/interfaces/1%2F1%2F2?attributes=name,admin_state"
}
],
"type": "notification"
}
Components of a notification message
type
Identifies the type of message. Notification messages have the type:
notification
data
Contains a comma-separated list of one or more topics in JSON format.
Components of a topic
In a notification message, each topic in the data contains the following components:
topicname
Contains the name of the topic, identified by the URI of the switch resource, including the optional query string.
resources
Contains a comma-separated list of one or more resources in JSON format. When the URI of a topic is a resource collection, a topic includes multiple resources.
Each resource includes the following components:
operation
For notification messages, operation is one of the following values:
inserted
The resource or resource attribute was added to the configuration of the switch.
deleted
The resource or resource attribute was deleted from the switch.
modified
The resource or resource attribute changed.
uri
Contains the URI of the resource instance within the resource collection. If the
topicname
is a resource instance instead of a collection,uri
matches the path portion of the URI intopicname
.values
The content of
values
depends on the operation:When the
operation
value isdeleted
,values
is empty.When the
operation
value isinserted
,values
contains the current names and values of the attributes specified in the query portion of thetopicname
. If no query string was included intopicname
, all attributes and values for that resource are included.When the
operation
value ismodified
,values
contains the name and current value of the attribute in the query string that changed value:If no query string was included in
topicname
, all attributes and values for that resource are included.If multiple attributes are included in the query string of a topic and only some of those attribute values changed, only the changed attributes are included.
If an attribute that was not included in the query string changes, no notification message is sent because that attribute is not part of the subscription.