airbyte-cdk 0.0.0.dev0__py3-none-any.whl
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.
- airbyte_cdk/__init__.py +358 -0
- airbyte_cdk/cli/__init__.py +1 -0
- airbyte_cdk/cli/source_declarative_manifest/__init__.py +5 -0
- airbyte_cdk/cli/source_declarative_manifest/_run.py +236 -0
- airbyte_cdk/cli/source_declarative_manifest/spec.json +17 -0
- airbyte_cdk/config_observation.py +104 -0
- airbyte_cdk/connector.py +123 -0
- airbyte_cdk/connector_builder/README.md +53 -0
- airbyte_cdk/connector_builder/__init__.py +3 -0
- airbyte_cdk/connector_builder/connector_builder_handler.py +121 -0
- airbyte_cdk/connector_builder/main.py +107 -0
- airbyte_cdk/connector_builder/models.py +73 -0
- airbyte_cdk/connector_builder/test_reader/__init__.py +7 -0
- airbyte_cdk/connector_builder/test_reader/helpers.py +689 -0
- airbyte_cdk/connector_builder/test_reader/message_grouper.py +173 -0
- airbyte_cdk/connector_builder/test_reader/reader.py +441 -0
- airbyte_cdk/connector_builder/test_reader/types.py +83 -0
- airbyte_cdk/destinations/__init__.py +8 -0
- airbyte_cdk/destinations/destination.py +154 -0
- airbyte_cdk/destinations/vector_db_based/README.md +37 -0
- airbyte_cdk/destinations/vector_db_based/__init__.py +38 -0
- airbyte_cdk/destinations/vector_db_based/config.py +298 -0
- airbyte_cdk/destinations/vector_db_based/document_processor.py +223 -0
- airbyte_cdk/destinations/vector_db_based/embedder.py +303 -0
- airbyte_cdk/destinations/vector_db_based/indexer.py +78 -0
- airbyte_cdk/destinations/vector_db_based/test_utils.py +63 -0
- airbyte_cdk/destinations/vector_db_based/utils.py +35 -0
- airbyte_cdk/destinations/vector_db_based/writer.py +104 -0
- airbyte_cdk/entrypoint.py +414 -0
- airbyte_cdk/exception_handler.py +56 -0
- airbyte_cdk/logger.py +109 -0
- airbyte_cdk/models/__init__.py +72 -0
- airbyte_cdk/models/airbyte_protocol.py +88 -0
- airbyte_cdk/models/airbyte_protocol_serializers.py +44 -0
- airbyte_cdk/models/well_known_types.py +5 -0
- airbyte_cdk/py.typed +0 -0
- airbyte_cdk/sources/__init__.py +26 -0
- airbyte_cdk/sources/abstract_source.py +326 -0
- airbyte_cdk/sources/concurrent_source/__init__.py +8 -0
- airbyte_cdk/sources/concurrent_source/concurrent_read_processor.py +255 -0
- airbyte_cdk/sources/concurrent_source/concurrent_source.py +165 -0
- airbyte_cdk/sources/concurrent_source/concurrent_source_adapter.py +147 -0
- airbyte_cdk/sources/concurrent_source/partition_generation_completed_sentinel.py +24 -0
- airbyte_cdk/sources/concurrent_source/stream_thread_exception.py +25 -0
- airbyte_cdk/sources/concurrent_source/thread_pool_manager.py +115 -0
- airbyte_cdk/sources/config.py +27 -0
- airbyte_cdk/sources/connector_state_manager.py +161 -0
- airbyte_cdk/sources/declarative/__init__.py +3 -0
- airbyte_cdk/sources/declarative/async_job/__init__.py +0 -0
- airbyte_cdk/sources/declarative/async_job/job.py +52 -0
- airbyte_cdk/sources/declarative/async_job/job_orchestrator.py +525 -0
- airbyte_cdk/sources/declarative/async_job/job_tracker.py +79 -0
- airbyte_cdk/sources/declarative/async_job/repository.py +35 -0
- airbyte_cdk/sources/declarative/async_job/status.py +24 -0
- airbyte_cdk/sources/declarative/async_job/timer.py +39 -0
- airbyte_cdk/sources/declarative/auth/__init__.py +8 -0
- airbyte_cdk/sources/declarative/auth/declarative_authenticator.py +42 -0
- airbyte_cdk/sources/declarative/auth/jwt.py +197 -0
- airbyte_cdk/sources/declarative/auth/oauth.py +293 -0
- airbyte_cdk/sources/declarative/auth/selective_authenticator.py +45 -0
- airbyte_cdk/sources/declarative/auth/token.py +267 -0
- airbyte_cdk/sources/declarative/auth/token_provider.py +82 -0
- airbyte_cdk/sources/declarative/checks/__init__.py +24 -0
- airbyte_cdk/sources/declarative/checks/check_dynamic_stream.py +61 -0
- airbyte_cdk/sources/declarative/checks/check_stream.py +56 -0
- airbyte_cdk/sources/declarative/checks/connection_checker.py +35 -0
- airbyte_cdk/sources/declarative/concurrency_level/__init__.py +7 -0
- airbyte_cdk/sources/declarative/concurrency_level/concurrency_level.py +50 -0
- airbyte_cdk/sources/declarative/concurrent_declarative_source.py +526 -0
- airbyte_cdk/sources/declarative/datetime/__init__.py +3 -0
- airbyte_cdk/sources/declarative/datetime/datetime_parser.py +65 -0
- airbyte_cdk/sources/declarative/datetime/min_max_datetime.py +118 -0
- airbyte_cdk/sources/declarative/declarative_component_schema.yaml +3975 -0
- airbyte_cdk/sources/declarative/declarative_source.py +36 -0
- airbyte_cdk/sources/declarative/declarative_stream.py +241 -0
- airbyte_cdk/sources/declarative/decoders/__init__.py +33 -0
- airbyte_cdk/sources/declarative/decoders/composite_raw_decoder.py +218 -0
- airbyte_cdk/sources/declarative/decoders/decoder.py +32 -0
- airbyte_cdk/sources/declarative/decoders/decoder_parser.py +30 -0
- airbyte_cdk/sources/declarative/decoders/json_decoder.py +65 -0
- airbyte_cdk/sources/declarative/decoders/noop_decoder.py +21 -0
- airbyte_cdk/sources/declarative/decoders/pagination_decoder_decorator.py +39 -0
- airbyte_cdk/sources/declarative/decoders/xml_decoder.py +98 -0
- airbyte_cdk/sources/declarative/decoders/zipfile_decoder.py +56 -0
- airbyte_cdk/sources/declarative/exceptions.py +9 -0
- airbyte_cdk/sources/declarative/extractors/__init__.py +21 -0
- airbyte_cdk/sources/declarative/extractors/dpath_extractor.py +86 -0
- airbyte_cdk/sources/declarative/extractors/http_selector.py +37 -0
- airbyte_cdk/sources/declarative/extractors/record_extractor.py +27 -0
- airbyte_cdk/sources/declarative/extractors/record_filter.py +91 -0
- airbyte_cdk/sources/declarative/extractors/record_selector.py +170 -0
- airbyte_cdk/sources/declarative/extractors/response_to_file_extractor.py +176 -0
- airbyte_cdk/sources/declarative/extractors/type_transformer.py +55 -0
- airbyte_cdk/sources/declarative/incremental/__init__.py +37 -0
- airbyte_cdk/sources/declarative/incremental/concurrent_partition_cursor.py +497 -0
- airbyte_cdk/sources/declarative/incremental/datetime_based_cursor.py +459 -0
- airbyte_cdk/sources/declarative/incremental/declarative_cursor.py +13 -0
- airbyte_cdk/sources/declarative/incremental/global_substream_cursor.py +357 -0
- airbyte_cdk/sources/declarative/incremental/per_partition_cursor.py +380 -0
- airbyte_cdk/sources/declarative/incremental/per_partition_with_global.py +200 -0
- airbyte_cdk/sources/declarative/incremental/resumable_full_refresh_cursor.py +122 -0
- airbyte_cdk/sources/declarative/interpolation/__init__.py +9 -0
- airbyte_cdk/sources/declarative/interpolation/filters.py +139 -0
- airbyte_cdk/sources/declarative/interpolation/interpolated_boolean.py +66 -0
- airbyte_cdk/sources/declarative/interpolation/interpolated_mapping.py +56 -0
- airbyte_cdk/sources/declarative/interpolation/interpolated_nested_mapping.py +52 -0
- airbyte_cdk/sources/declarative/interpolation/interpolated_string.py +79 -0
- airbyte_cdk/sources/declarative/interpolation/interpolation.py +34 -0
- airbyte_cdk/sources/declarative/interpolation/jinja.py +161 -0
- airbyte_cdk/sources/declarative/interpolation/macros.py +191 -0
- airbyte_cdk/sources/declarative/manifest_declarative_source.py +421 -0
- airbyte_cdk/sources/declarative/migrations/__init__.py +0 -0
- airbyte_cdk/sources/declarative/migrations/legacy_to_per_partition_state_migration.py +98 -0
- airbyte_cdk/sources/declarative/migrations/state_migration.py +24 -0
- airbyte_cdk/sources/declarative/models/__init__.py +2 -0
- airbyte_cdk/sources/declarative/models/declarative_component_schema.py +2503 -0
- airbyte_cdk/sources/declarative/parsers/__init__.py +3 -0
- airbyte_cdk/sources/declarative/parsers/custom_code_compiler.py +157 -0
- airbyte_cdk/sources/declarative/parsers/custom_exceptions.py +21 -0
- airbyte_cdk/sources/declarative/parsers/manifest_component_transformer.py +172 -0
- airbyte_cdk/sources/declarative/parsers/manifest_reference_resolver.py +213 -0
- airbyte_cdk/sources/declarative/parsers/model_to_component_factory.py +3407 -0
- airbyte_cdk/sources/declarative/partition_routers/__init__.py +29 -0
- airbyte_cdk/sources/declarative/partition_routers/async_job_partition_router.py +65 -0
- airbyte_cdk/sources/declarative/partition_routers/cartesian_product_stream_slicer.py +176 -0
- airbyte_cdk/sources/declarative/partition_routers/list_partition_router.py +121 -0
- airbyte_cdk/sources/declarative/partition_routers/partition_router.py +62 -0
- airbyte_cdk/sources/declarative/partition_routers/single_partition_router.py +63 -0
- airbyte_cdk/sources/declarative/partition_routers/substream_partition_router.py +437 -0
- airbyte_cdk/sources/declarative/requesters/README.md +56 -0
- airbyte_cdk/sources/declarative/requesters/__init__.py +9 -0
- airbyte_cdk/sources/declarative/requesters/error_handlers/__init__.py +25 -0
- airbyte_cdk/sources/declarative/requesters/error_handlers/backoff_strategies/__init__.py +23 -0
- airbyte_cdk/sources/declarative/requesters/error_handlers/backoff_strategies/constant_backoff_strategy.py +45 -0
- airbyte_cdk/sources/declarative/requesters/error_handlers/backoff_strategies/exponential_backoff_strategy.py +45 -0
- airbyte_cdk/sources/declarative/requesters/error_handlers/backoff_strategies/header_helper.py +41 -0
- airbyte_cdk/sources/declarative/requesters/error_handlers/backoff_strategies/wait_time_from_header_backoff_strategy.py +70 -0
- airbyte_cdk/sources/declarative/requesters/error_handlers/backoff_strategies/wait_until_time_from_header_backoff_strategy.py +77 -0
- airbyte_cdk/sources/declarative/requesters/error_handlers/backoff_strategy.py +17 -0
- airbyte_cdk/sources/declarative/requesters/error_handlers/composite_error_handler.py +101 -0
- airbyte_cdk/sources/declarative/requesters/error_handlers/default_error_handler.py +147 -0
- airbyte_cdk/sources/declarative/requesters/error_handlers/default_http_response_filter.py +40 -0
- airbyte_cdk/sources/declarative/requesters/error_handlers/error_handler.py +17 -0
- airbyte_cdk/sources/declarative/requesters/error_handlers/http_response_filter.py +179 -0
- airbyte_cdk/sources/declarative/requesters/http_job_repository.py +350 -0
- airbyte_cdk/sources/declarative/requesters/http_requester.py +433 -0
- airbyte_cdk/sources/declarative/requesters/paginators/__init__.py +21 -0
- airbyte_cdk/sources/declarative/requesters/paginators/default_paginator.py +327 -0
- airbyte_cdk/sources/declarative/requesters/paginators/no_pagination.py +76 -0
- airbyte_cdk/sources/declarative/requesters/paginators/paginator.py +65 -0
- airbyte_cdk/sources/declarative/requesters/paginators/strategies/__init__.py +25 -0
- airbyte_cdk/sources/declarative/requesters/paginators/strategies/cursor_pagination_strategy.py +98 -0
- airbyte_cdk/sources/declarative/requesters/paginators/strategies/offset_increment.py +102 -0
- airbyte_cdk/sources/declarative/requesters/paginators/strategies/page_increment.py +71 -0
- airbyte_cdk/sources/declarative/requesters/paginators/strategies/pagination_strategy.py +48 -0
- airbyte_cdk/sources/declarative/requesters/paginators/strategies/stop_condition.py +66 -0
- airbyte_cdk/sources/declarative/requesters/request_option.py +117 -0
- airbyte_cdk/sources/declarative/requesters/request_options/__init__.py +23 -0
- airbyte_cdk/sources/declarative/requesters/request_options/datetime_based_request_options_provider.py +92 -0
- airbyte_cdk/sources/declarative/requesters/request_options/default_request_options_provider.py +60 -0
- airbyte_cdk/sources/declarative/requesters/request_options/interpolated_nested_request_input_provider.py +59 -0
- airbyte_cdk/sources/declarative/requesters/request_options/interpolated_request_input_provider.py +68 -0
- airbyte_cdk/sources/declarative/requesters/request_options/interpolated_request_options_provider.py +119 -0
- airbyte_cdk/sources/declarative/requesters/request_options/request_options_provider.py +79 -0
- airbyte_cdk/sources/declarative/requesters/request_path.py +15 -0
- airbyte_cdk/sources/declarative/requesters/requester.py +144 -0
- airbyte_cdk/sources/declarative/resolvers/__init__.py +41 -0
- airbyte_cdk/sources/declarative/resolvers/components_resolver.py +55 -0
- airbyte_cdk/sources/declarative/resolvers/config_components_resolver.py +136 -0
- airbyte_cdk/sources/declarative/resolvers/http_components_resolver.py +112 -0
- airbyte_cdk/sources/declarative/retrievers/__init__.py +19 -0
- airbyte_cdk/sources/declarative/retrievers/async_retriever.py +124 -0
- airbyte_cdk/sources/declarative/retrievers/file_uploader.py +89 -0
- airbyte_cdk/sources/declarative/retrievers/retriever.py +54 -0
- airbyte_cdk/sources/declarative/retrievers/simple_retriever.py +702 -0
- airbyte_cdk/sources/declarative/schema/__init__.py +25 -0
- airbyte_cdk/sources/declarative/schema/default_schema_loader.py +47 -0
- airbyte_cdk/sources/declarative/schema/dynamic_schema_loader.py +285 -0
- airbyte_cdk/sources/declarative/schema/inline_schema_loader.py +19 -0
- airbyte_cdk/sources/declarative/schema/json_file_schema_loader.py +92 -0
- airbyte_cdk/sources/declarative/schema/schema_loader.py +17 -0
- airbyte_cdk/sources/declarative/spec/__init__.py +7 -0
- airbyte_cdk/sources/declarative/spec/spec.py +48 -0
- airbyte_cdk/sources/declarative/stream_slicers/__init__.py +7 -0
- airbyte_cdk/sources/declarative/stream_slicers/declarative_partition_generator.py +93 -0
- airbyte_cdk/sources/declarative/stream_slicers/stream_slicer.py +25 -0
- airbyte_cdk/sources/declarative/transformations/__init__.py +17 -0
- airbyte_cdk/sources/declarative/transformations/add_fields.py +146 -0
- airbyte_cdk/sources/declarative/transformations/dpath_flatten_fields.py +61 -0
- airbyte_cdk/sources/declarative/transformations/flatten_fields.py +52 -0
- airbyte_cdk/sources/declarative/transformations/keys_replace_transformation.py +61 -0
- airbyte_cdk/sources/declarative/transformations/keys_to_lower_transformation.py +22 -0
- airbyte_cdk/sources/declarative/transformations/keys_to_snake_transformation.py +68 -0
- airbyte_cdk/sources/declarative/transformations/remove_fields.py +75 -0
- airbyte_cdk/sources/declarative/transformations/transformation.py +37 -0
- airbyte_cdk/sources/declarative/types.py +25 -0
- airbyte_cdk/sources/declarative/yaml_declarative_source.py +67 -0
- airbyte_cdk/sources/file_based/README.md +152 -0
- airbyte_cdk/sources/file_based/__init__.py +24 -0
- airbyte_cdk/sources/file_based/availability_strategy/__init__.py +11 -0
- airbyte_cdk/sources/file_based/availability_strategy/abstract_file_based_availability_strategy.py +73 -0
- airbyte_cdk/sources/file_based/availability_strategy/default_file_based_availability_strategy.py +149 -0
- airbyte_cdk/sources/file_based/config/__init__.py +0 -0
- airbyte_cdk/sources/file_based/config/abstract_file_based_spec.py +153 -0
- airbyte_cdk/sources/file_based/config/avro_format.py +25 -0
- airbyte_cdk/sources/file_based/config/csv_format.py +210 -0
- airbyte_cdk/sources/file_based/config/excel_format.py +18 -0
- airbyte_cdk/sources/file_based/config/file_based_stream_config.py +99 -0
- airbyte_cdk/sources/file_based/config/jsonl_format.py +18 -0
- airbyte_cdk/sources/file_based/config/parquet_format.py +25 -0
- airbyte_cdk/sources/file_based/config/unstructured_format.py +102 -0
- airbyte_cdk/sources/file_based/config/validate_config_transfer_modes.py +81 -0
- airbyte_cdk/sources/file_based/discovery_policy/__init__.py +8 -0
- airbyte_cdk/sources/file_based/discovery_policy/abstract_discovery_policy.py +21 -0
- airbyte_cdk/sources/file_based/discovery_policy/default_discovery_policy.py +33 -0
- airbyte_cdk/sources/file_based/exceptions.py +159 -0
- airbyte_cdk/sources/file_based/file_based_source.py +466 -0
- airbyte_cdk/sources/file_based/file_based_stream_permissions_reader.py +123 -0
- airbyte_cdk/sources/file_based/file_based_stream_reader.py +209 -0
- airbyte_cdk/sources/file_based/file_record_data.py +22 -0
- airbyte_cdk/sources/file_based/file_types/__init__.py +37 -0
- airbyte_cdk/sources/file_based/file_types/avro_parser.py +233 -0
- airbyte_cdk/sources/file_based/file_types/csv_parser.py +527 -0
- airbyte_cdk/sources/file_based/file_types/excel_parser.py +196 -0
- airbyte_cdk/sources/file_based/file_types/file_transfer.py +30 -0
- airbyte_cdk/sources/file_based/file_types/file_type_parser.py +86 -0
- airbyte_cdk/sources/file_based/file_types/jsonl_parser.py +145 -0
- airbyte_cdk/sources/file_based/file_types/parquet_parser.py +275 -0
- airbyte_cdk/sources/file_based/file_types/unstructured_parser.py +480 -0
- airbyte_cdk/sources/file_based/remote_file.py +18 -0
- airbyte_cdk/sources/file_based/schema_helpers.py +281 -0
- airbyte_cdk/sources/file_based/schema_validation_policies/__init__.py +17 -0
- airbyte_cdk/sources/file_based/schema_validation_policies/abstract_schema_validation_policy.py +20 -0
- airbyte_cdk/sources/file_based/schema_validation_policies/default_schema_validation_policies.py +52 -0
- airbyte_cdk/sources/file_based/stream/__init__.py +13 -0
- airbyte_cdk/sources/file_based/stream/abstract_file_based_stream.py +197 -0
- airbyte_cdk/sources/file_based/stream/concurrent/__init__.py +0 -0
- airbyte_cdk/sources/file_based/stream/concurrent/adapters.py +343 -0
- airbyte_cdk/sources/file_based/stream/concurrent/cursor/__init__.py +9 -0
- airbyte_cdk/sources/file_based/stream/concurrent/cursor/abstract_concurrent_file_based_cursor.py +59 -0
- airbyte_cdk/sources/file_based/stream/concurrent/cursor/file_based_concurrent_cursor.py +313 -0
- airbyte_cdk/sources/file_based/stream/concurrent/cursor/file_based_final_state_cursor.py +83 -0
- airbyte_cdk/sources/file_based/stream/cursor/__init__.py +4 -0
- airbyte_cdk/sources/file_based/stream/cursor/abstract_file_based_cursor.py +66 -0
- airbyte_cdk/sources/file_based/stream/cursor/default_file_based_cursor.py +149 -0
- airbyte_cdk/sources/file_based/stream/default_file_based_stream.py +396 -0
- airbyte_cdk/sources/file_based/stream/identities_stream.py +49 -0
- airbyte_cdk/sources/file_based/stream/permissions_file_based_stream.py +92 -0
- airbyte_cdk/sources/file_based/types.py +10 -0
- airbyte_cdk/sources/http_config.py +10 -0
- airbyte_cdk/sources/http_logger.py +55 -0
- airbyte_cdk/sources/message/__init__.py +19 -0
- airbyte_cdk/sources/message/repository.py +137 -0
- airbyte_cdk/sources/source.py +95 -0
- airbyte_cdk/sources/specs/transfer_modes.py +26 -0
- airbyte_cdk/sources/streams/__init__.py +8 -0
- airbyte_cdk/sources/streams/availability_strategy.py +84 -0
- airbyte_cdk/sources/streams/call_rate.py +704 -0
- airbyte_cdk/sources/streams/checkpoint/__init__.py +26 -0
- airbyte_cdk/sources/streams/checkpoint/checkpoint_reader.py +335 -0
- airbyte_cdk/sources/streams/checkpoint/cursor.py +77 -0
- airbyte_cdk/sources/streams/checkpoint/per_partition_key_serializer.py +22 -0
- airbyte_cdk/sources/streams/checkpoint/resumable_full_refresh_cursor.py +51 -0
- airbyte_cdk/sources/streams/checkpoint/substream_resumable_full_refresh_cursor.py +110 -0
- airbyte_cdk/sources/streams/concurrent/README.md +7 -0
- airbyte_cdk/sources/streams/concurrent/__init__.py +3 -0
- airbyte_cdk/sources/streams/concurrent/abstract_stream.py +96 -0
- airbyte_cdk/sources/streams/concurrent/abstract_stream_facade.py +37 -0
- airbyte_cdk/sources/streams/concurrent/adapters.py +397 -0
- airbyte_cdk/sources/streams/concurrent/availability_strategy.py +94 -0
- airbyte_cdk/sources/streams/concurrent/clamping.py +99 -0
- airbyte_cdk/sources/streams/concurrent/cursor.py +481 -0
- airbyte_cdk/sources/streams/concurrent/cursor_types.py +32 -0
- airbyte_cdk/sources/streams/concurrent/default_stream.py +102 -0
- airbyte_cdk/sources/streams/concurrent/exceptions.py +18 -0
- airbyte_cdk/sources/streams/concurrent/helpers.py +42 -0
- airbyte_cdk/sources/streams/concurrent/partition_enqueuer.py +64 -0
- airbyte_cdk/sources/streams/concurrent/partition_reader.py +45 -0
- airbyte_cdk/sources/streams/concurrent/partitions/__init__.py +3 -0
- airbyte_cdk/sources/streams/concurrent/partitions/partition.py +48 -0
- airbyte_cdk/sources/streams/concurrent/partitions/partition_generator.py +18 -0
- airbyte_cdk/sources/streams/concurrent/partitions/stream_slicer.py +21 -0
- airbyte_cdk/sources/streams/concurrent/partitions/types.py +38 -0
- airbyte_cdk/sources/streams/concurrent/state_converters/__init__.py +0 -0
- airbyte_cdk/sources/streams/concurrent/state_converters/abstract_stream_state_converter.py +182 -0
- airbyte_cdk/sources/streams/concurrent/state_converters/datetime_stream_state_converter.py +223 -0
- airbyte_cdk/sources/streams/concurrent/state_converters/incrementing_count_stream_state_converter.py +92 -0
- airbyte_cdk/sources/streams/core.py +703 -0
- airbyte_cdk/sources/streams/http/__init__.py +10 -0
- airbyte_cdk/sources/streams/http/availability_strategy.py +54 -0
- airbyte_cdk/sources/streams/http/error_handlers/__init__.py +22 -0
- airbyte_cdk/sources/streams/http/error_handlers/backoff_strategy.py +28 -0
- airbyte_cdk/sources/streams/http/error_handlers/default_backoff_strategy.py +17 -0
- airbyte_cdk/sources/streams/http/error_handlers/default_error_mapping.py +86 -0
- airbyte_cdk/sources/streams/http/error_handlers/error_handler.py +42 -0
- airbyte_cdk/sources/streams/http/error_handlers/error_message_parser.py +19 -0
- airbyte_cdk/sources/streams/http/error_handlers/http_status_error_handler.py +110 -0
- airbyte_cdk/sources/streams/http/error_handlers/json_error_message_parser.py +52 -0
- airbyte_cdk/sources/streams/http/error_handlers/response_models.py +65 -0
- airbyte_cdk/sources/streams/http/exceptions.py +61 -0
- airbyte_cdk/sources/streams/http/http.py +673 -0
- airbyte_cdk/sources/streams/http/http_client.py +531 -0
- airbyte_cdk/sources/streams/http/rate_limiting.py +158 -0
- airbyte_cdk/sources/streams/http/requests_native_auth/__init__.py +14 -0
- airbyte_cdk/sources/streams/http/requests_native_auth/abstract_oauth.py +479 -0
- airbyte_cdk/sources/streams/http/requests_native_auth/abstract_token.py +34 -0
- airbyte_cdk/sources/streams/http/requests_native_auth/oauth.py +436 -0
- airbyte_cdk/sources/streams/http/requests_native_auth/token.py +83 -0
- airbyte_cdk/sources/streams/permissions/identities_stream.py +75 -0
- airbyte_cdk/sources/streams/utils/__init__.py +3 -0
- airbyte_cdk/sources/types.py +169 -0
- airbyte_cdk/sources/utils/__init__.py +7 -0
- airbyte_cdk/sources/utils/casing.py +12 -0
- airbyte_cdk/sources/utils/files_directory.py +15 -0
- airbyte_cdk/sources/utils/record_helper.py +53 -0
- airbyte_cdk/sources/utils/schema_helpers.py +230 -0
- airbyte_cdk/sources/utils/slice_logger.py +57 -0
- airbyte_cdk/sources/utils/transform.py +277 -0
- airbyte_cdk/sources/utils/types.py +7 -0
- airbyte_cdk/sql/__init__.py +0 -0
- airbyte_cdk/sql/_util/__init__.py +0 -0
- airbyte_cdk/sql/_util/hashing.py +34 -0
- airbyte_cdk/sql/_util/name_normalizers.py +92 -0
- airbyte_cdk/sql/constants.py +32 -0
- airbyte_cdk/sql/exceptions.py +235 -0
- airbyte_cdk/sql/secrets.py +123 -0
- airbyte_cdk/sql/shared/__init__.py +15 -0
- airbyte_cdk/sql/shared/catalog_providers.py +145 -0
- airbyte_cdk/sql/shared/sql_processor.py +786 -0
- airbyte_cdk/sql/types.py +160 -0
- airbyte_cdk/test/__init__.py +7 -0
- airbyte_cdk/test/catalog_builder.py +81 -0
- airbyte_cdk/test/entrypoint_wrapper.py +250 -0
- airbyte_cdk/test/mock_http/__init__.py +6 -0
- airbyte_cdk/test/mock_http/matcher.py +41 -0
- airbyte_cdk/test/mock_http/mocker.py +185 -0
- airbyte_cdk/test/mock_http/request.py +103 -0
- airbyte_cdk/test/mock_http/response.py +28 -0
- airbyte_cdk/test/mock_http/response_builder.py +237 -0
- airbyte_cdk/test/state_builder.py +33 -0
- airbyte_cdk/test/utils/__init__.py +1 -0
- airbyte_cdk/test/utils/data.py +24 -0
- airbyte_cdk/test/utils/http_mocking.py +16 -0
- airbyte_cdk/test/utils/manifest_only_fixtures.py +59 -0
- airbyte_cdk/test/utils/reading.py +26 -0
- airbyte_cdk/utils/__init__.py +10 -0
- airbyte_cdk/utils/airbyte_secrets_utils.py +80 -0
- airbyte_cdk/utils/analytics_message.py +25 -0
- airbyte_cdk/utils/constants.py +5 -0
- airbyte_cdk/utils/datetime_format_inferrer.py +94 -0
- airbyte_cdk/utils/datetime_helpers.py +499 -0
- airbyte_cdk/utils/event_timing.py +85 -0
- airbyte_cdk/utils/is_cloud_environment.py +18 -0
- airbyte_cdk/utils/mapping_helpers.py +162 -0
- airbyte_cdk/utils/message_utils.py +26 -0
- airbyte_cdk/utils/oneof_option_config.py +33 -0
- airbyte_cdk/utils/print_buffer.py +75 -0
- airbyte_cdk/utils/schema_inferrer.py +270 -0
- airbyte_cdk/utils/slice_hasher.py +37 -0
- airbyte_cdk/utils/spec_schema_transformations.py +26 -0
- airbyte_cdk/utils/stream_status_utils.py +43 -0
- airbyte_cdk/utils/traced_exception.py +145 -0
- airbyte_cdk-0.0.0.dev0.dist-info/LICENSE.txt +19 -0
- airbyte_cdk-0.0.0.dev0.dist-info/LICENSE_SHORT +1 -0
- airbyte_cdk-0.0.0.dev0.dist-info/METADATA +111 -0
- airbyte_cdk-0.0.0.dev0.dist-info/RECORD +368 -0
- airbyte_cdk-0.0.0.dev0.dist-info/WHEEL +4 -0
- airbyte_cdk-0.0.0.dev0.dist-info/entry_points.txt +3 -0
airbyte_cdk/sources/declarative/requesters/request_options/interpolated_request_options_provider.py
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
#
|
|
2
|
+
# Copyright (c) 2023 Airbyte, Inc., all rights reserved.
|
|
3
|
+
#
|
|
4
|
+
|
|
5
|
+
from dataclasses import InitVar, dataclass, field
|
|
6
|
+
from typing import Any, Mapping, MutableMapping, Optional, Union
|
|
7
|
+
|
|
8
|
+
from airbyte_cdk.sources.declarative.interpolation.interpolated_nested_mapping import NestedMapping
|
|
9
|
+
from airbyte_cdk.sources.declarative.requesters.request_options.interpolated_nested_request_input_provider import (
|
|
10
|
+
InterpolatedNestedRequestInputProvider,
|
|
11
|
+
)
|
|
12
|
+
from airbyte_cdk.sources.declarative.requesters.request_options.interpolated_request_input_provider import (
|
|
13
|
+
InterpolatedRequestInputProvider,
|
|
14
|
+
)
|
|
15
|
+
from airbyte_cdk.sources.declarative.requesters.request_options.request_options_provider import (
|
|
16
|
+
RequestOptionsProvider,
|
|
17
|
+
)
|
|
18
|
+
from airbyte_cdk.sources.types import Config, StreamSlice, StreamState
|
|
19
|
+
|
|
20
|
+
RequestInput = Union[str, Mapping[str, str]]
|
|
21
|
+
ValidRequestTypes = (str, list)
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
@dataclass
|
|
25
|
+
class InterpolatedRequestOptionsProvider(RequestOptionsProvider):
|
|
26
|
+
"""
|
|
27
|
+
Defines the request options to set on an outgoing HTTP request by evaluating `InterpolatedMapping`s
|
|
28
|
+
|
|
29
|
+
Attributes:
|
|
30
|
+
config (Config): The user-provided configuration as specified by the source's spec
|
|
31
|
+
request_parameters (Union[str, Mapping[str, str]]): The request parameters to set on an outgoing HTTP request
|
|
32
|
+
request_headers (Union[str, Mapping[str, str]]): The request headers to set on an outgoing HTTP request
|
|
33
|
+
request_body_data (Union[str, Mapping[str, str]]): The body data to set on an outgoing HTTP request
|
|
34
|
+
request_body_json (Union[str, Mapping[str, str]]): The json content to set on an outgoing HTTP request
|
|
35
|
+
"""
|
|
36
|
+
|
|
37
|
+
parameters: InitVar[Mapping[str, Any]]
|
|
38
|
+
config: Config = field(default_factory=dict)
|
|
39
|
+
request_parameters: Optional[RequestInput] = None
|
|
40
|
+
request_headers: Optional[RequestInput] = None
|
|
41
|
+
request_body_data: Optional[RequestInput] = None
|
|
42
|
+
request_body_json: Optional[NestedMapping] = None
|
|
43
|
+
|
|
44
|
+
def __post_init__(self, parameters: Mapping[str, Any]) -> None:
|
|
45
|
+
if self.request_parameters is None:
|
|
46
|
+
self.request_parameters = {}
|
|
47
|
+
if self.request_headers is None:
|
|
48
|
+
self.request_headers = {}
|
|
49
|
+
if self.request_body_data is None:
|
|
50
|
+
self.request_body_data = {}
|
|
51
|
+
if self.request_body_json is None:
|
|
52
|
+
self.request_body_json = {}
|
|
53
|
+
|
|
54
|
+
if self.request_body_json and self.request_body_data:
|
|
55
|
+
raise ValueError(
|
|
56
|
+
"RequestOptionsProvider should only contain either 'request_body_data' or 'request_body_json' not both"
|
|
57
|
+
)
|
|
58
|
+
|
|
59
|
+
self._parameter_interpolator = InterpolatedRequestInputProvider(
|
|
60
|
+
config=self.config, request_inputs=self.request_parameters, parameters=parameters
|
|
61
|
+
)
|
|
62
|
+
self._headers_interpolator = InterpolatedRequestInputProvider(
|
|
63
|
+
config=self.config, request_inputs=self.request_headers, parameters=parameters
|
|
64
|
+
)
|
|
65
|
+
self._body_data_interpolator = InterpolatedRequestInputProvider(
|
|
66
|
+
config=self.config, request_inputs=self.request_body_data, parameters=parameters
|
|
67
|
+
)
|
|
68
|
+
self._body_json_interpolator = InterpolatedNestedRequestInputProvider(
|
|
69
|
+
config=self.config, request_inputs=self.request_body_json, parameters=parameters
|
|
70
|
+
)
|
|
71
|
+
|
|
72
|
+
def get_request_params(
|
|
73
|
+
self,
|
|
74
|
+
*,
|
|
75
|
+
stream_state: Optional[StreamState] = None,
|
|
76
|
+
stream_slice: Optional[StreamSlice] = None,
|
|
77
|
+
next_page_token: Optional[Mapping[str, Any]] = None,
|
|
78
|
+
) -> MutableMapping[str, Any]:
|
|
79
|
+
interpolated_value = self._parameter_interpolator.eval_request_inputs(
|
|
80
|
+
stream_slice,
|
|
81
|
+
next_page_token,
|
|
82
|
+
valid_key_types=(str,),
|
|
83
|
+
valid_value_types=ValidRequestTypes,
|
|
84
|
+
)
|
|
85
|
+
if isinstance(interpolated_value, dict):
|
|
86
|
+
return interpolated_value
|
|
87
|
+
return {}
|
|
88
|
+
|
|
89
|
+
def get_request_headers(
|
|
90
|
+
self,
|
|
91
|
+
*,
|
|
92
|
+
stream_state: Optional[StreamState] = None,
|
|
93
|
+
stream_slice: Optional[StreamSlice] = None,
|
|
94
|
+
next_page_token: Optional[Mapping[str, Any]] = None,
|
|
95
|
+
) -> Mapping[str, Any]:
|
|
96
|
+
return self._headers_interpolator.eval_request_inputs(stream_slice, next_page_token)
|
|
97
|
+
|
|
98
|
+
def get_request_body_data(
|
|
99
|
+
self,
|
|
100
|
+
*,
|
|
101
|
+
stream_state: Optional[StreamState] = None,
|
|
102
|
+
stream_slice: Optional[StreamSlice] = None,
|
|
103
|
+
next_page_token: Optional[Mapping[str, Any]] = None,
|
|
104
|
+
) -> Union[Mapping[str, Any], str]:
|
|
105
|
+
return self._body_data_interpolator.eval_request_inputs(
|
|
106
|
+
stream_slice,
|
|
107
|
+
next_page_token,
|
|
108
|
+
valid_key_types=(str,),
|
|
109
|
+
valid_value_types=ValidRequestTypes,
|
|
110
|
+
)
|
|
111
|
+
|
|
112
|
+
def get_request_body_json(
|
|
113
|
+
self,
|
|
114
|
+
*,
|
|
115
|
+
stream_state: Optional[StreamState] = None,
|
|
116
|
+
stream_slice: Optional[StreamSlice] = None,
|
|
117
|
+
next_page_token: Optional[Mapping[str, Any]] = None,
|
|
118
|
+
) -> Mapping[str, Any]:
|
|
119
|
+
return self._body_json_interpolator.eval_request_inputs(stream_slice, next_page_token)
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
#
|
|
2
|
+
# Copyright (c) 2023 Airbyte, Inc., all rights reserved.
|
|
3
|
+
#
|
|
4
|
+
|
|
5
|
+
from abc import abstractmethod
|
|
6
|
+
from dataclasses import dataclass
|
|
7
|
+
from typing import Any, Mapping, Optional, Union
|
|
8
|
+
|
|
9
|
+
from airbyte_cdk.sources.types import StreamSlice, StreamState
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
@dataclass
|
|
13
|
+
class RequestOptionsProvider:
|
|
14
|
+
"""
|
|
15
|
+
Defines the request options to set on an outgoing HTTP request
|
|
16
|
+
|
|
17
|
+
Options can be passed by
|
|
18
|
+
- request parameter
|
|
19
|
+
- request headers
|
|
20
|
+
- body data
|
|
21
|
+
- json content
|
|
22
|
+
"""
|
|
23
|
+
|
|
24
|
+
@abstractmethod
|
|
25
|
+
def get_request_params(
|
|
26
|
+
self,
|
|
27
|
+
*,
|
|
28
|
+
stream_state: Optional[StreamState] = None,
|
|
29
|
+
stream_slice: Optional[StreamSlice] = None,
|
|
30
|
+
next_page_token: Optional[Mapping[str, Any]] = None,
|
|
31
|
+
) -> Mapping[str, Any]:
|
|
32
|
+
"""
|
|
33
|
+
Specifies the query parameters that should be set on an outgoing HTTP request given the inputs.
|
|
34
|
+
|
|
35
|
+
E.g: you might want to define query parameters for paging if next_page_token is not None.
|
|
36
|
+
"""
|
|
37
|
+
pass
|
|
38
|
+
|
|
39
|
+
@abstractmethod
|
|
40
|
+
def get_request_headers(
|
|
41
|
+
self,
|
|
42
|
+
*,
|
|
43
|
+
stream_state: Optional[StreamState] = None,
|
|
44
|
+
stream_slice: Optional[StreamSlice] = None,
|
|
45
|
+
next_page_token: Optional[Mapping[str, Any]] = None,
|
|
46
|
+
) -> Mapping[str, Any]:
|
|
47
|
+
"""Return any non-auth headers. Authentication headers will overwrite any overlapping headers returned from this method."""
|
|
48
|
+
|
|
49
|
+
@abstractmethod
|
|
50
|
+
def get_request_body_data(
|
|
51
|
+
self,
|
|
52
|
+
*,
|
|
53
|
+
stream_state: Optional[StreamState] = None,
|
|
54
|
+
stream_slice: Optional[StreamSlice] = None,
|
|
55
|
+
next_page_token: Optional[Mapping[str, Any]] = None,
|
|
56
|
+
) -> Union[Mapping[str, Any], str]:
|
|
57
|
+
"""
|
|
58
|
+
Specifies how to populate the body of the request with a non-JSON payload.
|
|
59
|
+
|
|
60
|
+
If returns a ready text that it will be sent as is.
|
|
61
|
+
If returns a dict that it will be converted to a urlencoded form.
|
|
62
|
+
E.g. {"key1": "value1", "key2": "value2"} => "key1=value1&key2=value2"
|
|
63
|
+
|
|
64
|
+
At the same time only one of the 'request_body_data' and 'request_body_json' functions can be overridden.
|
|
65
|
+
"""
|
|
66
|
+
|
|
67
|
+
@abstractmethod
|
|
68
|
+
def get_request_body_json(
|
|
69
|
+
self,
|
|
70
|
+
*,
|
|
71
|
+
stream_state: Optional[StreamState] = None,
|
|
72
|
+
stream_slice: Optional[StreamSlice] = None,
|
|
73
|
+
next_page_token: Optional[Mapping[str, Any]] = None,
|
|
74
|
+
) -> Mapping[str, Any]:
|
|
75
|
+
"""
|
|
76
|
+
Specifies how to populate the body of the request with a JSON payload.
|
|
77
|
+
|
|
78
|
+
At the same time only one of the 'request_body_data' and 'request_body_json' functions can be overridden.
|
|
79
|
+
"""
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
#
|
|
2
|
+
# Copyright (c) 2023 Airbyte, Inc., all rights reserved.
|
|
3
|
+
#
|
|
4
|
+
|
|
5
|
+
from dataclasses import InitVar, dataclass
|
|
6
|
+
from typing import Any, Mapping
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
@dataclass
|
|
10
|
+
class RequestPath:
|
|
11
|
+
"""
|
|
12
|
+
Describes that a component value should be inserted into the path
|
|
13
|
+
"""
|
|
14
|
+
|
|
15
|
+
parameters: InitVar[Mapping[str, Any]]
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
#
|
|
2
|
+
# Copyright (c) 2023 Airbyte, Inc., all rights reserved.
|
|
3
|
+
#
|
|
4
|
+
|
|
5
|
+
from abc import abstractmethod
|
|
6
|
+
from enum import Enum
|
|
7
|
+
from typing import Any, Callable, Mapping, MutableMapping, Optional, Union
|
|
8
|
+
|
|
9
|
+
import requests
|
|
10
|
+
|
|
11
|
+
from airbyte_cdk.sources.declarative.auth.declarative_authenticator import DeclarativeAuthenticator
|
|
12
|
+
from airbyte_cdk.sources.declarative.requesters.request_options.request_options_provider import (
|
|
13
|
+
RequestOptionsProvider,
|
|
14
|
+
)
|
|
15
|
+
from airbyte_cdk.sources.types import StreamSlice, StreamState
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class HttpMethod(Enum):
|
|
19
|
+
"""
|
|
20
|
+
Http Method to use when submitting an outgoing HTTP request
|
|
21
|
+
"""
|
|
22
|
+
|
|
23
|
+
DELETE = "DELETE"
|
|
24
|
+
GET = "GET"
|
|
25
|
+
PATCH = "PATCH"
|
|
26
|
+
POST = "POST"
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
class Requester(RequestOptionsProvider):
|
|
30
|
+
@abstractmethod
|
|
31
|
+
def get_authenticator(self) -> DeclarativeAuthenticator:
|
|
32
|
+
"""
|
|
33
|
+
Specifies the authenticator to use when submitting requests
|
|
34
|
+
"""
|
|
35
|
+
pass
|
|
36
|
+
|
|
37
|
+
@abstractmethod
|
|
38
|
+
def get_url_base(
|
|
39
|
+
self,
|
|
40
|
+
*,
|
|
41
|
+
stream_state: Optional[StreamState],
|
|
42
|
+
stream_slice: Optional[StreamSlice],
|
|
43
|
+
next_page_token: Optional[Mapping[str, Any]],
|
|
44
|
+
) -> str:
|
|
45
|
+
"""
|
|
46
|
+
:return: URL base for the API endpoint e.g: if you wanted to hit https://myapi.com/v1/some_entity then this should return "https://myapi.com/v1/"
|
|
47
|
+
"""
|
|
48
|
+
|
|
49
|
+
@abstractmethod
|
|
50
|
+
def get_path(
|
|
51
|
+
self,
|
|
52
|
+
*,
|
|
53
|
+
stream_state: Optional[StreamState],
|
|
54
|
+
stream_slice: Optional[StreamSlice],
|
|
55
|
+
next_page_token: Optional[Mapping[str, Any]],
|
|
56
|
+
) -> str:
|
|
57
|
+
"""
|
|
58
|
+
Returns the URL path for the API endpoint e.g: if you wanted to hit https://myapi.com/v1/some_entity then this should return "some_entity"
|
|
59
|
+
"""
|
|
60
|
+
|
|
61
|
+
@abstractmethod
|
|
62
|
+
def get_method(self) -> HttpMethod:
|
|
63
|
+
"""
|
|
64
|
+
Specifies the HTTP method to use
|
|
65
|
+
"""
|
|
66
|
+
|
|
67
|
+
@abstractmethod
|
|
68
|
+
def get_request_params(
|
|
69
|
+
self,
|
|
70
|
+
*,
|
|
71
|
+
stream_state: Optional[StreamState] = None,
|
|
72
|
+
stream_slice: Optional[StreamSlice] = None,
|
|
73
|
+
next_page_token: Optional[Mapping[str, Any]] = None,
|
|
74
|
+
) -> MutableMapping[str, Any]:
|
|
75
|
+
"""
|
|
76
|
+
Specifies the query parameters that should be set on an outgoing HTTP request given the inputs.
|
|
77
|
+
|
|
78
|
+
E.g: you might want to define query parameters for paging if next_page_token is not None.
|
|
79
|
+
"""
|
|
80
|
+
|
|
81
|
+
@abstractmethod
|
|
82
|
+
def get_request_headers(
|
|
83
|
+
self,
|
|
84
|
+
*,
|
|
85
|
+
stream_state: Optional[StreamState] = None,
|
|
86
|
+
stream_slice: Optional[StreamSlice] = None,
|
|
87
|
+
next_page_token: Optional[Mapping[str, Any]] = None,
|
|
88
|
+
) -> Mapping[str, Any]:
|
|
89
|
+
"""
|
|
90
|
+
Return any non-auth headers. Authentication headers will overwrite any overlapping headers returned from this method.
|
|
91
|
+
"""
|
|
92
|
+
|
|
93
|
+
@abstractmethod
|
|
94
|
+
def get_request_body_data(
|
|
95
|
+
self,
|
|
96
|
+
*,
|
|
97
|
+
stream_state: Optional[StreamState] = None,
|
|
98
|
+
stream_slice: Optional[StreamSlice] = None,
|
|
99
|
+
next_page_token: Optional[Mapping[str, Any]] = None,
|
|
100
|
+
) -> Union[Mapping[str, Any], str]:
|
|
101
|
+
"""
|
|
102
|
+
Specifies how to populate the body of the request with a non-JSON payload.
|
|
103
|
+
|
|
104
|
+
If returns a ready text that it will be sent as is.
|
|
105
|
+
If returns a dict that it will be converted to a urlencoded form.
|
|
106
|
+
E.g. {"key1": "value1", "key2": "value2"} => "key1=value1&key2=value2"
|
|
107
|
+
|
|
108
|
+
At the same time only one of the 'request_body_data' and 'request_body_json' functions can be overridden.
|
|
109
|
+
"""
|
|
110
|
+
|
|
111
|
+
@abstractmethod
|
|
112
|
+
def get_request_body_json(
|
|
113
|
+
self,
|
|
114
|
+
*,
|
|
115
|
+
stream_state: Optional[StreamState] = None,
|
|
116
|
+
stream_slice: Optional[StreamSlice] = None,
|
|
117
|
+
next_page_token: Optional[Mapping[str, Any]] = None,
|
|
118
|
+
) -> Mapping[str, Any]:
|
|
119
|
+
"""
|
|
120
|
+
Specifies how to populate the body of the request with a JSON payload.
|
|
121
|
+
|
|
122
|
+
At the same time only one of the 'request_body_data' and 'request_body_json' functions can be overridden.
|
|
123
|
+
"""
|
|
124
|
+
|
|
125
|
+
@abstractmethod
|
|
126
|
+
def send_request(
|
|
127
|
+
self,
|
|
128
|
+
stream_state: Optional[StreamState] = None,
|
|
129
|
+
stream_slice: Optional[StreamSlice] = None,
|
|
130
|
+
next_page_token: Optional[Mapping[str, Any]] = None,
|
|
131
|
+
path: Optional[str] = None,
|
|
132
|
+
request_headers: Optional[Mapping[str, Any]] = None,
|
|
133
|
+
request_params: Optional[Mapping[str, Any]] = None,
|
|
134
|
+
request_body_data: Optional[Union[Mapping[str, Any], str]] = None,
|
|
135
|
+
request_body_json: Optional[Mapping[str, Any]] = None,
|
|
136
|
+
log_formatter: Optional[Callable[[requests.Response], Any]] = None,
|
|
137
|
+
) -> Optional[requests.Response]:
|
|
138
|
+
"""
|
|
139
|
+
Sends a request and returns the response. Might return no response if the error handler chooses to ignore the response or throw an exception in case of an error.
|
|
140
|
+
If path is set, the path configured on the requester itself is ignored.
|
|
141
|
+
If header, params and body are set, they are merged with the ones configured on the requester itself.
|
|
142
|
+
|
|
143
|
+
If a log formatter is provided, it's used to log the performed request and response. If it's not provided, no logging is performed.
|
|
144
|
+
"""
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
#
|
|
2
|
+
# Copyright (c) 2024 Airbyte, Inc., all rights reserved.
|
|
3
|
+
#
|
|
4
|
+
|
|
5
|
+
from typing import Mapping
|
|
6
|
+
|
|
7
|
+
from pydantic.v1 import BaseModel
|
|
8
|
+
|
|
9
|
+
from airbyte_cdk.sources.declarative.models import (
|
|
10
|
+
ConfigComponentsResolver as ConfigComponentsResolverModel,
|
|
11
|
+
)
|
|
12
|
+
from airbyte_cdk.sources.declarative.models import (
|
|
13
|
+
HttpComponentsResolver as HttpComponentsResolverModel,
|
|
14
|
+
)
|
|
15
|
+
from airbyte_cdk.sources.declarative.resolvers.components_resolver import (
|
|
16
|
+
ComponentMappingDefinition,
|
|
17
|
+
ComponentsResolver,
|
|
18
|
+
ResolvedComponentMappingDefinition,
|
|
19
|
+
)
|
|
20
|
+
from airbyte_cdk.sources.declarative.resolvers.config_components_resolver import (
|
|
21
|
+
ConfigComponentsResolver,
|
|
22
|
+
StreamConfig,
|
|
23
|
+
)
|
|
24
|
+
from airbyte_cdk.sources.declarative.resolvers.http_components_resolver import (
|
|
25
|
+
HttpComponentsResolver,
|
|
26
|
+
)
|
|
27
|
+
|
|
28
|
+
COMPONENTS_RESOLVER_TYPE_MAPPING: Mapping[str, type[BaseModel]] = {
|
|
29
|
+
"HttpComponentsResolver": HttpComponentsResolverModel,
|
|
30
|
+
"ConfigComponentsResolver": ConfigComponentsResolverModel,
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
__all__ = [
|
|
34
|
+
"ComponentsResolver",
|
|
35
|
+
"HttpComponentsResolver",
|
|
36
|
+
"ComponentMappingDefinition",
|
|
37
|
+
"ResolvedComponentMappingDefinition",
|
|
38
|
+
"StreamConfig",
|
|
39
|
+
"ConfigComponentsResolver",
|
|
40
|
+
"COMPONENTS_RESOLVER_TYPE_MAPPING",
|
|
41
|
+
]
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
#
|
|
2
|
+
# Copyright (c) 2024 Airbyte, Inc., all rights reserved.
|
|
3
|
+
#
|
|
4
|
+
|
|
5
|
+
from abc import ABC, abstractmethod
|
|
6
|
+
from dataclasses import InitVar, dataclass
|
|
7
|
+
from typing import Any, Dict, Iterable, List, Mapping, Optional, Type, Union
|
|
8
|
+
|
|
9
|
+
from typing_extensions import deprecated
|
|
10
|
+
|
|
11
|
+
from airbyte_cdk.sources.declarative.interpolation import InterpolatedString
|
|
12
|
+
from airbyte_cdk.sources.source import ExperimentalClassWarning
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
@dataclass(frozen=True)
|
|
16
|
+
class ComponentMappingDefinition:
|
|
17
|
+
"""Defines the configuration for mapping a component in a stream. This class specifies
|
|
18
|
+
what field in the stream template should be updated with value, supporting dynamic interpolation
|
|
19
|
+
and type enforcement."""
|
|
20
|
+
|
|
21
|
+
field_path: List["InterpolatedString"]
|
|
22
|
+
value: Union["InterpolatedString", str]
|
|
23
|
+
value_type: Optional[Type[Any]]
|
|
24
|
+
parameters: InitVar[Mapping[str, Any]]
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
@dataclass(frozen=True)
|
|
28
|
+
class ResolvedComponentMappingDefinition:
|
|
29
|
+
"""Defines resolved configuration for mapping a component in a stream. This class specifies
|
|
30
|
+
what field in the stream template should be updated with value, supporting dynamic interpolation
|
|
31
|
+
and type enforcement."""
|
|
32
|
+
|
|
33
|
+
field_path: List["InterpolatedString"]
|
|
34
|
+
value: "InterpolatedString"
|
|
35
|
+
value_type: Optional[Type[Any]]
|
|
36
|
+
parameters: InitVar[Mapping[str, Any]]
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
@deprecated("This class is experimental. Use at your own risk.", category=ExperimentalClassWarning)
|
|
40
|
+
@dataclass
|
|
41
|
+
class ComponentsResolver(ABC):
|
|
42
|
+
"""
|
|
43
|
+
Abstract base class for resolving components in a stream template.
|
|
44
|
+
"""
|
|
45
|
+
|
|
46
|
+
@abstractmethod
|
|
47
|
+
def resolve_components(
|
|
48
|
+
self, stream_template_config: Dict[str, Any]
|
|
49
|
+
) -> Iterable[Dict[str, Any]]:
|
|
50
|
+
"""
|
|
51
|
+
Maps and populates values into a stream template configuration.
|
|
52
|
+
:param stream_template_config: The stream template with placeholders for components.
|
|
53
|
+
:yields: The resolved stream config with populated values.
|
|
54
|
+
"""
|
|
55
|
+
pass
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
#
|
|
2
|
+
# Copyright (c) 2024 Airbyte, Inc., all rights reserved.
|
|
3
|
+
#
|
|
4
|
+
|
|
5
|
+
from copy import deepcopy
|
|
6
|
+
from dataclasses import InitVar, dataclass, field
|
|
7
|
+
from typing import Any, Dict, Iterable, List, Mapping, Union
|
|
8
|
+
|
|
9
|
+
import dpath
|
|
10
|
+
from typing_extensions import deprecated
|
|
11
|
+
|
|
12
|
+
from airbyte_cdk.sources.declarative.interpolation import InterpolatedString
|
|
13
|
+
from airbyte_cdk.sources.declarative.resolvers.components_resolver import (
|
|
14
|
+
ComponentMappingDefinition,
|
|
15
|
+
ComponentsResolver,
|
|
16
|
+
ResolvedComponentMappingDefinition,
|
|
17
|
+
)
|
|
18
|
+
from airbyte_cdk.sources.source import ExperimentalClassWarning
|
|
19
|
+
from airbyte_cdk.sources.types import Config
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
@deprecated("This class is experimental. Use at your own risk.", category=ExperimentalClassWarning)
|
|
23
|
+
@dataclass
|
|
24
|
+
class StreamConfig:
|
|
25
|
+
"""
|
|
26
|
+
Identifies stream config details for dynamic schema extraction and processing.
|
|
27
|
+
"""
|
|
28
|
+
|
|
29
|
+
configs_pointer: List[Union[InterpolatedString, str]]
|
|
30
|
+
parameters: InitVar[Mapping[str, Any]]
|
|
31
|
+
|
|
32
|
+
def __post_init__(self, parameters: Mapping[str, Any]) -> None:
|
|
33
|
+
self.configs_pointer = [
|
|
34
|
+
InterpolatedString.create(path, parameters=parameters) for path in self.configs_pointer
|
|
35
|
+
]
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
@deprecated("This class is experimental. Use at your own risk.", category=ExperimentalClassWarning)
|
|
39
|
+
@dataclass
|
|
40
|
+
class ConfigComponentsResolver(ComponentsResolver):
|
|
41
|
+
"""
|
|
42
|
+
Resolves and populates stream templates with components fetched via source config.
|
|
43
|
+
|
|
44
|
+
Attributes:
|
|
45
|
+
stream_config (StreamConfig): The description of stream configuration used to fetch stream config from source config.
|
|
46
|
+
config (Config): Configuration object for the resolver.
|
|
47
|
+
components_mapping (List[ComponentMappingDefinition]): List of mappings to resolve.
|
|
48
|
+
parameters (InitVar[Mapping[str, Any]]): Additional parameters for interpolation.
|
|
49
|
+
"""
|
|
50
|
+
|
|
51
|
+
stream_config: StreamConfig
|
|
52
|
+
config: Config
|
|
53
|
+
components_mapping: List[ComponentMappingDefinition]
|
|
54
|
+
parameters: InitVar[Mapping[str, Any]]
|
|
55
|
+
_resolved_components: List[ResolvedComponentMappingDefinition] = field(
|
|
56
|
+
init=False, repr=False, default_factory=list
|
|
57
|
+
)
|
|
58
|
+
|
|
59
|
+
def __post_init__(self, parameters: Mapping[str, Any]) -> None:
|
|
60
|
+
"""
|
|
61
|
+
Initializes and parses component mappings, converting them to resolved definitions.
|
|
62
|
+
|
|
63
|
+
Args:
|
|
64
|
+
parameters (Mapping[str, Any]): Parameters for interpolation.
|
|
65
|
+
"""
|
|
66
|
+
|
|
67
|
+
for component_mapping in self.components_mapping:
|
|
68
|
+
if isinstance(component_mapping.value, (str, InterpolatedString)):
|
|
69
|
+
interpolated_value = (
|
|
70
|
+
InterpolatedString.create(component_mapping.value, parameters=parameters)
|
|
71
|
+
if isinstance(component_mapping.value, str)
|
|
72
|
+
else component_mapping.value
|
|
73
|
+
)
|
|
74
|
+
|
|
75
|
+
field_path = [
|
|
76
|
+
InterpolatedString.create(path, parameters=parameters)
|
|
77
|
+
for path in component_mapping.field_path
|
|
78
|
+
]
|
|
79
|
+
|
|
80
|
+
self._resolved_components.append(
|
|
81
|
+
ResolvedComponentMappingDefinition(
|
|
82
|
+
field_path=field_path,
|
|
83
|
+
value=interpolated_value,
|
|
84
|
+
value_type=component_mapping.value_type,
|
|
85
|
+
parameters=parameters,
|
|
86
|
+
)
|
|
87
|
+
)
|
|
88
|
+
else:
|
|
89
|
+
raise ValueError(
|
|
90
|
+
f"Expected a string or InterpolatedString for value in mapping: {component_mapping}"
|
|
91
|
+
)
|
|
92
|
+
|
|
93
|
+
@property
|
|
94
|
+
def _stream_config(self) -> Iterable[Mapping[str, Any]]:
|
|
95
|
+
path = [
|
|
96
|
+
node.eval(self.config) if not isinstance(node, str) else node
|
|
97
|
+
for node in self.stream_config.configs_pointer
|
|
98
|
+
]
|
|
99
|
+
stream_config = dpath.get(dict(self.config), path, default=[])
|
|
100
|
+
|
|
101
|
+
if not isinstance(stream_config, list):
|
|
102
|
+
stream_config = [stream_config]
|
|
103
|
+
|
|
104
|
+
return stream_config
|
|
105
|
+
|
|
106
|
+
def resolve_components(
|
|
107
|
+
self, stream_template_config: Dict[str, Any]
|
|
108
|
+
) -> Iterable[Dict[str, Any]]:
|
|
109
|
+
"""
|
|
110
|
+
Resolves components in the stream template configuration by populating values.
|
|
111
|
+
|
|
112
|
+
Args:
|
|
113
|
+
stream_template_config (Dict[str, Any]): Stream template to populate.
|
|
114
|
+
|
|
115
|
+
Yields:
|
|
116
|
+
Dict[str, Any]: Updated configurations with resolved components.
|
|
117
|
+
"""
|
|
118
|
+
kwargs = {"stream_template_config": stream_template_config}
|
|
119
|
+
|
|
120
|
+
for components_values in self._stream_config:
|
|
121
|
+
updated_config = deepcopy(stream_template_config)
|
|
122
|
+
kwargs["components_values"] = components_values # type: ignore[assignment] # component_values will always be of type Mapping[str, Any]
|
|
123
|
+
|
|
124
|
+
for resolved_component in self._resolved_components:
|
|
125
|
+
valid_types = (
|
|
126
|
+
(resolved_component.value_type,) if resolved_component.value_type else None
|
|
127
|
+
)
|
|
128
|
+
value = resolved_component.value.eval(
|
|
129
|
+
self.config, valid_types=valid_types, **kwargs
|
|
130
|
+
)
|
|
131
|
+
|
|
132
|
+
path = [path.eval(self.config, **kwargs) for path in resolved_component.field_path]
|
|
133
|
+
|
|
134
|
+
dpath.set(updated_config, path, value)
|
|
135
|
+
|
|
136
|
+
yield updated_config
|