API Reference¶
dartclient.core¶
-
class
dartclient.core.ModelFactory(client, engine_name=None, on_failure_email=None, on_started_email=None, on_success_email=None, tags=None)[source]¶ Provides factory methods for model objects that are used by SyncManager. You can sub-class to set project level defaults for each of the various model types.
-
create_action()[source]¶ Construct an action object and set the on_failure_email, on_success_email, and tags fields to the defaults.
Returns: the action object
-
create_dataset()[source]¶ Construct a dataset object and set the tags field to the default.
Returns: the dataset object
-
create_datastore()[source]¶ Create a datastore object and set the tags field to the default.
Returns: the datastore object
-
-
class
dartclient.core.SyncManager(client, model_factory)[source]¶ Provides convenient methods for synchronizing descriptions of a Dart model with a Dart server.
-
clean_datastore(datastore)[source]¶ Clean up the datastore, its workflows, etc.
Parameters: datastore – the datastore object
-
clean_workflow(workflow)[source]¶ Clean up the workflow, its actions and triggers, etc.
Parameters: workflow – the workflow object
-
filter_by(**kwargs)[source]¶ Convert the keyword args into a filters expression to use with list operations.
Parameters: kwargs – the keyword args Returns: the filters expression
-
find_action(action_name, workflow, action_state=None)[source]¶ Find the action by name and workflow
Parameters: - action_name – the action name
- action_state – the action state (optional)
- workflow – the owning workflow
Returns: the action object or None if not found
-
find_dataset(dataset_name)[source]¶ Find the dataset by name
Parameters: dataset_name – the dataset name Returns: the dataset object or None if not found
-
find_datastore(datastore_name, datastore_state)[source]¶ Find the datastore by name
Parameters: - datastore_name – the datastore name
- datastore_state – The state of the datastore. The default state for emr_engine should be ‘TEMPLATE’, otherwise ‘ACTIVE’.
Returns: the datastore object or None if not found
-
find_trigger(trigger_name, workflow)[source]¶ Find the trigger by name
Parameters: - trigger_name – the trigger name
- workflow – the owning workflow
Returns: the trigger object or None if not found
-
find_workflow(workflow_name, datastore)[source]¶ Find the workflow by name and datastore
Parameters: - workflow_name – the workflow name
- datastore – the owning datastore
Returns: the workflow object or None if not found
-
sync_action(action_name, workflow, callback, dataset=None, subscription=None, action_state=None)[source]¶ Synchronize an action with Dart.
Parameters: - action_name – The name of the action.
- action_state – The state of the action.
- workflow – The workflow containing the action.
- callback – A function with a signature (action) => action
Returns: The created or updated action.
-
sync_dataset(dataset_name, callback)[source]¶ Synchronize a dataset with Dataset.
Parameters: - dataset_name – The name of the dataset
- callback – A function with a signature (dataset) => dataset
Returns: The created or updated dataset
-
sync_datastore(datastore_name, datastore_state, callback)[source]¶ Synchronize a datastore with Dart.
Parameters: - datastore_name – The name of the datastore.
- datastore_state – The state of the datastore. The default state for emr_engine should be ‘TEMPLATE’, otherwise ‘ACTIVE’
- callback – A function with a signature (datastore) => datastore
Returns: The created or updated datastore.
-
sync_trigger(trigger_name, workflow, callback, subscription=None)[source]¶ Synchronize a trigger with Dart.
Parameters: - trigger_name – The name of the trigger
- callback – A function with a signature (trigger) => trigger
Returns: The created or updated trigger.
-
sync_workflow(workflow_name, datastore, callback)[source]¶ Synchronize a workflow with Dart.
Parameters: - workflow_name – The name of the workflow.
- datastore – The datastore containing the workflow.
- callback – A function with a signature (workflow) => workflow
Returns: The created or updated workflow.
-
-
dartclient.core.create_basic_authenticator(host, username, password)[source]¶ Create a HTTP Basic authenticator object to use with create_client.
Parameters: - host –
- username –
- password –
Returns:
-
dartclient.core.create_client(origin_url=None, config=None, api_url=None, authenticator=None)[source]¶ Create the Bravado swagger client from the specified origin url and config. For the moment, the Swagger specification for Dart is actually bundled with this client since Dart does not have an endpoint that exposes it dynamically.
Parameters: - origin_url – The location of the Swagger specification. If not specified, then api_url must be specified will assume that swagger.json is present at that location.
- config – An optional configuration dictionary to pass to the Bravado SwaggerClient.
- api_url – The base URL for the API endpoints.
- authenticator – An authenticator instance to use when making API requests
Returns: The Bravado SwaggerClient instance.
-
dartclient.core.create_sync_manager(client=None, origin_url=None, api_url=None, config=None, model_factory=None, model_defaults=None)[source]¶ Convenient method to create a SyncManager instance.
Parameters: - client – bravado.client.SwaggerClient instance
- origin_url – Origin URL for constructing a SwaggerClient from a Swagger specification if one is not supplied.
- api_url – the Dart API URL
- config – Configuration dictionary for constructing a SwaggerClient if one is not supplied
- model_factory – ModelFactory instance
- model_defaults – Dictionary of default values for construction a ModelFactory if one is not supplied
Returns: