Objects Data Models
Table of Contents
- Overview
- Model Types
- Common Model Patterns
- Usage Examples
- Models by Category
- Address Objects
- Service Objects
- Application Objects
- Group Objects
- Profile Objects
- Tag Objects
- Best Practices
- Related Documentation
Overview
The Strata Cloud Manager SDK uses Pydantic models for data validation and serialization. These models ensure that the data being sent to and received from the Strata Cloud Manager API adheres to the expected structure and constraints. This section documents the models for object configuration resources.
Model Types
For each configuration object, there are corresponding model types:
- Create Models: Used when creating new resources (
{Object}CreateModel
) - Update Models: Used when updating existing resources (
{Object}UpdateModel
) - Response Models: Used when parsing data retrieved from the API (
{Object}ResponseModel
) - Base Models: Common shared attributes for related models (
{Object}BaseModel
)
Common Model Patterns
Object models share common patterns:
- Container validation (exactly one of folder/snippet/device)
- UUID validation for identifiers
- String length and pattern validation
- Data type validation and conversion
- Tag normalization and validation
- Required field enforcement
Usage Examples
from scm.client import ScmClient
from scm.models.objects import AddressCreateModel, AddressUpdateModel
# Initialize clientclient = ScmClient(
client_id="your_client_id",
client_secret="your_client_secret",
tsg_id="your_tsg_id"
)
# Create a new object using a modeladdress = AddressCreateModel(
name="web-server",
description="Primary web server",
ip_netmask="10.0.1.100/32",
folder="Shared"
)
# Convert the model to a dictionary for the API calladdress_dict = address.model_dump(exclude_unset=True)
result = client.address.create(address_dict)
# Update an existing object using a modelupdate_address = AddressUpdateModel(
id=result.id,
name="web-server-updated",
description="Updated web server",
ip_netmask="10.0.1.101/32",
folder="Shared"
)
update_dict = update_address.model_dump(exclude_unset=True)
updated_result = client.address.update(update_dict)
from scm.models.objects import AddressCreateModel, AddressUpdateModel
# Initialize clientclient = ScmClient(
client_id="your_client_id",
client_secret="your_client_secret",
tsg_id="your_tsg_id"
)
# Create a new object using a modeladdress = AddressCreateModel(
name="web-server",
description="Primary web server",
ip_netmask="10.0.1.100/32",
folder="Shared"
)
# Convert the model to a dictionary for the API calladdress_dict = address.model_dump(exclude_unset=True)
result = client.address.create(address_dict)
# Update an existing object using a modelupdate_address = AddressUpdateModel(
id=result.id,
name="web-server-updated",
description="Updated web server",
ip_netmask="10.0.1.101/32",
folder="Shared"
)
update_dict = update_address.model_dump(exclude_unset=True)
updated_result = client.address.update(update_dict)
Models by Category
Address Objects
- Address Models - IP addresses, ranges, FQDNs, and wildcards
- Address Group Models - Static and dynamic address groups
Service Objects
- Service Models - Port and protocol definitions
- Service Group Models - Collections of services
Application Objects
- Application Models - Custom application definitions
- Application Filters Models - Application filtering criteria
- Application Group Models - Collections of applications
Group Objects
- Dynamic User Group Models - User group mapping
- External Dynamic Lists Models - External IP/URL/domain lists
Profile Objects
- HIP Object Models - Host Information Profile objects
- HIP Profile Models - Host Information Profiles
- HTTP Server Profiles Models - HTTP server configurations
- Log Forwarding Profile Models - Log forwarding configurations
Tag Objects
- Tag Models - Object categorization and organization tags
Best Practices
- Model Validation
- Always validate input data with models before sending to the API
- Handle validation errors appropriately
-
Use model_dump(exclude_unset=True) to avoid sending default values
-
Container Consistency
- Maintain consistent container usage (folder/snippet/device)
- Remember that exactly one container type must be specified
-
Use the same container type for related objects
-
Model Conversion
- Convert API responses to response models for type safety
- Use model_dump() for serialization to JSON or dictionaries
-
Leverage model validators for complex validation logic
-
Error Handling
- Catch and handle ValueError exceptions from model validation
- Implement proper error messages for validation failures
- Validate model data before executing API calls
Related Documentation
- Object Configuration - Working with object configurations
- Address Configuration - Address object operations
- Service Configuration - Service object operations