swh.coarnotify.server.views module#
Views.
- class swh.coarnotify.server.views.Receipt(notification: InboundNotification, request: Request)[source]#
Bases:
Response
A 201 HTTP Response containing the url of the created notification.
Init the Response.
- Parameters:
notification – the notification we created
request – the HTTP request
- class swh.coarnotify.server.views.Discover(request: Request)[source]#
Bases:
Response
A 200 HTTP Response containing the url of our inbox.
Init the Response.
- Parameters:
request – the HTTP request
- class swh.coarnotify.server.views.UserInbox(request: Request, notifications: QuerySet)[source]#
Bases:
Response
A 200 HTTP Response containing the url of our notifications sent by a user.
Init the Response.
- Parameters:
request – the HTTP request
notifications – a queryset if notifications
- swh.coarnotify.server.views.process_notification(request: Request) InboundNotification [source]#
Process an inbound COAR Notification.
structural payload validation
route notification to the proper handler depending on its type(s)
- Parameters:
request – an HTTP request
- Raises:
ParseError – invalid jsonld
ValidationError – invalid
@context
or inbox urlBadRequest – a CN with this id has already been processed
UnprocessableException – the CN was deemed unprocessable
NotAuthenticated – missing request.user
- Returns:
An HTTP response with an error code if the COAR Notification is structurally invalid, or a simple JSON response with a message key containing the outcome of the process (which is also send to the sender Inbox as a COAR Notification).
- swh.coarnotify.server.views.inbox(request, *args, **kwargs)[source]#
Main inbox API endpoint.
The response returned depends on the method used by the client:
HEAD: returns LDN inbox discovery headers
- GET:
unauthenticated: an HTML response
authenticated: user’s inbox
- POST:
unauthenticated: an exception
authenticated: the result of the payload processing
- Parameters:
request – an HTTP request
- Raises:
PermissionDenied – unable to auth user
- Returns:
An HTTP response