air_sdk.endpoints.node_instructions#
Stub file for node instructions endpoint type hints.
Classes#
Data structure for shell executor type (input for create). |
|
Required fields for FileData. |
|
Data structure for file executor type (input for create). |
|
Data structure for init executor type (input for create). |
|
Data structure for shell executor type (returned from API). |
|
Data structure for file executor type (returned from API). |
|
Data structure for init executor type (returned from API). |
|
Node instruction model representing an automation instruction for a node. |
|
API client for node instructions endpoints. |
Module Contents#
- class air_sdk.endpoints.node_instructions.ShellData[source]#
Bases:
TypedDictData structure for shell executor type (input for create).
- class air_sdk.endpoints.node_instructions._FileDataRequired[source]#
Bases:
TypedDictRequired fields for FileData.
- class air_sdk.endpoints.node_instructions.FileData[source]#
Bases:
_FileDataRequiredData structure for file executor type (input for create).
Required: files - List of file dicts, each with ‘path’ and ‘content’ keys. Optional: post_commands - Shell commands to run after creating files.
- class air_sdk.endpoints.node_instructions.InitData[source]#
Bases:
TypedDictData structure for init executor type (input for create).
- class air_sdk.endpoints.node_instructions.ShellDataResponse[source]#
Bases:
ShellDataData structure for shell executor type (returned from API).
- executor: Literal['shell']#
- class air_sdk.endpoints.node_instructions.FileDataResponse[source]#
Bases:
_FileDataRequiredData structure for file executor type (returned from API).
Required: files - List of file dicts, each with ‘path’ and ‘content’ keys. Optional: post_commands - Shell commands to run after creating files. Optional: executor - Executor type (added by API).
- executor: Literal['file']#
- class air_sdk.endpoints.node_instructions.InitDataResponse[source]#
Bases:
InitDataData structure for init executor type (returned from API).
- executor: Literal['init']#
- class air_sdk.endpoints.node_instructions.NodeInstruction[source]#
Bases:
air_sdk.air_model.AirModelNode instruction model representing an automation instruction for a node.
Node instructions are commands or automation scripts that can be executed on simulation nodes. They support various executors and can be configured to run again on rebuild.
- id#
Unique identifier for the node instruction
- name#
Human-readable name of the node instruction
- node#
Node this instruction belongs to
- data#
Instruction data (ShellData, FileData, or InitData)
- created#
Timestamp when the node instruction was created
- modified#
Timestamp when the node instruction was last modified
- run_again_on_rebuild#
Whether to re-run this instruction on simulation rebuild
- state#
Execution state (e.g., ‘pending’, ‘running’, ‘completed’, ‘failed’)
- created: datetime.datetime#
- modified: datetime.datetime#
- classmethod get_model_api() type[NodeInstructionEndpointAPI][source]#
Returns the respective AirModelAPI type for this model.
- property model_api: NodeInstructionEndpointAPI#
- update( ) None#
Update the node instruction’s properties.
- Parameters:
name – New name for the node instruction
run_again_on_rebuild – Whether to re-run the instruction on simulation rebuild
Example
>>> instruction = api.node_instructions.get('instruction-id') >>> instruction.update(name='New Name', run_again_on_rebuild=True)
- class air_sdk.endpoints.node_instructions.NodeInstructionEndpointAPI(
- api: air_sdk.AirApi,
- default_filters: dict[str, Any] | None = None,
Bases:
air_sdk.air_model.BaseEndpointAPI[NodeInstruction]API client for node instructions endpoints.
- model: type[NodeInstruction]#
- create(
- *,
- node: str | air_sdk.air_model.PrimaryKey,
- executor: Literal['shell', 'init', 'file'],
- data: ShellData | FileData | InitData,
- name: str | None = ...,
- run_again_on_rebuild: bool | None = ...,
Create a new node instruction.
- Parameters:
node – Node object or ID to execute the instruction on
name – Name for the instruction
executor – Type of executor (‘shell’, ‘init’, ‘file’)
data –
Instruction data/payload (executor-specific):
- ShellData - For ‘shell’ executor
Contains: ‘commands’ (list of shell commands)
- FileData - For ‘file’ executor
Contains: ‘files’ (list of dicts with ‘path’ and ‘content’) Optional: ‘post_commands’ (shell commands to run after creating files)
- InitData - For ‘init’ executor
Contains: ‘hostname’ (hostname to set for the node)
run_again_on_rebuild – Optional whether to run instruction again on rebuild
- Returns:
The created NodeInstruction instance
Example
>>> # Create shell instruction >>> instruction = api.node_instructions.create( ... name='Setup Script', ... node='node-id', ... executor='shell', ... data=ShellData(commands=['#!/bin/bash\necho "Hello"']), ... run_again_on_rebuild=True, ... )
>>> # Create file instruction >>> instruction = api.node_instructions.create( ... name='Install Package', ... node='node-id', ... executor='file', ... data=FileData( ... files=[{'path': 'package.txt', 'content': 'package=1.0.0'}], ... post_commands=['#!/bin/bash\necho "Hello"'], ... ), ... run_again_on_rebuild=True, ... )
>>> # Create init instruction >>> instruction = api.node_instructions.create( ... name='Initialize Environment', ... node='node-id', ... executor='init', ... data=InitData(hostname='my-node'), ... run_again_on_rebuild=True, ... )
- list(
- *,
- created_by_client: bool = ...,
- executor: Literal['shell', 'init', 'file'] = ...,
- name: str = ...,
- node: str = ...,
- run_again_on_rebuild: bool = ...,
- simulation: str = ...,
- state: str = ...,
- search: str = ...,
- ordering: str = ...,
- limit: int = ...,
- offset: int = ...,
List all node instructions.
- Parameters:
created_by_client – Filter by created by client
executor – Filter by executor (‘shell’, ‘init’, ‘file’)
name – Filter by name
node – Filter by node
run_again_on_rebuild – Filter by run_again_on_rebuild
simulation – Filter by simulation
state – Filter by state
search – Search by name
ordering – Order by field
limit – Limit the number of results
offset – Offset the results
- Returns:
Iterator of NodeInstruction instances
Example
>>> # List all instructions for a node >>> for instruction in api.node_instructions.list(node='node-id'): ... print(instruction.name)
>>> # List with multiple filters >>> for instruction in api.node_instructions.list( ... simulation='sim-id', ... executor='shell', ... state='complete', ... ordering='-created', ... ): ... print(instruction.name, instruction.state)
- get(pk: air_sdk.air_model.PrimaryKey) NodeInstruction#
Get a specific node instruction by ID.
- Parameters:
pk – The node instruction ID (string or UUID)
- Returns:
The NodeInstruction instance
Example
>>> instruction = api.node_instructions.get('instruction-id') >>> print(instruction.name)
- patch(
- *,
- pk: air_sdk.air_model.PrimaryKey,
- name: str | None | dataclasses._MISSING_TYPE = ...,
- run_again_on_rebuild: bool | None | dataclasses._MISSING_TYPE = ...,
Partially update a node instruction.
- Parameters:
pk – The node instruction ID
name – New name for the instruction
run_again_on_rebuild – Whether to run again on rebuild
- Returns:
The updated NodeInstruction instance
Example
>>> instruction = api.node_instructions.patch( ... 'instruction-id', ... name='Updated Name', ... run_again_on_rebuild=True ... )