Skip to content

Operations Data Models

Table of Contents

  1. Overview
  2. Model Types
  3. Common Model Patterns
  4. Usage Examples
  5. Models by Category
  6. Jobs
  7. Candidate Push
  8. Best Practices
  9. Related Documentation

Overview

The Strata Cloud Manager SDK uses Pydantic models for data validation and serialization of operations-related data. 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 operational tasks such as job management and configuration commits.

Model Types

For operations functionality, there are corresponding model types:

  • Request Models: Used when sending operational commands to the API
  • Response Models: Used when parsing operation results retrieved from the API
  • Data Models: Used to represent specific operational data structures

Common Model Patterns

Operations models share common patterns:

  • UUID validation for identifiers
  • Timestamp handling and validation
  • Status and result code validation
  • Pagination and filtering configuration
  • Job monitoring and control
  • Error handling and message parsing

Usage Examples

from scm.client import ScmClient
from scm.models.operations import CandidatePushModel
# Initialize clientclient = ScmClient(
client_id="your_client_id",
client_secret="your_client_secret",
tsg_id="your_tsg_id"
)
# Create a commit request using a modelcommit_request = CandidatePushModel(
description="Updated security policies",
folders=["Security Policies"],
device_groups=[],
devices=[],
include_uncommitted_changes=True,
admins=[]
)
# Convert the model to a dictionary for the API callcommit_dict = commit_request.model_dump(exclude_unset=True)
result = client.operations.commit(commit_dict)
# Check job statusjob_id = result.id
job_status = client.operations.get_job_status(job_id)
# List recent jobsjob_list = client.operations.list_jobs(limit=10)
for job in job_list.data:
print(f"Job {job.id}: {job.type_str} - {job.status_str}")

Models by Category

Jobs

Candidate Push

Best Practices

  1. Job Management
  2. Use appropriate job monitoring patterns for long-running operations
  3. Implement timeout handling for job completion
  4. Set up proper error handling for job failures
  5. Include job metadata such as descriptions for easier tracking

  6. Commit Operations

  7. Be specific about which folders to commit to minimize impact
  8. Include meaningful descriptions with commits
  9. Verify changes before committing to production
  10. Consider scheduling commits during maintenance windows

  11. Error Handling

  12. Check job status codes for proper error detection
  13. Parse error messages to provide meaningful feedback
  14. Implement retry logic for transient failures
  15. Log detailed job information for troubleshooting

  16. Performance Considerations

  17. Use pagination for listing large numbers of jobs
  18. Limit the scope of commits to improve performance
  19. Monitor job completion times for performance bottlenecks
  20. Consider batching changes for fewer commit operations