Skip to content

feat: Add DevicesAPIService for device-to-folder management#20

Open
CrazyLegsCooper-Qumodity wants to merge 1 commit intoPaloAltoNetworks:mainfrom
CrazyLegsCooper-Qumodity:firewall-move
Open

feat: Add DevicesAPIService for device-to-folder management#20
CrazyLegsCooper-Qumodity wants to merge 1 commit intoPaloAltoNetworks:mainfrom
CrazyLegsCooper-Qumodity:firewall-move

Conversation

@CrazyLegsCooper-Qumodity
Copy link
Copy Markdown

feat: Add DevicesAPIService for device-to-folder management

Problem

The SDK has Devices and DevicesPut model structs generated from the OpenAPI spec (model_devices.go, model_devices_put.go), but no API service is wired up to actually call the Devices endpoints. This means consumers of the SDK — including the Terraform provider — have no way to list, read, or update devices (e.g. moving firewalls between folders).

Solution

Add a DevicesAPIService to the config_setup package that exposes three operations:

Method HTTP Endpoint Purpose
ListDevices GET /config/setup/v1/devices List devices with optional limit, offset, and folder filter
GetDeviceByID GET /config/setup/v1/devices/{id} Retrieve a single device by UUID
UpdateDeviceByID PUT /config/setup/v1/devices/{id} Update mutable fields (folder, description, display_name, labels, snippets)

There is no Create or Delete — devices are onboarded externally (e.g. via Azure vWAN or Panorama) and cannot be created or removed through this API.

Changes

Modified files:

  • generated/config_setup/client.go — added DevicesAPI *DevicesAPIService field to APIClient and wired it in NewAPIClient()

New files:

  • generated/config_setup/api_devices.go — full DevicesAPIService implementation with ListDevices, GetDeviceByID, and UpdateDeviceByID, following the exact same patterns as api_folders.go
  • generated/config_setup/model_devices_list_response.goDevicesListResponse struct (wraps []Devices with Limit, Offset, Total pagination fields)
  • generated/config_setup/test/api_devices_test.go — integration tests: List, ListWithFolderFilter, GetByID, UpdateByID (with restore), GetByID_NotFound

Existing models used (not modified)

  • model_devices.goDevices struct with ~40 fields (Id, Name, Folder required; all others optional)
  • model_devices_put.goDevicesPut struct with 5 mutable fields (Description, DisplayName, Folder, Labels, Snippets)

Testing

  • 5 integration tests following the existing api_snippets_test.go pattern
  • Tests require live SCM credentials via config/scm-config.json
  • go build ./... compiles clean
  • Test file compiles clean via go test -c

Motivation

This is the prerequisite for adding scm_device resource and data sources to the Terraform provider, enabling users to move firewalls into the correct folder hierarchy via Terraform.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants