feat: Add DevicesAPIService for device-to-folder management#20
Open
CrazyLegsCooper-Qumodity wants to merge 1 commit intoPaloAltoNetworks:mainfrom
Open
feat: Add DevicesAPIService for device-to-folder management#20CrazyLegsCooper-Qumodity wants to merge 1 commit intoPaloAltoNetworks:mainfrom
CrazyLegsCooper-Qumodity wants to merge 1 commit intoPaloAltoNetworks:mainfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
feat: Add DevicesAPIService for device-to-folder management
Problem
The SDK has
DevicesandDevicesPutmodel 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
DevicesAPIServiceto theconfig_setuppackage that exposes three operations:ListDevices/config/setup/v1/deviceslimit,offset, andfolderfilterGetDeviceByID/config/setup/v1/devices/{id}UpdateDeviceByID/config/setup/v1/devices/{id}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— addedDevicesAPI *DevicesAPIServicefield toAPIClientand wired it inNewAPIClient()New files:
generated/config_setup/api_devices.go— fullDevicesAPIServiceimplementation withListDevices,GetDeviceByID, andUpdateDeviceByID, following the exact same patterns asapi_folders.gogenerated/config_setup/model_devices_list_response.go—DevicesListResponsestruct (wraps[]DeviceswithLimit,Offset,Totalpagination fields)generated/config_setup/test/api_devices_test.go— integration tests: List, ListWithFolderFilter, GetByID, UpdateByID (with restore), GetByID_NotFoundExisting models used (not modified)
model_devices.go—Devicesstruct with ~40 fields (Id, Name, Folder required; all others optional)model_devices_put.go—DevicesPutstruct with 5 mutable fields (Description, DisplayName, Folder, Labels, Snippets)Testing
api_snippets_test.gopatternconfig/scm-config.jsongo build ./...compiles cleango test -cMotivation
This is the prerequisite for adding
scm_deviceresource and data sources to the Terraform provider, enabling users to move firewalls into the correct folder hierarchy via Terraform.