-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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 connectors]: Assert there are no custom top-level fields #15489
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
849886c
move components to definitions field
girarda 49fc1f2
Also update the references
girarda 4bd1745
validate the top level fields and add version
girarda ae359be
raise exception on unknown fields
girarda 971eada
newline
girarda b6efb0e
unit tests
girarda 526d4ed
Merge branch 'master' into alex/lowcodeDefinitionsField
girarda 9bcfaef
set version to 0.1.0
girarda bb9fcb6
newline
girarda 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
50 changes: 50 additions & 0 deletions
50
airbyte-cdk/python/unit_tests/sources/declarative/test_yaml_declarative_source.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,50 @@ | ||
# | ||
# Copyright (c) 2022 Airbyte, Inc., all rights reserved. | ||
# | ||
|
||
import os | ||
import tempfile | ||
import unittest | ||
|
||
from airbyte_cdk.sources.declarative.exceptions import InvalidConnectorDefinitionException | ||
from airbyte_cdk.sources.declarative.yaml_declarative_source import YamlDeclarativeSource | ||
|
||
|
||
class TestYamlDeclarativeSource(unittest.TestCase): | ||
def test_source_is_created_if_toplevel_fields_are_known(self): | ||
content = """ | ||
version: "version" | ||
streams: "streams" | ||
check: "check" | ||
""" | ||
temporary_file = TestFileContent(content) | ||
YamlDeclarativeSource(temporary_file.filename) | ||
|
||
def test_source_is_not_created_if_toplevel_fields_are_unknown(self): | ||
content = """ | ||
version: "version" | ||
streams: "streams" | ||
check: "check" | ||
not_a_valid_field: "error" | ||
""" | ||
temporary_file = TestFileContent(content) | ||
with self.assertRaises(InvalidConnectorDefinitionException): | ||
YamlDeclarativeSource(temporary_file.filename) | ||
|
||
|
||
class TestFileContent: | ||
def __init__(self, content): | ||
self.file = tempfile.NamedTemporaryFile(mode="w", delete=False) | ||
|
||
with self.file as f: | ||
f.write(content) | ||
|
||
@property | ||
def filename(self): | ||
return self.file.name | ||
|
||
def __enter__(self): | ||
return self | ||
|
||
def __exit__(self, type, value, traceback): | ||
os.unlink(self.filename) |
74 changes: 38 additions & 36 deletions
74
...emplates/source-configuration-based/source_{{snakeCase name}}/{{snakeCase name}}.yaml.hbs
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 |
---|---|---|
@@ -1,42 +1,44 @@ | ||
schema_loader: | ||
type: JsonSchema | ||
file_path: "./source_{{snakeCase name}}/schemas/\{{ options['name'] }}.json" | ||
selector: | ||
type: RecordSelector | ||
extractor: | ||
type: JelloExtractor | ||
transform: "_" | ||
requester: | ||
type: HttpRequester | ||
name: "\{{ options['name'] }}" | ||
http_method: "GET" | ||
authenticator: | ||
type: BearerAuthenticator | ||
api_token: "\{{ config['api_key'] }}" | ||
retriever: | ||
type: SimpleRetriever | ||
$options: | ||
url_base: TODO "your_api_base_url" | ||
name: "\{{ options['name'] }}" | ||
primary_key: "\{{ options['primary_key'] }}" | ||
record_selector: | ||
$ref: "*ref(selector)" | ||
paginator: | ||
type: NoPagination | ||
customers_stream: | ||
type: DeclarativeStream | ||
$options: | ||
name: "customers" | ||
primary_key: "id" | ||
version: "0.1.0" | ||
|
||
definitions: | ||
schema_loader: | ||
$ref: "*ref(schema_loader)" | ||
type: JsonSchema | ||
file_path: "./source_{{snakeCase name}}/schemas/\{{ options['name'] }}.json" | ||
selector: | ||
type: RecordSelector | ||
extractor: | ||
type: JelloExtractor | ||
transform: "_" | ||
requester: | ||
type: HttpRequester | ||
name: "\{{ options['name'] }}" | ||
http_method: "GET" | ||
authenticator: | ||
type: BearerAuthenticator | ||
api_token: "\{{ config['api_key'] }}" | ||
retriever: | ||
$ref: "*ref(retriever)" | ||
requester: | ||
$ref: "*ref(requester)" | ||
path: TODO "your_endpoint_path" | ||
type: SimpleRetriever | ||
$options: | ||
url_base: TODO "your_api_base_url" | ||
name: "\{{ options['name'] }}" | ||
primary_key: "\{{ options['primary_key'] }}" | ||
record_selector: | ||
$ref: "*ref(definitions.selector)" | ||
paginator: | ||
type: NoPagination | ||
|
||
streams: | ||
- "*ref(customers_stream)" | ||
- type: DeclarativeStream | ||
$options: | ||
name: "customers" | ||
primary_key: "id" | ||
schema_loader: | ||
$ref: "*ref(definitions.schema_loader)" | ||
retriever: | ||
$ref: "*ref(definitions.retriever)" | ||
requester: | ||
$ref: "*ref(definitions.requester)" | ||
path: TODO "your_endpoint_path" | ||
check: | ||
type: CheckStream | ||
stream_names: ["customers"] |
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.
renamed the file