coarnotify.client¶
This module contains all the client-specific code for sending notifications to an inbox and receiving the responses it may return
Classes¶
The COAR Notify Client, which is the mechanism through which you will interact with external inboxes. |
|
An object representing the response from a COAR Notify inbox. |
Module Contents¶
- class coarnotify.client.COARNotifyClient(inbox_url: str = None, http_layer: coarnotify.http.HttpLayer = None)¶
The COAR Notify Client, which is the mechanism through which you will interact with external inboxes.
If you do not supply an inbox URL at construction you will need to supply it via the
inbox_url
setter, or when you send a notification- Parameters:
inbox_url – HTTP URI of the inbox to communicate with by default
http_layer – An implementation of the HttpLayer interface to use for sending HTTP requests. If not provided, the default implementation will be used based on
requests
- send(notification: coarnotify.core.notify.NotifyPattern, inbox_url: str = None, validate: bool = True) NotifyResponse ¶
Send the given notification to the inbox. If no inbox URL is provided, the default inbox URL will be used.
- Parameters:
notification – The notification object (from the models provided, or a subclass you have made of the NotifyPattern class)
inbox_url – The HTTP URI to send the notification to. Omit if using the default inbox_url supplied in the constructor. If it is omitted, and no value is passed here then we will also look in the
target.inbox
property of the notificationvalidate – Whether to validate the notification before sending. If you are sure the notification is valid, you can set this to False
- Returns:
a NotifyResponse object representing the response from the server
- property inbox_url: str | None¶
The HTTP URI of the inbox to communicate with by default
- class coarnotify.client.NotifyResponse(action, location=None)¶
An object representing the response from a COAR Notify inbox.
This contains the action that was carried out on the server:
CREATED - a new resource was created
ACCEPTED - the request was accepted, but the resource was not yet created
In the event that the resource is created, then there will also be a location URL which will give you access to the resource
- ACCEPTED = 'accepted'¶
- CREATED = 'created'¶
- property action: str¶
The action that was taken, will be one of the constants CREATED or ACCEPTED
- property location: str | None¶
The HTTP URI of the created resource, if present