1
0
mirror of synced 2026-01-21 15:06:13 -05:00
Files
airbyte/airbyte-cdk/python/airbyte_cdk/sources/declarative/requesters/request_option.py
Artem Inzhyyants 0954ad3d3a Airbyte CDK: add interpolation for request options (#35485)
Signed-off-by: Artem Inzhyyants <artem.inzhyyants@gmail.com>
Co-authored-by: Alexandre Girard <alexandre@airbyte.io>
2024-02-22 19:40:44 +01:00

39 lines
1.0 KiB
Python

#
# Copyright (c) 2023 Airbyte, Inc., all rights reserved.
#
from dataclasses import InitVar, dataclass
from enum import Enum
from typing import Any, Mapping, Union
from airbyte_cdk.sources.declarative.interpolation.interpolated_string import InterpolatedString
class RequestOptionType(Enum):
"""
Describes where to set a value on a request
"""
request_parameter = "request_parameter"
header = "header"
body_data = "body_data"
body_json = "body_json"
@dataclass
class RequestOption:
"""
Describes an option to set on a request
Attributes:
field_name (str): Describes the name of the parameter to inject
inject_into (RequestOptionType): Describes where in the HTTP request to inject the parameter
"""
field_name: Union[InterpolatedString, str]
inject_into: RequestOptionType
parameters: InitVar[Mapping[str, Any]]
def __post_init__(self, parameters: Mapping[str, Any]) -> None:
self.field_name = InterpolatedString.create(self.field_name, parameters=parameters)