Application Configuration Object
The Application
class provides functionality to manage custom application definitions in Palo Alto Networks' Strata
Cloud Manager.
Applications represent network applications and their characteristics, allowing you to define custom applications beyond
the predefined ones available in the system.
Overview
Applications in Strata Cloud Manager allow you to:
- Define custom applications with specific characteristics
- Categorize applications by type, risk level, and behavior
- Specify application properties like ports and protocols
- Track security-relevant attributes like known vulnerabilities
- Organize applications within folders or snippets
Methods
Method | Description |
---|---|
create() |
Creates a new application definition |
get() |
Retrieves an application by ID |
update() |
Updates an existing application |
delete() |
Deletes an application |
list() |
Lists applications with optional filtering |
fetch() |
Retrieves a single application by name |
Creating Applications
The create()
method allows you to define new custom applications. You must specify required fields like name,
category,
subcategory, technology, and risk level.
Example: Creating a Custom Application
"name": "internal-chat",
"category": "collaboration",
"subcategory": "instant-messaging",
"technology": "client-server",
"risk": 2,
"description": "Internal chat application",
"ports": ["tcp/8443"],
"folder": "Texas",
"transfers_files": True,
"has_known_vulnerabilities": False
}
new_app = applications.create(app_data)
print(f"Created application: {new_app.name}")
Getting Applications
Use the get()
method to retrieve an application by its ID.
app = applications.get(app_id)
print(f"Application: {app.name}")
print(f"Risk Level: {app.risk}")
Updating Applications
The update()
method allows you to modify existing applications.
fetched_app['description'] = 'Updated description for internal chat application'
updated_app = applications.update(fetched_app)
print(f"Updated application: {updated_app.name}")
Deleting Applications
Use the delete()
method to remove an application.
applications.delete(app_id)
print("Application deleted successfully")
Listing Applications
The list()
method retrieves multiple applications with optional filtering. You can filter the results using the
following kwargs:
category
: List[str] - Filter by category (e.g., ['collaboration', 'business-systems'])subcategory
: List[str] - Filter by subcategory (e.g., ['instant-messaging', 'database'])technology
: List[str] - Filter by technology (e.g., ['client-server', 'peer-to-peer'])risk
: List[int] - Filter by risk level (e.g., [1, 2, 3])
# List applications by categorycollab_apps = applications.list(
folder="Texas",
category=['collaboration']
)
# List applications by risk levelhigh_risk_apps = applications.list(
folder="Texas",
risk=[4, 5]
)
# List applications by technologyclient_server_apps = applications.list(
folder="Texas",
technology=['client-server']
)
# Combine multiple filtersfiltered_apps = applications.list(
folder="Texas",
category=['business-systems'],
subcategory=['database'],
risk=[3, 4, 5]
)
# Print the resultsfor app in apps:
print(f"Name: {app.name}, Category: {app.category}, Risk: {app.risk}")
Fetching Applications
The fetch()
method retrieves a single application by name from a specific container.
name="internal-chat",
folder="Texas"
)
print(f"Found application: {app['name']}")
print(f"Current risk level: {app['risk']}")
Full Workflow Example
Here's a complete example demonstrating the full lifecycle of an application:
from scm.config.objects import Application
# Initialize clientclient = Scm(
client_id="your_client_id",
client_secret="your_client_secret",
tsg_id="your_tsg_id"
)
# Initialize application objectapplications = Application(client)
# Create new applicationapp_data = {
"name": "custom-app",
"category": "business-systems",
"subcategory": "database",
"technology": "client-server",
"risk": 3,
"description": "Custom database application",
"ports": ["tcp/1521"],
"folder": "Texas",
"transfers_files": True
}
new_app = applications.create(app_data)
print(f"Created application: {new_app.name}")
# Fetch the application by namefetched_app = applications.fetch(
name="custom-app",
folder="Texas"
)
# Modify the fetched applicationfetched_app["description"] = "Updated database application"
fetched_app["risk"] = 4
fetched_app["has_known_vulnerabilities"] = True
# Update using the modified objectupdated_app = applications.update(fetched_app)
print(f"Updated application: {updated_app.name}")
print(f"New risk level: {updated_app.risk}")
# List all applicationsapps = applications.list(folder="Texas")
for app in apps:
print(f"Listed application: {app.name}")
# Clean upapplications.delete(new_app.id)
print("Application deleted successfully")