Managers

After you’ve instantiated a saltant.client.Client, you can interface with saltant models through managers, which are attributes of the Client class; that is,

  • Client.container_task_instances
  • Client.container_task_types
  • Client.executable_task_instances
  • Client.executable_task_types
  • Client.task_queues
  • Client.task_whitelists
  • Client.users

With these managers you can perform the usual API requests, along with some other convenience functions: for example, waiting for a task instance to finish.

Manager references

class saltant.models.container_task_instance.ContainerTaskInstanceManager(_client)

Bases: saltant.models.base_task_instance.BaseTaskInstanceManager

Manager for container task instances.

_client

saltant.client.Client – An authenticated saltant client.

list_url

str – The URL to list task instances.

detail_url

str – The URL format to get specific task instances.

clone_url

str – The URL format to clone a task instance.

terminate_url

str – The URL format to terminate a task instance.

model

saltant.models.container_task_instance.ContainerTaskInstance – The model of the task instance being used.

clone(uuid)

Clone the task instance with given UUID.

Parameters:uuid (str) – The UUID of the task instance to clone.
Returns:A task instance model instance representing the task instance created due to the clone.
Return type:saltant.models.base_task_instance.BaseTaskInstance
clone_many(uuids)

Clone the task instances with given UUIDs.

Parameters:uuids (list) – A list of strings containing the UUIDs of the task instances to clone.
Returns:A list of saltant.models.base_task_instance.BaseTaskInstance subclass instances representing the task instances created due to the clone.
Return type:list
create(task_type_id, task_queue_id, arguments=None, name='')

Create a task instance.

Parameters:
  • task_type_id (int) – The ID of the task type to base the task instance on.
  • task_queue_id (int) – The ID of the task queue to run the job on.
  • arguments (dict, optional) – The arguments to give the task type.
  • name (str, optional) – A non-unique name to give the task instance.
Returns:

A task instance model instance representing the task instance just created.

Return type:

saltant.models.base_task_instance.BaseTaskInstance

get(uuid)

Get the task instance with given UUID.

Parameters:uuid (str) – The UUID of the task instance to get.
Returns:A task instance model instance representing the task instance requested.
Return type:saltant.models.base_task_instance.BaseTaskInstance
list(filters=None)

List model instances.

Currently this gets everything and iterates through all possible pages in the API. This may be unsuitable for production environments with huge databases, so finer grained page support should likely be added at some point.

Parameters:filters (dict, optional) –

API query filters to apply to the request. For example:

{'name__startswith': 'azure',
 'user__in': [1, 2, 3, 4],}

See saltant’s API reference at https://saltant-org.github.io/saltant/ for each model’s available filters.

Returns:A list of saltant.models.resource.Model subclass instances (for example, container task type model instances).
Return type:list
model

alias of ContainerTaskInstance

response_data_to_model_instance(response_data)

Convert response data to a task instance model.

Parameters:response_data (dict) – The data from the request’s response.
Returns:A task instance model instance representing the task instance from the reponse data.
Return type:saltant.models.base_task_instance.BaseTaskInstance
response_data_to_model_instances_list(response_data)

Convert list response data to a list of models.

Parameters:response_data (dict) – The data from the request’s response.
Returns:A list of saltant.models.resource.Model subclass instances.
Return type:list
terminate(uuid)

Terminate the task instance with given UUID.

Parameters:uuid (str) – The UUID of the task instance to terminate.
Returns:A task instance model instance representing the task instance that was told to terminate.
Return type:saltant.models.base_task_instance.BaseTaskInstance
terminate_many(uuids)

Terminate the task instances with given UUIDs.

Parameters:uuids (list) – A list of strings containing the UUIDs of the task instances to terminate.
Returns:A list of saltant.models.base_task_instance.BaseTaskInstance instances representing the task instances told to terminate.
Return type:list
static validate_request_success(response_text, request_url, status_code, expected_status_code)

Validates that a request was successful.

Parameters:
  • response_text (str) – The response body of the request.
  • request_url (str) – The URL the request was made at.
  • status_code (int) – The status code of the response.
  • expected_status_code (int) – The expected status code of the response.
Raises:

saltant.exceptions.BadHttpRequestError – The HTTP request failed.

wait_until_finished(uuid, refresh_period=5)

Wait until a task instance with the given UUID is finished.

Parameters:
  • uuid (str) – The UUID of the task instance to wait for.
  • refresh_period (float, optional) – How many seconds to wait in between checking the task’s status. Defaults to 5 seconds.
Returns:

A task instance model instance representing the task instance which we waited for.

Return type:

saltant.models.base_task_instance.BaseTaskInstance

class saltant.models.container_task_type.ContainerTaskTypeManager(_client)

Bases: saltant.models.base_task_type.BaseTaskTypeManager

Manager for container task types.

_client

saltant.client.Client – An authenticated saltant client.

list_url

str – The URL to list task types.

detail_url

str – The URL format to get specific task types.

model

saltant.models.container_task_type.ContainerTaskType – The model of the task instance being used.

create(name, command_to_run, container_image, container_type, description='', logs_path='', results_path='', environment_variables=None, required_arguments=None, required_arguments_default_values=None, extra_data_to_post=None)

Create a container task type.

Parameters:
  • name (str) – The name of the task.
  • command_to_run (str) – The command to run to execute the task.
  • container_image (str) – The container name and tag. For example, ubuntu:14.04 for Docker; and docker://ubuntu:14:04 or shub://vsoch/hello-world for Singularity.
  • container_type (str) – The type of the container.
  • description (str, optional) – The description of the task type.
  • logs_path (str, optional) – The path of the logs directory inside the container.
  • results_path (str, optional) – The path of the results directory inside the container.
  • environment_variables (list, optional) – The environment variables required on the host to execute the task.
  • required_arguments (list, optional) – The argument names for the task type.
  • required_arguments_default_values (dict, optional) – Default values for the task’s required arguments.
  • extra_data_to_post (dict, optional) – Extra key-value pairs to add to the request data. This is useful for subclasses which require extra parameters.
Returns:

A container task type model instance representing the task type just created.

Return type:

saltant.models.container_task_type.ContainerTaskType

get(id=None, name=None)

Get a task type.

Either the id xor the name of the task type must be specified.

Parameters:
  • id (int, optional) – The id of the task type to get.
  • name (str, optional) – The name of the task type to get.
Returns:

A task type model instance representing the task type requested.

Return type:

saltant.models.base_task_type.BaseTaskType

Raises:

ValueError – Neither id nor name were set or both id and name were set.

list(filters=None)

List model instances.

Currently this gets everything and iterates through all possible pages in the API. This may be unsuitable for production environments with huge databases, so finer grained page support should likely be added at some point.

Parameters:filters (dict, optional) –

API query filters to apply to the request. For example:

{'name__startswith': 'azure',
 'user__in': [1, 2, 3, 4],}

See saltant’s API reference at https://saltant-org.github.io/saltant/ for each model’s available filters.

Returns:A list of saltant.models.resource.Model subclass instances (for example, container task type model instances).
Return type:list
model

alias of ContainerTaskType

put(id, name, description, command_to_run, environment_variables, required_arguments, required_arguments_default_values, logs_path, results_path, container_image, container_type, extra_data_to_put=None)

Updates a task type on the saltant server.

Parameters:
  • id (int) – The ID of the task type.
  • name (str) – The name of the task type.
  • description (str) – The description of the task type.
  • command_to_run (str) – The command to run to execute the task.
  • environment_variables (list) – The environment variables required on the host to execute the task.
  • required_arguments (list) – The argument names for the task type.
  • required_arguments_default_values (dict) – Default values for the tasks required arguments.
  • extra_data_to_put (dict, optional) – Extra key-value pairs to add to the request data. This is useful for subclasses which require extra parameters.
  • logs_path (str) – The path of the logs directory inside the container.
  • results_path (str) – The path of the results directory inside the container.
  • container_image (str) – The container name and tag. For example, ubuntu:14.04 for Docker; and docker://ubuntu:14:04 or shub://vsoch/hello-world for Singularity.
  • container_type (str) – The type of the container.
response_data_to_model_instance(response_data)

Convert response data to a task type model.

Parameters:response_data (dict) – The data from the request’s response.
Returns:A model instance representing the task type from the reponse data.
Return type:saltant.models.base_task_type.BaseTaskType
response_data_to_model_instances_list(response_data)

Convert list response data to a list of models.

Parameters:response_data (dict) – The data from the request’s response.
Returns:A list of saltant.models.resource.Model subclass instances.
Return type:list
static validate_request_success(response_text, request_url, status_code, expected_status_code)

Validates that a request was successful.

Parameters:
  • response_text (str) – The response body of the request.
  • request_url (str) – The URL the request was made at.
  • status_code (int) – The status code of the response.
  • expected_status_code (int) – The expected status code of the response.
Raises:

saltant.exceptions.BadHttpRequestError – The HTTP request failed.

class saltant.models.executable_task_instance.ExecutableTaskInstanceManager(_client)

Bases: saltant.models.base_task_instance.BaseTaskInstanceManager

Manager for executable task instances.

_client

saltant.client.Client – An authenticated saltant client.

list_url

str – The URL to list task instances.

detail_url

str – The URL format to get specific task instances.

clone_url

str – The URL format to clone a task instance.

terminate_url

str – The URL format to terminate a task instance.

model

saltant.models.executable_task_instance.ExecutableTaskInstance – The model of the task instance being used.

clone(uuid)

Clone the task instance with given UUID.

Parameters:uuid (str) – The UUID of the task instance to clone.
Returns:A task instance model instance representing the task instance created due to the clone.
Return type:saltant.models.base_task_instance.BaseTaskInstance
clone_many(uuids)

Clone the task instances with given UUIDs.

Parameters:uuids (list) – A list of strings containing the UUIDs of the task instances to clone.
Returns:A list of saltant.models.base_task_instance.BaseTaskInstance subclass instances representing the task instances created due to the clone.
Return type:list
create(task_type_id, task_queue_id, arguments=None, name='')

Create a task instance.

Parameters:
  • task_type_id (int) – The ID of the task type to base the task instance on.
  • task_queue_id (int) – The ID of the task queue to run the job on.
  • arguments (dict, optional) – The arguments to give the task type.
  • name (str, optional) – A non-unique name to give the task instance.
Returns:

A task instance model instance representing the task instance just created.

Return type:

saltant.models.base_task_instance.BaseTaskInstance

get(uuid)

Get the task instance with given UUID.

Parameters:uuid (str) – The UUID of the task instance to get.
Returns:A task instance model instance representing the task instance requested.
Return type:saltant.models.base_task_instance.BaseTaskInstance
list(filters=None)

List model instances.

Currently this gets everything and iterates through all possible pages in the API. This may be unsuitable for production environments with huge databases, so finer grained page support should likely be added at some point.

Parameters:filters (dict, optional) –

API query filters to apply to the request. For example:

{'name__startswith': 'azure',
 'user__in': [1, 2, 3, 4],}

See saltant’s API reference at https://saltant-org.github.io/saltant/ for each model’s available filters.

Returns:A list of saltant.models.resource.Model subclass instances (for example, container task type model instances).
Return type:list
model

alias of ExecutableTaskInstance

response_data_to_model_instance(response_data)

Convert response data to a task instance model.

Parameters:response_data (dict) – The data from the request’s response.
Returns:A task instance model instance representing the task instance from the reponse data.
Return type:saltant.models.base_task_instance.BaseTaskInstance
response_data_to_model_instances_list(response_data)

Convert list response data to a list of models.

Parameters:response_data (dict) – The data from the request’s response.
Returns:A list of saltant.models.resource.Model subclass instances.
Return type:list
terminate(uuid)

Terminate the task instance with given UUID.

Parameters:uuid (str) – The UUID of the task instance to terminate.
Returns:A task instance model instance representing the task instance that was told to terminate.
Return type:saltant.models.base_task_instance.BaseTaskInstance
terminate_many(uuids)

Terminate the task instances with given UUIDs.

Parameters:uuids (list) – A list of strings containing the UUIDs of the task instances to terminate.
Returns:A list of saltant.models.base_task_instance.BaseTaskInstance instances representing the task instances told to terminate.
Return type:list
static validate_request_success(response_text, request_url, status_code, expected_status_code)

Validates that a request was successful.

Parameters:
  • response_text (str) – The response body of the request.
  • request_url (str) – The URL the request was made at.
  • status_code (int) – The status code of the response.
  • expected_status_code (int) – The expected status code of the response.
Raises:

saltant.exceptions.BadHttpRequestError – The HTTP request failed.

wait_until_finished(uuid, refresh_period=5)

Wait until a task instance with the given UUID is finished.

Parameters:
  • uuid (str) – The UUID of the task instance to wait for.
  • refresh_period (float, optional) – How many seconds to wait in between checking the task’s status. Defaults to 5 seconds.
Returns:

A task instance model instance representing the task instance which we waited for.

Return type:

saltant.models.base_task_instance.BaseTaskInstance

class saltant.models.executable_task_type.ExecutableTaskTypeManager(_client)

Bases: saltant.models.base_task_type.BaseTaskTypeManager

Manager for executable task types.

_client

saltant.client.Client – An authenticated saltant client.

list_url

str – The URL to list task types.

detail_url

str – The URL format to get specific task types.

model

saltant.models.executable_task_type.ExecutableTaskType – The model of the task instance being used.

create(name, command_to_run, description='', environment_variables=None, required_arguments=None, required_arguments_default_values=None, json_file_option=None, extra_data_to_post=None)

Create a container task type.

Parameters:
  • name (str) – The name of the task.
  • command_to_run (str) – The command to run to execute the task.
  • description (str, optional) – The description of the task type.
  • environment_variables (list, optional) – The environment variables required on the host to execute the task.
  • required_arguments (list, optional) – The argument names for the task type.
  • required_arguments_default_values (dict, optional) – Default values for the task’s required arguments.
  • json_file_option (str, optional) – The name of a command line option, e.g., –json-file, which accepts a JSON-encoded file for the command to run.
  • extra_data_to_post (dict, optional) – Extra key-value pairs to add to the request data. This is useful for subclasses which require extra parameters.
Returns:

An executable task type model instance representing the task type just created.

Return type:

saltant.models.container_task_type.ExecutableTaskType

get(id=None, name=None)

Get a task type.

Either the id xor the name of the task type must be specified.

Parameters:
  • id (int, optional) – The id of the task type to get.
  • name (str, optional) – The name of the task type to get.
Returns:

A task type model instance representing the task type requested.

Return type:

saltant.models.base_task_type.BaseTaskType

Raises:

ValueError – Neither id nor name were set or both id and name were set.

list(filters=None)

List model instances.

Currently this gets everything and iterates through all possible pages in the API. This may be unsuitable for production environments with huge databases, so finer grained page support should likely be added at some point.

Parameters:filters (dict, optional) –

API query filters to apply to the request. For example:

{'name__startswith': 'azure',
 'user__in': [1, 2, 3, 4],}

See saltant’s API reference at https://saltant-org.github.io/saltant/ for each model’s available filters.

Returns:A list of saltant.models.resource.Model subclass instances (for example, container task type model instances).
Return type:list
model

alias of ExecutableTaskType

put(id, name, description, command_to_run, environment_variables, required_arguments, required_arguments_default_values, json_file_option, extra_data_to_put=None)

Updates a task type on the saltant server.

Parameters:
  • id (int) – The ID of the task type.
  • name (str) – The name of the task type.
  • description (str) – The description of the task type.
  • command_to_run (str) – The command to run to execute the task.
  • environment_variables (list) – The environment variables required on the host to execute the task.
  • required_arguments (list) – The argument names for the task type.
  • required_arguments_default_values (dict) – Default values for the tasks required arguments.
  • json_file_option (str) – The name of a command line option, e.g., –json-file, which accepts a JSON-encoded file for the command to run.
  • extra_data_to_put (dict, optional) – Extra key-value pairs to add to the request data. This is useful for subclasses which require extra parameters.
response_data_to_model_instance(response_data)

Convert response data to a task type model.

Parameters:response_data (dict) – The data from the request’s response.
Returns:A model instance representing the task type from the reponse data.
Return type:saltant.models.base_task_type.BaseTaskType
response_data_to_model_instances_list(response_data)

Convert list response data to a list of models.

Parameters:response_data (dict) – The data from the request’s response.
Returns:A list of saltant.models.resource.Model subclass instances.
Return type:list
static validate_request_success(response_text, request_url, status_code, expected_status_code)

Validates that a request was successful.

Parameters:
  • response_text (str) – The response body of the request.
  • request_url (str) – The URL the request was made at.
  • status_code (int) – The status code of the response.
  • expected_status_code (int) – The expected status code of the response.
Raises:

saltant.exceptions.BadHttpRequestError – The HTTP request failed.

class saltant.models.task_queue.TaskQueueManager(_client)

Bases: saltant.models.resource.ModelManager

Manager for task queues.

_client

saltant.client.Client – An authenticated saltant client.

list_url

str – The URL to list task queues.

detail_url

str – The URL format to get specific task queues.

model

saltant.models.task_queue.TaskQueue – The model of the task queue being used.

create(name, description='', private=False, runs_executable_tasks=True, runs_docker_container_tasks=True, runs_singularity_container_tasks=True, active=True, whitelists=None)

Create a task queue.

Parameters:
  • name (str) – The name of the task queue.
  • description (str, optional) – A description of the task queue.
  • private (bool, optional) – A boolean specifying whether the queue is exclusive to its creator. Defaults to False.
  • runs_executable_tasks (bool, optional) – A Boolean specifying whether the queue runs executable tasks. Defaults to True.
  • runs_docker_container_tasks (bool, optional) – A Boolean specifying whether the queue runs container tasks that run in Docker containers. Defaults to True.
  • runs_singularity_container_tasks (bool, optional) – A Boolean specifying whether the queue runs container tasks that run in Singularity containers. Defaults to True.
  • active (bool, optional) – A boolean specifying whether the queue is active. Default to True.
  • whitelists (list, optional) – A list of task whitelist IDs. Defaults to None (which gets translated to []).
Returns:

A task queue model instance representing the task queue just created.

Return type:

saltant.models.task_queue.TaskQueue

get(id=None, name=None)

Get a task queue.

Either the id xor the name of the task type must be specified.

Parameters:
  • id (int, optional) – The id of the task type to get.
  • name (str, optional) – The name of the task type to get.
Returns:

A task queue model instance representing the task queue requested.

Return type:

saltant.models.task_queue.TaskQueue

Raises:

ValueError – Neither id nor name were set or both id and name were set.

list(filters=None)

List model instances.

Currently this gets everything and iterates through all possible pages in the API. This may be unsuitable for production environments with huge databases, so finer grained page support should likely be added at some point.

Parameters:filters (dict, optional) –

API query filters to apply to the request. For example:

{'name__startswith': 'azure',
 'user__in': [1, 2, 3, 4],}

See saltant’s API reference at https://saltant-org.github.io/saltant/ for each model’s available filters.

Returns:A list of saltant.models.resource.Model subclass instances (for example, container task type model instances).
Return type:list
model

alias of TaskQueue

patch(id, name=None, description=None, private=None, runs_executable_tasks=None, runs_docker_container_tasks=None, runs_singularity_container_tasks=None, active=None, whitelists=None)

Partially updates a task queue on the saltant server.

Parameters:
  • id (int) – The ID of the task queue.
  • name (str, optional) – The name of the task queue.
  • description (str, optional) – The description of the task queue.
  • private (bool, optional) – A Booleon signalling whether the queue can only be used by its associated user.
  • runs_executable_tasks (bool, optional) – A Boolean specifying whether the queue runs executable tasks.
  • runs_docker_container_tasks (bool, optional) – A Boolean specifying whether the queue runs container tasks that run in Docker containers.
  • runs_singularity_container_tasks (bool, optional) – A Boolean specifying whether the queue runs container tasks that run in Singularity containers.
  • active (bool, optional) – A Booleon signalling whether the queue is active.
  • whitelists (list, optional) – A list of task whitelist IDs.
Returns:

A task queue model instance representing the task queue just updated.

Return type:

saltant.models.task_queue.TaskQueue

put(id, name, description, private, runs_executable_tasks, runs_docker_container_tasks, runs_singularity_container_tasks, active, whitelists)

Updates a task queue on the saltant server.

Parameters:
  • id (int) – The ID of the task queue.
  • name (str) – The name of the task queue.
  • description (str) – The description of the task queue.
  • private (bool) – A Booleon signalling whether the queue can only be used by its associated user.
  • runs_executable_tasks (bool) – A Boolean specifying whether the queue runs executable tasks.
  • runs_docker_container_tasks (bool) – A Boolean specifying whether the queue runs container tasks that run in Docker containers.
  • runs_singularity_container_tasks (bool) – A Boolean specifying whether the queue runs container tasks that run in Singularity containers.
  • active (bool) – A Booleon signalling whether the queue is active.
  • whitelists (list) – A list of task whitelist IDs.
Returns:

A task queue model instance representing the task queue just updated.

Return type:

saltant.models.task_queue.TaskQueue

response_data_to_model_instance(response_data)

Convert get response data to a model.

Parameters:response_data (dict) – The data from the request’s response.
Returns:A saltant.models.resource.Model subclass instance representing the resource given in the request’s response data.
Return type:saltant.models.resource.Model
response_data_to_model_instances_list(response_data)

Convert list response data to a list of models.

Parameters:response_data (dict) – The data from the request’s response.
Returns:A list of saltant.models.resource.Model subclass instances.
Return type:list
static validate_request_success(response_text, request_url, status_code, expected_status_code)

Validates that a request was successful.

Parameters:
  • response_text (str) – The response body of the request.
  • request_url (str) – The URL the request was made at.
  • status_code (int) – The status code of the response.
  • expected_status_code (int) – The expected status code of the response.
Raises:

saltant.exceptions.BadHttpRequestError – The HTTP request failed.

class saltant.models.task_whitelist.TaskWhitelistManager(_client)

Bases: saltant.models.resource.ModelManager

Manager for task whitelists.

_client

saltant.client.Client – An authenticated saltant client.

list_url

str – The URL to list task whitelists.

detail_url

str – The URL format to get specific task whitelists.

model

saltant.models.task_whitelist.TaskWhitelist – The model of the task whitelist being used.

create(name, description='', whitelisted_container_task_types=None, whitelisted_executable_task_types=None)

Create a task whitelist.

Parameters:
  • name (str) – The name of the task whitelist.
  • description (str, optional) – A description of the task whitelist.
  • whitelisted_container_task_types (list, optional) – A list of whitelisted container task type IDs.
  • whitelisted_executable_task_types (list, optional) – A list of whitelisted executable task type IDs.
Returns:

A task whitelist model instance representing the task whitelist just created.

Return type:

saltant.models.task_whitelist.TaskWhitelist

get(id=None, name=None)

Get a task whitelist.

Either the id xor the name of the task type must be specified.

Parameters:
  • id (int, optional) – The id of the task type to get.
  • name (str, optional) – The name of the task type to get.
Returns:

A task whitelist model instance representing the task whitelist requested.

Return type:

saltant.models.task_whitelist.TaskWhitelist

Raises:

ValueError – Neither id nor name were set or both id and name were set.

list(filters=None)

List model instances.

Currently this gets everything and iterates through all possible pages in the API. This may be unsuitable for production environments with huge databases, so finer grained page support should likely be added at some point.

Parameters:filters (dict, optional) –

API query filters to apply to the request. For example:

{'name__startswith': 'azure',
 'user__in': [1, 2, 3, 4],}

See saltant’s API reference at https://saltant-org.github.io/saltant/ for each model’s available filters.

Returns:A list of saltant.models.resource.Model subclass instances (for example, container task type model instances).
Return type:list
model

alias of TaskWhitelist

patch(id, name=None, description=None, whitelisted_container_task_types=None, whitelisted_executable_task_types=None)

Partially updates a task whitelist on the saltant server.

Parameters:
  • id (int) – The ID of the task whitelist.
  • name (str, optional) – The name of the task whitelist.
  • description (str, optional) – A description of the task whitelist.
  • whitelisted_container_task_types (list, optional) – A list of whitelisted container task type IDs.
  • whitelisted_executable_task_types (list, optional) – A list of whitelisted executable task type IDs.
Returns:

A task whitelist model instance representing the task whitelist just updated.

Return type:

saltant.models.task_whitelist.TaskWhitelist

put(id, name, description, whitelisted_container_task_types, whitelisted_executable_task_types)

Updates a task whitelist on the saltant server.

Parameters:
  • id (int) – The ID of the task whitelist.
  • name (str) – The name of the task whitelist.
  • description (str) – The description of the task whitelist.
  • whitelisted_container_task_types (list) – A list of whitelisted container task type IDs.
  • whitelisted_executable_task_types (list) – A list of whitelisted executable task type IDs.
Returns:

A task whitelist model instance representing the task whitelist just updated.

Return type:

saltant.models.task_whitelist.TaskWhitelist

response_data_to_model_instance(response_data)

Convert get response data to a model.

Parameters:response_data (dict) – The data from the request’s response.
Returns:A saltant.models.resource.Model subclass instance representing the resource given in the request’s response data.
Return type:saltant.models.resource.Model
response_data_to_model_instances_list(response_data)

Convert list response data to a list of models.

Parameters:response_data (dict) – The data from the request’s response.
Returns:A list of saltant.models.resource.Model subclass instances.
Return type:list
static validate_request_success(response_text, request_url, status_code, expected_status_code)

Validates that a request was successful.

Parameters:
  • response_text (str) – The response body of the request.
  • request_url (str) – The URL the request was made at.
  • status_code (int) – The status code of the response.
  • expected_status_code (int) – The expected status code of the response.
Raises:

saltant.exceptions.BadHttpRequestError – The HTTP request failed.

class saltant.models.user.UserManager(_client)

Bases: saltant.models.resource.ModelManager

Manager for task queues.

_client

saltant.client.Client – An authenticated saltant client.

list_url

str – The URL to list task queues.

detail_url

str – The URL format to get specific task queues.

model

saltant.models.user.User – The model of the task queue being used.

get(username)

Get a user.

Parameters:username (str) – The username of the user to get.
Returns:A user model instance representing the user requested.
Return type:saltant.models.user.User
list(filters=None)

List model instances.

Currently this gets everything and iterates through all possible pages in the API. This may be unsuitable for production environments with huge databases, so finer grained page support should likely be added at some point.

Parameters:filters (dict, optional) –

API query filters to apply to the request. For example:

{'name__startswith': 'azure',
 'user__in': [1, 2, 3, 4],}

See saltant’s API reference at https://saltant-org.github.io/saltant/ for each model’s available filters.

Returns:A list of saltant.models.resource.Model subclass instances (for example, container task type model instances).
Return type:list
model

alias of User

response_data_to_model_instance(response_data)

Convert get response data to a model.

Parameters:response_data (dict) – The data from the request’s response.
Returns:A saltant.models.resource.Model subclass instance representing the resource given in the request’s response data.
Return type:saltant.models.resource.Model
response_data_to_model_instances_list(response_data)

Convert list response data to a list of models.

Parameters:response_data (dict) – The data from the request’s response.
Returns:A list of saltant.models.resource.Model subclass instances.
Return type:list
static validate_request_success(response_text, request_url, status_code, expected_status_code)

Validates that a request was successful.

Parameters:
  • response_text (str) – The response body of the request.
  • request_url (str) – The URL the request was made at.
  • status_code (int) – The status code of the response.
  • expected_status_code (int) – The expected status code of the response.
Raises:

saltant.exceptions.BadHttpRequestError – The HTTP request failed.