matrice.action module#

class matrice.action.Action(session, action_id)[source]#

Bases: object

Represents an action within the system.

This class provides an interface to interact with a specific action identified by its action_id. It retrieves the action’s details such as type, project, user, status, creation time, and associated service from the API.

action_id#

The unique identifier for this action.

Type:

str

action_type#

The type of action (retrieved from the API response).

Type:

str

project_id#

The unique ID of the project associated with this action.

Type:

str

user_id#

The unique ID of the user who triggered the action.

Type:

str

step_code#

A code representing the current step of the action process.

Type:

str

status#

The current status of the action (e.g., “pending”, “completed”).

Type:

str

created_at#

The timestamp when the action was initiated.

Type:

str

service_name#

The name of the service handling this action.

Type:

str

__init__(session, action_id)[source]#

Initializes the Action object and fetches the action details from the API.

refresh()[source]#

Refreshes the action instance, updating its details by calling the API again.

Examples

>>> session = RPCSession()  # Assuming `RPCSession` is an existing session class
>>> action = Action(session, "action_id_1234")
>>> print(action.action_type)  # Output the type of action
__init__(session, action_id)[source]#

Initializes the Action object and fetches the action details from the API.

Parameters:
  • session (RPCSession) – An active session object that is used to make API calls.

  • action_id (str) – The unique identifier for the action whose details need to be fetched.

Notes

This constructor calls the get_action_details function to retrieve the action details, which are then set as attributes of the Action object.

If an error occurs while fetching the action details, an error message will be printed.

refresh()[source]#

Refresh the instance by reinstantiating it with the previous values.

matrice.action.get_action_details(session, action_id)[source]#

Fetches action details from the API.

Parameters:
  • session (RPCSession) – An active session object used to perform API requests.

  • action_id (str) – The unique identifier of the action whose details are being fetched.

Returns:

A tuple containing two elements: - A dictionary with the action details if the request is successful. - An error message (str) if the request fails, otherwise None.

Return type:

tuple

Raises:

ConnectionError – Raised when there’s a failure in communication with the API.

Examples

>>> session = RPCSession()
>>> data, error = get_action_details(session, "action_id_1234")
>>> if error is None:
>>>     pprint(data)
>>> else:
>>>     print(f"Error: {error}")