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
¶
Bases: BaseModel
The Nextmv Cloud account (organization).
To handle managed accounts, SSO must be configured for your organization. Please contact Nextmv support for assistance.
You can import the Account class directly from cloud:
This class provides access to account-level operations in the Nextmv Cloud, such as retrieving the queue of runs.
Note: It is recommended to use Account.get() or Account.new()
instead of direct initialization to ensure proper setup.
| PARAMETER | DESCRIPTION |
|---|---|
|
Client to use for interacting with the Nextmv Cloud API.
TYPE:
|
|
ID of the account (organization).
TYPE:
|
|
Name of the account (organization).
TYPE:
|
|
List of members in the account (organization).
TYPE:
|
|
Base endpoint for the account (SDK-specific).
TYPE:
|
|
Base endpoint for organization operations (SDK-specific).
TYPE:
|
Examples:
>>> from nextmv.cloud import Client, Account
>>> client = Client(api_key="your-api-key")
>>> # Retrieve an existing account
>>> account = Account.get(client=client, account_id="your-account-id")
>>> print(f"Account name: {account.name}")
Account name: Bunny Logistics
>>> # Create a new account
>>> new_account = Account.new(client=client, name="Hare Delivery Co", admins=["admin@example.com"])
>>> # Get the queue of runs
>>> queue = account.queue()
>>> print(f"Number of runs in queue: {len(queue.runs)}")
Number of runs in queue: 3
account_endpoint
class-attribute
instance-attribute
¶
Base endpoint for the account.
account_id
class-attribute
instance-attribute
¶
account_id: str | None = Field(
serialization_alias="id",
validation_alias=AliasChoices("id", "account_id"),
default=None,
)
ID of the account (organization).
client
class-attribute
instance-attribute
¶
Client to use for interacting with the Nextmv Cloud API.
delete
¶
Delete the account.
Permanently removes the account (organization) from Nextmv Cloud. You must have the administrator role on that account in order to delete it.
| RAISES | DESCRIPTION |
|---|---|
HTTPError
|
If the response status code is not 2xx. |
Examples:
Source code in nextmv/nextmv/cloud/account.py
get
classmethod
¶
get(client: Client, account_id: str) -> Account
Retrieve an account directly from Nextmv Cloud.
This function is useful if you want to populate an Account class
by fetching the attributes directly from Nextmv Cloud.
| PARAMETER | DESCRIPTION |
|---|---|
|
Client to use for interacting with the Nextmv Cloud API.
TYPE:
|
|
ID of the account to retrieve.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Account
|
The requested account. |
| RAISES | DESCRIPTION |
|---|---|
HTTPError
|
If the response status code is not 2xx. |
Examples:
>>> from nextmv.cloud import Client, Account
>>> client = Client(api_key="your-api-key")
>>> account = Account.get(client=client, account_id="bunny-logistics")
>>> print(f"Account: {account.name}")
Account: Bunny Logistics
>>> print(f"Members: {len(account.members)}")
Members: 3
Source code in nextmv/nextmv/cloud/account.py
members
class-attribute
instance-attribute
¶
members: list[AccountMember] | None = None
List of members in the account (organization).
model_post_init
¶
Initialize the organization_endpoint attribute.
This method is automatically called after class initialization to format the organization_endpoint URL with the account ID.
Source code in nextmv/nextmv/cloud/account.py
name
class-attribute
instance-attribute
¶
Name of the account (organization).
new
classmethod
¶
Create a new account (organization) directly in Nextmv Cloud.
To create managed accounts, SSO must be configured for your organization. Please contact Nextmv support for assistance.
| PARAMETER | DESCRIPTION |
|---|---|
|
Client to use for interacting with the Nextmv Cloud API.
TYPE:
|
|
Name of the new account.
TYPE:
|
|
List of admin user emails for the new account.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Account
|
The newly created account. |
Examples:
>>> from nextmv.cloud import Client
>>> client = Client(api_key="your-api-key")
>>> account = Account.new(client=client, name="My New Account", admins=["admin@example.com"])
Source code in nextmv/nextmv/cloud/account.py
organization_endpoint
class-attribute
instance-attribute
¶
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:
>>> from nextmv.cloud import Client, Account
>>> client = Client(api_key="your-api-key")
>>> account = Account.get(client=client, account_id="your-account-id")
>>> 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
update
¶
Update the account.
| PARAMETER | DESCRIPTION |
|---|---|
|
Name of the account.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Account
|
The updated account. |
| RAISES | DESCRIPTION |
|---|---|
HTTPError
|
If the response status code is not 2xx. |
Examples:
>>> from nextmv.cloud import Client, Account
>>> client = Client(api_key="your-api-key")
>>> account = Account.get(client=client, account_id="bunny-logistics")
>>> updated_account = account.update(name="Bunny Express Logistics")
>>> print(updated_account.name)
Bunny Express Logistics
Source code in nextmv/nextmv/cloud/account.py
AccountMember
¶
Bases: BaseModel
A member of a Nextmv Cloud account (organization).
You can import the AccountMember class directly from cloud:
Represents an individual member of an organization in Nextmv Cloud, including their role and invitation status.
| ATTRIBUTE | DESCRIPTION |
|---|---|
email |
Email of the account member.
TYPE:
|
role |
Role of the account member.
TYPE:
|
pending_invite |
Whether the member has a pending invite.
TYPE:
|
Examples:
>>> member = AccountMember.from_dict({
... "email": "peter.rabbit@carrotexpress.com",
... "role": "admin",
... "pending_invite": False
... })
>>> print(f"{member.email} - {member.role}")
peter.rabbit@carrotexpress.com - admin
pending_invite
class-attribute
instance-attribute
¶
Whether the member has a pending invite.
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:
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:
|
Examples:
>>> from nextmv.cloud import Client, Account
>>> client = Client(api_key="your-api-key")
>>> account = Account.get(client=client, account_id="your-account-id")
>>> 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
QueuedRun
¶
Bases: BaseModel
A run that is pending to be executed in the account.
You can import the QueuedRun class directly from cloud:
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:
|
user_email |
Email of the user who created the run.
TYPE:
|
name |
Name of the run.
TYPE:
|
description |
Description of the run.
TYPE:
|
created_at |
Creation date of the run.
TYPE:
|
application_id |
ID of the application used for the run.
TYPE:
|
application_instance_id |
ID of the application instance used for the run.
TYPE:
|
application_version_id |
ID of the application version used for the run.
TYPE:
|
execution_class |
Execution class used for the run.
TYPE:
|
status_v2 |
Status of the run.
TYPE:
|
Examples:
>>> queued_run = QueuedRun.from_dict({
... "id": "run-123456",
... "user_email": "user@example.com",
... "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_v2": "RUNNING"
... })
>>> print(queued_run.name)
My Run