> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.nvidia.com/dsx-air/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.nvidia.com/dsx-air/_mcp/server.

# air_sdk.endpoints.services

## Classes

| Name                                                                | Description                          |
| ------------------------------------------------------------------- | ------------------------------------ |
| [`Service`](#air_sdkendpointsservicesservice)                       | Represents a service in the Air API. |
| [`ServiceEndpointAPI`](#air_sdkendpointsservicesserviceendpointapi) | API for managing services.           |

## Module Contents

```python
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:**

```python
>>> # 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()
```

```python
id: str
```

Unique identifier

```python
name: str
```

Service name

```python
node_port: int
```

Port number on the node/interface

```python
interface: Interface
```

Interface object (foreign key relationship)

```python
service_type: str
```

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

```python
worker_port: int | None
```

External port on the worker (assigned by Air)

```python
worker_fqdn: str | None
```

Fully qualified domain name of the worker

```python
created: datetime.datetime
```

Timestamp when service was created

```python
modified: datetime.datetime
```

Timestamp when service was last modified

```python
get_model_api() -> type[ServiceEndpointAPI]
```

```python
delete() -> None
```

Delete the service.

After deletion, the service object should not be used.

**Example:**

```python
>>> service.delete()
```

```python
refresh() -> None
```

Refresh service data from the API.

**Example:**

```python
>>> service.refresh()
```

```python
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:**

```python
>>> # 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)
```

```python
API_PATH: str
```

```python
model: type[Service]
```

```python
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 = ...
) -> Iterator[Service]
```

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:**

```python
>>> # 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)
```

```python
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:**

```python
>>> service = api.services.get('3dadd54d-583c-432e-9383-a2b0b1d7f551')
>>> print(f'{service.name}: {service.worker_fqdn}:{service.worker_port}')
```

```python
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:**

```python
>>> service = api.services.create(
...     name='SSH Access',
...     node_port=22,
...     interface='interface-id',
...     service_type='ssh',
... )
```

```python
delete(pk: PrimaryKey) -> None
```

Delete a service.

**Parameters:**

* `pk` – Service ID

**Example:**

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