API Client represents a low level interface for Trigger API. All API operation can be performed using this.
A low-level client for Run API
from abeja.run import APIClient
api_client = APIClient()
create a trigger
API reference: POST /organizations/<organization_id>/deployments/<deployment_id>/triggers
organization_id = "1234567890123"
deployment_id = "1111111111111"
version_id = "ver-1111111111111111"
input_service_name = "datalake"
input_service_id = "2222222222222"
model_id = "3333333333333"
distribution = 0
retry_count = 0
environment = {
"EXAMPLE_ENV": "exmaple"
}
response = api_client.create_trigger(
organization_id, deployment_id, version_id, input_service_name, input_service_id,
model_id=model_id, distribution=distribution, retry_count=retry_count, environment=environment)
organization_id (str): The ID of the organization.
deployment_id (str): The ID of the deployment.
version_id (str): The ID of the version of a model.
input_service_name (str): specifies name of the input service, only datalake
is available for now.
input_service_id (str): specifies id of the service. In case of datalake
, specify channel_id
.
model_id (str): training model identifier
output_service_name (str): [optional] specifies name of the output service.
output_service_name (str): [optional] specifies id of the service. If output_service_name
is given, this field is required.
distribution (int): [optional] specifies the id whose remainder determine distributed queue, as default, round-robin is used.
retry_count (int): [optional] specifies the number of attempts from 0 to 9, defaults to 5.
environment (int): [optional] specifies the environment variables which can be referred from user code.
dict
Response Syntax:
{
"deployment_id": "1111111111111",
"input_service_id": "2222222222222",
"input_service_name": "datalake",
"models": {
"alias": "3333333333333"
},
"model_version": "0.0.3",
"model_version_id": "ver-1111111111111111",
"organization_id": "1234567890123",
"output_service_id": null,
"output_service_name": null,
"retry_count": 7,
"distribution": 0,
"trigger_id": "tri-3333333333333333",
"user_env_vars": {
"DEBUG": "debug"
}
}
Unauthorized: Authentication failed
NotFound:
Forbidden:
InternalServerError:
delete trigger
API reference: DELETE /organizations/<organization_id>/deployments/<deployment_id>/triggers/<trigger_id>
organization_id = "1234567890123"
deployment_id = "1111111111111"
trigger_id = "tri-3333333333333333"
response = api_client.delete_trigger(organization_id, deployment_id, trigger_id)
organization_id (str): The ID of the organization.
deployment_id (str): The ID of the deployment.
trigger_id (str): The ID of the trigger.
dict
Response Syntax:
{
"message": "tri-3333333333333333 deleted"
}
Unauthorized: Authentication failed
NotFound:
Forbidden:
InternalServerError:
get a trigger
API reference: GET /organizations/<organization_id>/deployments/<deployment_id>/triggers/<trigger_id>
organization_id = "1234567890123"
deployment_id = "1111111111111"
trigger_id = "tri-3333333333333333"
response = api_client.get_trigger(organization_id, deployment_id, trigger_id)
organization_id (str): The ID of the organization.
deployment_id (str): The ID of the deployment.
trigger_id (str): The ID of the trigger.
dict
Response Syntax:
{
"deployment_id": "1111111111111",
"input_service_id": "2222222222222",
"input_service_name": "datalake",
"models": {
"alias": "3333333333333"
},
"model_version": "0.0.3",
"model_version_id": "ver-1111111111111111",
"organization_id": "1234567890123",
"output_service_id": null,
"output_service_name": null,
"retry_count": 7,
"trigger_id": "tri-3333333333333333",
"user_env_vars": {
"DEBUG": "debug"
},
"created_at": "2018-01-01T00:00:00.000000Z",
"modified_at": "2018-01-01T00:00:00.000000Z"
}
Response Structure:
deployment_id (str): The ID of the deployment.
models (dict): combination of alias and model_id
model_version (str): The version of the model.
model_version_id (str): The ID of the version.
input_service_name (str): specifies name of the input service, only datalake
is available for now.
input_service_id (str): specifies id of the service. In case of datalake
, specify channel_id
.
output_service_name (str): [optional] specifies name of the output service.
output_service_name (str): [optional] specifies id of the service. If output_service_name
is given, this field is required.
retry_count (int): the number of attempts.
run_id (str): The ID of the run.
user_env_vars (str): environment variables which are available in user code.
created_at (str): created date of the run.
modified_at (str): modified date of the run.
Unauthorized: Authentication failed
NotFound:
Forbidden:
InternalServerError:
get runs of a trigger
API reference: GET /organizations/<organization_id>/deployments/<deployment_id>/triggers/<trigger_id>/runs
organization_id = "1234567890123"
deployment_id = "1111111111111"
trigger_id = "tri-3333333333333333"
response = api_client.get_trigger_runs(organization_id, deployment_id, trigger_id)
organization_id (str): The ID of the organization.
deployment_id (str): The ID of the deployment.
trigger_id (str): The ID of the trigger.
next_page_token (str): [optional] Token for offset of entries.
scan_forward (str): [optional] By default False
, the sort order is descending. To reverse the order, set this to True
dict
Response Syntax:
{
"entries": [
{
"created_at": "2019-01-01T00:00:00.000000Z",
"deployment_id": "1111111111111",
"input_data": {
"$datalake:1": "2222222222222/20190101T000000-e8286a2a-100a-4a40-a7de-5c9a5794b76c"
},
"models": {
"alias": "3333333333333"
},
"model_version_id": "ver-1111111111111111",
"modified_at": "2019-01-01T00:00:00.000000Z",
"output_template": null,
"retry_count": 5,
"run_id": "run-3333333333333333",
"status": "SUCCEEDED",
"trigger_id": "tri-3333333333333333",
"user_env_vars": {}
}
],
"next_page_token": "xxxxx"
}
Unauthorized: Authentication failed
NotFound:
Forbidden:
InternalServerError:
get triggers
API reference: GET /organizations/<organization_id>/deployments/<deployment_id>/triggers/
organization_id = "1234567890123"
deployment_id = "1111111111111"
response = api_client.get_triggers(organization_id, deployment_id)
organization_id (str): The ID of the organization.
deployment_id (str): The ID of the deployment.
dict
Response Syntax:
{
"entries": [
{
"deployment_id": "1111111111111",
"input_service_id": "2222222222222",
"input_service_name": "datalake",
"models": {
"alias": "3333333333333"
},
"model_version": "0.0.3",
"model_version_id": "ver-1111111111111111",
"organization_id": "1234567890123",
"output_service_id": null,
"output_service_name": null,
"retry_count": 7,
"trigger_id": "tri-3333333333333333",
"user_env_vars": {
"DEBUG": "debug"
},
"created_at": "2018-01-01T00:00:00.000000Z",
"modified_at": "2018-01-01T00:00:00.000000Z"
}
]
}
Unauthorized: Authentication failed
NotFound:
Forbidden:
InternalServerError: