foliolib.folio.api.pubsub.PubSub
- class foliolib.folio.api.pubsub.PubSub(tenant: str, okapi: Optional[foliolib.okapi.okapiClient.OkapiClient] = None)
Bases:
foliolib.folio.FolioApiPubSub API
API for event-driven approach
- Parameters
tenant (str) – Tenant id
okapi (OkapiClient, optional) – Instance of OkapiClient. Defaults to None.
Methods
delete_eventType(eventTypeName)Delete eventType item with given {eventTypeId}
delete_messagingModules(**kwargs)DELETE /pubsub/messaging-modulesdelete_publisher(eventTypeName, **kwargs)Remove publisher declaration for certain event type
delete_subscriber(eventTypeName, **kwargs)API to remove Subscriber declaration for certain event type
get_eventType(eventTypeName)Retrieve eventType item with given {eventTypeId}
Get a list of evet type descriptors
get_histories(**kwargs)Get activity history
get_payload_by_event(eventId)Get audit message payload by event id
get_publishers(eventTypeName)API to retrieve registered Publishers
get_subscribers(eventTypeName)API to retrieve registered Subscribers
modify_eventType(eventTypeName, eventType)Update eventType item with given {eventTypeId}
set_eventType(eventType)Create new event type
set_publish(publish)POST /pubsub/publishset_publisher(publisher)Declare a publisher for a set of event types
set_subscriber(subscriber)POST /pubsub/event-types/declare/subscriber- delete_eventType(eventTypeName: str)
Delete eventType item with given {eventTypeId}
DELETE /pubsub/event-types/{eventTypeName}- Parameters
eventTypeName (str) –
- Raises
OkapiRequestNotFound – Not Found
OkapiRequestError – Bad Request
OkapiFatalError – Server Error
- delete_messagingModules(**kwargs)
DELETE /pubsub/messaging-modules- Parameters
**kwargs (properties) – Keyword Arguments
- Keyword Arguments
moduleId (str) –
module name and version
Example
mod-pubsub-1.0.0
moduleRole (str) –
module role (PUBLISHER/SUBSCRIBER)
Example
PUBLISHER
- Raises
OkapiRequestError – Bad Request
- delete_publisher(eventTypeName: str, **kwargs)
Remove publisher declaration for certain event type
DELETE /pubsub/event-types/{eventTypeName}/publishers- Parameters
eventTypeName (str) –
**kwargs (properties) – Keyword Arguments
- Keyword Arguments
moduleId (str) –
Publisher module name and version
Example
mod-pubsub-1.0.0
- delete_subscriber(eventTypeName: str, **kwargs)
API to remove Subscriber declaration for certain event type
DELETE /pubsub/event-types/{eventTypeName}/subscribers- Parameters
eventTypeName (str) –
**kwargs (properties) – Keyword Arguments
- Keyword Arguments
moduleId (str) –
Subscriber module name and version
Example
mod-pubsub-1.0.0
- get_eventType(eventTypeName: str)
Retrieve eventType item with given {eventTypeId}
GET /pubsub/event-types/{eventTypeName}- Parameters
eventTypeName (str) –
- Returns
See Schema below
- Return type
dict
- Raises
OkapiRequestNotFound – Not Found
OkapiFatalError – Server Error
Schema
{ "$schema": "http://json-schema.org/draft-04/schema#", "description": "Event Descriptor data model", "javaType": "org.folio.rest.jaxrs.model.EventDescriptor", "type": "object", "additionalProperties": false, "properties": { "eventType": { "description": "Unique Event type, human-readable String, not UUID", "type": "string" }, "description": { "description": "Detailed description of the event type", "type": "string" }, "eventTTL": { "description": "Default time-to-live (TTL) for events of this type in minutes", "type": "integer" }, "signed": { "description": "Indicates whether all events of this event type must be digitally signed by the publisher", "type": "boolean", "default": false }, "tmp": { "description": "Indicates whether descriptor is temporary and should be overwritten", "type": "boolean", "default": false } }, "required": [ "eventType", "eventTTL" ] }
- get_eventTypes()
Get a list of evet type descriptors
GET /pubsub/event-types- Returns
See Schema below
- Return type
dict
- Raises
OkapiRequestError – Bad Request
OkapiRequestUnauthorized – Authentication is required
OkapiFatalError – Server Error
Schema
{ "$schema": "http://json-schema.org/draft-04/schema#", "description": "Collection of Event Descriptors", "type": "object", "additionalProperties": false, "properties": { "eventDescriptors": { "description": "List of Event Descriptors", "type": "array", "id": "eventDescriptorsList", "items": { "type": "object", "$ref": "./eventDescriptor.json" } }, "totalRecords": { "description": "Total number of Event Descriptors", "type": "integer" } }, "excludedFromEqualsAndHashCode": [ "totalRecords" ], "required": [ "eventDescriptors", "totalRecords" ] }
- get_histories(**kwargs)
Get activity history
GET /pubsub/history- Parameters
**kwargs (properties) – Keyword Arguments
- Keyword Arguments
startDate (str) –
start date of the period of time for which audit messages are required
Example
2019-09-20 12:00:00
endDate (str) –
end date of the period of time for which audit messages are required
Example
2019-09-27 12:00:00
eventId (str) – eventId by which audit messages should be filtered
eventType (str) – eventType by which audit messages should be filtered
correlationId (str) – correlationId by which audit messages should be filtered
- Returns
See Schema below
- Return type
dict
- Raises
OkapiRequestError – Bad Request
OkapiFatalError – Server Error
Schema
{ "$schema": "http://json-schema.org/draft-04/schema#", "description": "Collection of Audit Messages", "type": "object", "additionalProperties": false, "properties": { "auditMessages": { "description": "List of Audit Messages", "type": "array", "id": "auditMessagesList", "items": { "type": "object", "$ref": "./auditMessage.json" } }, "totalRecords": { "description": "Total number of Audit Messages", "type": "integer" } }, "excludedFromEqualsAndHashCode": [ "totalRecords" ], "required": [ "auditMessages", "totalRecords" ] }
- get_payload_by_event(eventId: str)
Get audit message payload by event id
GET /pubsub/audit-messages/{eventId}/payload- Parameters
eventId (str) –
- Returns
See Schema below
- Return type
dict
- Raises
OkapiRequestNotFound – Not Found
OkapiFatalError – Server Error
Schema
{ "$schema": "http://json-schema.org/draft-04/schema#", "description": "Message payload for event", "type": "object", "additionalProperties": false, "properties": { "eventId": { "description": "Unique Event type id, UUID", "$ref": "uuid.json" }, "content": { "description": "String representation of JSON message's payload", "type": "string" } }, "excludedFromEqualsAndHashCode": [ "content" ], "required": [ "eventId" ] }
- get_publishers(eventTypeName: str)
API to retrieve registered Publishers
GET /pubsub/event-types/{eventTypeName}/publishers- Parameters
eventTypeName (str) –
- Returns
See Schema below
- Return type
dict
Schema
{ "$schema": "http://json-schema.org/draft-04/schema#", "description": "Collection of Messaging Modules", "type": "object", "additionalProperties": false, "properties": { "messagingModules": { "description": "List of Messaging Modules", "type": "array", "id": "messagingModulesList", "items": { "type": "object", "$ref": "./messagingModule.json" } }, "totalRecords": { "description": "Total number of Messaging Modules", "type": "integer" } }, "excludedFromEqualsAndHashCode": [ "totalRecords" ], "required": [ "messagingModules", "totalRecords" ] }
- get_subscribers(eventTypeName: str)
API to retrieve registered Subscribers
GET /pubsub/event-types/{eventTypeName}/subscribers- Parameters
eventTypeName (str) –
- Returns
See Schema below
- Return type
dict
Schema
{ "$schema": "http://json-schema.org/draft-04/schema#", "description": "Collection of Messaging Modules", "type": "object", "additionalProperties": false, "properties": { "messagingModules": { "description": "List of Messaging Modules", "type": "array", "id": "messagingModulesList", "items": { "type": "object", "$ref": "./messagingModule.json" } }, "totalRecords": { "description": "Total number of Messaging Modules", "type": "integer" } }, "excludedFromEqualsAndHashCode": [ "totalRecords" ], "required": [ "messagingModules", "totalRecords" ] }
- modify_eventType(eventTypeName: str, eventType: dict)
Update eventType item with given {eventTypeId}
PUT /pubsub/event-types/{eventTypeName}- Parameters
eventTypeName (str) –
eventType (dict) – See Schema below
- Raises
OkapiRequestNotFound – Not Found
OkapiRequestError – Bad Request
OkapiFatalError – Server Error
OkapiRequestUnprocessableEntity – Unprocessable Entity
Schema
{ "$schema": "http://json-schema.org/draft-04/schema#", "description": "Event Descriptor data model", "javaType": "org.folio.rest.jaxrs.model.EventDescriptor", "type": "object", "additionalProperties": false, "properties": { "eventType": { "description": "Unique Event type, human-readable String, not UUID", "type": "string" }, "description": { "description": "Detailed description of the event type", "type": "string" }, "eventTTL": { "description": "Default time-to-live (TTL) for events of this type in minutes", "type": "integer" }, "signed": { "description": "Indicates whether all events of this event type must be digitally signed by the publisher", "type": "boolean", "default": false }, "tmp": { "description": "Indicates whether descriptor is temporary and should be overwritten", "type": "boolean", "default": false } }, "required": [ "eventType", "eventTTL" ] }
- set_eventType(eventType: dict)
Create new event type
POST /pubsub/event-types- Parameters
eventType (dict) – See Schema below
- Raises
OkapiRequestError – Bad Request
OkapiRequestUnauthorized – Authentication is required
OkapiFatalError – Server Error
OkapiRequestUnprocessableEntity – Unprocessable Entity
Headers
Location - URI to the created eventType item
Schema
{ "$schema": "http://json-schema.org/draft-04/schema#", "description": "Event Descriptor data model", "javaType": "org.folio.rest.jaxrs.model.EventDescriptor", "type": "object", "additionalProperties": false, "properties": { "eventType": { "description": "Unique Event type, human-readable String, not UUID", "type": "string" }, "description": { "description": "Detailed description of the event type", "type": "string" }, "eventTTL": { "description": "Default time-to-live (TTL) for events of this type in minutes", "type": "integer" }, "signed": { "description": "Indicates whether all events of this event type must be digitally signed by the publisher", "type": "boolean", "default": false }, "tmp": { "description": "Indicates whether descriptor is temporary and should be overwritten", "type": "boolean", "default": false } }, "required": [ "eventType", "eventTTL" ] }
- set_publish(publish: dict)
POST /pubsub/publish- Parameters
publish (dict) – See Schema below
- Raises
OkapiRequestError – Bad Request
OkapiFatalError – Server Error
Schema
{ "$schema": "http://json-schema.org/draft-04/schema#", "description": "Event data model", "type": "object", "additionalProperties": false, "properties": { "id": { "description": "UUID", "$ref": "uuid.json" }, "eventType": { "description": "Unique Event type, human-readable String, not UUID", "type": "string" }, "eventMetadata": { "description": "Event metadata", "type": "object", "additionalProperties": false, "properties": { "tenantId": { "description": "Tenant id", "type": "string" }, "eventTTL": { "description": "Time-to-live (TTL) for event in minutes", "type": "integer" }, "correlationId": { "description": "Id to track related events, can be a meaningful string or a UUID", "type": "string" }, "originalEventId": { "description": "Id of the event that started the sequence of related events", "$ref": "uuid.json" }, "publisherCallback": { "description": "Allows a publisher to provide a callback endpoint or an error Event Type to be notified that despite the fact that there are subscribers for such an event type no one has received the event within the specified period of time", "type": "object", "properties": { "endpoint": { "description": "Callback endpoint", "type": "string" }, "eventType": { "description": "Error Event Type", "type": "string" } } }, "createdDate": { "description": "Timestamp when event was created", "type": "string", "format": "date-time" }, "publishedDate": { "description": "Timestamp when event was initially published to the underlying topic", "type": "string", "format": "date-time" }, "createdBy": { "description": "Username of the user whose action caused an event", "type": "string" }, "publishedBy": { "description": "Name and version of the module that published an event", "type": "string" } }, "required": [ "tenantId", "eventTTL", "publishedBy" ] }, "eventPayload": { "description": "A payload for the event can be of any type of serializable data and it is up to a publisher and a consumer to agree on the data structures they want to exchange", "type": "string" } }, "excludedFromEqualsAndHashCode": [ "eventMetadata", "eventPayload" ], "required": [ "id", "eventType", "eventMetadata" ] }
- set_publisher(publisher: dict)
Declare a publisher for a set of event types
POST /pubsub/event-types/declare/publisher- Parameters
publisher (dict) – See Schema below
- Raises
OkapiRequestError – Bad Request
OkapiFatalError – Server Error
Schema
{ "$schema": "http://json-schema.org/draft-04/schema#", "description": "Describes types of events the module publishes", "type": "object", "additionalProperties": false, "properties": { "moduleId": { "description": "Publisher module name and version", "type": "string" }, "eventDescriptors": { "description": "List of event descriptors published by the module", "type": "array", "items": { "type": "object", "$ref": "./eventDescriptor.json" } } }, "required": [ "moduleId", "eventDescriptors" ] }
- set_subscriber(subscriber: dict)
POST /pubsub/event-types/declare/subscriber- Parameters
subscriber (dict) – See Schema below
- Raises
OkapiRequestError – Bad Request
OkapiFatalError – Server Error
Schema
{ "$schema": "http://json-schema.org/draft-04/schema#", "description": "Describes the types of events the module is subscribed", "type": "object", "additionalProperties": false, "properties": { "moduleId": { "description": "Subscriber module name and version", "type": "string" }, "subscriptionDefinitions": { "description": "List of event types (subscription definition) the module is subscribed", "type": "array", "items": { "type": "object", "$ref": "./subscriptionDefinition.json" } } }, "required": [ "moduleId", "subscriptionDefinitions" ] }