Notification groups
Overview#
Notifications groups are used to organize subscriptions under specific topics of interest. Application developers can decide the types of topics that users may be interested in subscribing to, and create groups for each of those topics.
For example, a notification group could be created for a set of notifications that relate to a specific action in a given application. All users subscribed to that group will then have the same set of notifications distributed to them.
Group properties#
When you create a new group, the following properties are supported:
_namespaces: A string array, which must contain a single item, which is the owning namespace for this group. The user must have the create permissions in this namespace for the IRNnotificationsvc:group:*_name: An immutable user-friendly name that must be unique within the namespace._description: An optional description.
Note: Once a subscription is created, you can then edit the
_descriptionproperty.
Using the Groups API#
This section lists some useful examples of using the Notification Service API to perform operations with notification groups.
For a full reference to the Groups API, refer to the Groups Rest API page.
Create group#
To create a group, named "group_1", refer to the sample code below.
const subscription = await IafNotification.createSubscription({ _namespaces: project._namespaces, _name: "group_1", _description: "My first group"}, ctx);Update group#
To update a group with a new description, refer to the sample code below.
const group = await IafNotification.updateGroup(group._id, { _description: "New description for group"}, ctx);List groups#
To list groups, you must provide a query. The query must include at a minimum, a set of namespaces for which the calling user has READ permission.
When creating or updating groups, the following query properties are supported:
namespacesname
To query for groups in your project, refer to the sample code below.
const groups = await IafNotification.listGroups({ namespaces: project._namespaces}, ctx);Delete a group#
To delete a group, refer to the sample code below.
await IafNotification.deleteGroup(group._id, ctx);