cdot65 / pan-scm-sdk

Python SDK for Palo Alto Networks Strata Cloud Manager.
https://cdot65.github.io/pan-scm-sdk/
Apache License 2.0
1 stars 1 forks source link

update method is successful but fails response validation #30

Closed cdot65 closed 2 weeks ago

cdot65 commented 2 weeks ago

The update method is trying to validate the response from the API, which may or may not be empty.

In [22]: update_address = addresses.fetch(folder='Texas', name='webserver network')

In [23]: update_address
Out[23]: 
{'name': 'webserver network',
 'ip_netmask': '192.168.1.0/24',
 'description': 'Internal network segment',
 'tag': ['Python', 'Automation'],
 'folder': 'Texas',
 'id': '8d166508-594f-4b1c-867e-33655e09bf4d'}

In [24]: update_address['name'] = 'webserver_network'

In [25]: addresses.update(update_address)
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Cell In[25], line 1
----> 1 addresses.update(update_address)

File ~/development/cdot65/pan-scm-sdk/scm/config/objects/address.py:83, in Address.update(self, data)
     81     endpoint = f"{self.ENDPOINT}/{data['id']}"
     82     response = self.api_client.put(endpoint, json=payload)
---> 83     return AddressResponseModel(**response)
     84 except Exception as e:
     85     if hasattr(e, "response") and e.response is not None:  # noqa

TypeError: scm.models.objects.address.AddressResponseModel() argument after ** must be a mapping, not NoneType

Recommendation is to allow for scenarios where the return value is empty.

cdot65 commented 2 weeks ago

This has been resolved in #26