GMan python API

Client python library for interacting with the GMan REST API interface.

from piperci.gman import client as gman_client
from piperci.gman import exceptions as gman_exceptions

GMan Client

piperci.gman.client.get_events(gman_url=None, thread_id=None, task_id=None, run_id=None, query_filter=None)

Get list of all events for a given thread_id, run_id, or task_id, optionally filtered by a lambda expression. :param gman_url: GMan endpoint as a string. :param thread_id: (Optional) Thread ID to query for as a string. :param task_id: (Optional) Task ID to query for as a string. :param run_id: (Optional) Run ID to query for as a string. :param query_filter: Lambda expression :return: List of task events

piperci.gman.client.get_thread_id_tasks(thread_id=None, gman_url=None, query_filter=None)

Get a list of tasks associated with the given thread_id :param thread_id: The thread_id to query with as a sring :param gman_url: The GMan endpoint as a string :param query_filter: lambda expression :return: List of tasks associated with thread_id

piperci.gman.client.request_new_task_id(run_id=None, gman_url=None, project=None, caller=None, status=None, thread_id=None, parent_id=None)

Request a new TaskID from GMan, associated with a given RunID :param run_id: Unique identifier to correlate taskIDs as a string :param gman_url: GMan endpoint as a string :param project: Name of your project as a string :param caller: The invoker of the task. as a string :param status: The initial status of the task. This must either be “started” or “received”. Unless the caller of this function is an executor this should always be “started” :param: thread_id: The thread_id that this task should be associated with. This will mainly be used by executors who need to tie their task_id to the main task thread. :param: parent_id: The parent_id of the task which was delegated to this task. This is mainly used by executors who need to tie their task_id to the task of it’s parent. :return: JSON resposne from GMan

piperci.gman.client.update_task_id(task_id=None, gman_url=None, status=None, message=None)

Updates a taskID status and/or message :param task_id: TaskID to update as a string :param gman_url: GMan endpoint as a string :param status: The status to apply to the task :param message: The message to apply to the task :return: JSON response from gman

piperci.gman.client.wait_for_task_status(task_id=None, status=None, gman_url=None, retry_max=10)

Returns true if given task_id has a status of the given status. If retry_max is reached without a matching status then a Timeout exception is raised. If the given task returns with a “failed” state then we raise a TaskError exception. :param task_id: TaskID to query for as a string :param status: Status to wait for as a string :param gman_url: GMan endpoint as a string :param retry_max: The number of times to retry the query as an integer :return: True or exception

piperci.gman.client.wait_for_thread_id_complete(thread_id=None, gman_url=None, retry_max=10)

Wait for all tasks under a given thread_id to return with a status of complete, up to the retry_max. :param thread_id: thread_id as a string to search for :param gman_url: GMan endpoint as a string :param retry_max: Number of times to retry as an integer :return: True or exception

GMan Exceptions

exception piperci.gman.exceptions.InvalidResponse
exception piperci.gman.exceptions.TaskError