air_sdk.endpoints.ztp_scripts#
Classes#
A ZTP (Zero Touch Provisioning) script for a simulation. |
|
Retrieve, update, and delete ZTP scripts for simulations. |
Module Contents#
- class air_sdk.endpoints.ztp_scripts.ZTPScript[source]#
Bases:
air_sdk.air_model.AirModelA ZTP (Zero Touch Provisioning) script for a simulation.
ZTPScript objects should not be created directly. Use simulation.create_ztp_script(content=’…’) instead.
Note
When printed, the content field is truncated to 50 characters with newlines collapsed to avoid flooding console/logs with large scripts. Access the full content via ztp_script.content.
- created#
When the script was created.
- modified#
When the script was last modified.
- content#
The script content.
- simulation#
The simulation this script belongs to.
Examples
>>> # Create a ZTP script >>> content = '#!/bin/bash\n# CUMULUS-AUTOPROVISIONING\necho Hi' >>> ztp_script = simulation.create_ztp_script(content=content)
>>> # Update the script >>> content = '#!/bin/bash\n# CUMULUS-AUTOPROVISIONING\necho "Updated!"' >>> ztp_script.update(content=content)
>>> # Delete the script >>> ztp_script.delete() >>> print(simulation.ztp_script) None
- created: datetime.datetime#
- modified: datetime.datetime#
- simulation: air_sdk.endpoints.simulations.Simulation#
- classmethod get_model_api() type[ZTPScriptEndpointAPI][source]#
Returns the respective AirModelAPI type for this model
- property model_api: ZTPScriptEndpointAPI#
The current model API instance.
- update(*, content: str) None[source]#
Update the content of this ZTP script.
- Parameters:
content – The new script content to use.
Example
>>> ztp_script = simulation.ztp_script >>> content = '#!/bin/bash\n# CUMULUS-AUTOPROVISIONING\n' >>> content += 'echo "Updated script"' >>> ztp_script.update(content=content)
- class air_sdk.endpoints.ztp_scripts.ZTPScriptEndpointAPI(
- api: air_sdk.AirApi,
- default_filters: dict[str, Any] | None = None,
Bases:
air_sdk.air_model.BaseEndpointAPI[ZTPScript]Retrieve, update, and delete ZTP scripts for simulations.
ZTPScripts should be created during import or off of Simulation objects:
Examples
>>> # Create a ZTP script >>> content = '#!/bin/bash\n# CUMULUS-AUTOPROVISIONING\necho "Hello!"' >>> simulation.create_ztp_script(content=content) <ZTPScript(content='#!/bin/bash...')>
>>> # Get a ZTP script >>> ztp_script = api.ztp_scripts.get(simulation) >>> print(ztp_script.content) #!/bin/bash # CUMULUS-AUTOPROVISIONING echo "Hello!"
>>> # Update a ZTP script >>> content = '#!/bin/bash\n# CUMULUS-AUTOPROVISIONING\necho "Updated!"' >>> api.ztp_scripts.patch(simulation, content=content)
>>> # Delete a ZTP script >>> api.ztp_scripts.delete(simulation)
- get(
- *,
- simulation: air_sdk.endpoints.simulations.Simulation | air_sdk.air_model.PrimaryKey,
Get the ZTP script for the simulation if it exists.
- Parameters:
simulation – The simulation object or simulation ID.
- Returns:
The ZTP script for the simulation.
- Raises:
AirUnexpectedResponse – If the simulation doesn’t have a ZTP script.
Example
>>> # Using simulation object >>> ztp_script = api.ztp_scripts.get(simulation)
>>> # Using simulation ID >>> ztp_script = api.ztp_scripts.get('simulation-uuid')
>>> print(ztp_script.content) #!/bin/bash # CUMULUS-AUTOPROVISIONING echo "Hello, world!"
- patch(
- *,
- simulation: air_sdk.endpoints.simulations.Simulation | air_sdk.air_model.PrimaryKey,
- content: str,
Update the content of the ZTPScript.
- Parameters:
simulation – The simulation object or simulation ID.
content – The new script content.
- Returns:
The updated ZTP script.
Examples
>>> # Using simulation object >>> with open('ztp_script.sh', 'r') as f: ... content = f.read() >>> updated_script = api.ztp_scripts.patch(simulation, content=content)
>>> # Using simulation ID >>> content = '#!/bin/bash\n# CUMULUS-AUTOPROVISIONING\necho Hi' >>> api.ztp_scripts.patch('simulation-uuid', content=content)
- update(
- *,
- simulation: air_sdk.endpoints.simulations.Simulation | air_sdk.air_model.PrimaryKey,
- content: str,
Update the content of the ZTPScript.
This is an alias for patch() provided for consistency with other endpoints.
- Parameters:
simulation – The simulation object or simulation ID.
content – The new script content.
- Returns:
The updated ZTP script.
Examples
>>> # Using simulation object >>> content = '#!/bin/bash\n# CUMULUS-AUTOPROVISIONING' >>> api.ztp_scripts.update(simulation=simulation, content=content)
>>> # Using simulation ID >>> api.ztp_scripts.update(simulation='sim-id', content=content)
- delete(
- *,
- simulation: air_sdk.endpoints.simulations.Simulation | air_sdk.air_model.PrimaryKey,
Delete the ZTP script for the simulation.
After deletion, simulation.ztp_script will return None.
- Parameters:
simulation – The simulation object or simulation ID.
Examples
>>> # Using simulation object >>> api.ztp_scripts.delete(simulation)
>>> # Using simulation ID >>> api.ztp_scripts.delete('simulation-uuid')
>>> print(simulation.ztp_script) None