-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Low-Code CDK] Separate request path from RequestOption component #22398
Merged
Merged
Changes from 4 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
4d41630
split apart path from RequestOption and fix usages and cleanup the code
brianjlai 368c262
replace usage of path with RequestPath and get rid of default to Requ…
brianjlai d803b82
fix bug where stream_slice_field was used in outbound request instead…
brianjlai ce06c9e
organize yaml schema names and update documentation for RequestOption…
brianjlai e97dde1
clean up tests
brianjlai 013e020
regenerate models
brianjlai 504b774
Merge branch 'low_code_cdk_to_beta' into brian/split_request_option
brianjlai File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
|
||
from dataclasses import InitVar, dataclass | ||
from enum import Enum | ||
from typing import Any, Mapping, Optional | ||
from typing import Any, Mapping | ||
|
||
|
||
class RequestOptionType(Enum): | ||
|
@@ -14,7 +14,6 @@ class RequestOptionType(Enum): | |
|
||
request_parameter = "request_parameter" | ||
header = "header" | ||
path = "path" | ||
body_data = "body_data" | ||
body_json = "body_json" | ||
|
||
|
@@ -25,21 +24,10 @@ class RequestOption: | |
Describes an option to set on a request | ||
|
||
Attributes: | ||
field_name (str): Describes the name of the parameter to inject. None if option_type == path. Required otherwise. | ||
inject_into (RequestOptionType): Describes where in the HTTP request to inject the parameter | ||
field_name (Optional[str]): Describes the name of the parameter to inject. None if option_type == path. Required otherwise. | ||
""" | ||
|
||
field_name: str | ||
inject_into: RequestOptionType | ||
parameters: InitVar[Mapping[str, Any]] | ||
field_name: Optional[str] = None | ||
|
||
def __post_init__(self, parameters: Mapping[str, Any]): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In the original implementation, only path RequestOption could skip |
||
if self.inject_into == RequestOptionType.path: | ||
if self.field_name is not None: | ||
raise ValueError(f"RequestOption with path cannot have a field name. Get {self.field_name}") | ||
elif self.field_name is None: | ||
raise ValueError(f"RequestOption expected field name for type {self.inject_into}") | ||
|
||
def is_path(self) -> bool: | ||
"""Returns true if the parameter is the path to send the request to""" | ||
return self.inject_into == RequestOptionType.path |
15 changes: 15 additions & 0 deletions
15
airbyte-cdk/python/airbyte_cdk/sources/declarative/requesters/request_path.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# | ||
# Copyright (c) 2022 Airbyte, Inc., all rights reserved. | ||
# | ||
|
||
from dataclasses import InitVar, dataclass | ||
from typing import Any, Mapping | ||
|
||
|
||
@dataclass | ||
class RequestPath: | ||
""" | ||
Describes that a component value should be inserted into the path | ||
""" | ||
|
||
parameters: InitVar[Mapping[str, Any]] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
getting rid of a default type because this could be a
RequestPath
now