README
openapi
Developer-friendly & type-safe Python SDK specifically catered to leverage openapi API.
Summary
Table of Contents
SDK Installation
[!NOTE] Python version upgrade policy
Once a Python version reaches its official end of life date, a 3-month grace period is provided for users to upgrade. Following this grace period, the minimum python version supported in the SDK will be updated.
The SDK can be installed with uv, pip, or poetry package managers.
uv
uv is a fast Python package installer and resolver, designed as a drop-in replacement for pip and pip-tools. It's recommended for its speed and modern Python tooling capabilities.
PIP
PIP is the default package installer for Python, enabling easy installation and management of packages from PyPI via the command line.
Poetry
Poetry is a modern tool that simplifies dependency management and package publishing by using a single pyproject.toml file to handle project metadata and dependencies.
Shell and script usage with uv
uvYou can use this SDK in a Python shell with uv and the uvx command that comes with it like so:
It's also possible to write a standalone Python script without needing to set up a whole project like so:
Once that is saved to a file, you can run it with uv run script.py where script.py can be replaced with the actual file name.
IDE Support
PyCharm
Generally, the SDK will work well with most IDEs out of the box. However, when using PyCharm, you can enjoy much better integration with Pydantic by installing an additional plugin.
SDK Example Usage
Example
The same SDK client can also be used to make asynchronous requests by importing asyncio.
Authentication
Per-Client Security Schemes
This SDK supports the following security scheme globally:
bearer_auth
http
HTTP Bearer
To authenticate with the API the bearer_auth parameter must be set when initializing the SDK client instance. For example:
Available Resources and Operations
Available methods
remove - Remove Additional Responders
get_org_analytics - Get Org level analytics
get_team - Get Team level analytics
list - List all Audit Logs
export - Initiate an asynchronous export of audit logs based on the provided filters. The export file will be generated and available for download. Use 'Get details of Audit Logs export history by ID' API to retrieve the download URL.
list_export_history - List all Audit Logs export history
get_export_history_by_id - Get details of Audit Logs export history by ID
get_by_id - Get audit log by ID
get_all - Get All Communication Card
create - Create Component Group
list - List Components
create - Create Component
get_by_id - Get Component By ID
update_by_id - Update Component By ID
list_by_service - Get All Dedup Key Overlay by Service
delete - Delete Dedup Key Overlay
get_by_team - Get Escalation Policy By team
create - Create Escalation Policies
remove - Remove Escalation Policy
get_by_id - Get Escalation Policy By ID
update - Update Escalation Policy
get_details - Get Export Details
refresh_ical_link - Refresh Schedule ICal Link
create_or_update_config - Create Or Update MSTeams Configuration
get_config - Get MSTeams Config
get_all - Get All Webhooks
list - List Global Event Rules
create_rule - Create Global Event Rule
delete_by_id - Delete Global Event Rule by ID
get_by_id - Get Global Event Rule by ID
update_by_id - Update Global Event Rule by ID
GlobalEventRules.Rulesets.Rules
list - List Ruleset Rules
create - Create Rule
get_by_id - Get Rule by ID
update_by_id - Update Rule by ID
reorder - Reorder Ruleset By Index
delete - Delete Global Oncall Reminder Rules
get - Get Global Oncall Reminder Rules
create - Create Global Oncall Reminder Rules
update - Update Global Oncall Reminder Rules
bulk_acknowledge - Bulk Acknowledge Incidents
export_incidents - Incident Export
bulk_update_priority - Bulk Incidents Priority Update
bulk_resolve - Bulk Resolve Incidents
get_by_id - Get Incident by ID
acknowledge - Acknowledge Incident
mark_slo_false_positive - Mark Incident SLO False Positive
update_priority - Incident Priority Update
reassign - Reassign Incident
resolve - Resolve Incident
get_status_by_request_ids - Get Incidents Status By RequestIDs
rebuild_circleci_project - Rebuild a Project In CircleCI
create_ticket - Create a Ticket on Jira Cloud
create_incident - Create an Incident in ServiceNow
trigger - Trigger a Webhook Manually
Incidents.AdditionalResponders
Incidents.AutoPauseTransientAlerts
mark_as_not_transient - Mark as Not Transient
mark_as_transient - Mark as Transient
create_slack_channel - Create Slack Channel in Communication Card
archive_slack_channel - Archive Slack Channel
create - Create Communication Card
delete - Delete Communication Card
update - Update Communication Card
get - Get Incident Events
export_async - Incident Export Async
create_jira_ticket - Create a Ticket on Jira Server
remove - Delete Postmortem By Incident
get_by_incident - Get Postmortem By Incident
update_by_incident - Update Postmortem By Incident
unsnooze - Unsnooze Incident Notifications
delete_by_id - Delete Issue By ID
update - Update Issue
list - List Status Page Issue States
delete - Delete Maintenance By ID
update_by_id - Update Maintenance By ID
get_for_alert_source - Get Dedup Key Overlay for Alert Source
list_by_schedule - List Schedule Rotations
create - Create Rotation
delete - Delete Rotation
get_by_id - Get Schedule Rotation by ID
update - Update Rotation
get_participants - Get Rotation Participants
update_participants - Update Rotation Participants
delete_by_id - Delete Rule by ID
reorder - Reorder Ruleset
attach - Attach Runbooks
get_all_by_team - Get All Runbooks By Team
create - Create Runbook
delete - Remove Runbook
get_by_id - Get Runbook By ID
update - Update Runbook
list - List Schedules
create - Create Schedule
delete - Delete Schedule
get_by_id - Get Schedule by ID
update - Update Schedule
pause_resume - Pause/Resume Schedule
change_timezone - Change Timezone
clone - Clone Schedule
get_ical_link - Get Schedule ICal Link
create_ical_link - Create Schedule ICal Link
delete_ical_link - Delete ICal Link
get_all - Get All Services
create - Create Service
get_by_name - Get Services By Name
get_by_id - Get Service By ID
update - Update Service
delete - Delete Service
update_apta_config - Auto Pause Transient Alerts (APTA)
create_or_update_iag_config - Intelligent Alert Grouping (IAG)
update_notification_delay_config - Delayed Notification Config
get - Get Deduplication Rules
create_or_update - Create or Update Deduplication Rules
create_or_update - Create or Update Dependencies
update - Update Slack Extension
create_or_update - Create or Update Maintenance Mode
get - Get Maintenance Mode
get_optin_for_key_based_deduplication - Get Opt-in for Key Based Deduplication for a service
optin_for_key_based_deduplication - Opt-in for Key Based Deduplication for a service
Services.Overlay.CustomContentTemplates
get_all - Get All Custom Content Template Overlay by Service
create_or_update - Create or Update Notification Template Overlay
render_dedup_key - Render Dedup Key template
Services.Overlays.CustomContentTemplates
render - Render Custom Content Overlay
delete - Delete Notification Template Overlay
get - Get Custom Content Template Overlay
update - Update Dedup Key Overlay
get - Get Routing Rules
create_or_update - Create or Update Routing Rules
get - Get Suppression Rules
create_or_update - Create or Update Suppression Rules
get - Get Tagging Rules
create_or_update - Create or Update Tagging Rules
list_all - Get All SLOs
create - Create SLO
update - Update SLO
remove - Remove SLO
get - Get SLO By ID
mark_affected - Mark SLO Affected
mark - Mark SLO False Positive
snooze - Snooze Incident Notifications
list - Get All Squads
get_by_id - Get Squad By ID
update_v4 - Update Squad
remove_member - Remove Squad Member
delete - Delete Squad
update - Update Squad Member
create - Create Squad
update_name - Update Squad Name
get_by_id - Get Maintenance By ID
list - List Status Pages
create - Create Status Page
delete_by_id - Delete Status Page By ID
get_by_id - Get Status Page By ID
update - Update Status Page By ID
list_statuses - List Status Page Statuses
list - List Component Groups
remove_by_id - Delete Component Group By ID
get_by_id - Get Component Group By ID
delete_by_id - Delete Component By ID
list - List Subscribers
get_all - Get All Teams
create - Create Team
get - Get Team By ID
update - Update Team
remove - Remove Team
add_bulk_member - Add Bulk Team Member
remove_member - Remove Team Member
update_member - Update Team Member
remove_role - Remove Team Role
get_all - Get All Users
add - Add User
update_org_level_permissions - Update Org Level Permissions
delete - Delete User
get_roles - Get User Roles
remove_from_org - Remove User From Org
get_by_id - Get User By ID
update_by_id - Update User by userID
remove - Remove Token
list - Get All Webforms
create - Create Webform
update - Update Webform
remove - Remove Webform
get_by_id - Get Webform By ID
list - List Workflows
create - Create Workflow
bulk_enable_disable - Bulk Enable/Disable Workflows
delete - Delete Workflow
get_by_id - Get Workflow By ID
update - Update Workflow
update_actions_order - Update Actions Order
delete_action - Delete Workflow Action
update_action - Update Workflow Action
enable_disable - Enable/Disable Workflow
get - Get Workflow Logs
Pagination
Some of the endpoints in this SDK support pagination. To use pagination, you make your SDK calls as usual, but the returned response object will have a Next method that can be called to pull down the next group of results. If the return value of Next is None, then there are no more pages to be fetched.
Here's an example of one such pagination call:
File uploads
Certain SDK methods accept file objects as part of a request body or multi-part request. It is possible and typically recommended to upload files as a stream rather than reading the entire contents into memory. This avoids excessive memory consumption and potentially crashing with out-of-memory errors when working with very large files. The following example demonstrates how to attach a file stream to a request.
[!TIP]
For endpoints that handle file uploads bytes arrays can also be used. However, using streams is recommended for large files.
Retries
Some of the endpoints in this SDK support retries. If you use the SDK without any configuration, it will fall back to the default retry strategy provided by the API. However, the default retry strategy can be overridden on a per-operation basis, or across the entire SDK.
To change the default retry strategy for a single API call, simply provide a RetryConfig object to the call:
If you'd like to override the default retry strategy for all operations that support retries, you can use the retry_config optional parameter when initializing the SDK:
Error Handling
SquadcastSDKError is the base class for all HTTP error responses. It has the following properties:
err.message
str
Error message
err.status_code
int
HTTP response status code eg 404
err.headers
httpx.Headers
HTTP response headers
err.body
str
HTTP body. Can be empty string if no body is returned.
err.raw_response
httpx.Response
Raw HTTP response
Example
Error Classes
Primary errors:
SquadcastSDKError: The base class for HTTP error responses.PaymentRequiredError: Client error. Status code402. *ForbiddenError: Access is forbidden. Status code403. *NotFoundError: The server cannot find the requested resource. Status code404. *ConflictError: The request conflicts with the current state of the server. Status code409. *UnprocessableEntityError: Client error. Status code422. *InternalServerError: Server error. Status code500. *BadGatewayError: Server error. Status code502. *ServiceUnavailableError: Service unavailable. Status code503. *GatewayTimeoutError: Server error. Status code504. *UnauthorizedError: Access is unauthorized. Status code401. *BadRequestError: The server could not understand the request due to invalid syntax. Status code400. *
Less common errors (8)
Network errors:
httpx.RequestError: Base class for request errors.httpx.ConnectError: HTTP client was unable to make a request to a server.httpx.TimeoutException: HTTP request timed out.
Inherit from SquadcastSDKError:
CommonV4Error: The server could not understand the request due to invalid syntax. Applicable to 32 of 230 methods.*ResponseBodyError1: Represents a CircleCI error response for a 400 status code. Status code400. Applicable to 1 of 230 methods.*ResponseBodyError2: Represents a CircleCI error response for a 400 status code. Status code400. Applicable to 1 of 230 methods.*ResponseValidationError: Type mismatch between the response data and the expected Pydantic model. Provides access to the Pydantic validation error via thecauseattribute.
* Check the method documentation to see if the error is applicable.
Server Selection
Override Server URL Per-Client
The default server can be overridden globally by passing a URL to the server_url: str optional parameter when initializing the SDK client instance. For example:
Custom HTTP Client
The Python SDK makes API calls using the httpx HTTP library. In order to provide a convenient way to configure timeouts, cookies, proxies, custom headers, and other low-level configuration, you can initialize the SDK client with your own HTTP client instance. Depending on whether you are using the sync or async version of the SDK, you can pass an instance of HttpClient or AsyncHttpClient respectively, which are Protocol's ensuring that the client has the necessary methods to make API calls. This allows you to wrap the client with your own custom logic, such as adding custom headers, logging, or error handling, or you can just pass an instance of httpx.Client or httpx.AsyncClient directly.
For example, you could specify a header for every request that this sdk makes as follows:
or you could wrap the client with your own custom logic:
Resource Management
The SquadcastSDK class implements the context manager protocol and registers a finalizer function to close the underlying sync and async HTTPX clients it uses under the hood. This will close HTTP connections, release memory and free up other resources held by the SDK. In short-lived Python programs and notebooks that make a few SDK method calls, resource management may not be a concern. However, in longer-lived programs, it is beneficial to create a single SDK instance via a context manager and reuse it across the application.
Debugging
You can setup your SDK to emit debug logs for SDK requests and responses.
You can pass your own logger class directly into your SDK.
Development
Maturity
This SDK is in beta, and there may be breaking changes between versions without a major version update. Therefore, we recommend pinning usage to a specific package version. This way, you can install the same version each time without breaking changes unless you are intentionally looking for the latest version.
Contributions
While we value open-source contributions to this SDK, this library is generated programmatically. Any manual changes added to internal files will be overwritten on the next generation. We look forward to hearing your feedback. Feel free to open a PR or an issue with a proof of concept and we'll do our best to include it in a future release.
SDK Created by Speakeasy
Last updated