Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

address-objects #3

Merged
merged 12 commits into from
Oct 10, 2024
88 changes: 69 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
@@ -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)
Expand All @@ -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

Expand All @@ -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
Expand All @@ -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.*
*Detailed documentation is available on our [GitHub Pages site](https://cdot65.github.io/pan-scm-sdk/).*
10 changes: 5 additions & 5 deletions pan_scm_sdk/models/address.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,18 @@ 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,
description="The name of the address object",
)

# 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,
Expand Down
Loading