air_sdk.endpoints.services

View as Markdown

Classes

NameDescription
ServiceRepresents a service in the Air API.
ServiceEndpointAPIAPI for managing services.

Module Contents

class air_sdk.endpoints.services.Service

Bases: air_sdk.bc.ServiceCompatMixin, air_sdk.bc.BaseCompatMixin, air_sdk.air_model.AirModel

Represents a service in the Air API.

A service exposes a port on a simulation interface to external networks, enabling connectivity between simulations and the outside world.

Example:

>>> # Access service details
>>> print(f'Service: {service.name}')
>>> print(f'Connect via: {service.worker_fqdn}:{service.worker_port}')
>>> print(f'Interface: {service.interface.name}')
>>>
>>> # Delete service
>>> service.delete()
id: str

Unique identifier

name: str

Service name

node_port: int

Port number on the node/interface

interface: Interface

Interface object (foreign key relationship)

service_type: str

Type of service (e.g., ‘ssh’, ‘http’, ‘https’)

worker_port: int | None

External port on the worker (assigned by Air)

worker_fqdn: str | None

Fully qualified domain name of the worker

Timestamp when service was created

Timestamp when service was last modified

get_model_api() -> type[ServiceEndpointAPI]
delete() -> None

Delete the service.

After deletion, the service object should not be used.

Example:

>>> service.delete()
refresh() -> None

Refresh service data from the API.

Example:

>>> service.refresh()
class air_sdk.endpoints.services.ServiceEndpointAPI

Bases: air_sdk.bc.ServiceEndpointAPICompatMixin, air_sdk.endpoints.mixins.ListApiMixin[air_sdk.endpoints.services.Service], air_sdk.endpoints.mixins.CreateApiMixin[air_sdk.endpoints.services.Service], air_sdk.endpoints.mixins.GetApiMixin[air_sdk.endpoints.services.Service], air_sdk.endpoints.mixins.DeleteApiMixin, air_sdk.air_model.BaseEndpointAPI[air_sdk.endpoints.services.Service]

API for managing services.

Services expose ports on simulation interfaces to enable external connectivity.

Example:

>>> # List all services
>>> for service in api.services.list():
... print(f'{service.name}: {service.worker_fqdn}:{service.worker_port}')
>>>
>>> # Create a service
>>> interface = api.interfaces.get('interface-id')
>>> service = api.services.create(
... name='SSH Service',
... node_port=22,
... interface=interface,
... service_type='ssh',
... )
>>>
>>> # Get a service
>>> service = api.services.get('service-id')
>>>
>>> # Delete a service by ID
>>> api.services.delete(service.id)
API_PATH: str
model: type[Service]
list(
*,
interface: PrimaryKey | None = ...,
name: str | None = ...,
node_port: int | None = ...,
worker_port: int | None = ...,
worker_fqdn: str | None = ...,
service_type: str | None = ...,
search: str | None = ...,
ordering: str | None = ...,
limit: int | None = ...,
offset: int | None = ...

List services with optional filtering and pagination.

Parameters:

  • interface – Filter by interface ID or instance
  • name – Filter by service name
  • node_port – Filter by node port
  • worker_port – Filter by worker port
  • worker_fqdn – Filter by worker FQDN
  • service_type – Filter by service type (ssh, http, https, etc.)
  • search – Search term to filter results
  • ordering – Field to order results by (prefix with ’-’ for descending)
  • limit – Maximum number of results to return
  • offset – Number of results to skip

Yields:

Service instances

Example:

>>> # List all services
>>> for service in api.services.list():
... print(service.name)
>>>
>>> # Filter by interface
>>> for service in api.services.list(interface='interface-id'):
... print(f"{service.name}: {service.worker_port}")
>>>
>>> # Filter by service type
>>> for service in api.services.list(service_type='ssh'):
... print(service.name)
get(pk: PrimaryKey) -> Service

Get a service by ID.

Parameters:

  • pk – Service ID

Returns:

Service instance

Raises:

  • AirUnexpectedResponse – Service not found or API error

Example:

>>> service = api.services.get('3dadd54d-583c-432e-9383-a2b0b1d7f551')
>>> print(f'{service.name}: {service.worker_fqdn}:{service.worker_port}')
create(
*,
name: str,
node_port: int,
interface: PrimaryKey,
service_type: Literal[SSH, HTTPS, HTTP, OTHER] = ...
) -> Service

Create a new service.

Parameters:

  • name – Service name
  • node_port – Port number on the node/interface
  • interface – Interface instance or ID
  • service_type – Service type - ‘SSH’, ‘HTTPS’, ‘HTTP’, or ‘OTHER’

Returns:

Created Service instance

Raises:

  • AirUnexpectedResponse – Creation failed

Example:

>>> service = api.services.create(
... name='SSH Access',
... node_port=22,
... interface='interface-id',
... service_type='ssh',
... )
delete(pk: PrimaryKey) -> None

Delete a service.

Parameters:

  • pk – Service ID

Example:

>>> api.services.delete('service-id')