From ef12dd11286daef161b4dc6cb070778b5d2ef933 Mon Sep 17 00:00:00 2001 From: Sherif Nada Date: Sun, 26 Sep 2021 23:20:49 -0700 Subject: [PATCH 1/7] save --- airbyte-api/src/main/openapi/config.yaml | 42 +++++++++++++++---- .../airbyte_protocol/airbyte_protocol.yaml | 40 +++++++++++++++--- .../api/generated-api-html/index.html | 16 +++---- 3 files changed, 77 insertions(+), 21 deletions(-) diff --git a/airbyte-api/src/main/openapi/config.yaml b/airbyte-api/src/main/openapi/config.yaml index c1e94241c04a..b59f102a15ff 100644 --- a/airbyte-api/src/main/openapi/config.yaml +++ b/airbyte-api/src/main/openapi/config.yaml @@ -1940,22 +1940,50 @@ components: type: string enum: ["oauth2.0"] # Future auth types should be added here oauth2Specification: - "$ref": "#/components/schemas/OAuth2Specification" + description: If the connector supports OAuth, this field should be non-null. OAuth2Specification: description: An object containing any metadata needed to describe this connector's Oauth flow type: object + required: + - rootObject + - oauthFlowInitParameters + - oauthFlowOutputParameters properties: + rootObject: + description: + "A list of strings representing a pointer to the root object which contains any oauth parameters in the ConnectorSpecification. + + Examples: + + if oauth parameters were contained inside the top level, rootObject=[] + If they were nested inside another object {'credentials': {'app_id' etc...}, rootObject=['credentials'] + If they were inside a oneOf {'switch': {oneOf: [{client_id...}, {non_oauth_param]}}, rootObject=['switch', 0] + " + type: array + items: + type: string oauthFlowInitParameters: description: - "Pointers to the fields in the ConnectorSpecification which are needed to obtain the initial refresh/access tokens for the OAuth flow. - Each inner array represents the path in the ConnectorSpecification of the referenced field. + "Pointers to the fields in the rootObject needed to obtain the initial refresh/access tokens for the OAuth flow. + Each inner array represents the path in the rootObject of the referenced field. For example. - Assume the ConnectorSpecification contains params 'app_secret', 'app_id' which are needed to get the initial refresh token. - If they are not nested in the config, then the array would look like this [['app_secret'], ['app_id']] - If they are nested inside, say, an object called 'auth_params' then this array would be [['auth_params', 'app_secret'], ['auth_params', 'app_id']]" + Assume the rootObject contains params 'app_secret', 'app_id' which are needed to get the initial refresh token. + If they are not nested in the rootObject, then the array would look like this [['app_secret'], ['app_id']] + If they are nested inside an object called 'auth_params' then this array would be [['auth_params', 'app_secret'], ['auth_params', 'app_id']]" + type: array + items: + description: A list of strings denoting a pointer into the rootObject for where to find this property + type: array + items: + type: string + oauthFlowOutputParameters: + description: + "Pointers to the fields in the rootObject which can be populated from successfully completing the oauth flow using the init parameters. + This is typically a refresh/access token. + Each inner array represents the path in the rootObject of the referenced field." type: array items: - description: A list of strings which describes each parameter's path inside the ConnectionSpecification + description: A list of strings denoting a pointer into the rootObject for where to find this property type: array items: type: string diff --git a/airbyte-protocol/models/src/main/resources/airbyte_protocol/airbyte_protocol.yaml b/airbyte-protocol/models/src/main/resources/airbyte_protocol/airbyte_protocol.yaml index d21aac6d9455..b708ac1a304d 100644 --- a/airbyte-protocol/models/src/main/resources/airbyte_protocol/airbyte_protocol.yaml +++ b/airbyte-protocol/models/src/main/resources/airbyte_protocol/airbyte_protocol.yaml @@ -211,18 +211,46 @@ definitions: OAuth2Specification: description: An object containing any metadata needed to describe this connector's Oauth flow type: object + required: + - rootObject + - oauthFlowInitParameters + - oauthFlowOutputParameters properties: + rootObject: + description: + "A list of strings representing a pointer to the root object which contains any oauth parameters in the ConnectorSpecification. + + Examples: + + if oauth parameters were contained inside the top level, rootObject=[] + If they were nested inside another object {'credentials': {'app_id' etc...}, rootObject=['credentials'] + If they were inside a oneOf {'switch': {oneOf: [{client_id...}, {non_oauth_param]}}, rootObject=['switch', 0] + " + type: array + items: + type: string oauthFlowInitParameters: description: - "Pointers to the fields in the ConnectorSpecification which are needed to obtain the initial refresh/access tokens for the OAuth flow. - Each inner array represents the path in the ConnectorSpecification of the referenced field. + "Pointers to the fields in the rootObject needed to obtain the initial refresh/access tokens for the OAuth flow. + Each inner array represents the path in the rootObject of the referenced field. For example. - Assume the ConnectorSpecification contains params 'app_secret', 'app_id' which are needed to get the initial refresh token. - If they are not nested in the config, then the array would look like this [['app_secret'], ['app_id']] - If they are nested inside, say, an object called 'auth_params' then this array would be [['auth_params', 'app_secret'], ['auth_params', 'app_id']]" + Assume the rootObject contains params 'app_secret', 'app_id' which are needed to get the initial refresh token. + If they are not nested in the rootObject, then the array would look like this [['app_secret'], ['app_id']] + If they are nested inside an object called 'auth_params' then this array would be [['auth_params', 'app_secret'], ['auth_params', 'app_id']]" + type: array + items: + description: A list of strings denoting a pointer into the rootObject for where to find this property + type: array + items: + type: string + oauthFlowOutputParameters: + description: + "Pointers to the fields in the rootObject which can be populated from successfully completing the oauth flow using the init parameters. + This is typically a refresh/access token. + Each inner array represents the path in the rootObject of the referenced field." type: array items: - description: A list of strings which describe the path inside a JSON object for finding the + description: A list of strings denoting a pointer into the rootObject for where to find this property type: array items: type: string diff --git a/docs/reference/api/generated-api-html/index.html b/docs/reference/api/generated-api-html/index.html index 74da34aa49be..e1ee37818163 100644 --- a/docs/reference/api/generated-api-html/index.html +++ b/docs/reference/api/generated-api-html/index.html @@ -2299,9 +2299,7 @@

Example data

"destinationDefinitionId" : "046b6c7f-0b8a-43b9-b35d-6489e6daee91", "authSpecification" : { "auth_type" : "oauth2.0", - "oauth2Specification" : { - "oauthFlowInitParameters" : [ [ "oauthFlowInitParameters", "oauthFlowInitParameters" ], [ "oauthFlowInitParameters", "oauthFlowInitParameters" ] ] - } + "oauth2Specification" : "" }, "jobInfo" : { "createdAt" : 0, @@ -4650,9 +4648,7 @@

Example data

"sourceDefinitionId" : "046b6c7f-0b8a-43b9-b35d-6489e6daee91", "authSpecification" : { "auth_type" : "oauth2.0", - "oauth2Specification" : { - "oauthFlowInitParameters" : [ [ "oauthFlowInitParameters", "oauthFlowInitParameters" ], [ "oauthFlowInitParameters", "oauthFlowInitParameters" ] ] - } + "oauth2Specification" : "" }, "jobInfo" : { "createdAt" : 0, @@ -6462,7 +6458,7 @@

AuthSpecification - auth_type (optional)
Enum:
oauth2.0
-
oauth2Specification (optional)
+
oauth2Specification (optional)
oas_any_type_not_mapped If the connector supports OAuth, this field should be non-null.
@@ -6967,7 +6963,11 @@

NotificationType - OAuth2Specification - Up

An object containing any metadata needed to describe this connector's Oauth flow
-
oauthFlowInitParameters (optional)
array[array[String]] Pointers to the fields in the ConnectorSpecification which are needed to obtain the initial refresh/access tokens for the OAuth flow. Each inner array represents the path in the ConnectorSpecification of the referenced field. For example. Assume the ConnectorSpecification contains params 'app_secret', 'app_id' which are needed to get the initial refresh token. If they are not nested in the config, then the array would look like this [['app_secret'], ['app_id']] If they are nested inside, say, an object called 'auth_params' then this array would be [['auth_params', 'app_secret'], ['auth_params', 'app_id']]
+
rootObject
array[String] A list of strings representing a pointer to the root object which contains any oauth parameters in the ConnectorSpecification. +Examples: +if oauth parameters were contained inside the top level, rootObject=[] If they were nested inside another object {'credentials': {'app_id' etc...}, rootObject=['credentials'] If they were inside a oneOf {'switch': {oneOf: [{client_id...}, {non_oauth_param]}}, rootObject=['switch', 0]
+
oauthFlowInitParameters
array[array[String]] Pointers to the fields in the rootObject needed to obtain the initial refresh/access tokens for the OAuth flow. Each inner array represents the path in the rootObject of the referenced field. For example. Assume the rootObject contains params 'app_secret', 'app_id' which are needed to get the initial refresh token. If they are not nested in the rootObject, then the array would look like this [['app_secret'], ['app_id']] If they are nested inside an object called 'auth_params' then this array would be [['auth_params', 'app_secret'], ['auth_params', 'app_id']]
+
oauthFlowOutputParameters
array[array[String]] Pointers to the fields in the rootObject which can be populated from successfully completing the oauth flow using the init parameters. This is typically a refresh/access token. Each inner array represents the path in the rootObject of the referenced field.
From dfd957f2b7a8975d23475c0ce8d5bbb651629e74 Mon Sep 17 00:00:00 2001 From: Sherif Nada Date: Sun, 26 Sep 2021 23:45:04 -0700 Subject: [PATCH 2/7] add tests --- .../converters/OauthModelConverter.java | 6 +- .../converters/OauthModelConverterTest.java | 71 +++++++++++++++++++ 2 files changed, 76 insertions(+), 1 deletion(-) create mode 100644 airbyte-server/src/test/java/io/airbyte/server/converters/OauthModelConverterTest.java diff --git a/airbyte-server/src/main/java/io/airbyte/server/converters/OauthModelConverter.java b/airbyte-server/src/main/java/io/airbyte/server/converters/OauthModelConverter.java index b86ee4e1f45f..e1623d049336 100644 --- a/airbyte-server/src/main/java/io/airbyte/server/converters/OauthModelConverter.java +++ b/airbyte-server/src/main/java/io/airbyte/server/converters/OauthModelConverter.java @@ -27,6 +27,7 @@ import io.airbyte.api.model.AuthSpecification; import io.airbyte.api.model.OAuth2Specification; import io.airbyte.protocol.models.ConnectorSpecification; + import java.util.Optional; public class OauthModelConverter { @@ -41,7 +42,10 @@ public static Optional getAuthSpec(ConnectorSpecification spe if (incomingAuthSpec.getAuthType() == io.airbyte.protocol.models.AuthSpecification.AuthType.OAUTH_2_0) { authSpecification.authType(AuthSpecification.AuthTypeEnum.OAUTH2_0) .oauth2Specification(new OAuth2Specification() - .oauthFlowInitParameters(incomingAuthSpec.getOauth2Specification().getOauthFlowInitParameters())); + .rootObject(incomingAuthSpec.getOauth2Specification().getRootObject()) + .oauthFlowInitParameters(incomingAuthSpec.getOauth2Specification().getOauthFlowInitParameters()) + .oauthFlowOutputParameters(incomingAuthSpec.getOauth2Specification().getOauthFlowOutputParameters()) + ); } return Optional.ofNullable(authSpecification); diff --git a/airbyte-server/src/test/java/io/airbyte/server/converters/OauthModelConverterTest.java b/airbyte-server/src/test/java/io/airbyte/server/converters/OauthModelConverterTest.java new file mode 100644 index 000000000000..dfad8b698b16 --- /dev/null +++ b/airbyte-server/src/test/java/io/airbyte/server/converters/OauthModelConverterTest.java @@ -0,0 +1,71 @@ +package io.airbyte.server.converters; + +import io.airbyte.commons.json.Jsons; +import io.airbyte.protocol.models.AuthSpecification; +import io.airbyte.protocol.models.ConnectorSpecification; +import io.airbyte.protocol.models.OAuth2Specification; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; + +import java.util.List; +import java.util.Optional; +import java.util.stream.Stream; + +import static org.junit.jupiter.api.Assertions.*; + +class OauthModelConverterTest { + + private static Stream testProvider() { + return Stream.of( + // all fields filled out with nesting + Arguments.of( + List.of(List.of("init1"), List.of("init2-1", "init2-2")), + List.of(List.of("output1"), List.of("output2-1", "output2-2")), + List.of("path")), + // init params only + Arguments.of( + List.of(List.of("init1"), List.of("init2-1", "init2-2")), + List.of(List.of()), + List.of()), + // output params only + Arguments.of( + List.of(List.of()), + List.of(List.of("output1"), List.of("output2-1", "output2-2")), + List.of()), + // rootObject only + Arguments.of( + List.of(List.of()), + List.of(List.of()), + List.of("path")) + ); + } + + @ParameterizedTest + @MethodSource("testProvider") + public void testIt(List> initParams, List> outputParams, List rootObject) { + ConnectorSpecification input = new ConnectorSpecification().withAuthSpecification( + new AuthSpecification() + .withAuthType(AuthSpecification.AuthType.OAUTH_2_0) + .withOauth2Specification(new OAuth2Specification() + .withOauthFlowInitParameters(initParams) + .withOauthFlowOutputParameters(outputParams) + .withRootObject(rootObject) + ) + ); + + io.airbyte.api.model.AuthSpecification expected = new io.airbyte.api.model.AuthSpecification() + .authType(io.airbyte.api.model.AuthSpecification.AuthTypeEnum.OAUTH2_0) + .oauth2Specification( + new io.airbyte.api.model.OAuth2Specification() + .oauthFlowInitParameters(initParams) + .oauthFlowOutputParameters(outputParams) + .rootObject(rootObject) + ); + + Optional authSpec = OauthModelConverter.getAuthSpec(input); + assertTrue(authSpec.isPresent()); + assertEquals(expected, authSpec.get()); + } +} From a408cac08860201796a1d31c6cf8a7ff428e6854 Mon Sep 17 00:00:00 2001 From: Sherif Nada Date: Mon, 27 Sep 2021 01:40:56 -0700 Subject: [PATCH 3/7] fix typo --- airbyte-api/src/main/openapi/config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/airbyte-api/src/main/openapi/config.yaml b/airbyte-api/src/main/openapi/config.yaml index b59f102a15ff..ddcf9c8f8043 100644 --- a/airbyte-api/src/main/openapi/config.yaml +++ b/airbyte-api/src/main/openapi/config.yaml @@ -1940,7 +1940,7 @@ components: type: string enum: ["oauth2.0"] # Future auth types should be added here oauth2Specification: - description: If the connector supports OAuth, this field should be non-null. + "$ref": "#/components/schemas/OAuth2Specification" OAuth2Specification: description: An object containing any metadata needed to describe this connector's Oauth flow type: object From cf551032399f9779823ffe7f6a5ad402a8ed8ebe Mon Sep 17 00:00:00 2001 From: Christophe Duong Date: Mon, 27 Sep 2021 11:18:55 +0200 Subject: [PATCH 4/7] Format code --- .../converters/OauthModelConverter.java | 4 +- .../converters/OauthModelConverterTest.java | 48 +++++++++++++------ 2 files changed, 34 insertions(+), 18 deletions(-) diff --git a/airbyte-server/src/main/java/io/airbyte/server/converters/OauthModelConverter.java b/airbyte-server/src/main/java/io/airbyte/server/converters/OauthModelConverter.java index e1623d049336..9b5d1246520a 100644 --- a/airbyte-server/src/main/java/io/airbyte/server/converters/OauthModelConverter.java +++ b/airbyte-server/src/main/java/io/airbyte/server/converters/OauthModelConverter.java @@ -27,7 +27,6 @@ import io.airbyte.api.model.AuthSpecification; import io.airbyte.api.model.OAuth2Specification; import io.airbyte.protocol.models.ConnectorSpecification; - import java.util.Optional; public class OauthModelConverter { @@ -44,8 +43,7 @@ public static Optional getAuthSpec(ConnectorSpecification spe .oauth2Specification(new OAuth2Specification() .rootObject(incomingAuthSpec.getOauth2Specification().getRootObject()) .oauthFlowInitParameters(incomingAuthSpec.getOauth2Specification().getOauthFlowInitParameters()) - .oauthFlowOutputParameters(incomingAuthSpec.getOauth2Specification().getOauthFlowOutputParameters()) - ); + .oauthFlowOutputParameters(incomingAuthSpec.getOauth2Specification().getOauthFlowOutputParameters())); } return Optional.ofNullable(authSpecification); diff --git a/airbyte-server/src/test/java/io/airbyte/server/converters/OauthModelConverterTest.java b/airbyte-server/src/test/java/io/airbyte/server/converters/OauthModelConverterTest.java index dfad8b698b16..8d9ce0ac4000 100644 --- a/airbyte-server/src/test/java/io/airbyte/server/converters/OauthModelConverterTest.java +++ b/airbyte-server/src/test/java/io/airbyte/server/converters/OauthModelConverterTest.java @@ -1,19 +1,40 @@ +/* + * MIT License + * + * Copyright (c) 2020 Airbyte + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + package io.airbyte.server.converters; -import io.airbyte.commons.json.Jsons; +import static org.junit.jupiter.api.Assertions.*; + import io.airbyte.protocol.models.AuthSpecification; import io.airbyte.protocol.models.ConnectorSpecification; import io.airbyte.protocol.models.OAuth2Specification; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.params.ParameterizedTest; -import org.junit.jupiter.params.provider.Arguments; -import org.junit.jupiter.params.provider.MethodSource; - import java.util.List; import java.util.Optional; import java.util.stream.Stream; - -import static org.junit.jupiter.api.Assertions.*; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; class OauthModelConverterTest { @@ -38,8 +59,7 @@ private static Stream testProvider() { Arguments.of( List.of(List.of()), List.of(List.of()), - List.of("path")) - ); + List.of("path"))); } @ParameterizedTest @@ -51,9 +71,7 @@ public void testIt(List> initParams, List> outputParam .withOauth2Specification(new OAuth2Specification() .withOauthFlowInitParameters(initParams) .withOauthFlowOutputParameters(outputParams) - .withRootObject(rootObject) - ) - ); + .withRootObject(rootObject))); io.airbyte.api.model.AuthSpecification expected = new io.airbyte.api.model.AuthSpecification() .authType(io.airbyte.api.model.AuthSpecification.AuthTypeEnum.OAUTH2_0) @@ -61,11 +79,11 @@ public void testIt(List> initParams, List> outputParam new io.airbyte.api.model.OAuth2Specification() .oauthFlowInitParameters(initParams) .oauthFlowOutputParameters(outputParams) - .rootObject(rootObject) - ); + .rootObject(rootObject)); Optional authSpec = OauthModelConverter.getAuthSpec(input); assertTrue(authSpec.isPresent()); assertEquals(expected, authSpec.get()); } + } From 32ac12872a96e417cd4b82fa2044522ff224b676 Mon Sep 17 00:00:00 2001 From: Christophe Duong Date: Mon, 27 Sep 2021 11:44:28 +0200 Subject: [PATCH 5/7] Regenerate docs --- docs/reference/api/generated-api-html/index.html | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/docs/reference/api/generated-api-html/index.html b/docs/reference/api/generated-api-html/index.html index e1ee37818163..9738ee68136b 100644 --- a/docs/reference/api/generated-api-html/index.html +++ b/docs/reference/api/generated-api-html/index.html @@ -2299,7 +2299,11 @@

Example data

"destinationDefinitionId" : "046b6c7f-0b8a-43b9-b35d-6489e6daee91", "authSpecification" : { "auth_type" : "oauth2.0", - "oauth2Specification" : "" + "oauth2Specification" : { + "oauthFlowOutputParameters" : [ [ "oauthFlowOutputParameters", "oauthFlowOutputParameters" ], [ "oauthFlowOutputParameters", "oauthFlowOutputParameters" ] ], + "rootObject" : [ "rootObject", "rootObject" ], + "oauthFlowInitParameters" : [ [ "oauthFlowInitParameters", "oauthFlowInitParameters" ], [ "oauthFlowInitParameters", "oauthFlowInitParameters" ] ] + } }, "jobInfo" : { "createdAt" : 0, @@ -4648,7 +4652,11 @@

Example data

"sourceDefinitionId" : "046b6c7f-0b8a-43b9-b35d-6489e6daee91", "authSpecification" : { "auth_type" : "oauth2.0", - "oauth2Specification" : "" + "oauth2Specification" : { + "oauthFlowOutputParameters" : [ [ "oauthFlowOutputParameters", "oauthFlowOutputParameters" ], [ "oauthFlowOutputParameters", "oauthFlowOutputParameters" ] ], + "rootObject" : [ "rootObject", "rootObject" ], + "oauthFlowInitParameters" : [ [ "oauthFlowInitParameters", "oauthFlowInitParameters" ], [ "oauthFlowInitParameters", "oauthFlowInitParameters" ] ] + } }, "jobInfo" : { "createdAt" : 0, @@ -6458,7 +6466,7 @@

AuthSpecification - auth_type (optional)

Enum:
oauth2.0
-
oauth2Specification (optional)
oas_any_type_not_mapped If the connector supports OAuth, this field should be non-null.
+
oauth2Specification (optional)
From 558264002ef805a678080835c6e65752462d0842 Mon Sep 17 00:00:00 2001 From: Christophe Duong Date: Mon, 27 Sep 2021 11:45:13 +0200 Subject: [PATCH 6/7] Format code --- .../python/airbyte_cdk/models/airbyte_protocol.py | 14 +++++++++++--- .../airbyte_protocol/models/airbyte_protocol.py | 14 +++++++++++--- .../unit_tests/test_incremental_streams.py | 3 +-- 3 files changed, 23 insertions(+), 8 deletions(-) diff --git a/airbyte-cdk/python/airbyte_cdk/models/airbyte_protocol.py b/airbyte-cdk/python/airbyte_cdk/models/airbyte_protocol.py index a9dceff1ce64..9d062cec1b37 100644 --- a/airbyte-cdk/python/airbyte_cdk/models/airbyte_protocol.py +++ b/airbyte-cdk/python/airbyte_cdk/models/airbyte_protocol.py @@ -104,9 +104,17 @@ class DestinationSyncMode(Enum): class OAuth2Specification(BaseModel): - oauthFlowInitParameters: Optional[List[List[str]]] = Field( - None, - description="Pointers to the fields in the ConnectorSpecification which are needed to obtain the initial refresh/access tokens for the OAuth flow. Each inner array represents the path in the ConnectorSpecification of the referenced field. For example. Assume the ConnectorSpecification contains params 'app_secret', 'app_id' which are needed to get the initial refresh token. If they are not nested in the config, then the array would look like this [['app_secret'], ['app_id']] If they are nested inside, say, an object called 'auth_params' then this array would be [['auth_params', 'app_secret'], ['auth_params', 'app_id']]", + rootObject: List[str] = Field( + ..., + description="A list of strings representing a pointer to the root object which contains any oauth parameters in the ConnectorSpecification.\nExamples:\nif oauth parameters were contained inside the top level, rootObject=[] If they were nested inside another object {'credentials': {'app_id' etc...}, rootObject=['credentials'] If they were inside a oneOf {'switch': {oneOf: [{client_id...}, {non_oauth_param]}}, rootObject=['switch', 0] ", + ) + oauthFlowInitParameters: List[List[str]] = Field( + ..., + description="Pointers to the fields in the rootObject needed to obtain the initial refresh/access tokens for the OAuth flow. Each inner array represents the path in the rootObject of the referenced field. For example. Assume the rootObject contains params 'app_secret', 'app_id' which are needed to get the initial refresh token. If they are not nested in the rootObject, then the array would look like this [['app_secret'], ['app_id']] If they are nested inside an object called 'auth_params' then this array would be [['auth_params', 'app_secret'], ['auth_params', 'app_id']]", + ) + oauthFlowOutputParameters: List[List[str]] = Field( + ..., + description="Pointers to the fields in the rootObject which can be populated from successfully completing the oauth flow using the init parameters. This is typically a refresh/access token. Each inner array represents the path in the rootObject of the referenced field.", ) diff --git a/airbyte-integrations/bases/airbyte-protocol/airbyte_protocol/models/airbyte_protocol.py b/airbyte-integrations/bases/airbyte-protocol/airbyte_protocol/models/airbyte_protocol.py index a9dceff1ce64..9d062cec1b37 100644 --- a/airbyte-integrations/bases/airbyte-protocol/airbyte_protocol/models/airbyte_protocol.py +++ b/airbyte-integrations/bases/airbyte-protocol/airbyte_protocol/models/airbyte_protocol.py @@ -104,9 +104,17 @@ class DestinationSyncMode(Enum): class OAuth2Specification(BaseModel): - oauthFlowInitParameters: Optional[List[List[str]]] = Field( - None, - description="Pointers to the fields in the ConnectorSpecification which are needed to obtain the initial refresh/access tokens for the OAuth flow. Each inner array represents the path in the ConnectorSpecification of the referenced field. For example. Assume the ConnectorSpecification contains params 'app_secret', 'app_id' which are needed to get the initial refresh token. If they are not nested in the config, then the array would look like this [['app_secret'], ['app_id']] If they are nested inside, say, an object called 'auth_params' then this array would be [['auth_params', 'app_secret'], ['auth_params', 'app_id']]", + rootObject: List[str] = Field( + ..., + description="A list of strings representing a pointer to the root object which contains any oauth parameters in the ConnectorSpecification.\nExamples:\nif oauth parameters were contained inside the top level, rootObject=[] If they were nested inside another object {'credentials': {'app_id' etc...}, rootObject=['credentials'] If they were inside a oneOf {'switch': {oneOf: [{client_id...}, {non_oauth_param]}}, rootObject=['switch', 0] ", + ) + oauthFlowInitParameters: List[List[str]] = Field( + ..., + description="Pointers to the fields in the rootObject needed to obtain the initial refresh/access tokens for the OAuth flow. Each inner array represents the path in the rootObject of the referenced field. For example. Assume the rootObject contains params 'app_secret', 'app_id' which are needed to get the initial refresh token. If they are not nested in the rootObject, then the array would look like this [['app_secret'], ['app_id']] If they are nested inside an object called 'auth_params' then this array would be [['auth_params', 'app_secret'], ['auth_params', 'app_id']]", + ) + oauthFlowOutputParameters: List[List[str]] = Field( + ..., + description="Pointers to the fields in the rootObject which can be populated from successfully completing the oauth flow using the init parameters. This is typically a refresh/access token. Each inner array represents the path in the rootObject of the referenced field.", ) diff --git a/airbyte-integrations/connectors/source-scaffold-source-http/unit_tests/test_incremental_streams.py b/airbyte-integrations/connectors/source-scaffold-source-http/unit_tests/test_incremental_streams.py index 5bb2c4081696..f0b1df433532 100644 --- a/airbyte-integrations/connectors/source-scaffold-source-http/unit_tests/test_incremental_streams.py +++ b/airbyte-integrations/connectors/source-scaffold-source-http/unit_tests/test_incremental_streams.py @@ -22,9 +22,8 @@ # SOFTWARE. # -from pytest import fixture - from airbyte_cdk.models import SyncMode +from pytest import fixture from source_scaffold_source_http.source import IncrementalScaffoldSourceHttpStream From 4ef2a266bd41829f52da457e4017e4e3350b905c Mon Sep 17 00:00:00 2001 From: Christophe Duong Date: Mon, 27 Sep 2021 12:26:22 +0200 Subject: [PATCH 7/7] Format connector code --- .../unit_tests/test_incremental_streams.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/airbyte-integrations/connectors/source-scaffold-source-http/unit_tests/test_incremental_streams.py b/airbyte-integrations/connectors/source-scaffold-source-http/unit_tests/test_incremental_streams.py index f0b1df433532..5bb2c4081696 100644 --- a/airbyte-integrations/connectors/source-scaffold-source-http/unit_tests/test_incremental_streams.py +++ b/airbyte-integrations/connectors/source-scaffold-source-http/unit_tests/test_incremental_streams.py @@ -22,8 +22,9 @@ # SOFTWARE. # -from airbyte_cdk.models import SyncMode from pytest import fixture + +from airbyte_cdk.models import SyncMode from source_scaffold_source_http.source import IncrementalScaffoldSourceHttpStream