Skip to content

Account Module

This section documents the account components of the Nextmv Cloud API.

account

Account management functionality for the Nextmv Cloud API.

This module provides classes for interacting with account-level resources in the Nextmv Platform, particularly for accessing and managing the queue of runs.

CLASS DESCRIPTION
QueuedRun

A run that is pending to be executed in the account.

Queue

A list of runs that are pending or currently being executed.

Account

The Nextmv Platform account with API access methods.

Account dataclass

Account(client: Client, endpoint: str = 'v1/account')

The Nextmv Platform account.

You can import the Account class directly from cloud:

from nextmv.cloud import Account

This class provides access to account-level operations in the Nextmv Platform, such as retrieving the queue of runs.

PARAMETER DESCRIPTION

client

Client to use for interacting with the Nextmv Cloud API.

TYPE: Client

endpoint

Base endpoint for the account, by default "v1/account"

TYPE: str DEFAULT: 'v1/account'

ATTRIBUTE DESCRIPTION
client

Client to use for interacting with the Nextmv Cloud API.

TYPE: Client

endpoint

Base endpoint for the account.

TYPE: str

Examples:

>>> from nextmv.cloud import Client, Account
>>> client = Client(api_key="your-api-key")
>>> account = Account(client=client)
>>> queue = account.queue()
>>> print(f"Number of runs in queue: {len(queue.runs)}")
Number of runs in queue: 3

client instance-attribute

client: Client

Client to use for interacting with the Nextmv Cloud API.

endpoint class-attribute instance-attribute

endpoint: str = 'v1/account'

Base endpoint for the account.

queue

queue() -> Queue

Get the queue of runs in the account.

Retrieves the current list of runs that are pending or being executed in the Nextmv account.

RETURNS DESCRIPTION
Queue

Queue of runs in the account.

RAISES DESCRIPTION
HTTPError

If the response status code is not 2xx.

Examples:

>>> account = Account(client=Client(api_key="your-api-key"))
>>> queue = account.queue()
>>> for run in queue.runs:
...     print(f"Run {run.id}: {run.name} - Status: {run.status_v2}")
Run run-123: Daily Optimization - Status: RUNNING
Run run-456: Weekly Planning - Status: QUEUED
Source code in nextmv/nextmv/cloud/account.py
def queue(self) -> Queue:
    """Get the queue of runs in the account.

    Retrieves the current list of runs that are pending or being executed
    in the Nextmv account.

    Returns
    -------
    Queue
        Queue of runs in the account.

    Raises
    ------
    requests.HTTPError
        If the response status code is not 2xx.

    Examples
    --------
    >>> account = Account(client=Client(api_key="your-api-key"))
    >>> queue = account.queue()
    >>> for run in queue.runs:
    ...     print(f"Run {run.id}: {run.name} - Status: {run.status_v2}")
    Run run-123: Daily Optimization - Status: RUNNING
    Run run-456: Weekly Planning - Status: QUEUED
    """
    response = self.client.request(
        method="GET",
        endpoint=self.endpoint + "/queue",
    )

    return Queue.from_dict(response.json())

Queue

Bases: BaseModel

A queue is a list of runs that are pending to be executed, or currently being executed, in the account.

You can import the Queue class directly from cloud:

from nextmv.cloud import Queue

The Queue object provides access to a list of queued runs in a Nextmv account. It is typically obtained through the Account.queue() method.

ATTRIBUTE DESCRIPTION
runs

List of runs in the queue.

TYPE: list[QueuedRun]

Examples:

>>> account = Account(client=Client(api_key="your-api-key"))
>>> queue = account.queue()
>>> print(f"Number of runs in queue: {len(queue.runs)}")
Number of runs in queue: 5
>>> # Accessing the first run in the queue
>>> if queue.runs:
...     print(f"First run: {queue.runs[0].name}")
First run: My Priority Run

runs instance-attribute

runs: list[QueuedRun]

List of runs in the queue.

QueuedRun

Bases: BaseModel

A run that is pending to be executed in the account.

You can import the QueuedRun class directly from cloud:

from nextmv.cloud import QueuedRun

Represents details of a run in the queue, including its status and metadata. QueuedRun objects are typically obtained through the Account.queue() method.

ATTRIBUTE DESCRIPTION
id

ID of the run.

TYPE: str

user_email

Email of the user who created the run.

TYPE: str

name

Name of the run.

TYPE: str

description

Description of the run.

TYPE: str

created_at

Creation date of the run.

TYPE: datetime

application_id

ID of the application used for the run.

TYPE: str

application_instance_id

ID of the application instance used for the run.

TYPE: str

application_version_id

ID of the application version used for the run.

TYPE: str

execution_class

Execution class used for the run.

TYPE: str

status

Deprecated: use status_v2.

TYPE: Status

status_v2

Status of the run.

TYPE: StatusV2

Examples:

>>> queued_run = QueuedRun.from_dict({
...     "id": "run-123456",
...     "user_email": "[email protected]",
...     "name": "My Run",
...     "description": "Test run",
...     "created_at": "2023-01-01T12:00:00Z",
...     "application_id": "app-123456",
...     "application_instance_id": "appins-123456",
...     "application_version_id": "appver-123456",
...     "execution_class": "standard",
...     "status": "RUNNING",
...     "status_v2": "RUNNING"
... })
>>> print(queued_run.name)
My Run

application_id instance-attribute

application_id: str

ID of the application used for the run.

application_instance_id instance-attribute

application_instance_id: str

ID of the application instance used for the run.

application_version_id instance-attribute

application_version_id: str

ID of the application version used for the run.

created_at instance-attribute

created_at: datetime

Creation date of the run.

description instance-attribute

description: str

Description of the run.

execution_class instance-attribute

execution_class: str

Execution class used for the run.

id instance-attribute

id: str

ID of the run.

name instance-attribute

name: str

Name of the run.

status instance-attribute

status: Status

Deprecated: use status_v2.

status_v2 instance-attribute

status_v2: StatusV2

Status of the run.

user_email instance-attribute

user_email: str

Email of the user who created the run.