API Client

API Client represents a low level interface for Trigger API. All API operation can be performed using this.

class abeja.triggers.APIClient(credential: typing.Union[dict, NoneType] = None, timeout: typing.Union[int, NoneType] = None, max_retry_count: typing.Union[int, NoneType] = None)

A low-level client for Run API

from abeja.run import APIClient

api_client = APIClient()
create_trigger(organization_id: str, deployment_id: str, version_id: str, input_service_name: str, input_service_id: str, output_service_name: typing.Union[str, NoneType] = None, output_service_id: typing.Union[str, NoneType] = None, distribution: typing.Union[int, NoneType] = None, retry_count: typing.Union[int, NoneType] = None, environment: typing.Union[typing.Dict[str, str], NoneType] = None, model_id: typing.Union[str, NoneType] = None)

create a trigger

API reference: POST /organizations/<organization_id>/deployments/<deployment_id>/triggers

Request Syntax:
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)
Params:
  • 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.
Return type:
dict
Returns:

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"
    }
}
Raises:
  • Unauthorized: Authentication failed
  • NotFound:
  • Forbidden:
  • InternalServerError:
delete_trigger(organization_id: str, deployment_id: str, trigger_id: str) → dict

delete trigger

API reference: DELETE /organizations/<organization_id>/deployments/<deployment_id>/triggers/<trigger_id>

Request Syntax:
organization_id = "1234567890123"
deployment_id = "1111111111111"
trigger_id = "tri-3333333333333333"
response = api_client.delete_trigger(organization_id, deployment_id, trigger_id)
Params:
  • organization_id (str): The ID of the organization.
  • deployment_id (str): The ID of the deployment.
  • trigger_id (str): The ID of the trigger.
Return type:
dict
Returns:

Response Syntax:

{
    "message": "tri-3333333333333333 deleted"
}
Raises:
  • Unauthorized: Authentication failed
  • NotFound:
  • Forbidden:
  • InternalServerError:
get_trigger(organization_id: str, deployment_id: str, trigger_id: str) → dict

get a trigger

API reference: GET /organizations/<organization_id>/deployments/<deployment_id>/triggers/<trigger_id>

Request Syntax:
organization_id = "1234567890123"
deployment_id = "1111111111111"
trigger_id = "tri-3333333333333333"
response = api_client.get_trigger(organization_id, deployment_id, trigger_id)
Params:
  • organization_id (str): The ID of the organization.
  • deployment_id (str): The ID of the deployment.
  • trigger_id (str): The ID of the trigger.
Return type:
dict
Returns:

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.
Raises:
  • Unauthorized: Authentication failed
  • NotFound:
  • Forbidden:
  • InternalServerError:
get_trigger_runs(organization_id: str, deployment_id: str, trigger_id: str, next_page_token: typing.Union[str, NoneType] = None, scan_forward: typing.Union[bool, NoneType] = None) → dict

get runs of a trigger

API reference: GET /organizations/<organization_id>/deployments/<deployment_id>/triggers/<trigger_id>/runs

Request Syntax:
organization_id = "1234567890123"
deployment_id = "1111111111111"
trigger_id = "tri-3333333333333333"
response = api_client.get_trigger_runs(organization_id, deployment_id, trigger_id)
Params:
  • 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
Return type:
dict
Returns:

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"
}
Raises:
  • Unauthorized: Authentication failed
  • NotFound:
  • Forbidden:
  • InternalServerError:
get_triggers(organization_id: str, deployment_id: str) → dict

get triggers

API reference: GET /organizations/<organization_id>/deployments/<deployment_id>/triggers/

Request Syntax:
organization_id = "1234567890123"
deployment_id = "1111111111111"
response = api_client.get_triggers(organization_id, deployment_id)
Params:
  • organization_id (str): The ID of the organization.
  • deployment_id (str): The ID of the deployment.
Return type:
dict
Returns:

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"
        }
    ]
}
Raises:
  • Unauthorized: Authentication failed
  • NotFound:
  • Forbidden:
  • InternalServerError: