Getting Started
Installation
pip install capo-cost-optimization-hub
Usage
from capo_cost_optimization_hub import AsyncCostOptimizationHubClient
async def main():
async with AsyncCostOptimizationHubClient() as cost_optimization_hub:
# Example: call the get_preferences operation
response = await cost_optimization_hub.get_preferences()
print(response["savings_estimation_mode"])
Pagination
Some operations in this SDK support pagination. If the operation supports pagination it will have an iter_ prefixed method that returns an async iterator.
from capo_cost_optimization_hub import AsyncCostOptimizationHubClient
async def main():
async with AsyncCostOptimizationHubClient() as cost_optimization_hub:
# Example: paginate over list_efficiency_metrics
async for item in cost_optimization_hub.iter_list_efficiency_metrics():
print(item)
Error Handling
The SDK raises exceptions for errors returned by the API. Catch them to handle failures gracefully.
from capo_cost_optimization_hub import AsyncCostOptimizationHubClient
from capo_cost_optimization_hub.error import AccessDeniedException
async def main():
async with AsyncCostOptimizationHubClient() as cost_optimization_hub:
try:
await cost_optimization_hub.get_preferences()
except AccessDeniedException as e:
print(f"Error: {e}")
print(e.data) # additional error data
Retrying
The SDK retries failed operations automatically. Retry behaviour follows the Smithy specification: errors are retried based on their is_retryable and is_throttling_error attributes. Throttling errors use a longer base delay. Network-level failures (connection errors and timeouts) are also retried. Non-retryable errors, such as client errors without the @retryable trait, are raised immediately without further attempts.
The number of attempts defaults to 3 and can be changed at the client level via retry_max_attempts, or per call via config_overrides.
from capo_cost_optimization_hub import AsyncCostOptimizationHubClient
async def main():
async with AsyncCostOptimizationHubClient() as cost_optimization_hub:
# Default: 3 attempts for every operation
response = await cost_optimization_hub.get_preferences()
# Override per operation
response = await cost_optimization_hub.get_preferences(config_overrides={"retry_max_attempts": 5})
# Disable retries for this call
response = await cost_optimization_hub.get_preferences(config_overrides={"retry_max_attempts": 1})
Release files for capo-cost-optimization-hub 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| capo_cost_optimization_hub-0.1.0.tar.gz | 86.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| capo_cost_optimization_hub-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 258.5 kB
Release files / capo_cost_optimization_hub-0.1.0.tar.gz
| Download URL | capo_cost_optimization_hub-0.1.0.tar.gz |
|---|---|
| Size | 86.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
aad6cf12bd5e46400d1d3c02bd4ed69120434b32a519d53bb77867184021c96c
|
|
BLAKE2b-256 checksum How to use checksums |
444ccda0438c191a456c6d3b7871afae5971e17d7de28964f588f76cf10c9608
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.12.19 {"installer":{"name":"uv","version":"0.12.19","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / capo_cost_optimization_hub-0.1.0-py3-none-any.whl
| Download URL | capo_cost_optimization_hub-0.1.0-py3-none-any.whl |
|---|---|
| Size | 171.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2967165df074a5958d823ce332cd655a0aefbb48cd28aef4bfd9fc0f8684fa57
|
|
BLAKE2b-256 checksum How to use checksums |
18d79acbf750864ed62672783d0bfadbd68fee0d80dd3e4573616528acc0b34a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.12.19 {"installer":{"name":"uv","version":"0.12.19","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|