diff --git a/README.md b/README.md index a60fceb5..02655346 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Strata Cloud Manager SDK -![Banner Image](https://raw.githubusercontent.com/cdot65/pan-scm-sdk/refs/heads/main/docs/images/logo.svg) +![Banner Image](https://raw.githubusercontent.com/cdot65/pan-scm-sdk/main/docs/images/logo.svg) [![Build Status](https://github.com/cdot65/pan-scm-sdk/actions/workflows/ci.yml/badge.svg)](https://github.com/cdot65/pan-scm-sdk/actions/workflows/ci.yml) [![PyPI version](https://badge.fury.io/py/pan-scm-sdk.svg)](https://badge.fury.io/py/pan-scm-sdk) @@ -14,18 +14,23 @@ Python SDK for Palo Alto Networks Strata Cloud Manager. - [Features](#features) - [Installation](#installation) - [Usage](#usage) - - [Authentication](#authentication) - - [Create Address Groups](#create-address-groups) - - [Create Address Objects](#create-address-objects) + - [Authentication](#authentication) + - [Creating Address Objects](#creating-address-objects) + - [Listing Addresses](#listing-addresses) + - [Updating an Address](#updating-an-address) + - [Deleting an Address](#deleting-an-address) - [Contributing](#contributing) - [License](#license) - [Support](#support) ## Features -- **feature1**: will add later -- **feature2**: will add later -- **feature3**: will add later +- **OAuth2 Authentication**: Securely authenticate with the Strata Cloud Manager API using OAuth2 client credentials + flow. +- **Resource Management**: Create, read, update, and delete configuration objects such as addresses. +- **Data Validation**: Utilize Pydantic models for data validation and serialization. +- **Exception Handling**: Comprehensive error handling with custom exceptions for API errors. +- **Extensibility**: Designed for easy extension to support additional resources and endpoints. ## Installation @@ -41,30 +46,75 @@ pip install pan-scm-sdk ## Usage -Will add later: - ### Authentication -Will add later: +Before interacting with the SDK, you need to authenticate using your Strata Cloud Manager credentials. +```python +from pan_scm_sdk.client import APIClient + +# Initialize the API client with your credentials +api_client = APIClient( + client_id="your_client_id", + client_secret="your_client_secret", + tsg_id="your_tsg_id", +) + +# The api_client is now ready to use ``` -will provide examples later -``` -### Create Address Groups +### Creating Address Objects + +```python +from pan_scm_sdk.resources.address import AddressClient +from pan_scm_sdk.models.address import Address + +# Create an AddressClient instance +address_client = AddressClient(api_client) -Will add later: +# Define a new address object +address = Address( + name="MyAddress", + ip_netmask="192.168.1.1/32", + folder="Shared", +) +# Create the address in Strata Cloud Manager +created_address = address_client.create_address(address) +print(f"Created address with ID: {created_address.id}") ``` -will provide examples later + +### Listing Addresses + +```python +# List addresses with optional filtering +addresses = address_client.list_addresses(limit=10) +for addr in addresses: + print(f"Address ID: {addr.id}, Name: {addr.name}, IP: {addr.ip_netmask}") ``` -### Create Address Objects +### Updating an Address + +```python +# Retrieve an existing address +address_id = "123e4567-e89b-12d3-a456-426655440000" +address = address_client.get_address(address_id) -Will add later: +# Update the address properties +address.description = "Updated description" +# Send the update to Strata Cloud Manager +updated_address = address_client.update_address(address_id, address) +print(f"Updated address with ID: {updated_address.id}") ``` -will provide examples later + +### Deleting an Address + +```python +# Delete an address by ID +address_id = "123e4567-e89b-12d3-a456-426655440000" +address_client.delete_address(address_id) +print(f"Deleted address with ID: {address_id}") ``` ## Contributing @@ -89,4 +139,4 @@ For support and questions, please refer to the [SUPPORT.md](./SUPPORT.md) file i --- -*Detailed documentation will be provided on our GitHub Pages site soon.* \ No newline at end of file +*Detailed documentation is available on our [GitHub Pages site](https://cdot65.github.io/pan-scm-sdk/).* \ No newline at end of file diff --git a/pan_scm_sdk/models/address.py b/pan_scm_sdk/models/address.py index 8aaea11c..9ab15081 100644 --- a/pan_scm_sdk/models/address.py +++ b/pan_scm_sdk/models/address.py @@ -35,11 +35,6 @@ class Address(BaseModel): ) # Required fields - id: str = Field( - ..., - description="The UUID of the address object", - examples=["123e4567-e89b-12d3-a456-426655440000"], - ) name: str = Field( ..., max_length=63, @@ -47,6 +42,11 @@ class Address(BaseModel): ) # Optional fields + id: Optional[str] = Field( + None, + description="The UUID of the address object", + examples=["123e4567-e89b-12d3-a456-426655440000"], + ) description: Optional[str] = Field( None, max_length=1023,