Management

The following commands are available for subscribers.

Commands
Description Command
Get available subscribers di:list:type subscriber
Get subscriber configurations di:configurations
Create subscriber configurations di:configurations:create
Update subscriber configurations di:configurations:update
Delete subscriber configurations di:configurations:type:identifier:delete
Execute a subscriber consume:subscriber {identifier}'
 
API routes
Description Route
Get available subscribers GET /api/v1/di/list/subscriber
Get subscriber configurations GET /api/v1/di/configurations
Create subscriber configurations POST /api/v1/di/configurations
Update subscriber configurations PUT /api/v1/di/configurations
Delete subscriber configurations DELETE /api/v1/di/configurations/{type}/{identifier}
Execute a subscriber GET /api/v1/consume/{identifier}

Subscribers

A list of available subscribers can be fetched by using the API and CLI by using the command di:list:type subscriber or calling the URL /api/v1/di/list/subscriber.

Example of a response:

{
"type": "subscriber",
"configurations": [],
"prototypes": [
{
"identifier": "file-queue",
"name": "File Queue",
"description": "",
"schema": {
"type": "object",
"properties": {
"source": {
"title": "Source identifier",
"type": "string"
},
"handler": {
"title": "Handler identifier",
"type": "string"
}
}
}
}
]
}

Subscriber configurations

Configurations can be managed using the API and CLI. The required fields to create or update a subscriber are described in the configuration section.

List of all subscribers

A list of subscribers can be fetched by using the API and CLI. The dependency injection command or API call to fetch configuration objects can be used to get all available subscribers.

The command is di:configurations and the API call GET /api/v1/di/configurations. A Loopback Where filter. can be added to the command and API call to only show subscriber configurations.

Example of a a filter:

{
"where": {
"type": "incoming-configuration"
}
}

The CLI command including filter would be di:configurations --filter '{"where": { "type": "incoming-configuration"}}' and the API call including filter is GET /api/v1/di/configurations?filter={"where": {"type": "incoming-configuration"}}

Example of the response:

{
"metadata": {
"totalCount": 164
},
"results": [
{
"type": "incoming-configuration",
"identifier": "acme-stock-subscriber",
"name": "ACME stock subscriber",
"object": {
"parameters": {
"subscriber": {
"type": "acme-stock",
"parameters": {
"location": "warehouse-1",
"limit": 10
}
},
"entityType": "stock-entity",
"remote": "acme-stock-remote"
}
}
}
]
}

Creating a new configuration

Create a new configuration by using the di:configurations:create command or sending data to POST /api/v1/di/configuration.

Updating configuration

Update an existing configuration by using the di:configurations:update command or sending data to PUT /api/v1/di/configuration.

Deleting configuration

Delete an existing configuration by usign the di:configurations:type:identifier:delete {type} {identifier} command or making a DELETE /api/v1/di/configurations/{type}/{identifier} request.

The {type} must be replaced with the related type which is subscriber in this case. The {identifier} is the identifier of the configuration that will be deleted.

Running subscribers

A subscriber can be run from the command line or the API by running consume:subscriber {identifier} from the CLI or by calling api/v1/consume/{identifier} where {identifier} is the identifier of the subscriber that needs to be executed.