Skip Headers
Oracle® Communications Services Gatekeeper RESTful Application Developer's Guide
Release 5.0

Part Number E16621-02
Go to Documentation Home
Home
Go to Book List
Book List
Go to Table of Contents
Contents
Go to Feedback page
Contact Us

Go to previous page
Previous
Go to next page
Next
View PDF

11 Presence

This chapter describes the operations in the Presence interface of the RESTful Web Services provided in Oracle Communications Services Gatekeeper.

About the Presence Interface

Applications use the RESTful Presence interface to act as either of two different parties to a presence interaction: as a presentity or as a watcher.

REST Service Descriptions Available at Run-time

When the Administration Server for your Services Gatekeeper domain is in the running state, the REST service descriptions of these operations can be found at

http://host:port/rest/presence/index.html

where host and port are the host name and port of the machine on which Services Gatekeeper is installed.

About Presentities and Watchers

A presentity agrees to have certain data (called attributes) such as current activity, available communication means, and contact addresses made available to others. As a presentity, an application can publish presence data about itself, check to see if any new watchers wish to subscribe to its presence data, authorize those watchers it chooses to authorize, block those it wishes not to have access, and get a list of currently subscribed watchers.

A watcher is the consumer of current activity, available communication means, and contact addresses made available by a presentity. As a watcher, an application can request to subscribe to all or a subset of a presentity's data, poll for that data, and start and end presence notifications.

Data Common to Operations in RESTful Presence Interface

This section describes the following data objects that are commonly used in the JSON data structures in RESTful Presence interface operations. They are described in detail here to avoid repeating the information.

attributes

The term attributes is used to describe the current attributes of a presentity. It specifies the single Presence attribute or the set of Presence attributes that a watcher might wish to view for a specified presentity. It is used in the request body for Subscribe Presence and Start Presence Notifications, the Request-URI query for Get User Presence and the response body for Get Open Subscriptions,

The following structure is used to specify the array of values for attributes:

