Skip to main content

BGP Address Family Profile

The BgpAddressFamilyProfile class manages BGP address family profile objects in Palo Alto Networks' Strata Cloud Manager. It extends from BaseObject and offers methods to create, retrieve, update, list, fetch, and delete BGP address family profiles. These profiles define IPv4 unicast and multicast settings for BGP peer groups, including add-path, allowas-in, maximum prefix limits, next-hop behavior, remove-private-AS, send-community, and ORF configuration.

Class Overview

from scm.client import Scm

# Initialize client
client = Scm(
client_id="your_client_id",
client_secret="your_client_secret",
tsg_id="your_tsg_id"
)

# Access the BGP Address Family Profile service directly through the client
bgp_af_profiles = client.bgp_address_family_profile
MethodDescriptionParametersReturn Type
create()Creates a new BGP address family profiledata: Dict[str, Any]BgpAddressFamilyProfileResponseModel
get()Retrieves a BGP address family profile by its unique IDobject_id: strBgpAddressFamilyProfileResponseModel
update()Updates an existing BGP address family profileprofile: BgpAddressFamilyProfileUpdateModelBgpAddressFamilyProfileResponseModel
list()Lists BGP address family profiles with optional filteringfolder: Optional[str], snippet: Optional[str], device: Optional[str], exact_match: bool = False, plus additional filtersList[BgpAddressFamilyProfileResponseModel]
fetch()Fetches a single BGP address family profile by name within a containername: str, folder: Optional[str], snippet: Optional[str], device: Optional[str]BgpAddressFamilyProfileResponseModel
delete()Deletes a BGP address family profile by its IDobject_id: strNone

BGP Address Family Profile Model Attributes

AttributeTypeRequiredDefaultDescription
namestrYesNoneProfile name
idUUIDYes*NoneUnique identifier (*response/update only)
ipv4BgpAddressFamilyProfileIpv4UnicastMulticastNoNoneIPv4 address family configuration
folderstrNo**NoneFolder location. Max 64 chars
snippetstrNo**NoneSnippet location. Max 64 chars
devicestrNo**NoneDevice location. Max 64 chars

* Only required for update and response models ** Exactly one container (folder/snippet/device) must be provided for create operations

IPv4 Unicast/Multicast Configuration

The ipv4 attribute wraps unicast and multicast address family settings. Both unicast and multicast share the same BgpAddressFamily model structure.

BgpAddressFamilyProfileIpv4UnicastMulticast

AttributeTypeRequiredDescription
unicastBgpAddressFamilyNoUnicast address family
multicastBgpAddressFamilyNoMulticast address family

BgpAddressFamily

AttributeTypeRequiredDescription
enableboolNoEnable address family
soft_reconfig_with_stored_infoboolNoSoft reconfiguration with stored routes
add_pathBgpAddressFamilyAddPathNoAdd-path configuration
as_overrideboolNoOverride ASNs in outbound updates
route_reflector_clientboolNoRoute reflector client
default_originateboolNoOriginate default route
default_originate_mapstrNoDefault originate route map
allowas_inBgpAddressFamilyAllowasInNoAllow-AS-in configuration
maximum_prefixBgpAddressFamilyMaximumPrefixNoMaximum prefix configuration
next_hopBgpAddressFamilyNextHopNoNext-hop configuration
remove_private_ASBgpAddressFamilyRemovePrivateASNoRemove private AS configuration
send_communityBgpAddressFamilySendCommunityNoSend community configuration
orfBgpAddressFamilyOrfNoORF configuration

BgpAddressFamilyAddPath

AttributeTypeRequiredDescription
tx_all_pathsboolNoAdvertise all paths to peer
tx_bestpath_per_ASboolNoAdvertise bestpath per neighboring AS

BgpAddressFamilyAllowasIn (oneOf)

AttributeTypeRequiredDescription
origindictNoAllow origin AS in path (mutually exclusive with occurrence)
occurrenceintNoNumber of times own AS can appear (1-10, mutually exclusive with origin)

BgpAddressFamilyMaximumPrefix

AttributeTypeRequiredDescription
num_prefixesintNoMaximum number of prefixes (1-4294967295)
thresholdintNoThreshold percentage (1-100)
actionBgpAddressFamilyMaximumPrefixActionNoAction on limit

BgpAddressFamilyNextHop (oneOf)

AttributeTypeRequiredDescription
selfdictNoSet next-hop to self (mutually exclusive with self_force)
self_forcedictNoForce next-hop to self (mutually exclusive with self)

BgpAddressFamilySendCommunity (oneOf)

AttributeTypeRequiredDescription
alldictNoSend all communities
bothdictNoSend both standard and extended
extendeddictNoSend extended communities
largedictNoSend large communities
standarddictNoSend standard communities

Only one send community type may be set at a time.

BgpAddressFamilyOrf

AttributeTypeRequiredDescription
orf_prefix_liststrNoORF prefix list mode (none, both, receive, send)

Exceptions

ExceptionHTTP CodeDescription
InvalidObjectError400Thrown when provided data or parameters are invalid
MissingQueryParameterError400Thrown when required query parameters (e.g., name or folder) are missing
NameNotUniqueError409Profile name already exists
ObjectNotPresentError404Profile not found
ReferenceNotZeroError409Profile still referenced
AuthenticationError401Authentication failed
ServerError500Internal server error

Methods

List BGP Address Family Profiles

# List all profiles in a folder
profiles = client.bgp_address_family_profile.list(
folder="Texas"
)

# Process results
for profile in profiles:
print(f"Name: {profile.name}")
if profile.ipv4 and profile.ipv4.unicast:
print(f" Unicast enabled: {profile.ipv4.unicast.enable}")

Filtering Responses

The list() method supports additional parameters to refine your query results even further. Alongside basic filters, you can leverage the exact_match, exclude_folders, exclude_snippets, and exclude_devices parameters to control which objects are included or excluded after the initial API response is fetched.

Parameters:

  • exact_match (bool): When True, only objects defined exactly in the specified container (folder, snippet, or device) are returned. Inherited or propagated objects are filtered out.
  • exclude_folders (List[str]): Provide a list of folder names that you do not want included in the results.
  • exclude_snippets (List[str]): Provide a list of snippet values to exclude from the results.
  • exclude_devices (List[str]): Provide a list of device values to exclude from the results.

Examples:

# Only return profiles defined exactly in 'Texas'
exact_profiles = client.bgp_address_family_profile.list(
folder='Texas',
exact_match=True
)

for profile in exact_profiles:
print(f"Exact match: {profile.name} in {profile.folder}")

# Exclude all profiles from the 'All' folder
no_all_profiles = client.bgp_address_family_profile.list(
folder='Texas',
exclude_folders=['All']
)

for profile in no_all_profiles:
assert profile.folder != 'All'
print(f"Filtered out 'All': {profile.name}")

Controlling Pagination with max_limit

The SDK supports pagination through the max_limit parameter, which defines how many objects are retrieved per API call. By default, max_limit is set to 2500. The API itself imposes a maximum allowed value of 5000. If you set max_limit higher than 5000, it will be capped to the API's maximum. The list() method will continue to iterate through all objects until all results have been retrieved. Adjusting max_limit can help manage retrieval performance and memory usage when working with large datasets.

Example:

from scm.client import Scm

# Initialize client
client = Scm(
client_id="your_client_id",
client_secret="your_client_secret",
tsg_id="your_tsg_id"
)

# Configure max_limit using the property setter
client.bgp_address_family_profile.max_limit = 4000

# List all profiles - auto-paginates through results
all_profiles = client.bgp_address_family_profile.list(folder='Texas')

Fetch a BGP Address Family Profile

# Fetch by name and folder
profile = client.bgp_address_family_profile.fetch(
name="unicast-basic",
folder="Texas"
)
print(f"Found profile: {profile.name}")

# Get by ID
profile_by_id = client.bgp_address_family_profile.get(profile.id)
print(f"Retrieved profile: {profile_by_id.name}")

Create a BGP Address Family Profile

