pyATS Datastructures

26.3 · active · verified Thu Apr 16

pyATS Datastructures provides extended data structures designed to enhance network automation and testing workflows. It offers specialized objects like `DataObject`, `DataList`, `DataDict`, and `MetaData` that allow for attribute-based access, schema validation, and meta-data handling, often used within the Cisco pyATS framework for managing configuration and state data. The current version is 26.3, and it follows the pyATS release cadence, typically releasing new versions quarterly or as needed with the main pyATS framework.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to create and interact with a `DataObject`, assigning attributes and converting it to a standard Python dictionary. `DataObject` provides attribute-style access and allows for nesting other `DataObject` instances.

from pyats.datastructures import DataObject

# Create a DataObject
data = DataObject()

# Assign attributes like a regular object
data.attr = 'value'
data.attr_2 = 123
data.nested = DataObject()
data.nested.item = 'nested_value'

# Access attributes
print(f"data.attr: {data.attr}")
print(f"data.nested.item: {data.nested.item}")

# Convert to a standard Python dictionary
plain_dict = data.to_dict()
print(f"Converted to dict: {plain_dict}")

assert plain_dict == {'attr': 'value', 'attr_2': 123, 'nested': {'item': 'nested_value'}}

view raw JSON →