capo-cloudcontrol 0.12.0__tar.gz → 0.14.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {capo_cloudcontrol-0.12.0/src/capo_cloudcontrol.egg-info → capo_cloudcontrol-0.14.0}/PKG-INFO +3 -1
- {capo_cloudcontrol-0.12.0 → capo_cloudcontrol-0.14.0}/README.md +2 -0
- {capo_cloudcontrol-0.12.0 → capo_cloudcontrol-0.14.0}/pyproject.toml +1 -1
- {capo_cloudcontrol-0.12.0 → capo_cloudcontrol-0.14.0}/src/capo_cloudcontrol/_auth/_sigv4.py +5 -2
- {capo_cloudcontrol-0.12.0 → capo_cloudcontrol-0.14.0}/src/capo_cloudcontrol/_services/_aws_config.py +15 -0
- {capo_cloudcontrol-0.12.0 → capo_cloudcontrol-0.14.0}/src/capo_cloudcontrol/_services/_pipeline.py +207 -0
- {capo_cloudcontrol-0.12.0 → capo_cloudcontrol-0.14.0}/src/capo_cloudcontrol/_services/async_cloud_control.py +12 -1
- {capo_cloudcontrol-0.12.0 → capo_cloudcontrol-0.14.0}/src/capo_cloudcontrol/_services/cloud_control.py +12 -1
- {capo_cloudcontrol-0.12.0 → capo_cloudcontrol-0.14.0/src/capo_cloudcontrol.egg-info}/PKG-INFO +3 -1
- {capo_cloudcontrol-0.12.0 → capo_cloudcontrol-0.14.0}/tests/test_sigv4.py +33 -0
- {capo_cloudcontrol-0.12.0 → capo_cloudcontrol-0.14.0}/LICENSE +0 -0
- {capo_cloudcontrol-0.12.0 → capo_cloudcontrol-0.14.0}/setup.cfg +0 -0
- {capo_cloudcontrol-0.12.0 → capo_cloudcontrol-0.14.0}/src/capo_cloudcontrol/__init__.py +0 -0
- {capo_cloudcontrol-0.12.0 → capo_cloudcontrol-0.14.0}/src/capo_cloudcontrol/_async.py +0 -0
- {capo_cloudcontrol-0.12.0 → capo_cloudcontrol-0.14.0}/src/capo_cloudcontrol/_auth/_identity.py +0 -0
- {capo_cloudcontrol-0.12.0 → capo_cloudcontrol-0.14.0}/src/capo_cloudcontrol/_auth/_providers.py +0 -0
- {capo_cloudcontrol-0.12.0 → capo_cloudcontrol-0.14.0}/src/capo_cloudcontrol/_auth/_signers.py +0 -0
- {capo_cloudcontrol-0.12.0 → capo_cloudcontrol-0.14.0}/src/capo_cloudcontrol/_auth/_zapros_handler.py +0 -0
- {capo_cloudcontrol-0.12.0 → capo_cloudcontrol-0.14.0}/src/capo_cloudcontrol/_aws.py +0 -0
- {capo_cloudcontrol-0.12.0 → capo_cloudcontrol-0.14.0}/src/capo_cloudcontrol/_body.py +0 -0
- {capo_cloudcontrol-0.12.0 → capo_cloudcontrol-0.14.0}/src/capo_cloudcontrol/_iter.py +0 -0
- {capo_cloudcontrol-0.12.0 → capo_cloudcontrol-0.14.0}/src/capo_cloudcontrol/_operations/cloud_api_service/cancel_resource_request.py +0 -0
- {capo_cloudcontrol-0.12.0 → capo_cloudcontrol-0.14.0}/src/capo_cloudcontrol/_operations/cloud_api_service/create_resource.py +0 -0
- {capo_cloudcontrol-0.12.0 → capo_cloudcontrol-0.14.0}/src/capo_cloudcontrol/_operations/cloud_api_service/delete_resource.py +0 -0
- {capo_cloudcontrol-0.12.0 → capo_cloudcontrol-0.14.0}/src/capo_cloudcontrol/_operations/cloud_api_service/get_resource.py +0 -0
- {capo_cloudcontrol-0.12.0 → capo_cloudcontrol-0.14.0}/src/capo_cloudcontrol/_operations/cloud_api_service/get_resource_request_status.py +0 -0
- {capo_cloudcontrol-0.12.0 → capo_cloudcontrol-0.14.0}/src/capo_cloudcontrol/_operations/cloud_api_service/list_resource_requests.py +0 -0
- {capo_cloudcontrol-0.12.0 → capo_cloudcontrol-0.14.0}/src/capo_cloudcontrol/_operations/cloud_api_service/list_resources.py +0 -0
- {capo_cloudcontrol-0.12.0 → capo_cloudcontrol-0.14.0}/src/capo_cloudcontrol/_operations/cloud_api_service/update_resource.py +0 -0
- {capo_cloudcontrol-0.12.0 → capo_cloudcontrol-0.14.0}/src/capo_cloudcontrol/_pagination.py +0 -0
- {capo_cloudcontrol-0.12.0 → capo_cloudcontrol-0.14.0}/src/capo_cloudcontrol/_protocol/__init__.py +0 -0
- {capo_cloudcontrol-0.12.0 → capo_cloudcontrol-0.14.0}/src/capo_cloudcontrol/_protocol/errors.py +0 -0
- {capo_cloudcontrol-0.12.0 → capo_cloudcontrol-0.14.0}/src/capo_cloudcontrol/_protocol/eventstream.py +0 -0
- {capo_cloudcontrol-0.12.0 → capo_cloudcontrol-0.14.0}/src/capo_cloudcontrol/_protocol/serialize.py +0 -0
- {capo_cloudcontrol-0.12.0 → capo_cloudcontrol-0.14.0}/src/capo_cloudcontrol/_protocol/xml.py +0 -0
- {capo_cloudcontrol-0.12.0 → capo_cloudcontrol-0.14.0}/src/capo_cloudcontrol/_rule_engine/__init__.py +0 -0
- {capo_cloudcontrol-0.12.0 → capo_cloudcontrol-0.14.0}/src/capo_cloudcontrol/_rule_engine/_aws_partition.py +0 -0
- {capo_cloudcontrol-0.12.0 → capo_cloudcontrol-0.14.0}/src/capo_cloudcontrol/_rule_engine/_endpoint_rule_set.py +0 -0
- {capo_cloudcontrol-0.12.0 → capo_cloudcontrol-0.14.0}/src/capo_cloudcontrol/_rule_engine/_endpoint_runtime.py +0 -0
- {capo_cloudcontrol-0.12.0 → capo_cloudcontrol-0.14.0}/src/capo_cloudcontrol/errors/__init__.py +0 -0
- {capo_cloudcontrol-0.12.0 → capo_cloudcontrol-0.14.0}/src/capo_cloudcontrol/errors/_base.py +0 -0
- {capo_cloudcontrol-0.12.0 → capo_cloudcontrol-0.14.0}/src/capo_cloudcontrol/errors/already_exists_exception.py +0 -0
- {capo_cloudcontrol-0.12.0 → capo_cloudcontrol-0.14.0}/src/capo_cloudcontrol/errors/client_token_conflict_exception.py +0 -0
- {capo_cloudcontrol-0.12.0 → capo_cloudcontrol-0.14.0}/src/capo_cloudcontrol/errors/concurrent_modification_exception.py +0 -0
- {capo_cloudcontrol-0.12.0 → capo_cloudcontrol-0.14.0}/src/capo_cloudcontrol/errors/concurrent_operation_exception.py +0 -0
- {capo_cloudcontrol-0.12.0 → capo_cloudcontrol-0.14.0}/src/capo_cloudcontrol/errors/general_service_exception.py +0 -0
- {capo_cloudcontrol-0.12.0 → capo_cloudcontrol-0.14.0}/src/capo_cloudcontrol/errors/handler_failure_exception.py +0 -0
- {capo_cloudcontrol-0.12.0 → capo_cloudcontrol-0.14.0}/src/capo_cloudcontrol/errors/handler_internal_failure_exception.py +0 -0
- {capo_cloudcontrol-0.12.0 → capo_cloudcontrol-0.14.0}/src/capo_cloudcontrol/errors/invalid_credentials_exception.py +0 -0
- {capo_cloudcontrol-0.12.0 → capo_cloudcontrol-0.14.0}/src/capo_cloudcontrol/errors/invalid_request_exception.py +0 -0
- {capo_cloudcontrol-0.12.0 → capo_cloudcontrol-0.14.0}/src/capo_cloudcontrol/errors/network_failure_exception.py +0 -0
- {capo_cloudcontrol-0.12.0 → capo_cloudcontrol-0.14.0}/src/capo_cloudcontrol/errors/not_stabilized_exception.py +0 -0
- {capo_cloudcontrol-0.12.0 → capo_cloudcontrol-0.14.0}/src/capo_cloudcontrol/errors/not_updatable_exception.py +0 -0
- {capo_cloudcontrol-0.12.0 → capo_cloudcontrol-0.14.0}/src/capo_cloudcontrol/errors/private_type_exception.py +0 -0
- {capo_cloudcontrol-0.12.0 → capo_cloudcontrol-0.14.0}/src/capo_cloudcontrol/errors/request_token_not_found_exception.py +0 -0
- {capo_cloudcontrol-0.12.0 → capo_cloudcontrol-0.14.0}/src/capo_cloudcontrol/errors/resource_conflict_exception.py +0 -0
- {capo_cloudcontrol-0.12.0 → capo_cloudcontrol-0.14.0}/src/capo_cloudcontrol/errors/resource_not_found_exception.py +0 -0
- {capo_cloudcontrol-0.12.0 → capo_cloudcontrol-0.14.0}/src/capo_cloudcontrol/errors/service_internal_error_exception.py +0 -0
- {capo_cloudcontrol-0.12.0 → capo_cloudcontrol-0.14.0}/src/capo_cloudcontrol/errors/service_limit_exceeded_exception.py +0 -0
- {capo_cloudcontrol-0.12.0 → capo_cloudcontrol-0.14.0}/src/capo_cloudcontrol/errors/throttling_exception.py +0 -0
- {capo_cloudcontrol-0.12.0 → capo_cloudcontrol-0.14.0}/src/capo_cloudcontrol/errors/type_not_found_exception.py +0 -0
- {capo_cloudcontrol-0.12.0 → capo_cloudcontrol-0.14.0}/src/capo_cloudcontrol/errors/unsupported_action_exception.py +0 -0
- {capo_cloudcontrol-0.12.0 → capo_cloudcontrol-0.14.0}/src/capo_cloudcontrol/py.typed +0 -0
- {capo_cloudcontrol-0.12.0 → capo_cloudcontrol-0.14.0}/src/capo_cloudcontrol/types/_prelude/blob.py +0 -0
- {capo_cloudcontrol-0.12.0 → capo_cloudcontrol-0.14.0}/src/capo_cloudcontrol/types/_prelude/timestamp.py +0 -0
- {capo_cloudcontrol-0.12.0 → capo_cloudcontrol-0.14.0}/src/capo_cloudcontrol/types/_unknown.py +0 -0
- {capo_cloudcontrol-0.12.0 → capo_cloudcontrol-0.14.0}/src/capo_cloudcontrol/types/cancel_resource_request_input.py +0 -0
- {capo_cloudcontrol-0.12.0 → capo_cloudcontrol-0.14.0}/src/capo_cloudcontrol/types/cancel_resource_request_output.py +0 -0
- {capo_cloudcontrol-0.12.0 → capo_cloudcontrol-0.14.0}/src/capo_cloudcontrol/types/client_token.py +0 -0
- {capo_cloudcontrol-0.12.0 → capo_cloudcontrol-0.14.0}/src/capo_cloudcontrol/types/create_resource_input.py +0 -0
- {capo_cloudcontrol-0.12.0 → capo_cloudcontrol-0.14.0}/src/capo_cloudcontrol/types/create_resource_output.py +0 -0
- {capo_cloudcontrol-0.12.0 → capo_cloudcontrol-0.14.0}/src/capo_cloudcontrol/types/delete_resource_input.py +0 -0
- {capo_cloudcontrol-0.12.0 → capo_cloudcontrol-0.14.0}/src/capo_cloudcontrol/types/delete_resource_output.py +0 -0
- {capo_cloudcontrol-0.12.0 → capo_cloudcontrol-0.14.0}/src/capo_cloudcontrol/types/error_message.py +0 -0
- {capo_cloudcontrol-0.12.0 → capo_cloudcontrol-0.14.0}/src/capo_cloudcontrol/types/get_resource_input.py +0 -0
- {capo_cloudcontrol-0.12.0 → capo_cloudcontrol-0.14.0}/src/capo_cloudcontrol/types/get_resource_output.py +0 -0
- {capo_cloudcontrol-0.12.0 → capo_cloudcontrol-0.14.0}/src/capo_cloudcontrol/types/get_resource_request_status_input.py +0 -0
- {capo_cloudcontrol-0.12.0 → capo_cloudcontrol-0.14.0}/src/capo_cloudcontrol/types/get_resource_request_status_output.py +0 -0
- {capo_cloudcontrol-0.12.0 → capo_cloudcontrol-0.14.0}/src/capo_cloudcontrol/types/handler_error_code.py +0 -0
- {capo_cloudcontrol-0.12.0 → capo_cloudcontrol-0.14.0}/src/capo_cloudcontrol/types/handler_next_token.py +0 -0
- {capo_cloudcontrol-0.12.0 → capo_cloudcontrol-0.14.0}/src/capo_cloudcontrol/types/hook_failure_mode.py +0 -0
- {capo_cloudcontrol-0.12.0 → capo_cloudcontrol-0.14.0}/src/capo_cloudcontrol/types/hook_invocation_point.py +0 -0
- {capo_cloudcontrol-0.12.0 → capo_cloudcontrol-0.14.0}/src/capo_cloudcontrol/types/hook_progress_event.py +0 -0
- {capo_cloudcontrol-0.12.0 → capo_cloudcontrol-0.14.0}/src/capo_cloudcontrol/types/hook_status.py +0 -0
- {capo_cloudcontrol-0.12.0 → capo_cloudcontrol-0.14.0}/src/capo_cloudcontrol/types/hook_type_arn.py +0 -0
- {capo_cloudcontrol-0.12.0 → capo_cloudcontrol-0.14.0}/src/capo_cloudcontrol/types/hooks_progress_event.py +0 -0
- {capo_cloudcontrol-0.12.0 → capo_cloudcontrol-0.14.0}/src/capo_cloudcontrol/types/identifier.py +0 -0
- {capo_cloudcontrol-0.12.0 → capo_cloudcontrol-0.14.0}/src/capo_cloudcontrol/types/list_resource_requests_input.py +0 -0
- {capo_cloudcontrol-0.12.0 → capo_cloudcontrol-0.14.0}/src/capo_cloudcontrol/types/list_resource_requests_output.py +0 -0
- {capo_cloudcontrol-0.12.0 → capo_cloudcontrol-0.14.0}/src/capo_cloudcontrol/types/list_resources_input.py +0 -0
- {capo_cloudcontrol-0.12.0 → capo_cloudcontrol-0.14.0}/src/capo_cloudcontrol/types/list_resources_output.py +0 -0
- {capo_cloudcontrol-0.12.0 → capo_cloudcontrol-0.14.0}/src/capo_cloudcontrol/types/max_results.py +0 -0
- {capo_cloudcontrol-0.12.0 → capo_cloudcontrol-0.14.0}/src/capo_cloudcontrol/types/next_token.py +0 -0
- {capo_cloudcontrol-0.12.0 → capo_cloudcontrol-0.14.0}/src/capo_cloudcontrol/types/operation.py +0 -0
- {capo_cloudcontrol-0.12.0 → capo_cloudcontrol-0.14.0}/src/capo_cloudcontrol/types/operation_status.py +0 -0
- {capo_cloudcontrol-0.12.0 → capo_cloudcontrol-0.14.0}/src/capo_cloudcontrol/types/operation_statuses.py +0 -0
- {capo_cloudcontrol-0.12.0 → capo_cloudcontrol-0.14.0}/src/capo_cloudcontrol/types/operations.py +0 -0
- {capo_cloudcontrol-0.12.0 → capo_cloudcontrol-0.14.0}/src/capo_cloudcontrol/types/patch_document.py +0 -0
- {capo_cloudcontrol-0.12.0 → capo_cloudcontrol-0.14.0}/src/capo_cloudcontrol/types/progress_event.py +0 -0
- {capo_cloudcontrol-0.12.0 → capo_cloudcontrol-0.14.0}/src/capo_cloudcontrol/types/properties.py +0 -0
- {capo_cloudcontrol-0.12.0 → capo_cloudcontrol-0.14.0}/src/capo_cloudcontrol/types/request_token.py +0 -0
- {capo_cloudcontrol-0.12.0 → capo_cloudcontrol-0.14.0}/src/capo_cloudcontrol/types/resource_description.py +0 -0
- {capo_cloudcontrol-0.12.0 → capo_cloudcontrol-0.14.0}/src/capo_cloudcontrol/types/resource_descriptions.py +0 -0
- {capo_cloudcontrol-0.12.0 → capo_cloudcontrol-0.14.0}/src/capo_cloudcontrol/types/resource_request_status_filter.py +0 -0
- {capo_cloudcontrol-0.12.0 → capo_cloudcontrol-0.14.0}/src/capo_cloudcontrol/types/resource_request_status_summaries.py +0 -0
- {capo_cloudcontrol-0.12.0 → capo_cloudcontrol-0.14.0}/src/capo_cloudcontrol/types/role_arn.py +0 -0
- {capo_cloudcontrol-0.12.0 → capo_cloudcontrol-0.14.0}/src/capo_cloudcontrol/types/status_message.py +0 -0
- {capo_cloudcontrol-0.12.0 → capo_cloudcontrol-0.14.0}/src/capo_cloudcontrol/types/timestamp.py +0 -0
- {capo_cloudcontrol-0.12.0 → capo_cloudcontrol-0.14.0}/src/capo_cloudcontrol/types/type_name.py +0 -0
- {capo_cloudcontrol-0.12.0 → capo_cloudcontrol-0.14.0}/src/capo_cloudcontrol/types/type_version_id.py +0 -0
- {capo_cloudcontrol-0.12.0 → capo_cloudcontrol-0.14.0}/src/capo_cloudcontrol/types/update_resource_input.py +0 -0
- {capo_cloudcontrol-0.12.0 → capo_cloudcontrol-0.14.0}/src/capo_cloudcontrol/types/update_resource_output.py +0 -0
- {capo_cloudcontrol-0.12.0 → capo_cloudcontrol-0.14.0}/src/capo_cloudcontrol.egg-info/SOURCES.txt +0 -0
- {capo_cloudcontrol-0.12.0 → capo_cloudcontrol-0.14.0}/src/capo_cloudcontrol.egg-info/dependency_links.txt +0 -0
- {capo_cloudcontrol-0.12.0 → capo_cloudcontrol-0.14.0}/src/capo_cloudcontrol.egg-info/requires.txt +0 -0
- {capo_cloudcontrol-0.12.0 → capo_cloudcontrol-0.14.0}/src/capo_cloudcontrol.egg-info/top_level.txt +0 -0
- {capo_cloudcontrol-0.12.0 → capo_cloudcontrol-0.14.0}/tests/test_body.py +0 -0
{capo_cloudcontrol-0.12.0/src/capo_cloudcontrol.egg-info → capo_cloudcontrol-0.14.0}/PKG-INFO
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: capo-cloudcontrol
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.14.0
|
|
4
4
|
Summary: Typed, async Python SDK for AWS Cloudcontrol.
|
|
5
5
|
Project-URL: Homepage, https://capo-sdk.dev/
|
|
6
6
|
Project-URL: Documentation, https://capo-sdk.dev/services/cloudcontrol/
|
|
@@ -95,6 +95,8 @@ The SDK retries failed operations automatically. Retry behaviour follows the Smi
|
|
|
95
95
|
|
|
96
96
|
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`.
|
|
97
97
|
|
|
98
|
+
`retry_mode="adaptive"` (or `AWS_RETRY_MODE=adaptive`, or `retry_mode = adaptive` in the AWS profile) also slows the whole client down once the service starts throttling it, then speeds back up as requests succeed. The default is `standard`.
|
|
99
|
+
|
|
98
100
|
```python
|
|
99
101
|
from capo_cloudcontrol import AsyncCloudControlClient
|
|
100
102
|
|
|
@@ -62,6 +62,8 @@ The SDK retries failed operations automatically. Retry behaviour follows the Smi
|
|
|
62
62
|
|
|
63
63
|
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`.
|
|
64
64
|
|
|
65
|
+
`retry_mode="adaptive"` (or `AWS_RETRY_MODE=adaptive`, or `retry_mode = adaptive` in the AWS profile) also slows the whole client down once the service starts throttling it, then speeds back up as requests succeed. The default is `standard`.
|
|
66
|
+
|
|
65
67
|
```python
|
|
66
68
|
from capo_cloudcontrol import AsyncCloudControlClient
|
|
67
69
|
|
|
@@ -471,12 +471,15 @@ def presign_sigv4(
|
|
|
471
471
|
*,
|
|
472
472
|
expires_in: int = 3600,
|
|
473
473
|
now: _dt.datetime | None = None,
|
|
474
|
+
payload_hash: str = "UNSIGNED-PAYLOAD",
|
|
474
475
|
) -> Request:
|
|
475
476
|
"""Return a new ``Request`` whose URL carries SigV4 query-string auth.
|
|
476
477
|
|
|
477
478
|
The signature travels in the URL (``X-Amz-*`` query params), so the result
|
|
478
479
|
is usable standalone (browser, curl). Payload is signed as
|
|
479
|
-
``UNSIGNED-PAYLOAD``, so the body is not bound by the signature
|
|
480
|
+
``UNSIGNED-PAYLOAD``, so the body is not bound by the signature, unless
|
|
481
|
+
``payload_hash`` says otherwise: an RDS or DSQL auth token signs the
|
|
482
|
+
SHA-256 of an empty body instead.
|
|
480
483
|
|
|
481
484
|
``expires_in`` is the validity window in seconds; range 1..604800 (7 days),
|
|
482
485
|
bounded by the max lifetime of the derived signing key.
|
|
@@ -542,7 +545,7 @@ def presign_sigv4(
|
|
|
542
545
|
f"{canonical_query}\n"
|
|
543
546
|
f"{canonical_headers}\n"
|
|
544
547
|
f"{signed_headers}\n"
|
|
545
|
-
f"
|
|
548
|
+
f"{payload_hash}"
|
|
546
549
|
)
|
|
547
550
|
|
|
548
551
|
string_to_sign = (
|
{capo_cloudcontrol-0.12.0 → capo_cloudcontrol-0.14.0}/src/capo_cloudcontrol/_services/_aws_config.py
RENAMED
|
@@ -31,6 +31,7 @@ class AwsSettings:
|
|
|
31
31
|
use_fips: bool
|
|
32
32
|
use_dual_stack: bool
|
|
33
33
|
max_attempts: int
|
|
34
|
+
retry_mode: str
|
|
34
35
|
|
|
35
36
|
|
|
36
37
|
def _env_bool(name: str) -> bool | None:
|
|
@@ -109,12 +110,22 @@ def load_aws_settings() -> AwsSettings:
|
|
|
109
110
|
use_dual_stack = False
|
|
110
111
|
max_attempts_raw = os.environ.get("AWS_MAX_ATTEMPTS") or profile.get("max_attempts")
|
|
111
112
|
max_attempts = int(max_attempts_raw) if max_attempts_raw else 3
|
|
113
|
+
retry_mode = (
|
|
114
|
+
(os.environ.get("AWS_RETRY_MODE") or profile.get("retry_mode") or "standard")
|
|
115
|
+
.strip()
|
|
116
|
+
.lower()
|
|
117
|
+
)
|
|
118
|
+
if retry_mode not in ("legacy", "standard", "adaptive"):
|
|
119
|
+
raise ValueError(
|
|
120
|
+
f"invalid retry_mode {retry_mode!r}: expected 'legacy', 'standard' or 'adaptive'"
|
|
121
|
+
)
|
|
112
122
|
return AwsSettings(
|
|
113
123
|
region=region,
|
|
114
124
|
endpoint=endpoint,
|
|
115
125
|
use_fips=use_fips,
|
|
116
126
|
use_dual_stack=use_dual_stack,
|
|
117
127
|
max_attempts=max_attempts,
|
|
128
|
+
retry_mode=retry_mode,
|
|
118
129
|
)
|
|
119
130
|
|
|
120
131
|
|
|
@@ -134,6 +145,8 @@ def aws_config() -> Interceptor[TInput, TOutput]:
|
|
|
134
145
|
options.use_dual_stack = settings.use_dual_stack
|
|
135
146
|
if options.retry_max_attempts is None:
|
|
136
147
|
options.retry_max_attempts = settings.max_attempts
|
|
148
|
+
if options.retry_mode is None:
|
|
149
|
+
options.retry_mode = settings.retry_mode
|
|
137
150
|
return next(request)
|
|
138
151
|
|
|
139
152
|
return interceptor
|
|
@@ -155,6 +168,8 @@ def aaws_config() -> AsyncInterceptor[TInput, TOutput]:
|
|
|
155
168
|
options.use_dual_stack = settings.use_dual_stack
|
|
156
169
|
if options.retry_max_attempts is None:
|
|
157
170
|
options.retry_max_attempts = settings.max_attempts
|
|
171
|
+
if options.retry_mode is None:
|
|
172
|
+
options.retry_mode = settings.retry_mode
|
|
158
173
|
return await next(request)
|
|
159
174
|
|
|
160
175
|
return interceptor
|
{capo_cloudcontrol-0.12.0 → capo_cloudcontrol-0.14.0}/src/capo_cloudcontrol/_services/_pipeline.py
RENAMED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
3
|
import logging
|
|
4
|
+
import math
|
|
4
5
|
import random
|
|
5
6
|
import threading
|
|
6
7
|
import time
|
|
@@ -88,15 +89,134 @@ class ThreadSafeRetryQuota(RetryQuota):
|
|
|
88
89
|
super().release(last_retry_cost)
|
|
89
90
|
|
|
90
91
|
|
|
92
|
+
class RateLimiter:
|
|
93
|
+
"""Send tokens shared by all operations of one client in adaptive retry mode: the rate drops on throttling and regrows on success."""
|
|
94
|
+
|
|
95
|
+
MIN_FILL_RATE: float = 0.5
|
|
96
|
+
MIN_CAPACITY: float = 1.0
|
|
97
|
+
BETA: float = 0.7
|
|
98
|
+
SCALE_CONSTANT: float = 0.4
|
|
99
|
+
SMOOTHING: float = 0.8
|
|
100
|
+
MAX_RATE_SCALE: float = 2.0
|
|
101
|
+
|
|
102
|
+
def __init__(self, clock: Callable[[], float] = time.monotonic) -> None:
|
|
103
|
+
self._clock = clock
|
|
104
|
+
now = clock()
|
|
105
|
+
self._enabled: bool = False
|
|
106
|
+
self._fill_rate: float = 1.0
|
|
107
|
+
self._max_capacity: float = 1.0
|
|
108
|
+
self._capacity: float = 0.0
|
|
109
|
+
self._last_refill: float = now
|
|
110
|
+
self._last_max_rate: float = 0.0
|
|
111
|
+
self._last_throttle: float = now
|
|
112
|
+
self._measured_rate: float = 0.0
|
|
113
|
+
self._rate_bucket: float = math.floor(now)
|
|
114
|
+
self._request_count: int = 0
|
|
115
|
+
|
|
116
|
+
def acquire(self) -> float:
|
|
117
|
+
"""Take a send token: return 0, or the seconds to wait before asking again."""
|
|
118
|
+
if not self._enabled:
|
|
119
|
+
return 0.0
|
|
120
|
+
self._refill(self._clock())
|
|
121
|
+
if self._capacity >= 1:
|
|
122
|
+
self._capacity -= 1
|
|
123
|
+
return 0.0
|
|
124
|
+
return (1 - self._capacity) / self._fill_rate
|
|
125
|
+
|
|
126
|
+
def update(self, is_throttling: bool) -> None:
|
|
127
|
+
"""Adjust the send rate after an attempt: cut it on throttling, regrow it otherwise."""
|
|
128
|
+
now = self._clock()
|
|
129
|
+
self._measure(now)
|
|
130
|
+
self._adjust(is_throttling, now)
|
|
131
|
+
|
|
132
|
+
def throttled_mid_stream(self) -> None:
|
|
133
|
+
"""Cut the send rate for throttling reported inside an open event stream. No new request was sent, so the measured rate is left alone."""
|
|
134
|
+
self._adjust(True, self._clock())
|
|
135
|
+
|
|
136
|
+
def _adjust(self, is_throttling: bool, now: float) -> None:
|
|
137
|
+
if is_throttling:
|
|
138
|
+
rate = (
|
|
139
|
+
min(self._measured_rate, self._fill_rate)
|
|
140
|
+
if self._enabled
|
|
141
|
+
else self._measured_rate
|
|
142
|
+
)
|
|
143
|
+
self._last_max_rate = rate
|
|
144
|
+
self._last_throttle = now
|
|
145
|
+
new_rate = rate * self.BETA
|
|
146
|
+
self._enabled = True
|
|
147
|
+
else:
|
|
148
|
+
window = (self._last_max_rate * (1 - self.BETA) / self.SCALE_CONSTANT) ** (
|
|
149
|
+
1 / 3
|
|
150
|
+
)
|
|
151
|
+
new_rate = (
|
|
152
|
+
self.SCALE_CONSTANT * (now - self._last_throttle - window) ** 3
|
|
153
|
+
+ self._last_max_rate
|
|
154
|
+
)
|
|
155
|
+
self._set_rate(min(new_rate, self.MAX_RATE_SCALE * self._measured_rate), now)
|
|
156
|
+
if is_throttling:
|
|
157
|
+
logger.debug(
|
|
158
|
+
"throttled, send rate lowered to %.2f requests/s",
|
|
159
|
+
self._fill_rate,
|
|
160
|
+
extra={"send_rate": self._fill_rate},
|
|
161
|
+
)
|
|
162
|
+
|
|
163
|
+
def _refill(self, now: float) -> None:
|
|
164
|
+
self._capacity = min(
|
|
165
|
+
self._max_capacity,
|
|
166
|
+
self._capacity + (now - self._last_refill) * self._fill_rate,
|
|
167
|
+
)
|
|
168
|
+
self._last_refill = now
|
|
169
|
+
|
|
170
|
+
def _measure(self, now: float) -> None:
|
|
171
|
+
# Requests per second, counted in half-second buckets and smoothed.
|
|
172
|
+
bucket = math.floor(now * 2) / 2
|
|
173
|
+
self._request_count += 1
|
|
174
|
+
if bucket > self._rate_bucket:
|
|
175
|
+
current = self._request_count / (bucket - self._rate_bucket)
|
|
176
|
+
self._measured_rate = current * self.SMOOTHING + self._measured_rate * (
|
|
177
|
+
1 - self.SMOOTHING
|
|
178
|
+
)
|
|
179
|
+
self._request_count = 0
|
|
180
|
+
self._rate_bucket = bucket
|
|
181
|
+
|
|
182
|
+
def _set_rate(self, rate: float, now: float) -> None:
|
|
183
|
+
self._refill(now)
|
|
184
|
+
self._fill_rate = max(rate, self.MIN_FILL_RATE)
|
|
185
|
+
self._max_capacity = max(rate, self.MIN_CAPACITY)
|
|
186
|
+
self._capacity = min(self._capacity, self._max_capacity)
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
class ThreadSafeRateLimiter(RateLimiter):
|
|
190
|
+
"""A ``RateLimiter`` that sync clients can share across threads."""
|
|
191
|
+
|
|
192
|
+
def __init__(self, clock: Callable[[], float] = time.monotonic) -> None:
|
|
193
|
+
super().__init__(clock)
|
|
194
|
+
self._lock: threading.Lock = threading.Lock()
|
|
195
|
+
|
|
196
|
+
def acquire(self) -> float:
|
|
197
|
+
with self._lock:
|
|
198
|
+
return super().acquire()
|
|
199
|
+
|
|
200
|
+
def update(self, is_throttling: bool) -> None:
|
|
201
|
+
with self._lock:
|
|
202
|
+
super().update(is_throttling)
|
|
203
|
+
|
|
204
|
+
def throttled_mid_stream(self) -> None:
|
|
205
|
+
with self._lock:
|
|
206
|
+
super().throttled_mid_stream()
|
|
207
|
+
|
|
208
|
+
|
|
91
209
|
@dataclass
|
|
92
210
|
class OperationOptions:
|
|
93
211
|
client: Client
|
|
94
212
|
retry_quota: RetryQuota
|
|
213
|
+
rate_limiter: RateLimiter
|
|
95
214
|
use_dual_stack: bool | None = None
|
|
96
215
|
use_fips: bool | None = None
|
|
97
216
|
region: str | None = None
|
|
98
217
|
endpoint: str | None = None
|
|
99
218
|
retry_max_attempts: int | None = None
|
|
219
|
+
retry_mode: str | None = None
|
|
100
220
|
credentials_provider: IdentityProvider[Credentials] | None = None
|
|
101
221
|
anonymous: bool | None = None
|
|
102
222
|
|
|
@@ -105,11 +225,13 @@ class OperationOptions:
|
|
|
105
225
|
class AsyncOperationOptions:
|
|
106
226
|
client: AsyncClient
|
|
107
227
|
retry_quota: RetryQuota
|
|
228
|
+
rate_limiter: RateLimiter
|
|
108
229
|
use_dual_stack: bool | None = None
|
|
109
230
|
use_fips: bool | None = None
|
|
110
231
|
region: str | None = None
|
|
111
232
|
endpoint: str | None = None
|
|
112
233
|
retry_max_attempts: int | None = None
|
|
234
|
+
retry_mode: str | None = None
|
|
113
235
|
credentials_provider: IdentityProvider[Credentials] | None = None
|
|
114
236
|
anonymous: bool | None = None
|
|
115
237
|
|
|
@@ -428,6 +550,91 @@ def aretry() -> AsyncInterceptor[TInput, TOutput]:
|
|
|
428
550
|
return interceptor
|
|
429
551
|
|
|
430
552
|
|
|
553
|
+
def rate_limit() -> Interceptor[TInput, TOutput]:
|
|
554
|
+
def interceptor(
|
|
555
|
+
request: OperationRequest[TInput], next: NextFn[TInput, TOutput]
|
|
556
|
+
) -> OperationResponse[TOutput]:
|
|
557
|
+
if request.options.retry_mode != "adaptive":
|
|
558
|
+
return next(request)
|
|
559
|
+
limiter = request.options.rate_limiter
|
|
560
|
+
while (wait := limiter.acquire()) > 0:
|
|
561
|
+
time.sleep(wait)
|
|
562
|
+
try:
|
|
563
|
+
response = next(request)
|
|
564
|
+
except Exception as exc:
|
|
565
|
+
limiter.update(isinstance(exc, ServiceError) and exc.is_throttling_error)
|
|
566
|
+
raise
|
|
567
|
+
limiter.update(False)
|
|
568
|
+
return response
|
|
569
|
+
|
|
570
|
+
return interceptor
|
|
571
|
+
|
|
572
|
+
|
|
573
|
+
def arate_limit() -> AsyncInterceptor[TInput, TOutput]:
|
|
574
|
+
async def interceptor(
|
|
575
|
+
request: AsyncOperationRequest[TInput], next: AsyncNextFn[TInput, TOutput]
|
|
576
|
+
) -> AsyncOperationResponse[TOutput]:
|
|
577
|
+
if request.options.retry_mode != "adaptive":
|
|
578
|
+
return await next(request)
|
|
579
|
+
limiter = request.options.rate_limiter
|
|
580
|
+
while (wait := limiter.acquire()) > 0:
|
|
581
|
+
await anysleep(wait)
|
|
582
|
+
try:
|
|
583
|
+
response = await next(request)
|
|
584
|
+
except Exception as exc:
|
|
585
|
+
limiter.update(isinstance(exc, ServiceError) and exc.is_throttling_error)
|
|
586
|
+
raise
|
|
587
|
+
limiter.update(False)
|
|
588
|
+
return response
|
|
589
|
+
|
|
590
|
+
return interceptor
|
|
591
|
+
|
|
592
|
+
|
|
593
|
+
def _on_event_stream_error(
|
|
594
|
+
exc: ServiceError, options: OperationOptions | AsyncOperationOptions
|
|
595
|
+
) -> None:
|
|
596
|
+
# An error event arrives after a 200 response, so raise_error never saw it:
|
|
597
|
+
# mark it by its code here. It is not retried, but adaptive mode slows down.
|
|
598
|
+
_apply_retry_rules(exc, exc.response)
|
|
599
|
+
if exc.is_throttling_error and options.retry_mode == "adaptive":
|
|
600
|
+
options.rate_limiter.throttled_mid_stream()
|
|
601
|
+
|
|
602
|
+
|
|
603
|
+
def watch_event_stream(output: Any, member: str, options: OperationOptions) -> None:
|
|
604
|
+
"""Wrap the event stream ``output[member]`` so the errors it raises get their retry flags and reach the rate limiter."""
|
|
605
|
+
if member not in output:
|
|
606
|
+
return
|
|
607
|
+
events = output[member]
|
|
608
|
+
|
|
609
|
+
def watched() -> Iterator[Any]:
|
|
610
|
+
try:
|
|
611
|
+
yield from events
|
|
612
|
+
except ServiceError as exc:
|
|
613
|
+
_on_event_stream_error(exc, options)
|
|
614
|
+
raise
|
|
615
|
+
|
|
616
|
+
output[member] = watched()
|
|
617
|
+
|
|
618
|
+
|
|
619
|
+
def awatch_event_stream(
|
|
620
|
+
output: Any, member: str, options: AsyncOperationOptions
|
|
621
|
+
) -> None:
|
|
622
|
+
"""Wrap the event stream ``output[member]`` so the errors it raises get their retry flags and reach the rate limiter."""
|
|
623
|
+
if member not in output:
|
|
624
|
+
return
|
|
625
|
+
events = output[member]
|
|
626
|
+
|
|
627
|
+
async def watched() -> AsyncIterator[Any]:
|
|
628
|
+
try:
|
|
629
|
+
async for event in events:
|
|
630
|
+
yield event
|
|
631
|
+
except ServiceError as exc:
|
|
632
|
+
_on_event_stream_error(exc, options)
|
|
633
|
+
raise
|
|
634
|
+
|
|
635
|
+
output[member] = watched()
|
|
636
|
+
|
|
637
|
+
|
|
431
638
|
def log_operation(operation_logging: OperationLogging) -> Interceptor[TInput, TOutput]:
|
|
432
639
|
operation = operation_logging.operation
|
|
433
640
|
redact_input = operation_logging.redact_input
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import uuid
|
|
4
4
|
import warnings
|
|
5
5
|
from collections.abc import AsyncIterator
|
|
6
|
-
from typing import TYPE_CHECKING, Any, Iterable, Optional
|
|
6
|
+
from typing import TYPE_CHECKING, Any, Iterable, Literal, Optional
|
|
7
7
|
|
|
8
8
|
from typing_extensions import Self, TypedDict
|
|
9
9
|
from zapros import AsyncBaseHandler, AsyncClient
|
|
@@ -26,9 +26,11 @@ from capo_cloudcontrol._services._pipeline import (
|
|
|
26
26
|
AsyncOperationRequest,
|
|
27
27
|
AsyncOperationResponse,
|
|
28
28
|
OperationLogging,
|
|
29
|
+
RateLimiter,
|
|
29
30
|
RetryQuota,
|
|
30
31
|
aexecute_pipeline,
|
|
31
32
|
alog_operation,
|
|
33
|
+
arate_limit,
|
|
32
34
|
aretry,
|
|
33
35
|
)
|
|
34
36
|
|
|
@@ -68,6 +70,7 @@ if TYPE_CHECKING:
|
|
|
68
70
|
class AsyncCloudControlClientConfig(TypedDict, total=False, closed=True):
|
|
69
71
|
operation_interceptors: Iterable[AsyncInterceptor[Any, Any]]
|
|
70
72
|
retry_max_attempts: int | None
|
|
73
|
+
retry_mode: Literal["standard", "adaptive"] | None
|
|
71
74
|
region: str | None
|
|
72
75
|
use_dual_stack: bool | None
|
|
73
76
|
use_fips: bool | None
|
|
@@ -83,6 +86,7 @@ class AsyncCloudControlClient:
|
|
|
83
86
|
http_handler: HTTP handler for sending requests. If not provided, creates a default handler.
|
|
84
87
|
operation_interceptors: Interceptors that wrap every operation call. If not provided, defaults to an empty list.
|
|
85
88
|
retry_max_attempts: Maximum number of times to retry a failed operation. Defaults to 3.
|
|
89
|
+
retry_mode: ``"standard"`` (the default) or ``"adaptive"``, which also slows the whole client down when the service throttles it.
|
|
86
90
|
region: The value of the ``AWS::Region`` endpoint parameter.
|
|
87
91
|
use_dual_stack: The value of the ``AWS::UseDualStack`` endpoint parameter.
|
|
88
92
|
use_fips: The value of the ``AWS::UseFIPS`` endpoint parameter.
|
|
@@ -97,6 +101,7 @@ class AsyncCloudControlClient:
|
|
|
97
101
|
http_handler: AsyncBaseHandler | None = None,
|
|
98
102
|
operation_interceptors: Iterable[AsyncInterceptor[Any, Any]] | None = None,
|
|
99
103
|
retry_max_attempts: int | None = None,
|
|
104
|
+
retry_mode: Literal["standard", "adaptive"] | None = None,
|
|
100
105
|
region: str | None = None,
|
|
101
106
|
use_dual_stack: bool | None = None,
|
|
102
107
|
use_fips: bool | None = None,
|
|
@@ -113,6 +118,8 @@ class AsyncCloudControlClient:
|
|
|
113
118
|
self._client = client.wrap_with_middleware(lambda next: AuthMiddleware(next))
|
|
114
119
|
# One retry quota for all of this client's operations.
|
|
115
120
|
self._retry_quota = RetryQuota()
|
|
121
|
+
# One send-rate limiter too, used when retry_mode is adaptive.
|
|
122
|
+
self._rate_limiter = RateLimiter()
|
|
116
123
|
if credentials is not None and credentials_provider is not None:
|
|
117
124
|
warnings.warn(
|
|
118
125
|
"Both credentials and credentials_provider given; provider takes precedence"
|
|
@@ -130,6 +137,7 @@ class AsyncCloudControlClient:
|
|
|
130
137
|
{
|
|
131
138
|
"operation_interceptors": operation_interceptors or [],
|
|
132
139
|
"retry_max_attempts": retry_max_attempts,
|
|
140
|
+
"retry_mode": retry_mode,
|
|
133
141
|
"region": region,
|
|
134
142
|
"use_dual_stack": use_dual_stack,
|
|
135
143
|
"use_fips": use_fips,
|
|
@@ -154,12 +162,15 @@ class AsyncCloudControlClient:
|
|
|
154
162
|
if operation_logging is not None:
|
|
155
163
|
interceptors_.append(alog_operation(operation_logging))
|
|
156
164
|
interceptors_.append(aretry())
|
|
165
|
+
interceptors_.append(arate_limit())
|
|
157
166
|
options_: AsyncOperationOptions = AsyncOperationOptions(
|
|
158
167
|
client=self._client,
|
|
159
168
|
retry_quota=self._retry_quota,
|
|
169
|
+
rate_limiter=self._rate_limiter,
|
|
160
170
|
retry_max_attempts=overrides.get(
|
|
161
171
|
"retry_max_attempts", self._config.get("retry_max_attempts")
|
|
162
172
|
),
|
|
173
|
+
retry_mode=overrides.get("retry_mode", self._config.get("retry_mode")),
|
|
163
174
|
region=overrides.get("region", self._config.get("region")),
|
|
164
175
|
use_dual_stack=overrides.get(
|
|
165
176
|
"use_dual_stack", self._config.get("use_dual_stack")
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import uuid
|
|
4
4
|
import warnings
|
|
5
5
|
from collections.abc import Iterator
|
|
6
|
-
from typing import TYPE_CHECKING, Any, Iterable, Optional
|
|
6
|
+
from typing import TYPE_CHECKING, Any, Iterable, Literal, Optional
|
|
7
7
|
|
|
8
8
|
from typing_extensions import Self, TypedDict
|
|
9
9
|
from zapros import BaseHandler, Client
|
|
@@ -26,9 +26,11 @@ from capo_cloudcontrol._services._pipeline import (
|
|
|
26
26
|
OperationOptions,
|
|
27
27
|
OperationRequest,
|
|
28
28
|
OperationResponse,
|
|
29
|
+
ThreadSafeRateLimiter,
|
|
29
30
|
ThreadSafeRetryQuota,
|
|
30
31
|
execute_pipeline,
|
|
31
32
|
log_operation,
|
|
33
|
+
rate_limit,
|
|
32
34
|
retry,
|
|
33
35
|
)
|
|
34
36
|
|
|
@@ -68,6 +70,7 @@ if TYPE_CHECKING:
|
|
|
68
70
|
class CloudControlClientConfig(TypedDict, total=False, closed=True):
|
|
69
71
|
operation_interceptors: Iterable[Interceptor[Any, Any]]
|
|
70
72
|
retry_max_attempts: int | None
|
|
73
|
+
retry_mode: Literal["standard", "adaptive"] | None
|
|
71
74
|
region: str | None
|
|
72
75
|
use_dual_stack: bool | None
|
|
73
76
|
use_fips: bool | None
|
|
@@ -83,6 +86,7 @@ class CloudControlClient:
|
|
|
83
86
|
http_handler: HTTP handler for sending requests. If not provided, creates a default handler.
|
|
84
87
|
operation_interceptors: Interceptors that wrap every operation call. If not provided, defaults to an empty list.
|
|
85
88
|
retry_max_attempts: Maximum number of times to retry a failed operation. Defaults to 3.
|
|
89
|
+
retry_mode: ``"standard"`` (the default) or ``"adaptive"``, which also slows the whole client down when the service throttles it.
|
|
86
90
|
region: The value of the ``AWS::Region`` endpoint parameter.
|
|
87
91
|
use_dual_stack: The value of the ``AWS::UseDualStack`` endpoint parameter.
|
|
88
92
|
use_fips: The value of the ``AWS::UseFIPS`` endpoint parameter.
|
|
@@ -97,6 +101,7 @@ class CloudControlClient:
|
|
|
97
101
|
http_handler: BaseHandler | None = None,
|
|
98
102
|
operation_interceptors: Iterable[Interceptor[Any, Any]] | None = None,
|
|
99
103
|
retry_max_attempts: int | None = None,
|
|
104
|
+
retry_mode: Literal["standard", "adaptive"] | None = None,
|
|
100
105
|
region: str | None = None,
|
|
101
106
|
use_dual_stack: bool | None = None,
|
|
102
107
|
use_fips: bool | None = None,
|
|
@@ -113,6 +118,8 @@ class CloudControlClient:
|
|
|
113
118
|
self._client = client.wrap_with_middleware(lambda next: AuthMiddleware(next))
|
|
114
119
|
# One retry quota for all of this client's operations.
|
|
115
120
|
self._retry_quota = ThreadSafeRetryQuota()
|
|
121
|
+
# One send-rate limiter too, used when retry_mode is adaptive.
|
|
122
|
+
self._rate_limiter = ThreadSafeRateLimiter()
|
|
116
123
|
if credentials is not None and credentials_provider is not None:
|
|
117
124
|
warnings.warn(
|
|
118
125
|
"Both credentials and credentials_provider given; provider takes precedence"
|
|
@@ -130,6 +137,7 @@ class CloudControlClient:
|
|
|
130
137
|
{
|
|
131
138
|
"operation_interceptors": operation_interceptors or [],
|
|
132
139
|
"retry_max_attempts": retry_max_attempts,
|
|
140
|
+
"retry_mode": retry_mode,
|
|
133
141
|
"region": region,
|
|
134
142
|
"use_dual_stack": use_dual_stack,
|
|
135
143
|
"use_fips": use_fips,
|
|
@@ -154,12 +162,15 @@ class CloudControlClient:
|
|
|
154
162
|
if operation_logging is not None:
|
|
155
163
|
interceptors_.append(log_operation(operation_logging))
|
|
156
164
|
interceptors_.append(retry())
|
|
165
|
+
interceptors_.append(rate_limit())
|
|
157
166
|
options_: OperationOptions = OperationOptions(
|
|
158
167
|
client=self._client,
|
|
159
168
|
retry_quota=self._retry_quota,
|
|
169
|
+
rate_limiter=self._rate_limiter,
|
|
160
170
|
retry_max_attempts=overrides.get(
|
|
161
171
|
"retry_max_attempts", self._config.get("retry_max_attempts")
|
|
162
172
|
),
|
|
173
|
+
retry_mode=overrides.get("retry_mode", self._config.get("retry_mode")),
|
|
163
174
|
region=overrides.get("region", self._config.get("region")),
|
|
164
175
|
use_dual_stack=overrides.get(
|
|
165
176
|
"use_dual_stack", self._config.get("use_dual_stack")
|
{capo_cloudcontrol-0.12.0 → capo_cloudcontrol-0.14.0/src/capo_cloudcontrol.egg-info}/PKG-INFO
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: capo-cloudcontrol
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.14.0
|
|
4
4
|
Summary: Typed, async Python SDK for AWS Cloudcontrol.
|
|
5
5
|
Project-URL: Homepage, https://capo-sdk.dev/
|
|
6
6
|
Project-URL: Documentation, https://capo-sdk.dev/services/cloudcontrol/
|
|
@@ -95,6 +95,8 @@ The SDK retries failed operations automatically. Retry behaviour follows the Smi
|
|
|
95
95
|
|
|
96
96
|
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`.
|
|
97
97
|
|
|
98
|
+
`retry_mode="adaptive"` (or `AWS_RETRY_MODE=adaptive`, or `retry_mode = adaptive` in the AWS profile) also slows the whole client down once the service starts throttling it, then speeds back up as requests succeed. The default is `standard`.
|
|
99
|
+
|
|
98
100
|
```python
|
|
99
101
|
from capo_cloudcontrol import AsyncCloudControlClient
|
|
100
102
|
|
|
@@ -36,6 +36,7 @@ from capo_cloudcontrol._auth._sigv4 import (
|
|
|
36
36
|
_derive_signing_key,
|
|
37
37
|
_trim_header_value,
|
|
38
38
|
_uri_encode,
|
|
39
|
+
presign_sigv4,
|
|
39
40
|
sign_sigv4,
|
|
40
41
|
)
|
|
41
42
|
from capo_cloudcontrol._protocol.eventstream import Message, MessageDecoder, encode_headers
|
|
@@ -356,6 +357,38 @@ def test_s3_get_object_example():
|
|
|
356
357
|
# ---------------------------------------------------------------------------
|
|
357
358
|
|
|
358
359
|
|
|
360
|
+
def test_presign_signs_the_given_payload_hash():
|
|
361
|
+
"""An RDS IAM auth token signs the SHA-256 of an empty body, not
|
|
362
|
+
UNSIGNED-PAYLOAD. The vector is botocore's ``generate_db_auth_token`` for
|
|
363
|
+
the same host, user, region, credentials and clock."""
|
|
364
|
+
req = Request(
|
|
365
|
+
URL(
|
|
366
|
+
"https://db.abc.us-east-1.rds.amazonaws.com:5432/"
|
|
367
|
+
"?Action=connect&DBUser=app+user%40x"
|
|
368
|
+
),
|
|
369
|
+
"GET",
|
|
370
|
+
)
|
|
371
|
+
ctx: SigV4AuthContext = {
|
|
372
|
+
**_TEST_SUITE_CTX,
|
|
373
|
+
"signing_region": "eu-west-1",
|
|
374
|
+
"signing_name": "rds-db",
|
|
375
|
+
}
|
|
376
|
+
presigned = presign_sigv4(
|
|
377
|
+
req,
|
|
378
|
+
ctx,
|
|
379
|
+
expires_in=900,
|
|
380
|
+
now=dt.datetime(2026, 11, 21, 12, 0, tzinfo=dt.timezone.utc),
|
|
381
|
+
payload_hash=hashlib.sha256(b"").hexdigest(),
|
|
382
|
+
)
|
|
383
|
+
assert str(presigned.url) == (
|
|
384
|
+
"https://db.abc.us-east-1.rds.amazonaws.com:5432/?Action=connect"
|
|
385
|
+
"&DBUser=app%20user%40x&X-Amz-Algorithm=AWS4-HMAC-SHA256"
|
|
386
|
+
"&X-Amz-Credential=AKIDEXAMPLE%2F20261121%2Feu-west-1%2Frds-db%2Faws4_request"
|
|
387
|
+
"&X-Amz-Date=20261121T120000Z&X-Amz-Expires=900&X-Amz-SignedHeaders=host"
|
|
388
|
+
"&X-Amz-Signature=c949b1e47c86c7b6d7d8d2390316cd9c4c2f801a203e802b1bc961ebabefd08e"
|
|
389
|
+
)
|
|
390
|
+
|
|
391
|
+
|
|
359
392
|
def test_session_token_added_and_signed():
|
|
360
393
|
ctx: SigV4AuthContext = {**_TEST_SUITE_CTX, "session_token": "TOKEN123"}
|
|
361
394
|
req = _make_request(
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{capo_cloudcontrol-0.12.0 → capo_cloudcontrol-0.14.0}/src/capo_cloudcontrol/_auth/_identity.py
RENAMED
|
File without changes
|
{capo_cloudcontrol-0.12.0 → capo_cloudcontrol-0.14.0}/src/capo_cloudcontrol/_auth/_providers.py
RENAMED
|
File without changes
|
{capo_cloudcontrol-0.12.0 → capo_cloudcontrol-0.14.0}/src/capo_cloudcontrol/_auth/_signers.py
RENAMED
|
File without changes
|
{capo_cloudcontrol-0.12.0 → capo_cloudcontrol-0.14.0}/src/capo_cloudcontrol/_auth/_zapros_handler.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{capo_cloudcontrol-0.12.0 → capo_cloudcontrol-0.14.0}/src/capo_cloudcontrol/_protocol/__init__.py
RENAMED
|
File without changes
|
{capo_cloudcontrol-0.12.0 → capo_cloudcontrol-0.14.0}/src/capo_cloudcontrol/_protocol/errors.py
RENAMED
|
File without changes
|
{capo_cloudcontrol-0.12.0 → capo_cloudcontrol-0.14.0}/src/capo_cloudcontrol/_protocol/eventstream.py
RENAMED
|
File without changes
|
{capo_cloudcontrol-0.12.0 → capo_cloudcontrol-0.14.0}/src/capo_cloudcontrol/_protocol/serialize.py
RENAMED
|
File without changes
|
{capo_cloudcontrol-0.12.0 → capo_cloudcontrol-0.14.0}/src/capo_cloudcontrol/_protocol/xml.py
RENAMED
|
File without changes
|
{capo_cloudcontrol-0.12.0 → capo_cloudcontrol-0.14.0}/src/capo_cloudcontrol/_rule_engine/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{capo_cloudcontrol-0.12.0 → capo_cloudcontrol-0.14.0}/src/capo_cloudcontrol/errors/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{capo_cloudcontrol-0.12.0 → capo_cloudcontrol-0.14.0}/src/capo_cloudcontrol/types/_prelude/blob.py
RENAMED
|
File without changes
|
|
File without changes
|
{capo_cloudcontrol-0.12.0 → capo_cloudcontrol-0.14.0}/src/capo_cloudcontrol/types/_unknown.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{capo_cloudcontrol-0.12.0 → capo_cloudcontrol-0.14.0}/src/capo_cloudcontrol/types/client_token.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{capo_cloudcontrol-0.12.0 → capo_cloudcontrol-0.14.0}/src/capo_cloudcontrol/types/error_message.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{capo_cloudcontrol-0.12.0 → capo_cloudcontrol-0.14.0}/src/capo_cloudcontrol/types/hook_status.py
RENAMED
|
File without changes
|
{capo_cloudcontrol-0.12.0 → capo_cloudcontrol-0.14.0}/src/capo_cloudcontrol/types/hook_type_arn.py
RENAMED
|
File without changes
|
|
File without changes
|
{capo_cloudcontrol-0.12.0 → capo_cloudcontrol-0.14.0}/src/capo_cloudcontrol/types/identifier.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{capo_cloudcontrol-0.12.0 → capo_cloudcontrol-0.14.0}/src/capo_cloudcontrol/types/max_results.py
RENAMED
|
File without changes
|
{capo_cloudcontrol-0.12.0 → capo_cloudcontrol-0.14.0}/src/capo_cloudcontrol/types/next_token.py
RENAMED
|
File without changes
|
{capo_cloudcontrol-0.12.0 → capo_cloudcontrol-0.14.0}/src/capo_cloudcontrol/types/operation.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{capo_cloudcontrol-0.12.0 → capo_cloudcontrol-0.14.0}/src/capo_cloudcontrol/types/operations.py
RENAMED
|
File without changes
|
{capo_cloudcontrol-0.12.0 → capo_cloudcontrol-0.14.0}/src/capo_cloudcontrol/types/patch_document.py
RENAMED
|
File without changes
|
{capo_cloudcontrol-0.12.0 → capo_cloudcontrol-0.14.0}/src/capo_cloudcontrol/types/progress_event.py
RENAMED
|
File without changes
|
{capo_cloudcontrol-0.12.0 → capo_cloudcontrol-0.14.0}/src/capo_cloudcontrol/types/properties.py
RENAMED
|
File without changes
|
{capo_cloudcontrol-0.12.0 → capo_cloudcontrol-0.14.0}/src/capo_cloudcontrol/types/request_token.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{capo_cloudcontrol-0.12.0 → capo_cloudcontrol-0.14.0}/src/capo_cloudcontrol/types/role_arn.py
RENAMED
|
File without changes
|
{capo_cloudcontrol-0.12.0 → capo_cloudcontrol-0.14.0}/src/capo_cloudcontrol/types/status_message.py
RENAMED
|
File without changes
|
{capo_cloudcontrol-0.12.0 → capo_cloudcontrol-0.14.0}/src/capo_cloudcontrol/types/timestamp.py
RENAMED
|
File without changes
|
{capo_cloudcontrol-0.12.0 → capo_cloudcontrol-0.14.0}/src/capo_cloudcontrol/types/type_name.py
RENAMED
|
File without changes
|
{capo_cloudcontrol-0.12.0 → capo_cloudcontrol-0.14.0}/src/capo_cloudcontrol/types/type_version_id.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{capo_cloudcontrol-0.12.0 → capo_cloudcontrol-0.14.0}/src/capo_cloudcontrol.egg-info/SOURCES.txt
RENAMED
|
File without changes
|
|
File without changes
|
{capo_cloudcontrol-0.12.0 → capo_cloudcontrol-0.14.0}/src/capo_cloudcontrol.egg-info/requires.txt
RENAMED
|
File without changes
|
{capo_cloudcontrol-0.12.0 → capo_cloudcontrol-0.14.0}/src/capo_cloudcontrol.egg-info/top_level.txt
RENAMED
|
File without changes
|
|
File without changes
|