Skip to main content

Python SDK for Palo Alto Networks Strata Cloud Manager.

Project description

Strata Cloud Manager SDK

Banner Image

Build Status PyPI version Python versions License

Python SDK for Palo Alto Networks Strata Cloud Manager.

Table of Contents

Features

  • 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, address groups, and applications.
  • 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

Requirements:

  • Python 3.10 or higher

Install the package via pip:

pip install pan-scm-sdk

Usage

Authentication

Before interacting with the SDK, you need to authenticate using your Strata Cloud Manager credentials.

from scm.client import Scm

# Initialize the API client with your credentials
scm = Scm(
    client_id="your_client_id",
    client_secret="your_client_secret",
    tsg_id="your_tsg_id",
)

# The SCM client is now ready to use

Managing Address Objects

Listing Addresses

from scm.config.objects import Address

# Create an Address instance
address = Address(scm)

# List addresses in a specific folder
addresses = address.list(folder='Prisma Access')

# Iterate through the addresses
for addr in addresses:
    print(f"Address Name: {addr.name}, IP: {addr.ip_netmask or addr.fqdn}")

Creating an Address

# Define a new address object
address_data = {
    "name": "test123",
    "fqdn": "test123.example.com",
    "description": "Created via pan-scm-sdk",
    "folder": "Prisma Access",
}

# Create the address in Strata Cloud Manager
new_address = address.create(address_data)
print(f"Created address with ID: {new_address.id}")

Managing Address Groups

Listing Address Groups

from scm.config.objects import AddressGroup

# Create an AddressGroup instance
address_group = AddressGroup(scm)

# List address groups in a specific folder
address_groups = address_group.list(folder='Prisma Access')

# Iterate through the address groups
for ag in address_groups:
    print(f"Address Group Name: {ag.name}, Description: {ag.description}")

Creating an Address Group

# Define a new address group
address_group_data = {
    "name": "example-group",
    "description": "This is a test address group",
    "static": ["Branch-test1", "Branch-test2"],
    "folder": "Prisma Access",
}

# Create the address group in Strata Cloud Manager
new_address_group = address_group.create(address_group_data)
print(f"Created address group with ID: {new_address_group.id}")

Managing Applications

Listing Applications

from scm.config.objects import Application

# Create an Application instance
application = Application(scm)

# List applications in a specific folder
applications = application.list(folder='Prisma Access')

# Iterate through the applications
for app in applications:
    print(f"Application Name: {app.name}, Category: {app.category}")

Creating an Application

# Define a new application
application_data = {
    "name": "test123",
    "category": "collaboration",
    "subcategory": "internet-conferencing",
    "technology": "client-server",
    "risk": 1,
    "description": "Created via pan-scm-sdk",
    "ports": ["tcp/80,443", "udp/3478"],
    "folder": "Prisma Access",
    "evasive": False,
    "pervasive": False,
    "excessive_bandwidth_use": False,
    "used_by_malware": False,
    "transfers_files": False,
    "has_known_vulnerabilities": True,
    "tunnels_other_apps": False,
    "prone_to_misuse": False,
    "no_certifications": False,
}

# Create the application in Strata Cloud Manager
new_application = application.create(application_data)
print(f"Created application with ID: {new_application.id}")

Contributing

We welcome contributions! To contribute:

  1. Fork the repository.
  2. Create a new feature branch (git checkout -b feature/your-feature).
  3. Commit your changes (git commit -m 'Add new feature').
  4. Push to your branch (git push origin feature/your-feature).
  5. Open a Pull Request.

Ensure your code adheres to the project's coding standards and includes tests where appropriate.

License

This project is licensed under the Apache 2.0 License. See the LICENSE file for details.

Support

For support and questions, please refer to the SUPPORT.md file in this repository.


Detailed documentation is available on our GitHub Pages site.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pan_scm_sdk-0.1.3.tar.gz (17.4 kB view details)

Uploaded Source

Built Distribution

pan_scm_sdk-0.1.3-py3-none-any.whl (23.4 kB view details)

Uploaded Python 3

File details

Details for the file pan_scm_sdk-0.1.3.tar.gz.

File metadata

  • Download URL: pan_scm_sdk-0.1.3.tar.gz
  • Upload date:
  • Size: 17.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.7.1 CPython/3.11.7 Darwin/23.6.0

File hashes

Hashes for pan_scm_sdk-0.1.3.tar.gz
Algorithm Hash digest
SHA256 c9c5c0fec8137a9dc2b28ebdfef22d8de591f558ceac909e1a305f8b2254fda0
MD5 eacfdcdda582710276e9d188f2210eaf
BLAKE2b-256 d17ede0ca29305ceba7efe7d675ed9b82eecac66cc25a865bd7a8f50515c6e2d

See more details on using hashes here.

File details

Details for the file pan_scm_sdk-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: pan_scm_sdk-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 23.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.7.1 CPython/3.11.7 Darwin/23.6.0

File hashes

Hashes for pan_scm_sdk-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 b1cb5f9ba7f8798536f8b4ff0a8d7be0cf10f3a3d4db47c1a197985674f465c1
MD5 138c769ae14da22123d2c4f760217073
BLAKE2b-256 9d98c0901d09a830c96dc9b3b7b6ac93a2b219016c4a032c4b63e8d64dac1dc5

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page