Skip to main content

A client library for accessing CompassOne API

Project description

CompassOne API Client for Python

The CompassOne API Client provides a Python-based interface to interact with the CompassOne public API. It simplifies the process of making API requests and handling responses with comprehensive type safety and multiple execution modes.

Table of Contents

Python Version Compatibility

This client requires Python 3.7 or higher due to the use of:

  • f-strings
  • Type hints
  • Modern exception handling
  • Async/await syntax
  • Other Python 3.7+ features

It is tested and supported on Python versions:

  • 3.7
  • 3.8
  • 3.9
  • 3.10
  • 3.11
  • 3.12
  • 3.13

Installation

Install the CompassOne API client for Python with the desired version, e.g., 1.2.3

pip install compassone-sdk=1.2.3

Usage

Creating a Client

To use the CompassOne API client, you first need to create an authenticated client instance:

from compassone_sdk import AuthenticatedClient

COMPASS_ONE_API_URL="https://api.blackpointcyber.com"
COMPASS_ONE_API_TOKEN="your_api_token_here"

# Create an authenticated client instance with your API credentials
authenticated_client = AuthenticatedClient(base_url=COMPASS_ONE_API_URL, token=COMPASS_ONE_API_TOKEN)

Function Variants

The CompassOne API client provides multiple function variants for each API endpoint to accommodate different use cases:

Available Function Variants

Each API endpoint offers the following variants:

  • .sync_detailed(): Synchronous function that returns a detailed response object containing status code, headers, and parsed data
  • .asyncio_detailed(): Asynchronous function that returns a detailed response object containing status code, headers, and parsed data

API Organization

The API functions are organized under the compassone_sdk.api package, grouped by resource categories:

  • Account APIs: compassone_sdk.api.account
  • Tenant APIs: compassone_sdk.api.tenant
  • Contact Group APIs: compassone_sdk.api.contact_group
  • Cloud MDR APIs: compassone_sdk.api.cloud_mdr
  • Cloud MDR Cisco APIs: compassone_sdk.api.cloud_mdr_cisco
  • Cloud MDR Google APIs: compassone_sdk.api.cloud_mdr_google
  • Cloud MDR M365 APIs: compassone_sdk.api.cloud_mdr_m365

Synchronous Usage Examples

Account API Examples

Here are examples of how to use the Account API endpoints synchronously:

from compassone_sdk.api.account import get_account_controller_list
from compassone_sdk.models.tev1_paginated_accounts_response_dto import TEV1PaginatedAccountsResponseDto

# Make a synchronous API call to get the list of accounts
# This returns a detailed response object with status code, headers, and parsed data
# The 'client' parameter should be the authenticated_client instance created above
response = get_account_controller_list.sync_detailed(client=authenticated_client)

# response.parsed contains the parsed response data as a TEV1PaginatedAccountsResponseDto object
# This includes a list of accounts with pagination information
result: TEV1PaginatedAccountsResponseDto = response.parsed

Synchronous Usage

Account API Examples

Here are examples of how to use the Account API endpoints synchronously:

from compassone_sdk.api.account import get_account_controller_list

# Make a synchronous API call to get the list of accounts
# This returns a detailed response object with status code, headers, and parsed data
# The 'client' parameter should be the authenticated_client instance created above
response = get_account_controller_list.sync_detailed(client=authenticated_client)

# response.parsed contains the parsed response data as a TEV1PaginatedAccountsResponseDto object
# This includes a list of accounts with pagination information
result: TEV1PaginatedAccountsResponseDto = response.parsed

Asynchronous Usage

Tenant API Examples

Here are examples of how to use the Tenant API endpoints asynchronously:

import asyncio

from compassone_sdk.api.tenant import get_tenant_controller_list
from compassone_sdk.models.tev1_paginated_tenants_response_dto import TEV1PaginatedTenantsResponseDto

# Make a synchronous API call to get the list of accounts
# This returns a detailed response object with status code, headers, and parsed data
# The 'client' parameter should be the authenticated_client instance created above
response = asyncio.run(get_tenant_controller_list.asyncio_detailed(client=authenticated_client, account_id="your_account_id_here"))

# response.parsed contains the parsed response data as a TEV1PaginatedAccountsResponseDto object
# This includes a list of accounts with pagination information
result: TEV1PaginatedTenantsResponseDto = response.parsed

Error Handling

All API methods in this SDK return a Response object, which contains the following attributes:

  • status_code: The HTTP status code of the response.
  • content: The raw response content as bytes.
  • headers: The response headers.
  • parsed: The parsed response data (or None if parsing failed or the response was not successful).

You should always check the status_code and/or the parsed attribute to determine if the request was successful. For convenience

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

compassone_sdk-0.0.60.tar.gz (62.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

compassone_sdk-0.0.60-py3-none-any.whl (194.8 kB view details)

Uploaded Python 3

File details

Details for the file compassone_sdk-0.0.60.tar.gz.

File metadata

  • Download URL: compassone_sdk-0.0.60.tar.gz
  • Upload date:
  • Size: 62.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.3 CPython/3.9.23 Linux/6.8.0-1030-aws

File hashes

Hashes for compassone_sdk-0.0.60.tar.gz
Algorithm Hash digest
SHA256 73031e0561ce80436960d1a9046a6fcdeaaa40eb9b5915762f28aaf75906553a
MD5 d7a3244461b706a34943fbf651957775
BLAKE2b-256 c7c9df1e9216c1f788fe08cb3d2460303c01f1904fb29102f5819dd1ac1305ed

See more details on using hashes here.

File details

Details for the file compassone_sdk-0.0.60-py3-none-any.whl.

File metadata

  • Download URL: compassone_sdk-0.0.60-py3-none-any.whl
  • Upload date:
  • Size: 194.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.3 CPython/3.9.23 Linux/6.8.0-1030-aws

File hashes

Hashes for compassone_sdk-0.0.60-py3-none-any.whl
Algorithm Hash digest
SHA256 ca2a27cf73c723f5bff68f467e2afec9dc2a9e1f366f3ff713c46d4ec3505278
MD5 c95edbf26186d203641717e8a205c905
BLAKE2b-256 902787b5b773d7d0a8e0baf7da94db9b224022c7d0db251b30abecae499d4c9e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page