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
|
@@ -0,0 +1,433 @@
|
|
|
1
|
+
#
|
|
2
|
+
# Copyright (c) 2023 Airbyte, Inc., all rights reserved.
|
|
3
|
+
#
|
|
4
|
+
|
|
5
|
+
import logging
|
|
6
|
+
import os
|
|
7
|
+
from dataclasses import InitVar, dataclass, field
|
|
8
|
+
from typing import Any, Callable, Mapping, MutableMapping, Optional, Union
|
|
9
|
+
from urllib.parse import urljoin
|
|
10
|
+
|
|
11
|
+
import requests
|
|
12
|
+
|
|
13
|
+
from airbyte_cdk.sources.declarative.auth.declarative_authenticator import (
|
|
14
|
+
DeclarativeAuthenticator,
|
|
15
|
+
NoAuth,
|
|
16
|
+
)
|
|
17
|
+
from airbyte_cdk.sources.declarative.decoders import Decoder
|
|
18
|
+
from airbyte_cdk.sources.declarative.decoders.json_decoder import JsonDecoder
|
|
19
|
+
from airbyte_cdk.sources.declarative.interpolation.interpolated_string import (
|
|
20
|
+
InterpolatedString,
|
|
21
|
+
)
|
|
22
|
+
from airbyte_cdk.sources.declarative.requesters.request_options.interpolated_request_options_provider import (
|
|
23
|
+
InterpolatedRequestOptionsProvider,
|
|
24
|
+
)
|
|
25
|
+
from airbyte_cdk.sources.declarative.requesters.requester import HttpMethod, Requester
|
|
26
|
+
from airbyte_cdk.sources.message import MessageRepository, NoopMessageRepository
|
|
27
|
+
from airbyte_cdk.sources.streams.call_rate import APIBudget
|
|
28
|
+
from airbyte_cdk.sources.streams.http import HttpClient
|
|
29
|
+
from airbyte_cdk.sources.streams.http.error_handlers import ErrorHandler
|
|
30
|
+
from airbyte_cdk.sources.types import Config, EmptyString, StreamSlice, StreamState
|
|
31
|
+
from airbyte_cdk.utils.mapping_helpers import (
|
|
32
|
+
combine_mappings,
|
|
33
|
+
get_interpolation_context,
|
|
34
|
+
)
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
@dataclass
|
|
38
|
+
class HttpRequester(Requester):
|
|
39
|
+
"""
|
|
40
|
+
Default implementation of a Requester
|
|
41
|
+
|
|
42
|
+
Attributes:
|
|
43
|
+
name (str): Name of the stream. Only used for request/response caching
|
|
44
|
+
url_base (Union[InterpolatedString, str]): Base url to send requests to
|
|
45
|
+
path (Union[InterpolatedString, str]): Path to send requests to
|
|
46
|
+
http_method (Union[str, HttpMethod]): HTTP method to use when sending requests
|
|
47
|
+
request_options_provider (Optional[InterpolatedRequestOptionsProvider]): request option provider defining the options to set on outgoing requests
|
|
48
|
+
authenticator (DeclarativeAuthenticator): Authenticator defining how to authenticate to the source
|
|
49
|
+
error_handler (Optional[ErrorHandler]): Error handler defining how to detect and handle errors
|
|
50
|
+
backoff_strategies (Optional[List[BackoffStrategy]]): List of backoff strategies to use when retrying requests
|
|
51
|
+
config (Config): The user-provided configuration as specified by the source's spec
|
|
52
|
+
use_cache (bool): Indicates that data should be cached for this stream
|
|
53
|
+
"""
|
|
54
|
+
|
|
55
|
+
name: str
|
|
56
|
+
url_base: Union[InterpolatedString, str]
|
|
57
|
+
config: Config
|
|
58
|
+
parameters: InitVar[Mapping[str, Any]]
|
|
59
|
+
|
|
60
|
+
path: Optional[Union[InterpolatedString, str]] = None
|
|
61
|
+
authenticator: Optional[DeclarativeAuthenticator] = None
|
|
62
|
+
http_method: Union[str, HttpMethod] = HttpMethod.GET
|
|
63
|
+
request_options_provider: Optional[InterpolatedRequestOptionsProvider] = None
|
|
64
|
+
error_handler: Optional[ErrorHandler] = None
|
|
65
|
+
api_budget: Optional[APIBudget] = None
|
|
66
|
+
disable_retries: bool = False
|
|
67
|
+
message_repository: MessageRepository = NoopMessageRepository()
|
|
68
|
+
use_cache: bool = False
|
|
69
|
+
_exit_on_rate_limit: bool = False
|
|
70
|
+
stream_response: bool = False
|
|
71
|
+
decoder: Decoder = field(default_factory=lambda: JsonDecoder(parameters={}))
|
|
72
|
+
|
|
73
|
+
def __post_init__(self, parameters: Mapping[str, Any]) -> None:
|
|
74
|
+
self._url_base = InterpolatedString.create(self.url_base, parameters=parameters)
|
|
75
|
+
self._path = InterpolatedString.create(
|
|
76
|
+
self.path if self.path else EmptyString, parameters=parameters
|
|
77
|
+
)
|
|
78
|
+
if self.request_options_provider is None:
|
|
79
|
+
self._request_options_provider = InterpolatedRequestOptionsProvider(
|
|
80
|
+
config=self.config, parameters=parameters
|
|
81
|
+
)
|
|
82
|
+
elif isinstance(self.request_options_provider, dict):
|
|
83
|
+
self._request_options_provider = InterpolatedRequestOptionsProvider(
|
|
84
|
+
config=self.config, **self.request_options_provider
|
|
85
|
+
)
|
|
86
|
+
else:
|
|
87
|
+
self._request_options_provider = self.request_options_provider
|
|
88
|
+
self._authenticator = self.authenticator or NoAuth(parameters=parameters)
|
|
89
|
+
self._http_method = (
|
|
90
|
+
HttpMethod[self.http_method] if isinstance(self.http_method, str) else self.http_method
|
|
91
|
+
)
|
|
92
|
+
self.error_handler = self.error_handler
|
|
93
|
+
self._parameters = parameters
|
|
94
|
+
|
|
95
|
+
if self.error_handler is not None and hasattr(self.error_handler, "backoff_strategies"):
|
|
96
|
+
backoff_strategies = self.error_handler.backoff_strategies # type: ignore
|
|
97
|
+
else:
|
|
98
|
+
backoff_strategies = None
|
|
99
|
+
|
|
100
|
+
self._http_client = HttpClient(
|
|
101
|
+
name=self.name,
|
|
102
|
+
logger=self.logger,
|
|
103
|
+
error_handler=self.error_handler,
|
|
104
|
+
api_budget=self.api_budget,
|
|
105
|
+
authenticator=self._authenticator,
|
|
106
|
+
use_cache=self.use_cache,
|
|
107
|
+
backoff_strategy=backoff_strategies,
|
|
108
|
+
disable_retries=self.disable_retries,
|
|
109
|
+
message_repository=self.message_repository,
|
|
110
|
+
)
|
|
111
|
+
|
|
112
|
+
@property
|
|
113
|
+
def exit_on_rate_limit(self) -> bool:
|
|
114
|
+
return self._exit_on_rate_limit
|
|
115
|
+
|
|
116
|
+
@exit_on_rate_limit.setter
|
|
117
|
+
def exit_on_rate_limit(self, value: bool) -> None:
|
|
118
|
+
self._exit_on_rate_limit = value
|
|
119
|
+
|
|
120
|
+
def get_authenticator(self) -> DeclarativeAuthenticator:
|
|
121
|
+
return self._authenticator
|
|
122
|
+
|
|
123
|
+
def get_url_base(
|
|
124
|
+
self,
|
|
125
|
+
*,
|
|
126
|
+
stream_state: Optional[StreamState] = None,
|
|
127
|
+
stream_slice: Optional[StreamSlice] = None,
|
|
128
|
+
next_page_token: Optional[Mapping[str, Any]] = None,
|
|
129
|
+
) -> str:
|
|
130
|
+
interpolation_context = get_interpolation_context(
|
|
131
|
+
stream_state=stream_state,
|
|
132
|
+
stream_slice=stream_slice,
|
|
133
|
+
next_page_token=next_page_token,
|
|
134
|
+
)
|
|
135
|
+
return str(self._url_base.eval(self.config, **interpolation_context))
|
|
136
|
+
|
|
137
|
+
def get_path(
|
|
138
|
+
self,
|
|
139
|
+
*,
|
|
140
|
+
stream_state: Optional[StreamState] = None,
|
|
141
|
+
stream_slice: Optional[StreamSlice] = None,
|
|
142
|
+
next_page_token: Optional[Mapping[str, Any]] = None,
|
|
143
|
+
) -> str:
|
|
144
|
+
interpolation_context = get_interpolation_context(
|
|
145
|
+
stream_state=stream_state,
|
|
146
|
+
stream_slice=stream_slice,
|
|
147
|
+
next_page_token=next_page_token,
|
|
148
|
+
)
|
|
149
|
+
path = str(self._path.eval(self.config, **interpolation_context))
|
|
150
|
+
return path.lstrip("/")
|
|
151
|
+
|
|
152
|
+
def get_method(self) -> HttpMethod:
|
|
153
|
+
return self._http_method
|
|
154
|
+
|
|
155
|
+
def get_request_params(
|
|
156
|
+
self,
|
|
157
|
+
*,
|
|
158
|
+
stream_state: Optional[StreamState] = None,
|
|
159
|
+
stream_slice: Optional[StreamSlice] = None,
|
|
160
|
+
next_page_token: Optional[Mapping[str, Any]] = None,
|
|
161
|
+
) -> MutableMapping[str, Any]:
|
|
162
|
+
return self._request_options_provider.get_request_params(
|
|
163
|
+
stream_state=stream_state,
|
|
164
|
+
stream_slice=stream_slice,
|
|
165
|
+
next_page_token=next_page_token,
|
|
166
|
+
)
|
|
167
|
+
|
|
168
|
+
def get_request_headers(
|
|
169
|
+
self,
|
|
170
|
+
*,
|
|
171
|
+
stream_state: Optional[StreamState] = None,
|
|
172
|
+
stream_slice: Optional[StreamSlice] = None,
|
|
173
|
+
next_page_token: Optional[Mapping[str, Any]] = None,
|
|
174
|
+
) -> Mapping[str, Any]:
|
|
175
|
+
return self._request_options_provider.get_request_headers(
|
|
176
|
+
stream_state=stream_state,
|
|
177
|
+
stream_slice=stream_slice,
|
|
178
|
+
next_page_token=next_page_token,
|
|
179
|
+
)
|
|
180
|
+
|
|
181
|
+
# fixing request options provider types has a lot of dependencies
|
|
182
|
+
def get_request_body_data( # type: ignore
|
|
183
|
+
self,
|
|
184
|
+
*,
|
|
185
|
+
stream_state: Optional[StreamState] = None,
|
|
186
|
+
stream_slice: Optional[StreamSlice] = None,
|
|
187
|
+
next_page_token: Optional[Mapping[str, Any]] = None,
|
|
188
|
+
) -> Union[Mapping[str, Any], str]:
|
|
189
|
+
return (
|
|
190
|
+
self._request_options_provider.get_request_body_data(
|
|
191
|
+
stream_state=stream_state,
|
|
192
|
+
stream_slice=stream_slice,
|
|
193
|
+
next_page_token=next_page_token,
|
|
194
|
+
)
|
|
195
|
+
or {}
|
|
196
|
+
)
|
|
197
|
+
|
|
198
|
+
# fixing request options provider types has a lot of dependencies
|
|
199
|
+
def get_request_body_json( # type: ignore
|
|
200
|
+
self,
|
|
201
|
+
*,
|
|
202
|
+
stream_state: Optional[StreamState] = None,
|
|
203
|
+
stream_slice: Optional[StreamSlice] = None,
|
|
204
|
+
next_page_token: Optional[Mapping[str, Any]] = None,
|
|
205
|
+
) -> Optional[Mapping[str, Any]]:
|
|
206
|
+
return self._request_options_provider.get_request_body_json(
|
|
207
|
+
stream_state=stream_state,
|
|
208
|
+
stream_slice=stream_slice,
|
|
209
|
+
next_page_token=next_page_token,
|
|
210
|
+
)
|
|
211
|
+
|
|
212
|
+
@property
|
|
213
|
+
def logger(self) -> logging.Logger:
|
|
214
|
+
return logging.getLogger(f"airbyte.HttpRequester.{self.name}")
|
|
215
|
+
|
|
216
|
+
def _get_request_options(
|
|
217
|
+
self,
|
|
218
|
+
stream_state: Optional[StreamState],
|
|
219
|
+
stream_slice: Optional[StreamSlice],
|
|
220
|
+
next_page_token: Optional[Mapping[str, Any]],
|
|
221
|
+
requester_method: Callable[..., Optional[Union[Mapping[str, Any], str]]],
|
|
222
|
+
auth_options_method: Callable[..., Optional[Union[Mapping[str, Any], str]]],
|
|
223
|
+
extra_options: Optional[Union[Mapping[str, Any], str]] = None,
|
|
224
|
+
) -> Union[Mapping[str, Any], str]:
|
|
225
|
+
"""
|
|
226
|
+
Get the request_option from the requester, the authenticator and extra_options passed in.
|
|
227
|
+
Raise a ValueError if there's a key collision
|
|
228
|
+
Returned merged mapping otherwise
|
|
229
|
+
"""
|
|
230
|
+
|
|
231
|
+
is_body_json = requester_method.__name__ == "get_request_body_json"
|
|
232
|
+
|
|
233
|
+
return combine_mappings(
|
|
234
|
+
[
|
|
235
|
+
requester_method(
|
|
236
|
+
stream_state=stream_state,
|
|
237
|
+
stream_slice=stream_slice,
|
|
238
|
+
next_page_token=next_page_token,
|
|
239
|
+
),
|
|
240
|
+
auth_options_method(),
|
|
241
|
+
extra_options,
|
|
242
|
+
],
|
|
243
|
+
allow_same_value_merge=is_body_json,
|
|
244
|
+
)
|
|
245
|
+
|
|
246
|
+
def _request_headers(
|
|
247
|
+
self,
|
|
248
|
+
stream_state: Optional[StreamState] = None,
|
|
249
|
+
stream_slice: Optional[StreamSlice] = None,
|
|
250
|
+
next_page_token: Optional[Mapping[str, Any]] = None,
|
|
251
|
+
extra_headers: Optional[Mapping[str, Any]] = None,
|
|
252
|
+
) -> Mapping[str, Any]:
|
|
253
|
+
"""
|
|
254
|
+
Specifies request headers.
|
|
255
|
+
Authentication headers will overwrite any overlapping headers returned from this method.
|
|
256
|
+
"""
|
|
257
|
+
headers = self._get_request_options(
|
|
258
|
+
stream_state,
|
|
259
|
+
stream_slice,
|
|
260
|
+
next_page_token,
|
|
261
|
+
self.get_request_headers,
|
|
262
|
+
self.get_authenticator().get_auth_header,
|
|
263
|
+
extra_headers,
|
|
264
|
+
)
|
|
265
|
+
if isinstance(headers, str):
|
|
266
|
+
raise ValueError("Request headers cannot be a string")
|
|
267
|
+
return {str(k): str(v) for k, v in headers.items()}
|
|
268
|
+
|
|
269
|
+
def _request_params(
|
|
270
|
+
self,
|
|
271
|
+
stream_state: Optional[StreamState],
|
|
272
|
+
stream_slice: Optional[StreamSlice],
|
|
273
|
+
next_page_token: Optional[Mapping[str, Any]],
|
|
274
|
+
extra_params: Optional[Mapping[str, Any]] = None,
|
|
275
|
+
) -> Mapping[str, Any]:
|
|
276
|
+
"""
|
|
277
|
+
Specifies the query parameters that should be set on an outgoing HTTP request given the inputs.
|
|
278
|
+
|
|
279
|
+
E.g: you might want to define query parameters for paging if next_page_token is not None.
|
|
280
|
+
"""
|
|
281
|
+
options = self._get_request_options(
|
|
282
|
+
stream_state,
|
|
283
|
+
stream_slice,
|
|
284
|
+
next_page_token,
|
|
285
|
+
self.get_request_params,
|
|
286
|
+
self.get_authenticator().get_request_params,
|
|
287
|
+
extra_params,
|
|
288
|
+
)
|
|
289
|
+
if isinstance(options, str):
|
|
290
|
+
raise ValueError("Request params cannot be a string")
|
|
291
|
+
|
|
292
|
+
for k, v in options.items():
|
|
293
|
+
if isinstance(v, (dict,)):
|
|
294
|
+
raise ValueError(
|
|
295
|
+
f"Invalid value for `{k}` parameter. The values of request params cannot be an object."
|
|
296
|
+
)
|
|
297
|
+
|
|
298
|
+
return options
|
|
299
|
+
|
|
300
|
+
def _request_body_data(
|
|
301
|
+
self,
|
|
302
|
+
stream_state: Optional[StreamState],
|
|
303
|
+
stream_slice: Optional[StreamSlice],
|
|
304
|
+
next_page_token: Optional[Mapping[str, Any]],
|
|
305
|
+
extra_body_data: Optional[Union[Mapping[str, Any], str]] = None,
|
|
306
|
+
) -> Optional[Union[Mapping[str, Any], str]]:
|
|
307
|
+
"""
|
|
308
|
+
Specifies how to populate the body of the request with a non-JSON payload.
|
|
309
|
+
|
|
310
|
+
If returns a ready text that it will be sent as is.
|
|
311
|
+
If returns a dict that it will be converted to a urlencoded form.
|
|
312
|
+
E.g. {"key1": "value1", "key2": "value2"} => "key1=value1&key2=value2"
|
|
313
|
+
|
|
314
|
+
At the same time only one of the 'request_body_data' and 'request_body_json' functions can be overridden.
|
|
315
|
+
"""
|
|
316
|
+
# Warning: use self.state instead of the stream_state passed as argument!
|
|
317
|
+
return self._get_request_options(
|
|
318
|
+
stream_state,
|
|
319
|
+
stream_slice,
|
|
320
|
+
next_page_token,
|
|
321
|
+
self.get_request_body_data,
|
|
322
|
+
self.get_authenticator().get_request_body_data,
|
|
323
|
+
extra_body_data,
|
|
324
|
+
)
|
|
325
|
+
|
|
326
|
+
def _request_body_json(
|
|
327
|
+
self,
|
|
328
|
+
stream_state: Optional[StreamState],
|
|
329
|
+
stream_slice: Optional[StreamSlice],
|
|
330
|
+
next_page_token: Optional[Mapping[str, Any]],
|
|
331
|
+
extra_body_json: Optional[Mapping[str, Any]] = None,
|
|
332
|
+
) -> Optional[Mapping[str, Any]]:
|
|
333
|
+
"""
|
|
334
|
+
Specifies how to populate the body of the request with a JSON payload.
|
|
335
|
+
|
|
336
|
+
At the same time only one of the 'request_body_data' and 'request_body_json' functions can be overridden.
|
|
337
|
+
"""
|
|
338
|
+
# Warning: use self.state instead of the stream_state passed as argument!
|
|
339
|
+
options = self._get_request_options(
|
|
340
|
+
stream_state,
|
|
341
|
+
stream_slice,
|
|
342
|
+
next_page_token,
|
|
343
|
+
self.get_request_body_json,
|
|
344
|
+
self.get_authenticator().get_request_body_json,
|
|
345
|
+
extra_body_json,
|
|
346
|
+
)
|
|
347
|
+
if isinstance(options, str):
|
|
348
|
+
raise ValueError("Request body json cannot be a string")
|
|
349
|
+
return options
|
|
350
|
+
|
|
351
|
+
@classmethod
|
|
352
|
+
def _join_url(cls, url_base: str, path: str) -> str:
|
|
353
|
+
"""
|
|
354
|
+
Joins a base URL with a given path and returns the resulting URL with any trailing slash removed.
|
|
355
|
+
|
|
356
|
+
This method ensures that there are no duplicate slashes when concatenating the base URL and the path,
|
|
357
|
+
which is useful when the full URL is provided from an interpolation context.
|
|
358
|
+
|
|
359
|
+
Args:
|
|
360
|
+
url_base (str): The base URL to which the path will be appended.
|
|
361
|
+
path (str): The path to join with the base URL.
|
|
362
|
+
|
|
363
|
+
Returns:
|
|
364
|
+
str: The resulting joined URL.
|
|
365
|
+
|
|
366
|
+
Note:
|
|
367
|
+
Related issue: https://github.com/airbytehq/airbyte-internal-issues/issues/11869
|
|
368
|
+
- If the path is an empty string or None, the method returns the base URL with any trailing slash removed.
|
|
369
|
+
|
|
370
|
+
Example:
|
|
371
|
+
1) _join_url("https://example.com/api/", "endpoint") >> 'https://example.com/api/endpoint'
|
|
372
|
+
2) _join_url("https://example.com/api", "/endpoint") >> 'https://example.com/api/endpoint'
|
|
373
|
+
3) _join_url("https://example.com/api/", "") >> 'https://example.com/api/'
|
|
374
|
+
4) _join_url("https://example.com/api", None) >> 'https://example.com/api'
|
|
375
|
+
"""
|
|
376
|
+
|
|
377
|
+
# return a full-url if provided directly from interpolation context
|
|
378
|
+
if path == EmptyString or path is None:
|
|
379
|
+
return url_base
|
|
380
|
+
else:
|
|
381
|
+
# since we didn't provide a full-url, the url_base might not have a trailing slash
|
|
382
|
+
# so we join the url_base and path correctly
|
|
383
|
+
if not url_base.endswith("/"):
|
|
384
|
+
url_base += "/"
|
|
385
|
+
|
|
386
|
+
return urljoin(url_base, path)
|
|
387
|
+
|
|
388
|
+
def send_request(
|
|
389
|
+
self,
|
|
390
|
+
stream_state: Optional[StreamState] = None,
|
|
391
|
+
stream_slice: Optional[StreamSlice] = None,
|
|
392
|
+
next_page_token: Optional[Mapping[str, Any]] = None,
|
|
393
|
+
path: Optional[str] = None,
|
|
394
|
+
request_headers: Optional[Mapping[str, Any]] = None,
|
|
395
|
+
request_params: Optional[Mapping[str, Any]] = None,
|
|
396
|
+
request_body_data: Optional[Union[Mapping[str, Any], str]] = None,
|
|
397
|
+
request_body_json: Optional[Mapping[str, Any]] = None,
|
|
398
|
+
log_formatter: Optional[Callable[[requests.Response], Any]] = None,
|
|
399
|
+
) -> Optional[requests.Response]:
|
|
400
|
+
request, response = self._http_client.send_request(
|
|
401
|
+
http_method=self.get_method().value,
|
|
402
|
+
url=self._join_url(
|
|
403
|
+
self.get_url_base(
|
|
404
|
+
stream_state=stream_state,
|
|
405
|
+
stream_slice=stream_slice,
|
|
406
|
+
next_page_token=next_page_token,
|
|
407
|
+
),
|
|
408
|
+
path
|
|
409
|
+
or self.get_path(
|
|
410
|
+
stream_state=stream_state,
|
|
411
|
+
stream_slice=stream_slice,
|
|
412
|
+
next_page_token=next_page_token,
|
|
413
|
+
),
|
|
414
|
+
),
|
|
415
|
+
request_kwargs={"stream": self.stream_response},
|
|
416
|
+
headers=self._request_headers(
|
|
417
|
+
stream_state, stream_slice, next_page_token, request_headers
|
|
418
|
+
),
|
|
419
|
+
params=self._request_params(
|
|
420
|
+
stream_state, stream_slice, next_page_token, request_params
|
|
421
|
+
),
|
|
422
|
+
json=self._request_body_json(
|
|
423
|
+
stream_state, stream_slice, next_page_token, request_body_json
|
|
424
|
+
),
|
|
425
|
+
data=self._request_body_data(
|
|
426
|
+
stream_state, stream_slice, next_page_token, request_body_data
|
|
427
|
+
),
|
|
428
|
+
dedupe_query_params=True,
|
|
429
|
+
log_formatter=log_formatter,
|
|
430
|
+
exit_on_rate_limit=self._exit_on_rate_limit,
|
|
431
|
+
)
|
|
432
|
+
|
|
433
|
+
return response
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
#
|
|
2
|
+
# Copyright (c) 2023 Airbyte, Inc., all rights reserved.
|
|
3
|
+
#
|
|
4
|
+
|
|
5
|
+
from airbyte_cdk.sources.declarative.requesters.paginators.default_paginator import (
|
|
6
|
+
DefaultPaginator,
|
|
7
|
+
PaginatorTestReadDecorator,
|
|
8
|
+
)
|
|
9
|
+
from airbyte_cdk.sources.declarative.requesters.paginators.no_pagination import NoPagination
|
|
10
|
+
from airbyte_cdk.sources.declarative.requesters.paginators.paginator import Paginator
|
|
11
|
+
from airbyte_cdk.sources.declarative.requesters.paginators.strategies.pagination_strategy import (
|
|
12
|
+
PaginationStrategy,
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
__all__ = [
|
|
16
|
+
"DefaultPaginator",
|
|
17
|
+
"NoPagination",
|
|
18
|
+
"PaginationStrategy",
|
|
19
|
+
"Paginator",
|
|
20
|
+
"PaginatorTestReadDecorator",
|
|
21
|
+
]
|