CloudServices/Notifications/Specification: Difference between revisions

Jump to navigation Jump to search
Line 125: Line 125:
* '''Client Queue''': Entity within the message broker where all messages destined for a particular client of a user are sent (i.e. one queue per client).
* '''Client Queue''': Entity within the message broker where all messages destined for a particular client of a user are sent (i.e. one queue per client).


== Server API ==
== Agent API ==


The server API consists of:
The Agent API consists of a standard REST API, using HTTP GET, POST, PUT, and DELETE commands to retrieve and manipulate resources. The following table gives a summary of the API supported by the Agent:


=== Send Notification ===
{| class="wikitable"
 
|-
'''POST''' '''https://''server''/''notifications'' '''
! GET
 
! POST
Sends a notification.
! PUT
 
! DELETE
The body of the request is a JSON object of the form:
! Path
! Description
|-
| style="text-align: center;"|
| style="text-align: center;"|X
| style="text-align: center;"|
| style="text-align: center;"|
| /notifications
| Used by web apps to send notifications. The body of the HTTP request should contain a JSON string of the following form:
<pre>
{"routing_key": "routing_key",
"type": "the type of notification",
"timestamp": "UNIX timestamp",
"payload": "notification message"}
</pre>
All fields are mandatory.
|-
| style="text-align: center;"| X
| style="text-align: center;"|
| style="text-align: center;"|
| style="text-align: center;"|
| /users/'''name'''/subscriptions
| Retrieves all subscriptions for the user with the specified name. Only the authenticated user corresponding to '''name''' has permission to view this list. The list is returned as a JSON string of the form:
<pre>
[{"routing_key": "routing_key",
  "app_name": "Name of app",
  "app_host": "domain of app"},
...
]
</pre>
Each item in the JSON array corresponds to a subscription for the specified user.
|-
| style="text-align: center;"|
| style="text-align: center;"|
| style="text-align: center;"|X
| style="text-align: center;"|
| /users/'''name'''
| To PUT a user (i.e. create new user account) you'll need an HTTP body looking like the following:
<pre>
<pre>
{
{"password": "user's account password"}
    'user_app_key': user-app-key,
    'type': the type of notification
    'timestamp': web-app-specified time the notification was generated,
    'payload': notification message
}
</pre>
</pre>
 
|}
The Content-Type field can optionally be set to 'application/JSON'.
   
Return codes:
* ''201'': Accepted (indicates the notification was received by the server for processing, but may or may not be processed)
* ''403'': Forbidden (indicates the notification was not received due to exceeding limits or some other security reason, e.g. IP blacklisted)
 
'''Detailed Flow'''
TODO: Sequence diagram of request flow.


== Security Considerations ==
== Security Considerations ==
169

edits

Navigation menu