Address Configuration Object
The Address
class provides functionality to manage address objects in Palo Alto Networks' Strata Cloud Manager. This
includes creating, retrieving, updating, and deleting address objects of various types including IP/Netmask, IP Range,
IP Wildcard, and FQDN (Fully Qualified Domain Name).
Overview
Address objects are fundamental building blocks used in security policies and NAT rules. They can represent:
- Individual IP addresses or networks (using CIDR notation)
- IP address ranges
- IP addresses with wildcard masks
- Fully Qualified Domain Names (FQDNs)
Methods
Method | Description |
---|---|
create() |
Creates a new address object |
get() |
Retrieves an address object by ID |
update() |
Updates an existing address object |
delete() |
Deletes an address object |
list() |
Lists address objects with optional filtering |
fetch() |
Retrieves a single address object by name |
Creating Address Objects
The create()
method allows you to create new address objects. You must specify exactly one address type (ip_netmask,
ip_range, ip_wildcard, or fqdn) and one container type (folder, snippet, or device).
Example: Creating an IP/Netmask Address
"name": "internal_network",
"ip_netmask": "192.168.1.0/24",
"description": "Internal network segment",
"folder": "Texas",
"tag": ["Python", "Automation"]
}
new_address = addresses.create(address_data)
print(f"Created address with ID: {new_address.id}")
Example: Creating an FQDN Address
"name": "example_website",
"fqdn": "www.example.com",
"description": "Example website address",
"folder": "Texas",
"tag": ["Python", "Automation"]
}
new_address = addresses.create(address_data)
print(f"Created address with ID: {new_address.id}")
Getting Address Objects
Use the get()
method to retrieve an address object by its ID.
address_obj = addresses.get(address_id)
print(f"Address Name: {address_obj.name}")
Updating Address Objects
The update()
method allows you to modify existing address objects.
# update the dictionary's descriptionexample_website['description'] = "this is just a test"
addresses.update(example_website)
Deleting Address Objects
Use the delete()
method to remove an address object.
addresses.delete(address_id)
print("Address object deleted successfully")
Listing Address Objects
The list()
method retrieves multiple address objects with optional filtering. You can filter the results using the
following kwargs:
types
: List[str] - Filter by address types (e.g., ['netmask', 'range', 'wildcard', 'fqdn'])values
: List[str] - Filter by address values (e.g., ['10.0.0.0/24', '192.168.1.0/24'])tags
: List[str] - Filter by tags (e.g., ['Automation', 'Production'])
folder="Texas",
)
# List only netmask addressesnetmask_addresses = addresses.list(
folder="Texas",
types=['netmask']
)
# List addresses with specific valuesspecific_networks = addresses.list(
folder="Texas",
values=['10.0.0.0/24', '192.168.1.0/24']
)
# List addresses with specific tagstagged_addresses = addresses.list(
folder="Texas",
tags=['Automation', 'Production']
)
# Combine multiple filtersfiltered_addresses = addresses.list(
folder="Texas",
types=['netmask', 'range'],
tags=['Production']
)
# Print the resultsfor addr in texas_addresses:
if addr.ip_netmask:
print(f"Name: {addr.name}, Value: {addr.ip_netmask}")
elif addr.fqdn:
print(f"Name: {addr.name}, Value: {addr.fqdn}")
elif addr.ip_range:
print(f"Name: {addr.name}, Value: {addr.ip_range}")
else:
print(f"Name: {addr.name}, Value: {addr.wildcard}")
Fetching Address Objects
The fetch()
method retrieves a single address object by name and container.
name="dallas-desktop1",
folder="Texas"
)
# fetch will return a Python dictionary, not a pydantic modelprint(f"Found address: {desktop1['name']}")
Full Workflow Example
Here's a complete example demonstrating the full lifecycle of an address object:
from scm.config.objects import Address
# Initialize clientclient = Scm(
client_id="your_client_id",
client_secret="your_client_secret",
tsg_id="your_tsg_id"
)
# Initialize address objectaddresses = Address(client)
# Create new addresscreate_data = {
"name": "test_network",
"ip_netmask": "10.0.0.0/24",
"description": "Test network segment",
"folder": "Texas",
"tag": ["Python", "Automation"]
}
new_address = addresses.create(create_data)
print(f"Created address: {new_address.name}")
# Fetch the address by namefetched = addresses.fetch(name="test_network", folder="Texas")
# Modify the fetched objectfetched["description"] = "Updated test network segment"
fetched["tag"] = ["Python"]
# Update using the modified objectupdated = addresses.update(fetched)
print(f"Updated description: {updated.description}")
# Clean upaddresses.delete(new_address.id)
print("Address deleted successfully")