Skip to navigation

air_sdk.endpoints.ztp_templates

View as Markdown

Classes

NameDescription
ZTPTemplateA starting-point ZTP configuration, one per OS type.
ZTPTemplateEndpointAPIEndpoint API for managing ZTP templates.

Module Contents

class air_sdk.endpoints.ztp_templates.ZTPTemplate

Bases: air_sdk.air_model.AirModel

A starting-point ZTP configuration, one per OS type.

A template is example content offered in the ZTP editor, not a simulation’s own configuration. Editing a template never changes any existing simulation. Templates are platform-wide rather than per organization, and os_type identifies the row in the URL.

id: str

Unique identifier for the template

os_type: Literal[cumulus, nvos]

OS family this template applies to. It identifies the template, so it cannot be changed: assigning another value raises AttributeError and sends no request

template: str | dict[str, Any]

Template body. Cumulus holds a string containing the provisioning script; NVOS holds a JSON object containing the ZTP configuration. Object keys are returned sorted by name, which for NVOS is the order the sections run in. Array order is left as stored

Timestamp when the template was created

Timestamp when the template was last modified

created_by: str | None

UUID of the client that created the template, or None for a seeded template or once that client is deleted

last_modified_by: str | None

UUID of the client that created or last updated the template, or None for a seeded template no client has edited yet or once that client is deleted

get_model_api() -> type[ZTPTemplateEndpointAPI]
model_api: ZTPTemplateEndpointAPI
update(
*,
template: str | dict[str, Any] = ...,
**kwargs: Any
) -> None

Replace the body of this template.

os_type identifies the template and cannot be changed; create a separate template to cover another OS type.

Parameters:

  • template – The new body. A string for Cumulus, a JSON object for NVOS
  • **kwargs – Additional fields for future API compatibility

Example:

>>> template.update(template='#!/bin/bash\n#CUMULUS-AUTOPROVISIONING\n')
delete() -> None

Delete this template.

Simulations keep the ZTP configuration they already saved; only the starting point offered in the editor is removed. After deletion, the instance’s os_type is set to None.

Example:

>>> template.delete()
class air_sdk.endpoints.ztp_templates.ZTPTemplateEndpointAPI

Bases: air_sdk.air_model.BaseEndpointAPI[air_sdk.endpoints.ztp_templates.ZTPTemplate]

Endpoint API for managing ZTP templates.

Any client with an Air role can read a template. Creating, updating and deleting are restricted to Admin and SRE clients.

API_PATH: str
get(
pk: PrimaryKey,
**params: Any

Retrieve the template for one OS type.

Parameters:

  • pk – The OS type identifying the template, e.g. 'cumulus'
  • **params – Additional query parameters

Returns:

The matching ZTPTemplate

Example:

>>> template = api.ztp_templates.get('cumulus')
create(
*,
os_type: Literal[cumulus, nvos],
template: str | dict[str, Any],
**kwargs: Any

Create the template for one OS type.

Only one template may exist per OS type, and Air seeds a Cumulus and an NVOS template when it’s deployed, so create() returns 400 while that OS type has a template. To change a template, use patch() or the template’s update().

Parameters:

  • os_type – OS family the template applies to
  • template – The body. A string for Cumulus, a JSON object for NVOS
  • **kwargs – Additional fields for future API compatibility

Returns:

The created ZTPTemplate

Example:

>>> # Works only when the OS type has no template
>>> api.ztp_templates.create(
... os_type='nvos',
... template={'ztp': {'01-image': {'uninstall': True}}},
... )
patch(
pk: PrimaryKey,
*,
template: str | dict[str, Any] = ...,
**kwargs: Any

Replace the body of the template for one OS type.

Parameters:

  • pk – The OS type identifying the template
  • template – The new body
  • **kwargs – Additional fields for future API compatibility

Returns:

The updated ZTPTemplate

Example:

>>> api.ztp_templates.patch(
... 'nvos',
... template={'ztp': {'01-image': {'uninstall': True}}},
... )
update(
*,
ztp_template: ZTPTemplate | PrimaryKey,
template: str | dict[str, Any] = ...,
**kwargs: Any

Replace the body of a template.

Parameters:

  • ztp_template – The template instance, or the OS type identifying it
  • template – The new body
  • **kwargs – Additional fields for future API compatibility

Returns:

The updated ZTPTemplate

Example:

>>> api.ztp_templates.update(
... ztp_template='nvos',
... template={'ztp': {'01-image': {'uninstall': True}}},
... )
delete(
pk: PrimaryKey,
**kwargs: Any
) -> None

Delete the template for one OS type.

Parameters:

  • pk – The OS type identifying the template
  • **kwargs – Additional parameters

Example:

>>> api.ztp_templates.delete('nvos')