Skip to main content

Device Configuration Object

Provides access to device resources in Palo Alto Networks Strata Cloud Manager. Devices enroll out-of-band, so the SDK does not expose create or delete — but it does expose update() to modify the five writable fields defined by the upstream devices-put schema (display_name, folder, description, labels, snippets).

Class Overview

The Device class supports listing, filtering, retrieving, and updating device resources.

Methods

MethodDescriptionParametersReturn Type
get()Retrieves a device by IDdevice_id: strDeviceResponseModel
fetch()Gets device by namename: strDeviceResponseModel
list()Lists devices with filtering**filtersList[DeviceResponseModel]
update()Updates a device's metadatadevice: DeviceUpdateModelDeviceResponseModel

Model Attributes

AttributeTypeRequiredDefaultDescription
namestrNoNoneDevice name
idstrYes*NoneUnique device identifier
display_namestrNoNoneDisplay name for the device
serial_numberstrNoNoneDevice serial number
familystrNoNoneDevice family (e.g., 'vm')
modelstrNoNoneDevice model (e.g., 'PA-VM')
folderstrNoNoneFolder name containing the device
hostnamestrNoNoneDevice hostname
typestrNoNoneDevice type (e.g., 'on-prem')
device_onlyboolNoNoneTrue if device-only entry
is_connectedboolNoNoneConnection status
descriptionstrNoNoneDevice description
labelsList[str]NoNoneLabels assigned to the device
snippetsList[str]NoNoneSnippets associated with the device

* Only required for response models

Response-Only Attributes

AttributeTypeRequiredDefaultDescription
connected_sincestrNoNoneISO timestamp when connected
software_versionstrNoNoneSoftware version
ip_addressstrNoNoneIPv4 address
ipV6_addressstrNoNoneIPv6 address
mac_addressstrNoNoneMAC address
uptimestrNoNoneDevice uptime
ha_statestrNoNoneHA state
ha_peer_statestrNoNoneHA peer state
ha_peer_serialstrNoNoneHA peer serial number
available_licensesList[DeviceLicenseModel]NoNoneAvailable licenses
installed_licensesList[DeviceLicenseModel]NoNoneInstalled licenses

Exceptions

ExceptionHTTP CodeDescription
InvalidObjectError400Invalid device data or format
ObjectNotPresentError404Requested device not found
APIErrorVariousGeneral API communication error
AuthenticationError401Authentication failed
ServerError500Internal server error

Basic Configuration

from scm.client import Scm

client = Scm(
client_id="your_client_id",
client_secret="your_client_secret",
tsg_id="your_tsg_id"
)

devices = client.device

Methods

List Devices

all_devices = client.device.list()

for device in all_devices:
print(device.id, device.name, device.model)

Filtering responses:

# Filter by type (server-side)
vm_devices = client.device.list(type="vm")

# Filter by serial number (server-side)
specific_device = client.device.list(serial_number="001122334455")

# Filter by model (server-side)
pa_devices = client.device.list(model="PA-VM")

# Filter device-only resources (client-side)
device_only = client.device.list(device_only=True)

# Filter by labels (client-side, any match)
labeled_devices = client.device.list(labels=["production", "datacenter-1"])

Controlling pagination with max_limit:

client.device.max_limit = 100

all_devices = client.device.list()

Fetch a Device

device = client.device.fetch(name="PA-VM-1")
if device:
print(f"Found device: {device.name}")
print(f"Serial: {device.serial_number}")

Get a Device by ID

device = client.device.get("001122334455")
print(f"Device: {device.name}")
print(f"Model: {device.model}")
print(f"Software Version: {device.software_version}")

Update a Device

The upstream PUT /config/setup/v1/devices/{id} endpoint accepts only five writable fields: display_name, folder, description, labels, and snippets. Pass a DeviceUpdateModel with the device's id plus any subset of those fields.

from scm.models.setup.device import DeviceUpdateModel

# Attach labels to a device
updated = client.device.update(
DeviceUpdateModel(
id="001122334455",
labels=["production", "datacenter-1"],
)
)

# Move a device into a different folder and rename it
updated = client.device.update(
DeviceUpdateModel(
id="001122334455",
folder="Prod",
display_name="edge-fw-1",
description="Edge firewall, east region",
)
)

Fields not listed in DeviceUpdateModel (e.g. serial_number, hostname, is_connected) are not accepted by the API and will raise a validation error at the SDK layer.

Error Handling

from scm.exceptions import ObjectNotPresentError, InvalidObjectError, APIError

try:
device = client.device.get("nonexistent-id")
except ObjectNotPresentError as e:
print(f"Device not found: {e}")
except InvalidObjectError as e:
print(f"Invalid device type: {e}")
except APIError as e:
print(f"API error occurred: {e}")