"attributes": ["Activity|Place|Privacy|Sphere|Communication|Other"

Each element of the array denotes a single Presence attribute and in turn, represented by a JSON attribute-value pair (or a JSON data object). An empty array indicates that the watcher is interested in all of the Presence attributes associated with a presentity.

PresenceAttribute

The term presenceAttribute indicates the type of presentity data that must be updated or changed for the watcher. It is used in the request body for Update Subscription Authorization and in subscription notifications.

The values presenceAttribute accepts are specified in the following name/value pair structure:

"presenceAttribute": ["Activity|Place|Privacy|Sphere|Communication|Other"

unionElement

The term unionElement indicates the type of presentity data that is presented. It is used in the request body for Publish, the response body for Get User Presence and in notifications for a change in status.

The values unionElement accepts are specified in the following name/value pair structure:

"unionElement": ["Activity|Place|Privacy|Sphere|Communication|Other"

Activity

The term activity specifies the presentity's current activity. It is one of the values accepted by attributes. The values activity accepts are specified in the following name/value pair structure:

"activity": "ActivityNone|Available|Busy|DoNotDisturb|OnThePhone|Steering|Meeting|Away|Meal|PermanentAbsence|Holiday|Performance|InTransit|Travel|Sleeping|ActivityOther

where:

  • ActivityNone indicates that the value has not been set.

  • ActivityOther refers to any non-listed activity type.

Place

The place attribute specifies the current type of location for a presentity. It is one of the values accepted by the attributes attribute. The values place accepts are specified in the following name/value pair structure:

"place": "PlaceNone|Home|Office|PublicTransport|Street|Outdoors|PublicPlace|Hotel|Theatre|Restaurant|School|Industrial|Quiet|Noisy|Aircraft|Ship|Bus|Station|Mall|Airport|Train|PlaceOther"

where:

  • PlaceNone indicates that the value has not been set.

  • PlaceOther refers to any other type of place not listed here.

Privacy

The privacy attribute specifies the level of privacy in the presentity's current environment. It is one of the values accepted by the attributes attribute. The values privacy accepts are specified in the following name/value pair structure:

"privacy": "PrivacyNone|PrivacyPublic|PrivacyPrivate|PrivacyQuiet|PrivacyOther"

where:

  • PrivacyNone indicates that the value has not been set.

  • PrivacyOther refers to any other level of privacy not listed here.

Sphere

The sphere attribute specifies the sphere within which the presentity is currently acting. It is one of the values accepted by the attributes attribute. The values sphere accepts are specified in the following name/value pair structure:

"sphere": "SphereNone|SphereWork|SphereHome|SphereOther"

where:

  • SphereNone indicates that the sphere has not been set.)

  • SphereOther is used to refer to any other type of sphere not listed here.

Type

The type attribute specifies the type of contact client for a specified or preferred form of communication. It is one of the values accepted by the means JSON data object. The values type accepts are specified in the following name/value pair structure:

"type": "Phone|Chat|Sms|Video|Web|Email|Mms|MeansOther"

Communication

The communication attribute specifies the connection information for a presentity's preferred form of communication. It is one of the values accepted by attributes, presenceAttribute and unionElement. It accepts only one value, means, specified in the following structure:

"communication": {"means": [{
      "contact": "URI",
      "priority": "Float",
      "type": "Phone|Chat|Sms|Video|Web|Email|Mms|MeansOther"
    }]
}

Means

The means object specifies the parameters for the preferred form of communication. It accepts the following parameters:

  • contact. String. Required. The contact address for this particular means or form of communications, as a URI.

  • priority. Number (floating point). required parameter. The priority of this particular means. Valid entries start at 0.0 for the lowest priority and range in increasing order to 1.0 as the value for highest priority.

  • type. Described earlier. See "Type".

The following structure is used to specify the array of values for means:

"means": [{
      "contact": "URI",
      "priority": "Float",
      "type": "Phone|Chat|Sms|Video|Web|Email|Mms|MeansOther"
    }]

TypeandValue

The typeAndValue JSON object contains the presence information for a presentity. It is used in Get User Presence and Publish operations and in the Presence notifications. It is made up of the following parameters (each of which has been described earlier):

  • unionElement. String. Required. See "unionElement".

  • activity. String. Optional. Present if the value for unionElement is Activity. See "Activity".

  • place. String. Optional. Present if the value for unionElement is Place. See "Place".

  • privacy. String. Optional. Present if the value for unionElement is Privacy. See "Privacy".

  • sphere. String. Optional. Present if the value for unionElement is Sphere. See "Sphere".

  • communication: JSON object. Optional. Present if the value for unionElement is Communication. See "Communication".

  • other: JSON object. Optional. See "Other".

The following structure is used to specify the values for typeAndValue:

"typeAndValue": {
    "unionElement": "Activity|Place|Privacy|Sphere|Communication|Other",
    "activity": "ActivityNone|Available|Busy|DoNotDisturb|OnThePhone|Steering|Meeting|Away|Meal|PermanentAbsence|Holiday|Performance|InTransit|Travel|Sleeping|ActivityOther",
    "communication": {"means": [{
      "contact": "URI",
      "priority": "Float",
      "type": "Phone|Chat|Sms|Video|Web|Email|Mms|MeansOther"
    }]
}

Other

The other JSON object specifies the parameters for arbitrary information. It has the following parameters:

  • name. String. Required. The name for this specific information.

  • value. String. Required. The specific value to be matched for the name.

The following structure is used to specify the values for typeAndValue:

"other": {
      "name": "String",
      "value": "String"
    }

Get Open Subscriptions

The Get Open Subscription operation polls for any watchers who wish to subscribe to this presentity's data.

To retrieve the information on the applications, the subscription?status=open query string is included in the Request-URI of the GET method.

If the Get Open Subscription operation is successful, the response body contains the result JSON data object with the information on the watchers.

Authorization

Basic

HTTP Method

GET

URI

http://host:port/rest/presence/subscription?status=open

where:

Request Header

The MIME-type for the Content-Type header field is application/json.

Request Body

There is no request body.

Response Header

Standard header fields. If the request fails, the Status-Line header field will contain the status code and the reason for the failure. See "Errors and Exceptions".

Response Body

The information on the watchers is returned as an array of values for the result attribute. Each element in the array contains the following attribute-value pairs.

The response body for this operation is represented by the following JSON data structure, where the value part of each name/value pair indicates its data type:

{"result": [{
  "application": "String",
  "attributes": ["Activity|Place|Privacy|Sphere|Communication|Other"],
  "watcher": "URI"
}]}

Get My Watchers

The Get My Watchers operation retrieves an array of current watchers.

To retrieve the information on the current watchers, include the subscription?filter=watcher query string in the Request-URI of the GET method.

If the Get My Watchers operation is successful, the response body contains the result JSON data object with the list of current watchers.

Authorization

Basic

HTTP Method

GET

URI

http://host:port/rest/presence/subscription?filter=watcher

where:

Request Header

The MIME-type for the Content-Type header field is application/json.

Request Body

There is no request body.

Response Header

Standard header fields. If the request fails, the Status-Line header field will contain the status code and the reason for the failure. See "Errors and Exceptions".

Response Body

The response body contains a JSON data object as the value for the result entry. The value for result is an array of URIs which represent the addresses of the set of current watchers:

{"result": ["URI"]}

Update Subscription Authorization

The Update Subscription Authorization operation is used to add watchers who have recently asked for subscriptions or to change permissions for any current watchers.

To do so, provide the address of the watcher along with the decision on whether permission must be granted, and the Presence attribute for which such permission must be granted (or revoked).

If the request fails, the Status-Line header field will contain the status code and the reason for the failure.

Authorization

Basic

HTTP Method

PUT

URI

http://host:port/rest/presence/subscription/authorization

where host and port are the host name and port of the machine on which Services Gatekeeper is installed.

Request Header

The MIME-type for the Content-Type header field is application/json.

Request Body

The request body for the Update Subscription Authorization operation accepts the following parameters:

The request body is represented by the following JSON data structure, where the value part of each name/value pair indicates its data type:

{
  "decisions": [{
    "decision": "Boolean",
    "presenceAttribute": "Activity|Place|Privacy|Sphere|Communication|Other"
  }],
  "watcher": "URI"
}

Response Header

Standard header fields. If the request fails, the Status-Line header field will contain the status code and the reason for the failure. See "Errors and Exceptions".

Response Body

There is no response body.


Subscribe Presence

The Subscribe Presence operation requests a subscription to a presentity's data. No data will be available until the presentity authorizes the watcher using Update Subscription Authorization.

To request a subscription to a presentity's data, provide the address of the presentity or group whose data is being requested, the Presence attributes this watcher wishes to see. Because the actual data depends on whether the subscription is authorized, a reference data object must also be provided in the request body. The reference object (also a JSON object) contains the correlator for the notification, the endpoint address (a specific Bayeux channel name) to which the notifications must be sent and, optionally, the interface name (a string to identify the notification).

If the request fails, the Status-Line header field will contain the status code and the reason for the failure.

Authorization

Basic

HTTP Method

PUT

URI

http://host:port/rest/presence/subscription

where host and port are the host name and port of the machine on which Services Gatekeeper is installed.

Request Header

The MIME-type for the Content-Type header field is application/json.

Request Body

The request body for the Subscribe Presence operation accepts the following parameters:

The request body is represented by the following JSON data structure, where the value part of each name/value pair indicates its data type:

{
  "application": "String",
  "presentity": "URI",
  "reference": {
    "correlator": "String",
    "endpoint": "URI",
    "interfaceName": "String"
  },
  "attributes": ["Activity|Place|Privacy|Sphere|Communication|Other"]
}

Response Header

Standard header fields. If the request fails, the Status-Line header field will contain the status code and the reason for the failure. See "Errors and Exceptions".

Response Body

There is no response body.


Block Subscription

The Block Subscription operation allows a presentity to block a watcher's access to the presentity's data. The watcher is notified with a Subscription Ended notification.

To block a watcher's subscription to a presentity's data, provide the address of the watcher as a URI in the Request-URI of the DELETE method.

If the request fails, the Status-Line header field will contain the status code and the reason for the failure.

Authorization

Basic

HTTP Method

DELETE

URI

http://host:port/rest/presence/subscription/${watcher}

where:

Request Header

The MIME-type for the Content-Type header field is application/json.

Request Body

There is no request body.

Response Header

Standard header fields. If the request fails, the Status-Line header field will contain the status code and the reason for the failure. See "Errors and Exceptions".

Response Body

There is no response body.


Start Presence Notification

The Start Presence Notification operation begins delivering presence data to the endpoint defined in the reference attribute. This operation is only functional if the presentity has approved the watcher.

To set up for such notifications, provide the SIP-formatted URI of the presentity for which the watcher must receive notifications, the Presence attributes which will trigger the notifications and a reference object for the delivery of the notifications. The reference object (also a JSON object) contains the correlator for the notification, the endpoint address (a specific Bayeux channel name) to which the notifications must be sent and, optionally, the interface name (a string to identify the notification). Additionally, you can specify the request frequency, the total number of notifications and the duration for the notification and whether the check must start immediately.

If the Start Presence Notification request is successful, the endpoint address specified in the request body will receive a notification when:

The application accesses the endpoint address to retrieve the specific notifications.

If there is any issue with subscriptions, the response body will contain the address(es) of the presentity (or presentities) to whose attributes the watcher did not successfully subscribe.

Authorization

Basic

HTTP Method

PUT

URI

http://host:port/rest/presence/notification

where host and port are the host name and port of the machine on which Services Gatekeeper is installed.

Request Header

The MIME-type for the Content-Type header field is application/json.

Request Body

The request body for the Start Presence Notification operation accepts following parameters:

The request body is represented by the following JSON data structure, where the value part of each name/value pair indicates its data type:

{
  "checkImmediate": "Boolean",
  "frequency": {
    "metric": "Millisecond|Second|Minute|Hour|Day|Week|Month|Year",
    "units": "Integer"
  },
  "presentity": "URI",
  "reference": {
    "correlator": "String",
    "endpoint": "URI",
    "interfaceName": "String"
  },
  "attributes": ["Activity|Place|Privacy|Sphere|Communication|Other"],
  "count": "Integer",
  "duration": {
    "metric": "Millisecond|Second|Minute|Hour|Day|Week|Month|Year",
    "units": "Integer"
  }
}

Response Header

The Location header field contains the URI of the publish/subscribe server:

http://host:port/rest/presence/notifications

If the request fails, the Status-Line header field will contain the status code and the reason for the failure. See "Errors and Exceptions".

Response Body

The requested information is returned in a JSON object as the value for the result attribute. It is an array of URIs which represent the addresses of the presentities to whose attributes the watcher did not successfully subscribe:

{"result": ["URI"]}

The actual notifications delivered to the endpoint address are described below.

Notification of Subscription to a Presentity's Data

The notifySubscription notification indicates whether the presentity has (or has not) authorized the watcher and the attributes that are permitted to be viewed.

The notifySubscription is a JSON object containing the following:

The subscription notification is represented by the following JSON data structure, where the value part of each name/value pair indicates its data type:

{"notifySubscription": {
  "presentity": "URI",
  "decisions": [{
    "decision": "Boolean",
    "presenceAttribute": "Activity|Place|Privacy|Sphere|Communication|Other"
  }]
}}

Notification of a Status Change for a Presentity

The statusChanged JSON object is delivered when there is a change to a specified attribute.

This object is sent to the Bayeux channel name associated with the application instance and specified in the request body as the endpoint attribute value.

The statusChanged is a nested JSON object containing the following:

The notification for a status change is represented by the following JSON data structure, where the value part of each name/value pair indicates its data type:

{"statusChanged": {
  "changedAttributes": [{
    "lastChange": "Calendar",
    "typeAndValue": {
      "unionElement": "Activity|Place|Privacy|Sphere|Communication|Other",
      "activity": "ActivityNone|Available|Busy|DoNotDisturb|OnThePhone|Steering|Meeting|Away|Meal|PermanentAbsence|Holiday|Performance|InTransit|Travel|Sleeping|ActivityOther",
      "communication": {"means": [{
        "contact": "URI",
        "priority": "Float",
        "type": "Phone|Chat|Sms|Video|Web|Email|Mms|MeansOther"
      }]},
      "other": {
        "name": "String",
        "value": "String"
      },
      "place": "PlaceNone|Home|Office|PublicTransport|Street|Outdoors|PublicPlace|Hotel|Theatre|Restaurant|School|Industrial|Quiet|Noisy|Aircraft|Ship|Bus|Station|Mall|Airport|Train|PlaceOther",
      "privacy": "PrivacyNone|PrivacyPublic|PrivacyPrivate|PrivacyQuiet|PrivacyOther",
      "sphere": "SphereNone|SphereWork|SphereHome|SphereOther"
    },
    "note": "String"
  }],
  "correlator": "String",
  "presentity": "URI"
}}

Notification Signalling End to Monitoring of Presentity

The statusEnd JSON object is delivered when the notification count specified as the value for count is reached or when the duration specified for units in the duration object is reached.

It is sent to the Bayeux channel name associated with the application instance and specified in the request body as the endpoint attribute value.

The statusEnd is a JSON object containing the following:

The notification signalling the end of the monitoring of a presentity is represented by the following JSON data structure, where the value part of each name/value pair indicates its data type:

{"statusEnd": {"correlator": "String"}}

Notification of End to a Subscription

The subscriptionEnded JSON object is delivered when the subscription has been terminated, either blocked by the presentity or because of a timeout or connection failure.

It is sent to the Bayeux channel name associated with the application instance and specified in the request body as the endpoint attribute value.

The subscriptionEnded is a JSON object containing the following:

The notification signalling the end of the subscription to a presentity is represented by the following JSON data structure, where the value part of each name/value pair indicates its data type:

{"subscriptionEnded": {
  "presentity": "URI",
  "reason": "String"
}}

End Presence Notification

The End Presence Notification operation stops a Presence notification.

To stop a previously set up Presence notification, provide the correlator for the notification passed earlier in the Start Presence Notification request.

There is no request or response body for the End Presence Notification operation. If the request fails, the body of the error response will contain the identifier for the notification and the type of exception.

Authorization

Basic

HTTP Method

DELETE

URI

http://host:port/rest/presence/notification/${correlator}

where:

Request Body

There is no request body.

Response Header

Standard header fields. If the request fails, the Status-Line header field will contain the status code and the reason for the failure. See "Errors and Exceptions".

Response Body

There is no response body.


Get User Presence

The Get User Presence operation retrieves the aggregated presence data of a presentity to whose data the watcher has previously successfully subscribed. Only the attributes that the watcher is authorized to see are returned.

To retrieve the information, include the URI of the presentity and the required attributes as a data object in the query string of the Request-URI of the GET method.

If the Get User Presence operation is successful, the response body contains the result JSON data object with the aggregated presence data of the specified presentity.

Authorization

Basic

HTTP Method

GET

URI

http://host:port/rest/presence/data?filter=${query}

where host and port are the host name and port of the machine on which Services Gatekeeper is installed. ${query} is a data object with the following parameters:

The following JSON data structure represents this data object in the URI. The value part of each name/value pair indicates its data type:

{
  "presentity": "URI",
  "attributes": ["Activity|Place|Privacy|Sphere|Communication|Other"]
}

Request Header

The MIME-type for the Content-Type header field is application/json.

Request Body

There is no request body.

Response Header

Standard header fields. If the request fails, the Status-Line header field will contain the status code and the reason for the failure. See "Errors and Exceptions".

Response Body

The requested information is returned in a JSON object as the value for the result attribute. It is an array of nested JSON objects and attributes which represent the aggregated presence data of a presentity. It contains the following:

The response body for this operation is represented by the following JSON data structure, where the value part of each name/value pair indicates its data type:

{"result": [{
  "lastChange": "Calendar",
  "typeAndValue": {
    "unionElement": "Activity|Place|Privacy|Sphere|Communication|Other",
    "activity": "ActivityNone|Available|Busy|DoNotDisturb|OnThePhone|Steering|Meeting|Away|Meal|PermanentAbsence|Holiday|Performance|InTransit|Travel|Sleeping|ActivityOther",
    "communication": {"means": [{
      "contact": "URI",
      "priority": "Float",
      "type": "Phone|Chat|Sms|Video|Web|Email|Mms|MeansOther"
    }]},
    "other": {
      "name": "String",
      "value": "String"
    },
    "place": "PlaceNone|Home|Office|PublicTransport|Street|Outdoors|PublicPlace|Hotel|Theatre|Restaurant|School|Industrial|Quiet|Noisy|Aircraft|Ship|Bus|Station|Mall|Airport|Train|PlaceOther",
    "privacy": "PrivacyNone|PrivacyPublic|PrivacyPrivate|PrivacyQuiet|PrivacyOther",
    "sphere": "SphereNone|SphereWork|SphereHome|SphereOther"
  },
  "note": "String"
}]}

Publish

The Publish operation allows the presentity to publish presence information.

To publish the information, the request body contains the presence JSON data object with the aggregated presence data of the specified presentity.

If the request fails, the body of the error response will contain the identifier for the notification and the type of exception.

Authorization

Basic

HTTP Method

PUT

URI

http://host:port/rest/presence/data

where host and port are the host name and port of the machine on which Services Gatekeeper is installed.

Request Header

The MIME-type for the Content-Type header field is application/json.

Request Body

The request body for the Publish operation is a nested data object. The value for presence attribute is an array of nested JSON structures which represent the aggregated presence data of a presentity. It accepts the following parameters:

The request body for this operation is represented by the following JSON data structure, where the value part of each name/value pair indicates its data type:

{"presence": [{
  "lastChange": "Calendar",
  "typeAndValue": {
    "unionElement": "Activity|Place|Privacy|Sphere|Communication|Other",
    "activity": "ActivityNone|Available|Busy|DoNotDisturb|OnThePhone|Steering|Meeting|Away|Meal|PermanentAbsence|Holiday|Performance|InTransit|Travel|Sleeping|ActivityOther",
    "communication": {"means": [{
      "contact": "URI",
      "priority": "Float",
      "type": "Phone|Chat|Sms|Video|Web|Email|Mms|MeansOther"
    }]},
    "other": {
      "name": "String",
      "value": "String"
    },
    "place": "PlaceNone|Home|Office|PublicTransport|Street|Outdoors|PublicPlace|Hotel|Theatre|Restaurant|School|Industrial|Quiet|Noisy|Aircraft|Ship|Bus|Station|Mall|Airport|Train|PlaceOther",
    "privacy": "PrivacyNone|PrivacyPublic|PrivacyPrivate|PrivacyQuiet|PrivacyOther",
    "sphere": "SphereNone|SphereWork|SphereHome|SphereOther"
  },
  "note": "String"
}]}

Response Header

Standard header fields. If the request fails, the Status-Line header field will contain the status code and the reason for the failure. See "Errors and Exceptions".

Response Body

There is no response body.