from scm.client import Scm

# Initialize client
client = Scm(
client_id="your_client_id",
client_secret="your_client_secret",
tsg_id="your_tsg_id"
)

# Create a basic unicast profile with send-community
profile_data = {
"name": "unicast-basic",
"ipv4": {
"unicast": {
"enable": True,
"send_community": {
"all": {}
},
"next_hop": {
"self": {}
}
}
},
"folder": "Texas"
}

new_profile = client.bgp_address_family_profile.create(profile_data)
print(f"Created profile with ID: {new_profile.id}")

# Create a profile with maximum prefix and allowas-in
advanced_profile_data = {
"name": "unicast-advanced",
"ipv4": {
"unicast": {
"enable": True,
"maximum_prefix": {
"num_prefixes": 10000,
"threshold": 80,
"action": {
"restart": {
"interval": 120
}
}
},
"allowas_in": {
"occurrence": 3
},
"remove_private_AS": {
"all": {}
},
"soft_reconfig_with_stored_info": True
}
},
"folder": "Texas"
}

advanced_profile = client.bgp_address_family_profile.create(advanced_profile_data)
print(f"Created advanced profile with ID: {advanced_profile.id}")

# Create a profile with both unicast and multicast
dual_profile_data = {
"name": "dual-af-profile",
"ipv4": {
"unicast": {
"enable": True,
"send_community": {
"standard": {}
}
},
"multicast": {
"enable": True,
"default_originate": True
}
},
"folder": "Texas"
}

dual_profile = client.bgp_address_family_profile.create(dual_profile_data)
print(f"Created dual AF profile with ID: {dual_profile.id}")

Update a BGP Address Family Profile

# Fetch existing profile
existing_profile = client.bgp_address_family_profile.fetch(
name="unicast-basic",
folder="Texas"
)

# Enable add-path
existing_profile.ipv4.unicast.add_path = {
"tx_all_paths": True
}

# Perform update
updated_profile = client.bgp_address_family_profile.update(existing_profile)

Delete a BGP Address Family Profile

# Delete by ID
profile_id = "123e4567-e89b-12d3-a456-426655440000"
client.bgp_address_family_profile.delete(profile_id)

Use Cases

Performing Commits

# Prepare commit parameters
commit_params = {
"folders": ["Texas"],
"description": "Updated BGP address family profile configurations",
"sync": True,
"timeout": 300 # 5 minute timeout
}

# Commit the changes directly on the client
result = client.commit(**commit_params)

print(f"Commit job ID: {result.job_id}")

Monitoring Jobs

# Get status of specific job directly from the client
job_status = client.get_job_status(result.job_id)
print(f"Job status: {job_status.data[0].status_str}")

# List recent jobs directly from the client
recent_jobs = client.list_jobs(limit=10)
for job in recent_jobs.data:
print(f"Job {job.id}: {job.type_str} - {job.status_str}")

Error Handling

from scm.client import Scm
from scm.exceptions import (
InvalidObjectError,
MissingQueryParameterError,
NameNotUniqueError,
ObjectNotPresentError,
ReferenceNotZeroError
)

# Initialize client
client = Scm(
client_id="your_client_id",
client_secret="your_client_secret",
tsg_id="your_tsg_id"
)

try:
# Create BGP address family profile
profile_config = {
"name": "test-af-profile",
"ipv4": {
"unicast": {
"enable": True
}
},
"folder": "Texas"
}

new_profile = client.bgp_address_family_profile.create(profile_config)

# Commit changes
result = client.commit(
folders=["Texas"],
description="Added BGP address family profile",
sync=True
)

# Check job status
status = client.get_job_status(result.job_id)

except InvalidObjectError as e:
print(f"Invalid profile data: {e.message}")
except NameNotUniqueError as e:
print(f"Profile name already exists: {e.message}")
except ObjectNotPresentError as e:
print(f"Profile not found: {e.message}")
except ReferenceNotZeroError as e:
print(f"Profile still in use: {e.message}")
except MissingQueryParameterError as e:
print(f"Missing parameter: {e.message}")