capo-elementalinference 0.1.0__tar.gz → 0.3.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_elementalinference-0.1.0/src/capo_elementalinference.egg-info → capo_elementalinference-0.3.0}/PKG-INFO +27 -9
- {capo_elementalinference-0.1.0 → capo_elementalinference-0.3.0}/README.md +22 -7
- {capo_elementalinference-0.1.0 → capo_elementalinference-0.3.0}/pyproject.toml +5 -2
- {capo_elementalinference-0.1.0 → capo_elementalinference-0.3.0}/src/capo_elementalinference/__init__.py +1 -0
- {capo_elementalinference-0.1.0 → capo_elementalinference-0.3.0}/src/capo_elementalinference/_auth/_signers.py +54 -17
- {capo_elementalinference-0.1.0 → capo_elementalinference-0.3.0}/src/capo_elementalinference/_auth/_sigv4.py +164 -19
- capo_elementalinference-0.3.0/src/capo_elementalinference/_body.py +221 -0
- {capo_elementalinference-0.1.0 → capo_elementalinference-0.3.0}/src/capo_elementalinference/_operations/elemental_inference/associate_feed.py +3 -2
- {capo_elementalinference-0.1.0 → capo_elementalinference-0.3.0}/src/capo_elementalinference/_operations/elemental_inference/create_dictionary.py +3 -2
- {capo_elementalinference-0.1.0 → capo_elementalinference-0.3.0}/src/capo_elementalinference/_operations/elemental_inference/create_feed.py +3 -2
- {capo_elementalinference-0.1.0 → capo_elementalinference-0.3.0}/src/capo_elementalinference/_operations/elemental_inference/delete_dictionary.py +3 -2
- {capo_elementalinference-0.1.0 → capo_elementalinference-0.3.0}/src/capo_elementalinference/_operations/elemental_inference/delete_feed.py +3 -2
- capo_elementalinference-0.3.0/src/capo_elementalinference/_operations/elemental_inference/delete_feed_policy.py +143 -0
- {capo_elementalinference-0.1.0 → capo_elementalinference-0.3.0}/src/capo_elementalinference/_operations/elemental_inference/disassociate_feed.py +3 -2
- {capo_elementalinference-0.1.0 → capo_elementalinference-0.3.0}/src/capo_elementalinference/_operations/elemental_inference/export_dictionary_entries.py +3 -2
- {capo_elementalinference-0.1.0 → capo_elementalinference-0.3.0}/src/capo_elementalinference/_operations/elemental_inference/get_dictionary.py +3 -2
- {capo_elementalinference-0.1.0 → capo_elementalinference-0.3.0}/src/capo_elementalinference/_operations/elemental_inference/get_feed.py +3 -2
- capo_elementalinference-0.3.0/src/capo_elementalinference/_operations/elemental_inference/get_feed_policy.py +168 -0
- capo_elementalinference-0.3.0/src/capo_elementalinference/_operations/elemental_inference/get_fixture.py +183 -0
- {capo_elementalinference-0.1.0 → capo_elementalinference-0.3.0}/src/capo_elementalinference/_operations/elemental_inference/list_dictionaries.py +3 -2
- {capo_elementalinference-0.1.0 → capo_elementalinference-0.3.0}/src/capo_elementalinference/_operations/elemental_inference/list_feeds.py +3 -2
- {capo_elementalinference-0.1.0 → capo_elementalinference-0.3.0}/src/capo_elementalinference/_operations/elemental_inference/list_tags_for_resource.py +3 -2
- capo_elementalinference-0.3.0/src/capo_elementalinference/_operations/elemental_inference/put_feed_policy.py +173 -0
- capo_elementalinference-0.3.0/src/capo_elementalinference/_operations/elemental_inference/search_fixtures.py +178 -0
- {capo_elementalinference-0.1.0 → capo_elementalinference-0.3.0}/src/capo_elementalinference/_operations/elemental_inference/tag_resource.py +3 -2
- {capo_elementalinference-0.1.0 → capo_elementalinference-0.3.0}/src/capo_elementalinference/_operations/elemental_inference/untag_resource.py +3 -2
- {capo_elementalinference-0.1.0 → capo_elementalinference-0.3.0}/src/capo_elementalinference/_operations/elemental_inference/update_dictionary.py +3 -2
- {capo_elementalinference-0.1.0 → capo_elementalinference-0.3.0}/src/capo_elementalinference/_operations/elemental_inference/update_feed.py +3 -2
- {capo_elementalinference-0.1.0 → capo_elementalinference-0.3.0}/src/capo_elementalinference/_protocol/eventstream.py +15 -13
- {capo_elementalinference-0.1.0 → capo_elementalinference-0.3.0}/src/capo_elementalinference/_resources/elemental_inference/feed_resource.py +320 -0
- {capo_elementalinference-0.1.0 → capo_elementalinference-0.3.0}/src/capo_elementalinference/_services/_pipeline.py +68 -2
- capo_elementalinference-0.3.0/src/capo_elementalinference/_services/async_elemental_inference.py +1406 -0
- capo_elementalinference-0.3.0/src/capo_elementalinference/_services/elemental_inference.py +1385 -0
- {capo_elementalinference-0.1.0 → capo_elementalinference-0.3.0}/src/capo_elementalinference/errors/__init__.py +6 -0
- capo_elementalinference-0.3.0/src/capo_elementalinference/errors/gateway_timed_out_exception.py +47 -0
- capo_elementalinference-0.3.0/src/capo_elementalinference/errors/service_unavailable_exception.py +47 -0
- capo_elementalinference-0.3.0/src/capo_elementalinference/types/clipping_config.py +51 -0
- capo_elementalinference-0.3.0/src/capo_elementalinference/types/competitor.py +29 -0
- capo_elementalinference-0.3.0/src/capo_elementalinference/types/competitor_list.py +29 -0
- capo_elementalinference-0.3.0/src/capo_elementalinference/types/contextual_metadata_config.py +42 -0
- {capo_elementalinference-0.1.0 → capo_elementalinference-0.3.0}/src/capo_elementalinference/types/create_feed_request.py +9 -0
- {capo_elementalinference-0.1.0 → capo_elementalinference-0.3.0}/src/capo_elementalinference/types/create_feed_response.py +9 -0
- capo_elementalinference-0.3.0/src/capo_elementalinference/types/cropping_config.py +42 -0
- capo_elementalinference-0.3.0/src/capo_elementalinference/types/data_source_configuration.py +31 -0
- capo_elementalinference-0.3.0/src/capo_elementalinference/types/data_source_sport.py +17 -0
- capo_elementalinference-0.3.0/src/capo_elementalinference/types/delete_feed_policy_request.py +24 -0
- capo_elementalinference-0.3.0/src/capo_elementalinference/types/filter_name.py +14 -0
- capo_elementalinference-0.3.0/src/capo_elementalinference/types/filter_value.py +5 -0
- capo_elementalinference-0.3.0/src/capo_elementalinference/types/filter_value_list.py +19 -0
- capo_elementalinference-0.3.0/src/capo_elementalinference/types/fixture_date.py +5 -0
- capo_elementalinference-0.3.0/src/capo_elementalinference/types/fixture_id.py +5 -0
- capo_elementalinference-0.3.0/src/capo_elementalinference/types/fixture_summary.py +87 -0
- capo_elementalinference-0.3.0/src/capo_elementalinference/types/fixture_summary_list.py +31 -0
- capo_elementalinference-0.3.0/src/capo_elementalinference/types/get_feed_policy_request.py +24 -0
- capo_elementalinference-0.3.0/src/capo_elementalinference/types/get_feed_policy_response.py +31 -0
- {capo_elementalinference-0.1.0 → capo_elementalinference-0.3.0}/src/capo_elementalinference/types/get_feed_response.py +9 -0
- capo_elementalinference-0.3.0/src/capo_elementalinference/types/get_fixture_request.py +24 -0
- capo_elementalinference-0.3.0/src/capo_elementalinference/types/get_fixture_response.py +87 -0
- capo_elementalinference-0.3.0/src/capo_elementalinference/types/iam_role_arn.py +5 -0
- {capo_elementalinference-0.1.0 → capo_elementalinference-0.3.0}/src/capo_elementalinference/types/output_config.py +25 -1
- capo_elementalinference-0.3.0/src/capo_elementalinference/types/policy_document.py +5 -0
- capo_elementalinference-0.3.0/src/capo_elementalinference/types/put_feed_policy_request.py +34 -0
- capo_elementalinference-0.3.0/src/capo_elementalinference/types/put_feed_policy_response.py +18 -0
- capo_elementalinference-0.3.0/src/capo_elementalinference/types/s3_uri.py +5 -0
- capo_elementalinference-0.3.0/src/capo_elementalinference/types/search_filter.py +57 -0
- capo_elementalinference-0.3.0/src/capo_elementalinference/types/search_filter_list.py +31 -0
- capo_elementalinference-0.3.0/src/capo_elementalinference/types/search_fixtures_request.py +86 -0
- capo_elementalinference-0.3.0/src/capo_elementalinference/types/search_fixtures_response.py +47 -0
- capo_elementalinference-0.3.0/src/capo_elementalinference/types/summary_generation_mode.py +17 -0
- capo_elementalinference-0.3.0/src/capo_elementalinference/types/template_group.py +51 -0
- capo_elementalinference-0.3.0/src/capo_elementalinference/types/template_group_list.py +31 -0
- capo_elementalinference-0.3.0/src/capo_elementalinference/types/template_uri_list.py +17 -0
- {capo_elementalinference-0.1.0 → capo_elementalinference-0.3.0}/src/capo_elementalinference/types/update_feed_request.py +10 -1
- {capo_elementalinference-0.1.0 → capo_elementalinference-0.3.0}/src/capo_elementalinference/types/update_feed_response.py +9 -0
- {capo_elementalinference-0.1.0 → capo_elementalinference-0.3.0/src/capo_elementalinference.egg-info}/PKG-INFO +27 -9
- {capo_elementalinference-0.1.0 → capo_elementalinference-0.3.0}/src/capo_elementalinference.egg-info/SOURCES.txt +39 -0
- {capo_elementalinference-0.1.0 → capo_elementalinference-0.3.0}/src/capo_elementalinference.egg-info/requires.txt +4 -0
- capo_elementalinference-0.3.0/tests/test_body.py +225 -0
- {capo_elementalinference-0.1.0 → capo_elementalinference-0.3.0}/tests/test_sigv4.py +217 -16
- capo_elementalinference-0.1.0/src/capo_elementalinference/_services/async_elemental_inference.py +0 -294
- capo_elementalinference-0.1.0/src/capo_elementalinference/_services/elemental_inference.py +0 -291
- capo_elementalinference-0.1.0/src/capo_elementalinference/types/clipping_config.py +0 -30
- capo_elementalinference-0.1.0/src/capo_elementalinference/types/cropping_config.py +0 -18
- {capo_elementalinference-0.1.0 → capo_elementalinference-0.3.0}/LICENSE +0 -0
- {capo_elementalinference-0.1.0 → capo_elementalinference-0.3.0}/setup.cfg +0 -0
- {capo_elementalinference-0.1.0 → capo_elementalinference-0.3.0}/src/capo_elementalinference/_async.py +0 -0
- {capo_elementalinference-0.1.0 → capo_elementalinference-0.3.0}/src/capo_elementalinference/_auth/_identity.py +0 -0
- {capo_elementalinference-0.1.0 → capo_elementalinference-0.3.0}/src/capo_elementalinference/_auth/_providers.py +0 -0
- {capo_elementalinference-0.1.0 → capo_elementalinference-0.3.0}/src/capo_elementalinference/_auth/_zapros_handler.py +0 -0
- {capo_elementalinference-0.1.0 → capo_elementalinference-0.3.0}/src/capo_elementalinference/_iter.py +0 -0
- {capo_elementalinference-0.1.0 → capo_elementalinference-0.3.0}/src/capo_elementalinference/_pagination.py +0 -0
- {capo_elementalinference-0.1.0 → capo_elementalinference-0.3.0}/src/capo_elementalinference/_protocol/__init__.py +0 -0
- {capo_elementalinference-0.1.0 → capo_elementalinference-0.3.0}/src/capo_elementalinference/_protocol/errors.py +0 -0
- {capo_elementalinference-0.1.0 → capo_elementalinference-0.3.0}/src/capo_elementalinference/_protocol/serialize.py +0 -0
- {capo_elementalinference-0.1.0 → capo_elementalinference-0.3.0}/src/capo_elementalinference/_protocol/xml.py +0 -0
- {capo_elementalinference-0.1.0 → capo_elementalinference-0.3.0}/src/capo_elementalinference/_resources/elemental_inference/dictionary_resource.py +0 -0
- {capo_elementalinference-0.1.0 → capo_elementalinference-0.3.0}/src/capo_elementalinference/_rule_engine/__init__.py +0 -0
- {capo_elementalinference-0.1.0 → capo_elementalinference-0.3.0}/src/capo_elementalinference/_rule_engine/_aws_partition.py +0 -0
- {capo_elementalinference-0.1.0 → capo_elementalinference-0.3.0}/src/capo_elementalinference/_rule_engine/_endpoint_rule_set.py +0 -0
- {capo_elementalinference-0.1.0 → capo_elementalinference-0.3.0}/src/capo_elementalinference/_rule_engine/_endpoint_runtime.py +0 -0
- {capo_elementalinference-0.1.0 → capo_elementalinference-0.3.0}/src/capo_elementalinference/_services/_aws_config.py +0 -0
- {capo_elementalinference-0.1.0 → capo_elementalinference-0.3.0}/src/capo_elementalinference/errors/_base.py +0 -0
- {capo_elementalinference-0.1.0 → capo_elementalinference-0.3.0}/src/capo_elementalinference/errors/access_denied_exception.py +0 -0
- {capo_elementalinference-0.1.0 → capo_elementalinference-0.3.0}/src/capo_elementalinference/errors/conflict_exception.py +0 -0
- {capo_elementalinference-0.1.0 → capo_elementalinference-0.3.0}/src/capo_elementalinference/errors/internal_server_error_exception.py +0 -0
- {capo_elementalinference-0.1.0 → capo_elementalinference-0.3.0}/src/capo_elementalinference/errors/resource_not_found_exception.py +0 -0
- {capo_elementalinference-0.1.0 → capo_elementalinference-0.3.0}/src/capo_elementalinference/errors/service_quota_exceeded_exception.py +0 -0
- {capo_elementalinference-0.1.0 → capo_elementalinference-0.3.0}/src/capo_elementalinference/errors/too_many_request_exception.py +0 -0
- {capo_elementalinference-0.1.0 → capo_elementalinference-0.3.0}/src/capo_elementalinference/errors/validation_exception.py +0 -0
- {capo_elementalinference-0.1.0 → capo_elementalinference-0.3.0}/src/capo_elementalinference/py.typed +0 -0
- {capo_elementalinference-0.1.0 → capo_elementalinference-0.3.0}/src/capo_elementalinference/types/_prelude/blob.py +0 -0
- {capo_elementalinference-0.1.0 → capo_elementalinference-0.3.0}/src/capo_elementalinference/types/_prelude/timestamp.py +0 -0
- {capo_elementalinference-0.1.0 → capo_elementalinference-0.3.0}/src/capo_elementalinference/types/aspect_ratio.py +0 -0
- {capo_elementalinference-0.1.0 → capo_elementalinference-0.3.0}/src/capo_elementalinference/types/associate_feed_request.py +0 -0
- {capo_elementalinference-0.1.0 → capo_elementalinference-0.3.0}/src/capo_elementalinference/types/associate_feed_response.py +0 -0
- {capo_elementalinference-0.1.0 → capo_elementalinference-0.3.0}/src/capo_elementalinference/types/associated_resource_name.py +0 -0
- {capo_elementalinference-0.1.0 → capo_elementalinference-0.3.0}/src/capo_elementalinference/types/create_dictionary_request.py +0 -0
- {capo_elementalinference-0.1.0 → capo_elementalinference-0.3.0}/src/capo_elementalinference/types/create_dictionary_response.py +0 -0
- {capo_elementalinference-0.1.0 → capo_elementalinference-0.3.0}/src/capo_elementalinference/types/create_output.py +0 -0
- {capo_elementalinference-0.1.0 → capo_elementalinference-0.3.0}/src/capo_elementalinference/types/create_output_list.py +0 -0
- {capo_elementalinference-0.1.0 → capo_elementalinference-0.3.0}/src/capo_elementalinference/types/delete_dictionary_request.py +0 -0
- {capo_elementalinference-0.1.0 → capo_elementalinference-0.3.0}/src/capo_elementalinference/types/delete_dictionary_response.py +0 -0
- {capo_elementalinference-0.1.0 → capo_elementalinference-0.3.0}/src/capo_elementalinference/types/delete_feed_request.py +0 -0
- {capo_elementalinference-0.1.0 → capo_elementalinference-0.3.0}/src/capo_elementalinference/types/delete_feed_response.py +0 -0
- {capo_elementalinference-0.1.0 → capo_elementalinference-0.3.0}/src/capo_elementalinference/types/dictionary_arn.py +0 -0
- {capo_elementalinference-0.1.0 → capo_elementalinference-0.3.0}/src/capo_elementalinference/types/dictionary_entries_payload.py +0 -0
- {capo_elementalinference-0.1.0 → capo_elementalinference-0.3.0}/src/capo_elementalinference/types/dictionary_id.py +0 -0
- {capo_elementalinference-0.1.0 → capo_elementalinference-0.3.0}/src/capo_elementalinference/types/dictionary_language.py +0 -0
- {capo_elementalinference-0.1.0 → capo_elementalinference-0.3.0}/src/capo_elementalinference/types/dictionary_status.py +0 -0
- {capo_elementalinference-0.1.0 → capo_elementalinference-0.3.0}/src/capo_elementalinference/types/dictionary_summary.py +0 -0
- {capo_elementalinference-0.1.0 → capo_elementalinference-0.3.0}/src/capo_elementalinference/types/dictionary_summary_list.py +0 -0
- {capo_elementalinference-0.1.0 → capo_elementalinference-0.3.0}/src/capo_elementalinference/types/disassociate_feed_request.py +0 -0
- {capo_elementalinference-0.1.0 → capo_elementalinference-0.3.0}/src/capo_elementalinference/types/disassociate_feed_response.py +0 -0
- {capo_elementalinference-0.1.0 → capo_elementalinference-0.3.0}/src/capo_elementalinference/types/export_dictionary_entries_request.py +0 -0
- {capo_elementalinference-0.1.0 → capo_elementalinference-0.3.0}/src/capo_elementalinference/types/export_dictionary_entries_response.py +0 -0
- {capo_elementalinference-0.1.0 → capo_elementalinference-0.3.0}/src/capo_elementalinference/types/feed_arn.py +0 -0
- {capo_elementalinference-0.1.0 → capo_elementalinference-0.3.0}/src/capo_elementalinference/types/feed_association.py +0 -0
- {capo_elementalinference-0.1.0 → capo_elementalinference-0.3.0}/src/capo_elementalinference/types/feed_id.py +0 -0
- {capo_elementalinference-0.1.0 → capo_elementalinference-0.3.0}/src/capo_elementalinference/types/feed_references.py +0 -0
- {capo_elementalinference-0.1.0 → capo_elementalinference-0.3.0}/src/capo_elementalinference/types/feed_status.py +0 -0
- {capo_elementalinference-0.1.0 → capo_elementalinference-0.3.0}/src/capo_elementalinference/types/feed_summary.py +0 -0
- {capo_elementalinference-0.1.0 → capo_elementalinference-0.3.0}/src/capo_elementalinference/types/feed_summary_list.py +0 -0
- {capo_elementalinference-0.1.0 → capo_elementalinference-0.3.0}/src/capo_elementalinference/types/get_dictionary_request.py +0 -0
- {capo_elementalinference-0.1.0 → capo_elementalinference-0.3.0}/src/capo_elementalinference/types/get_dictionary_response.py +0 -0
- {capo_elementalinference-0.1.0 → capo_elementalinference-0.3.0}/src/capo_elementalinference/types/get_feed_request.py +0 -0
- {capo_elementalinference-0.1.0 → capo_elementalinference-0.3.0}/src/capo_elementalinference/types/get_output.py +0 -0
- {capo_elementalinference-0.1.0 → capo_elementalinference-0.3.0}/src/capo_elementalinference/types/get_output_list.py +0 -0
- {capo_elementalinference-0.1.0 → capo_elementalinference-0.3.0}/src/capo_elementalinference/types/list_dictionaries_request.py +0 -0
- {capo_elementalinference-0.1.0 → capo_elementalinference-0.3.0}/src/capo_elementalinference/types/list_dictionaries_response.py +0 -0
- {capo_elementalinference-0.1.0 → capo_elementalinference-0.3.0}/src/capo_elementalinference/types/list_feeds_request.py +0 -0
- {capo_elementalinference-0.1.0 → capo_elementalinference-0.3.0}/src/capo_elementalinference/types/list_feeds_response.py +0 -0
- {capo_elementalinference-0.1.0 → capo_elementalinference-0.3.0}/src/capo_elementalinference/types/list_tags_for_resource_request.py +0 -0
- {capo_elementalinference-0.1.0 → capo_elementalinference-0.3.0}/src/capo_elementalinference/types/list_tags_for_resource_response.py +0 -0
- {capo_elementalinference-0.1.0 → capo_elementalinference-0.3.0}/src/capo_elementalinference/types/output_status.py +0 -0
- {capo_elementalinference-0.1.0 → capo_elementalinference-0.3.0}/src/capo_elementalinference/types/profanity_filter_mode.py +0 -0
- {capo_elementalinference-0.1.0 → capo_elementalinference-0.3.0}/src/capo_elementalinference/types/resource_arn.py +0 -0
- {capo_elementalinference-0.1.0 → capo_elementalinference-0.3.0}/src/capo_elementalinference/types/resource_description.py +0 -0
- {capo_elementalinference-0.1.0 → capo_elementalinference-0.3.0}/src/capo_elementalinference/types/resource_name.py +0 -0
- {capo_elementalinference-0.1.0 → capo_elementalinference-0.3.0}/src/capo_elementalinference/types/string_list.py +0 -0
- {capo_elementalinference-0.1.0 → capo_elementalinference-0.3.0}/src/capo_elementalinference/types/subtitling_config.py +0 -0
- {capo_elementalinference-0.1.0 → capo_elementalinference-0.3.0}/src/capo_elementalinference/types/tag_key.py +0 -0
- {capo_elementalinference-0.1.0 → capo_elementalinference-0.3.0}/src/capo_elementalinference/types/tag_key_list.py +0 -0
- {capo_elementalinference-0.1.0 → capo_elementalinference-0.3.0}/src/capo_elementalinference/types/tag_map.py +0 -0
- {capo_elementalinference-0.1.0 → capo_elementalinference-0.3.0}/src/capo_elementalinference/types/tag_resource_request.py +0 -0
- {capo_elementalinference-0.1.0 → capo_elementalinference-0.3.0}/src/capo_elementalinference/types/tag_value.py +0 -0
- {capo_elementalinference-0.1.0 → capo_elementalinference-0.3.0}/src/capo_elementalinference/types/transcription_language.py +0 -0
- {capo_elementalinference-0.1.0 → capo_elementalinference-0.3.0}/src/capo_elementalinference/types/untag_resource_request.py +0 -0
- {capo_elementalinference-0.1.0 → capo_elementalinference-0.3.0}/src/capo_elementalinference/types/update_dictionary_request.py +0 -0
- {capo_elementalinference-0.1.0 → capo_elementalinference-0.3.0}/src/capo_elementalinference/types/update_dictionary_response.py +0 -0
- {capo_elementalinference-0.1.0 → capo_elementalinference-0.3.0}/src/capo_elementalinference/types/update_output.py +0 -0
- {capo_elementalinference-0.1.0 → capo_elementalinference-0.3.0}/src/capo_elementalinference/types/update_output_list.py +0 -0
- {capo_elementalinference-0.1.0 → capo_elementalinference-0.3.0}/src/capo_elementalinference.egg-info/dependency_links.txt +0 -0
- {capo_elementalinference-0.1.0 → capo_elementalinference-0.3.0}/src/capo_elementalinference.egg-info/top_level.txt +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: capo-elementalinference
|
|
3
|
-
Version: 0.
|
|
4
|
-
Summary: Python SDK for Elementalinference.
|
|
3
|
+
Version: 0.3.0
|
|
4
|
+
Summary: Python SDK for AWS Elementalinference.
|
|
5
5
|
Classifier: Development Status :: 4 - Beta
|
|
6
6
|
Classifier: Intended Audience :: Developers
|
|
7
7
|
Classifier: License :: OSI Approved :: MIT License
|
|
@@ -17,7 +17,10 @@ Classifier: Typing :: Typed
|
|
|
17
17
|
Requires-Python: >=3.10
|
|
18
18
|
Description-Content-Type: text/markdown
|
|
19
19
|
License-File: LICENSE
|
|
20
|
+
Requires-Dist: jmespath>=1.0
|
|
20
21
|
Requires-Dist: zapros>=0.13.0
|
|
22
|
+
Provides-Extra: anyio
|
|
23
|
+
Requires-Dist: anyio>=3.0; extra == "anyio"
|
|
21
24
|
Provides-Extra: sso
|
|
22
25
|
Requires-Dist: capo-sso>=0.2.0; extra == "sso"
|
|
23
26
|
Requires-Dist: capo-sso-oidc>=0.2.0; extra == "sso"
|
|
@@ -40,9 +43,24 @@ from capo_elementalinference import AsyncElementalInferenceClient
|
|
|
40
43
|
|
|
41
44
|
async def main():
|
|
42
45
|
async with AsyncElementalInferenceClient() as elemental_inference:
|
|
43
|
-
# Example: call the
|
|
44
|
-
response = await elemental_inference.
|
|
45
|
-
print(response["
|
|
46
|
+
# Example: call the get_fixture operation
|
|
47
|
+
response = await elemental_inference.get_fixture()
|
|
48
|
+
print(response["fixture_id"])
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## Pagination
|
|
52
|
+
|
|
53
|
+
Some operations in this SDK support pagination. If the operation supports pagination it will have an `iter_` prefixed method that returns an async iterator.
|
|
54
|
+
|
|
55
|
+
```python
|
|
56
|
+
from capo_elementalinference import AsyncElementalInferenceClient
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
async def main():
|
|
60
|
+
async with AsyncElementalInferenceClient() as elemental_inference:
|
|
61
|
+
# Example: paginate over search_fixtures
|
|
62
|
+
async for item in elemental_inference.iter_search_fixtures():
|
|
63
|
+
print(item)
|
|
46
64
|
```
|
|
47
65
|
|
|
48
66
|
## Error Handling
|
|
@@ -57,7 +75,7 @@ from capo_elementalinference.error import AccessDeniedException
|
|
|
57
75
|
async def main():
|
|
58
76
|
async with AsyncElementalInferenceClient() as elemental_inference:
|
|
59
77
|
try:
|
|
60
|
-
await elemental_inference.
|
|
78
|
+
await elemental_inference.get_fixture()
|
|
61
79
|
except AccessDeniedException as e:
|
|
62
80
|
print(f"Error: {e}")
|
|
63
81
|
print(e.data) # additional error data
|
|
@@ -76,11 +94,11 @@ from capo_elementalinference import AsyncElementalInferenceClient
|
|
|
76
94
|
async def main():
|
|
77
95
|
async with AsyncElementalInferenceClient() as elemental_inference:
|
|
78
96
|
# Default: 3 attempts for every operation
|
|
79
|
-
response = await elemental_inference.
|
|
97
|
+
response = await elemental_inference.get_fixture()
|
|
80
98
|
|
|
81
99
|
# Override per operation
|
|
82
|
-
response = await elemental_inference.
|
|
100
|
+
response = await elemental_inference.get_fixture(config_overrides={"retry_max_attempts": 5})
|
|
83
101
|
|
|
84
102
|
# Disable retries for this call
|
|
85
|
-
response = await elemental_inference.
|
|
103
|
+
response = await elemental_inference.get_fixture(config_overrides={"retry_max_attempts": 1})
|
|
86
104
|
```
|
|
@@ -14,9 +14,24 @@ from capo_elementalinference import AsyncElementalInferenceClient
|
|
|
14
14
|
|
|
15
15
|
async def main():
|
|
16
16
|
async with AsyncElementalInferenceClient() as elemental_inference:
|
|
17
|
-
# Example: call the
|
|
18
|
-
response = await elemental_inference.
|
|
19
|
-
print(response["
|
|
17
|
+
# Example: call the get_fixture operation
|
|
18
|
+
response = await elemental_inference.get_fixture()
|
|
19
|
+
print(response["fixture_id"])
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Pagination
|
|
23
|
+
|
|
24
|
+
Some operations in this SDK support pagination. If the operation supports pagination it will have an `iter_` prefixed method that returns an async iterator.
|
|
25
|
+
|
|
26
|
+
```python
|
|
27
|
+
from capo_elementalinference import AsyncElementalInferenceClient
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
async def main():
|
|
31
|
+
async with AsyncElementalInferenceClient() as elemental_inference:
|
|
32
|
+
# Example: paginate over search_fixtures
|
|
33
|
+
async for item in elemental_inference.iter_search_fixtures():
|
|
34
|
+
print(item)
|
|
20
35
|
```
|
|
21
36
|
|
|
22
37
|
## Error Handling
|
|
@@ -31,7 +46,7 @@ from capo_elementalinference.error import AccessDeniedException
|
|
|
31
46
|
async def main():
|
|
32
47
|
async with AsyncElementalInferenceClient() as elemental_inference:
|
|
33
48
|
try:
|
|
34
|
-
await elemental_inference.
|
|
49
|
+
await elemental_inference.get_fixture()
|
|
35
50
|
except AccessDeniedException as e:
|
|
36
51
|
print(f"Error: {e}")
|
|
37
52
|
print(e.data) # additional error data
|
|
@@ -50,11 +65,11 @@ from capo_elementalinference import AsyncElementalInferenceClient
|
|
|
50
65
|
async def main():
|
|
51
66
|
async with AsyncElementalInferenceClient() as elemental_inference:
|
|
52
67
|
# Default: 3 attempts for every operation
|
|
53
|
-
response = await elemental_inference.
|
|
68
|
+
response = await elemental_inference.get_fixture()
|
|
54
69
|
|
|
55
70
|
# Override per operation
|
|
56
|
-
response = await elemental_inference.
|
|
71
|
+
response = await elemental_inference.get_fixture(config_overrides={"retry_max_attempts": 5})
|
|
57
72
|
|
|
58
73
|
# Disable retries for this call
|
|
59
|
-
response = await elemental_inference.
|
|
74
|
+
response = await elemental_inference.get_fixture(config_overrides={"retry_max_attempts": 1})
|
|
60
75
|
```
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "capo-elementalinference"
|
|
3
|
-
version = "0.
|
|
4
|
-
description = "Python SDK for Elementalinference."
|
|
3
|
+
version = "0.3.0"
|
|
4
|
+
description = "Python SDK for AWS Elementalinference."
|
|
5
5
|
readme = "README.md"
|
|
6
6
|
requires-python = ">=3.10"
|
|
7
7
|
classifiers = [
|
|
@@ -19,10 +19,13 @@ classifiers = [
|
|
|
19
19
|
"Typing :: Typed",
|
|
20
20
|
]
|
|
21
21
|
dependencies = [
|
|
22
|
+
"jmespath>=1.0",
|
|
22
23
|
"zapros>=0.13.0",
|
|
23
24
|
]
|
|
24
25
|
|
|
25
26
|
[project.optional-dependencies]
|
|
27
|
+
# Async file request bodies via Body.async_from_path
|
|
28
|
+
anyio = ["anyio>=3.0"]
|
|
26
29
|
# IAM Identity Center (SSO), assume-role and web-identity credentials providers
|
|
27
30
|
sso = [
|
|
28
31
|
"capo-sso>=0.2.0",
|
|
@@ -48,6 +48,7 @@ from ._auth._providers import (
|
|
|
48
48
|
)
|
|
49
49
|
from ._auth._signers import Signer as Signer
|
|
50
50
|
from ._auth._signers import SigV4Signer as SigV4Signer
|
|
51
|
+
from ._body import Body as Body
|
|
51
52
|
from ._services._pipeline import (
|
|
52
53
|
AsyncOperationOptions as AsyncOperationOptions,
|
|
53
54
|
)
|
|
@@ -7,7 +7,11 @@ from zapros import Request
|
|
|
7
7
|
|
|
8
8
|
from capo_elementalinference._auth._identity import Credentials, Identity
|
|
9
9
|
from capo_elementalinference._auth._providers import IdentityProvider
|
|
10
|
-
from capo_elementalinference._auth._sigv4 import
|
|
10
|
+
from capo_elementalinference._auth._sigv4 import (
|
|
11
|
+
S3_SIGNING_NAMES,
|
|
12
|
+
SigV4AuthContext,
|
|
13
|
+
sign_sigv4,
|
|
14
|
+
)
|
|
11
15
|
|
|
12
16
|
IdentityT = TypeVar("IdentityT", bound="Identity")
|
|
13
17
|
|
|
@@ -30,14 +34,25 @@ class SigV4Signer(Signer[Credentials]):
|
|
|
30
34
|
The full auth scheme (``name`` variant, ``signingName``, ``signingRegion``,
|
|
31
35
|
encoding/normalization flags) is provided by the caller — either from the
|
|
32
36
|
endpoint rule-set's ``authSchemes`` property or built by the generated
|
|
33
|
-
``get_signer`` from operation defaults.
|
|
37
|
+
``get_signer`` from operation defaults. ``unsigned_payload`` mirrors the
|
|
38
|
+
operation's ``aws.auth#unsignedPayload`` trait: the body is sent but left
|
|
39
|
+
out of the signature. ``event_stream`` marks a request event stream: the
|
|
40
|
+
request is signed with the ``STREAMING-AWS4-HMAC-SHA256-EVENTS`` payload
|
|
41
|
+
marker and every event with a signature chained from it.
|
|
34
42
|
"""
|
|
35
43
|
|
|
36
44
|
def __init__(
|
|
37
|
-
self,
|
|
45
|
+
self,
|
|
46
|
+
provider: IdentityProvider[Credentials],
|
|
47
|
+
*,
|
|
48
|
+
auth_scheme: dict[str, Any],
|
|
49
|
+
unsigned_payload: bool = False,
|
|
50
|
+
event_stream: bool = False,
|
|
38
51
|
) -> None:
|
|
39
52
|
super().__init__(provider)
|
|
40
53
|
self._auth_scheme = auth_scheme
|
|
54
|
+
self._unsigned_payload = unsigned_payload
|
|
55
|
+
self._event_stream = event_stream
|
|
41
56
|
|
|
42
57
|
async def asign(self, req: Request) -> Request:
|
|
43
58
|
creds = await self.provider.aresolve_identity()
|
|
@@ -55,13 +70,24 @@ class SigV4Signer(Signer[Credentials]):
|
|
|
55
70
|
"disableNormalizePath", False
|
|
56
71
|
),
|
|
57
72
|
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
body
|
|
64
|
-
|
|
73
|
+
unsigned_payload = self._unsigned_payload
|
|
74
|
+
if (
|
|
75
|
+
not unsigned_payload
|
|
76
|
+
and not self._event_stream
|
|
77
|
+
and req.body is not None
|
|
78
|
+
and not isinstance(req.body, bytes)
|
|
79
|
+
):
|
|
80
|
+
if self._auth_scheme["signingName"] in S3_SIGNING_NAMES:
|
|
81
|
+
# S3 accepts UNSIGNED-PAYLOAD for any operation; streamed bodies rely on it.
|
|
82
|
+
unsigned_payload = True
|
|
83
|
+
else:
|
|
84
|
+
raise NotImplementedError(
|
|
85
|
+
"Currently we don't support signed chunked payloads, so buffer the body and "
|
|
86
|
+
"pass bytes as a workaround; chunked signed implementation coming soon"
|
|
87
|
+
)
|
|
88
|
+
return sign_sigv4(
|
|
89
|
+
req, ctx, unsigned_payload=unsigned_payload, event_stream=self._event_stream
|
|
90
|
+
)
|
|
65
91
|
|
|
66
92
|
def sign(self, req: Request) -> Request:
|
|
67
93
|
creds = self.provider.resolve_identity()
|
|
@@ -79,10 +105,21 @@ class SigV4Signer(Signer[Credentials]):
|
|
|
79
105
|
"disableNormalizePath", False
|
|
80
106
|
),
|
|
81
107
|
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
body
|
|
88
|
-
|
|
108
|
+
unsigned_payload = self._unsigned_payload
|
|
109
|
+
if (
|
|
110
|
+
not unsigned_payload
|
|
111
|
+
and not self._event_stream
|
|
112
|
+
and req.body is not None
|
|
113
|
+
and not isinstance(req.body, bytes)
|
|
114
|
+
):
|
|
115
|
+
if self._auth_scheme["signingName"] in S3_SIGNING_NAMES:
|
|
116
|
+
# S3 accepts UNSIGNED-PAYLOAD for any operation; streamed bodies rely on it.
|
|
117
|
+
unsigned_payload = True
|
|
118
|
+
else:
|
|
119
|
+
raise NotImplementedError(
|
|
120
|
+
"Currently we don't support signed chunked payloads, so buffer the body and "
|
|
121
|
+
"pass bytes as a workaround; chunked signed implementation coming soon"
|
|
122
|
+
)
|
|
123
|
+
return sign_sigv4(
|
|
124
|
+
req, ctx, unsigned_payload=unsigned_payload, event_stream=self._event_stream
|
|
125
|
+
)
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"""AWS Signature Version 4 — single-chunk signing.
|
|
1
|
+
"""AWS Signature Version 4 — single-chunk and event-stream signing.
|
|
2
2
|
|
|
3
3
|
Reference:
|
|
4
4
|
https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_sigv-create-signed-request.html
|
|
@@ -15,7 +15,8 @@ import functools
|
|
|
15
15
|
import hashlib
|
|
16
16
|
import hmac
|
|
17
17
|
import re
|
|
18
|
-
from
|
|
18
|
+
from collections.abc import AsyncIterator, Iterator
|
|
19
|
+
from typing import Any, Literal, TypedDict, cast
|
|
19
20
|
from urllib.parse import quote, unquote
|
|
20
21
|
|
|
21
22
|
import zapros
|
|
@@ -23,6 +24,9 @@ from pywhatwgurl import URLSearchParams
|
|
|
23
24
|
from zapros import Headers, Request
|
|
24
25
|
from zapros._utils import get_host_header_value
|
|
25
26
|
|
|
27
|
+
from .._iter import AnyIterator
|
|
28
|
+
from .._protocol.eventstream import HeaderValue, Message, encode_headers
|
|
29
|
+
|
|
26
30
|
|
|
27
31
|
def build_sigv4_auth_scheme(
|
|
28
32
|
signing_name: str, region: str | None, endpoint_scheme: dict[str, Any] | None = None
|
|
@@ -65,6 +69,10 @@ class SigV4AuthContext(TypedDict):
|
|
|
65
69
|
|
|
66
70
|
|
|
67
71
|
_SIGV4_ALGORITHM = "AWS4-HMAC-SHA256"
|
|
72
|
+
# Per-event algorithm and request payload marker of a signed event stream.
|
|
73
|
+
_EVENT_ALGORITHM = "AWS4-HMAC-SHA256-PAYLOAD"
|
|
74
|
+
_EVENT_STREAM_PAYLOAD = "STREAMING-AWS4-HMAC-SHA256-EVENTS"
|
|
75
|
+
_AMZ_DATE_FORMAT = "%Y%m%dT%H%M%SZ"
|
|
68
76
|
_EMPTY_PAYLOAD_SHA256 = hashlib.sha256(b"").hexdigest()
|
|
69
77
|
|
|
70
78
|
# Headers excluded from the signed-headers set. Mirrors botocore's denylist:
|
|
@@ -95,9 +103,11 @@ _UNSIGNED_HEADERS = frozenset(
|
|
|
95
103
|
|
|
96
104
|
_MULTI_SPACE = re.compile(r" +")
|
|
97
105
|
|
|
98
|
-
# Services that require the payload hash to travel in ``x-amz-content-sha256
|
|
99
|
-
#
|
|
100
|
-
|
|
106
|
+
# Services that require the payload hash to travel in ``x-amz-content-sha256``
|
|
107
|
+
# on every request, and that accept ``UNSIGNED-PAYLOAD`` for any operation.
|
|
108
|
+
# Other services sign the hash into the canonical request without sending it,
|
|
109
|
+
# and only see the header when the payload is left unsigned.
|
|
110
|
+
S3_SIGNING_NAMES = frozenset({"s3", "s3express", "s3-outposts", "s3-object-lambda"})
|
|
101
111
|
|
|
102
112
|
|
|
103
113
|
def _uri_encode(value: str) -> str:
|
|
@@ -231,12 +241,20 @@ def _canonical_query_from_pairs(pairs: list[tuple[str, str]]) -> str:
|
|
|
231
241
|
def sign_sigv4(
|
|
232
242
|
request: Request,
|
|
233
243
|
ctx: SigV4AuthContext,
|
|
234
|
-
|
|
244
|
+
*,
|
|
245
|
+
unsigned_payload: bool = False,
|
|
246
|
+
event_stream: bool = False,
|
|
235
247
|
) -> Request:
|
|
236
248
|
"""Return a new ``Request`` carrying SigV4 single-chunk auth headers.
|
|
237
249
|
|
|
238
|
-
|
|
239
|
-
|
|
250
|
+
The payload hash covers ``request.body``, which must be ``bytes`` or
|
|
251
|
+
``None``. ``unsigned_payload`` signs ``UNSIGNED-PAYLOAD`` instead and
|
|
252
|
+
forwards any body unchanged (streaming S3 requests and operations carrying
|
|
253
|
+
``aws.auth#unsignedPayload``). ``event_stream`` signs a request event
|
|
254
|
+
stream: the ``STREAMING-AWS4-HMAC-SHA256-EVENTS`` marker stands in for the
|
|
255
|
+
payload hash and the body — an iterator of encoded event messages — is
|
|
256
|
+
wrapped in an :class:`EventStreamIterator` that signs every event with a
|
|
257
|
+
signature chained from this request's.
|
|
240
258
|
"""
|
|
241
259
|
service = ctx["signing_name"]
|
|
242
260
|
region = ctx["signing_region"]
|
|
@@ -250,21 +268,31 @@ def sign_sigv4(
|
|
|
250
268
|
date_stamp = amz_date[:8]
|
|
251
269
|
else:
|
|
252
270
|
now = _amz_now()
|
|
253
|
-
amz_date = now.strftime(
|
|
271
|
+
amz_date = now.strftime(_AMZ_DATE_FORMAT)
|
|
254
272
|
date_stamp = now.strftime("%Y%m%d")
|
|
255
273
|
headers["X-Amz-Date"] = amz_date
|
|
256
274
|
|
|
257
|
-
# Payload hash. For S3-family services, x-amz-content-sha256 is mandatory
|
|
258
|
-
#
|
|
275
|
+
# Payload hash. For S3-family services, x-amz-content-sha256 is mandatory;
|
|
276
|
+
# for every service it is the only way to announce an unsigned payload or
|
|
277
|
+
# an event stream.
|
|
278
|
+
# Either way it must be set BEFORE computing the canonical request (it
|
|
279
|
+
# gets signed).
|
|
259
280
|
payload_hash = headers.get("X-Amz-Content-SHA256")
|
|
260
281
|
if payload_hash is None:
|
|
261
|
-
if
|
|
282
|
+
if event_stream:
|
|
283
|
+
payload_hash = _EVENT_STREAM_PAYLOAD
|
|
284
|
+
elif unsigned_payload:
|
|
262
285
|
payload_hash = "UNSIGNED-PAYLOAD"
|
|
286
|
+
elif request.body is None:
|
|
287
|
+
payload_hash = _EMPTY_PAYLOAD_SHA256
|
|
288
|
+
elif isinstance(request.body, bytes):
|
|
289
|
+
payload_hash = hashlib.sha256(request.body).hexdigest()
|
|
263
290
|
else:
|
|
264
|
-
|
|
265
|
-
|
|
291
|
+
raise TypeError(
|
|
292
|
+
"sign_sigv4 hashes a bytes body only; pass unsigned_payload=True "
|
|
293
|
+
"to send a streamed body without a payload hash"
|
|
266
294
|
)
|
|
267
|
-
if service in
|
|
295
|
+
if service in S3_SIGNING_NAMES or unsigned_payload or event_stream:
|
|
268
296
|
headers["X-Amz-Content-SHA256"] = payload_hash
|
|
269
297
|
|
|
270
298
|
# Session token (STS / assumed-role credentials).
|
|
@@ -308,18 +336,135 @@ def sign_sigv4(
|
|
|
308
336
|
f"Signature={signature}"
|
|
309
337
|
)
|
|
310
338
|
|
|
311
|
-
|
|
312
|
-
if
|
|
339
|
+
body = request.body
|
|
340
|
+
if event_stream:
|
|
341
|
+
if not isinstance(body, (Iterator, AsyncIterator)):
|
|
342
|
+
raise TypeError(
|
|
343
|
+
"event_stream requires an iterator of encoded events as the body"
|
|
344
|
+
)
|
|
345
|
+
body = EventStreamIterator(
|
|
346
|
+
cast("Iterator[bytes] | AsyncIterator[bytes]", body), ctx, signature
|
|
347
|
+
)
|
|
348
|
+
if body is not None:
|
|
313
349
|
return Request(
|
|
314
350
|
request.url,
|
|
315
351
|
request.method,
|
|
316
352
|
headers,
|
|
317
|
-
body=
|
|
353
|
+
body=body,
|
|
318
354
|
context=request.context,
|
|
319
355
|
)
|
|
320
356
|
return Request(request.url, request.method, headers, context=request.context)
|
|
321
357
|
|
|
322
358
|
|
|
359
|
+
def _sign_event(
|
|
360
|
+
ctx: SigV4AuthContext, prior_signature: str, payload: bytes
|
|
361
|
+
) -> tuple[bytes, str]:
|
|
362
|
+
"""Wrap one encoded event in a signed outer message.
|
|
363
|
+
|
|
364
|
+
Returns ``(frame, signature)``; the hex signature seeds the next event.
|
|
365
|
+
The string to sign chains every frame to its predecessor — the first one
|
|
366
|
+
to the request's ``Authorization`` signature — so the service can verify
|
|
367
|
+
the stream incrementally::
|
|
368
|
+
|
|
369
|
+
AWS4-HMAC-SHA256-PAYLOAD
|
|
370
|
+
<date, YYYYMMDDTHHMMSSZ>
|
|
371
|
+
<credential scope>
|
|
372
|
+
<prior signature, hex>
|
|
373
|
+
<hex sha256 of the encoded ``:date`` header>
|
|
374
|
+
<hex sha256 of the payload>
|
|
375
|
+
|
|
376
|
+
The AWS SDKs (and the service) use the ``-PAYLOAD`` algorithm name; the
|
|
377
|
+
Transcribe developer guide's pseudocode omits the suffix.
|
|
378
|
+
"""
|
|
379
|
+
service = ctx["signing_name"]
|
|
380
|
+
region = ctx["signing_region"]
|
|
381
|
+
now = _amz_now()
|
|
382
|
+
amz_date = now.strftime(_AMZ_DATE_FORMAT)
|
|
383
|
+
date_stamp = amz_date[:8]
|
|
384
|
+
credential_scope = f"{date_stamp}/{region}/{service}/aws4_request"
|
|
385
|
+
date_header: dict[str, HeaderValue] = {":date": now}
|
|
386
|
+
string_to_sign = "\n".join(
|
|
387
|
+
(
|
|
388
|
+
_EVENT_ALGORITHM,
|
|
389
|
+
amz_date,
|
|
390
|
+
credential_scope,
|
|
391
|
+
prior_signature,
|
|
392
|
+
hashlib.sha256(encode_headers(date_header)).hexdigest(),
|
|
393
|
+
hashlib.sha256(payload).hexdigest(),
|
|
394
|
+
)
|
|
395
|
+
)
|
|
396
|
+
signing_key = _derive_signing_key(
|
|
397
|
+
ctx["secret_access_key"], date_stamp, region, service
|
|
398
|
+
)
|
|
399
|
+
signature = hmac.new(
|
|
400
|
+
signing_key, string_to_sign.encode("utf-8"), hashlib.sha256
|
|
401
|
+
).hexdigest()
|
|
402
|
+
frame = Message(
|
|
403
|
+
{**date_header, ":chunk-signature": bytes.fromhex(signature)}, payload
|
|
404
|
+
).encode()
|
|
405
|
+
return frame, signature
|
|
406
|
+
|
|
407
|
+
|
|
408
|
+
class EventStreamIterator(AnyIterator[bytes]):
|
|
409
|
+
"""Sign a request event stream, one frame per event.
|
|
410
|
+
|
|
411
|
+
Wraps an iterator of encoded event messages (as produced by the generated
|
|
412
|
+
``serialize_event_*`` functions). Each event becomes the payload of an
|
|
413
|
+
outer message carrying ``:date`` and ``:chunk-signature`` headers, the
|
|
414
|
+
signature chained from the previous frame's and seeded by the request's
|
|
415
|
+
``Authorization`` signature. Once the events are exhausted, one empty
|
|
416
|
+
signed frame is yielded to mark the end of the stream.
|
|
417
|
+
|
|
418
|
+
Like :class:`~capo._body.Body`, it is both a sync and an async iterator:
|
|
419
|
+
iterate it the way the wrapped source is iterable (``next`` over a sync
|
|
420
|
+
source, ``async for`` over an async one).
|
|
421
|
+
|
|
422
|
+
Reference:
|
|
423
|
+
https://docs.aws.amazon.com/transcribe/latest/dg/streaming-setting-up.html
|
|
424
|
+
"""
|
|
425
|
+
|
|
426
|
+
def __init__(
|
|
427
|
+
self,
|
|
428
|
+
events: Iterator[bytes] | AsyncIterator[bytes],
|
|
429
|
+
ctx: SigV4AuthContext,
|
|
430
|
+
seed_signature: str,
|
|
431
|
+
) -> None:
|
|
432
|
+
self._events = events
|
|
433
|
+
self._ctx = ctx
|
|
434
|
+
self._prior_signature = seed_signature
|
|
435
|
+
self._ended = False
|
|
436
|
+
|
|
437
|
+
def _frame(self, payload: bytes) -> bytes:
|
|
438
|
+
frame, self._prior_signature = _sign_event(
|
|
439
|
+
self._ctx, self._prior_signature, payload
|
|
440
|
+
)
|
|
441
|
+
return frame
|
|
442
|
+
|
|
443
|
+
def __next__(self) -> bytes:
|
|
444
|
+
if self._ended:
|
|
445
|
+
raise StopIteration
|
|
446
|
+
if not isinstance(self._events, Iterator):
|
|
447
|
+
raise TypeError("this event stream wraps an async source; use `async for`")
|
|
448
|
+
try:
|
|
449
|
+
payload = next(cast(Iterator[bytes], self._events))
|
|
450
|
+
except StopIteration:
|
|
451
|
+
self._ended = True
|
|
452
|
+
payload = b""
|
|
453
|
+
return self._frame(payload)
|
|
454
|
+
|
|
455
|
+
async def __anext__(self) -> bytes:
|
|
456
|
+
if self._ended:
|
|
457
|
+
raise StopAsyncIteration
|
|
458
|
+
if not isinstance(self._events, AsyncIterator):
|
|
459
|
+
raise TypeError("this event stream wraps a sync source; use `for`")
|
|
460
|
+
try:
|
|
461
|
+
payload = await cast(AsyncIterator[bytes], self._events).__anext__()
|
|
462
|
+
except StopAsyncIteration:
|
|
463
|
+
self._ended = True
|
|
464
|
+
payload = b""
|
|
465
|
+
return self._frame(payload)
|
|
466
|
+
|
|
467
|
+
|
|
323
468
|
def presign_sigv4(
|
|
324
469
|
request: Request,
|
|
325
470
|
ctx: SigV4AuthContext,
|
|
@@ -346,7 +491,7 @@ def presign_sigv4(
|
|
|
346
491
|
service = ctx["signing_name"]
|
|
347
492
|
region = ctx["signing_region"]
|
|
348
493
|
|
|
349
|
-
amz_date = sign_time.strftime(
|
|
494
|
+
amz_date = sign_time.strftime(_AMZ_DATE_FORMAT)
|
|
350
495
|
date_stamp = sign_time.strftime("%Y%m%d")
|
|
351
496
|
credential_scope = f"{date_stamp}/{region}/{service}/aws4_request"
|
|
352
497
|
|