diff --git a/airbyte-config/init/src/main/resources/config/STANDARD_SOURCE_DEFINITION/badc5925-0485-42be-8caa-b34096cb71b5.json b/airbyte-config/init/src/main/resources/config/STANDARD_SOURCE_DEFINITION/badc5925-0485-42be-8caa-b34096cb71b5.json index d0e74a25ca0c7..dc0ea8587af63 100644 --- a/airbyte-config/init/src/main/resources/config/STANDARD_SOURCE_DEFINITION/badc5925-0485-42be-8caa-b34096cb71b5.json +++ b/airbyte-config/init/src/main/resources/config/STANDARD_SOURCE_DEFINITION/badc5925-0485-42be-8caa-b34096cb71b5.json @@ -2,6 +2,6 @@ "sourceDefinitionId": "badc5925-0485-42be-8caa-b34096cb71b5", "name": "Survey Monkey", "dockerRepository": "airbyte/source-surveymonkey", - "dockerImageTag": "0.1.3", + "dockerImageTag": "0.1.4", "documentationUrl": "https://docs.airbyte.io/integrations/sources/surveymonkey" } diff --git a/airbyte-config/init/src/main/resources/seed/source_definitions.yaml b/airbyte-config/init/src/main/resources/seed/source_definitions.yaml index 48bf6af698060..c8e3555037576 100644 --- a/airbyte-config/init/src/main/resources/seed/source_definitions.yaml +++ b/airbyte-config/init/src/main/resources/seed/source_definitions.yaml @@ -561,7 +561,7 @@ - name: Survey Monkey sourceDefinitionId: badc5925-0485-42be-8caa-b34096cb71b5 dockerRepository: airbyte/source-surveymonkey - dockerImageTag: 0.1.3 + dockerImageTag: 0.1.4 documentationUrl: https://docs.airbyte.io/integrations/sources/surveymonkey sourceType: api - name: Tempo diff --git a/airbyte-config/init/src/main/resources/seed/source_specs.yaml b/airbyte-config/init/src/main/resources/seed/source_specs.yaml index eefc469674fae..e3243aa63eab1 100644 --- a/airbyte-config/init/src/main/resources/seed/source_specs.yaml +++ b/airbyte-config/init/src/main/resources/seed/source_specs.yaml @@ -5660,7 +5660,7 @@ supportsNormalization: false supportsDBT: false supported_destination_sync_modes: [] -- dockerImage: "airbyte/source-surveymonkey:0.1.3" +- dockerImage: "airbyte/source-surveymonkey:0.1.4" spec: documentationUrl: "https://docs.airbyte.io/integrations/sources/surveymonkey" connectionSpecification: diff --git a/airbyte-integrations/connectors/source-surveymonkey/Dockerfile b/airbyte-integrations/connectors/source-surveymonkey/Dockerfile index c5dacbc738925..51e56e8a1bccd 100644 --- a/airbyte-integrations/connectors/source-surveymonkey/Dockerfile +++ b/airbyte-integrations/connectors/source-surveymonkey/Dockerfile @@ -12,5 +12,5 @@ RUN pip install . ENV AIRBYTE_ENTRYPOINT "python /airbyte/integration_code/main.py" ENTRYPOINT ["python", "/airbyte/integration_code/main.py"] -LABEL io.airbyte.version=0.1.3 +LABEL io.airbyte.version=0.1.4 LABEL io.airbyte.name=airbyte/source-surveymonkey diff --git a/airbyte-integrations/connectors/source-surveymonkey/source_surveymonkey/source.py b/airbyte-integrations/connectors/source-surveymonkey/source_surveymonkey/source.py index 27fafa79c5f9f..48a6fbbca0adf 100644 --- a/airbyte-integrations/connectors/source-surveymonkey/source_surveymonkey/source.py +++ b/airbyte-integrations/connectors/source-surveymonkey/source_surveymonkey/source.py @@ -5,8 +5,8 @@ from typing import Any, List, Mapping, Tuple import pendulum +import requests from airbyte_cdk.logger import AirbyteLogger -from airbyte_cdk.models import SyncMode from airbyte_cdk.sources import AbstractSource from airbyte_cdk.sources.streams import Stream from airbyte_cdk.sources.streams.http.auth import TokenAuthenticator @@ -15,14 +15,30 @@ class SourceSurveymonkey(AbstractSource): + + SCOPES = { + "collectors_read", + "contacts_read", + "groups_read", + "library_read", + "responses_read", + "responses_read_detail", + "roles_read", + "surveys_read", + "users_read", + "webhooks_read", + "workgroups_members_read", + "workgroups_read", + "workgroups_shares_read", + } + def check_connection(self, logger: AirbyteLogger, config: Mapping[str, Any]) -> Tuple[bool, Any]: + url = "https://api.surveymonkey.com/v3/users/me" + authenticator = self.get_authenticator(config) try: - authenticator = self.get_authenticator(config) - start_date = pendulum.parse(config["start_date"]) - stream = Surveys(authenticator=authenticator, start_date=start_date) - records = stream.read_records(sync_mode=SyncMode.full_refresh) - next(records) - return True, None + response = requests.get(url=url, headers=authenticator.get_auth_header()) + response.raise_for_status() + return self._check_scopes(response.json()) except Exception as e: return False, repr(e) @@ -36,3 +52,11 @@ def streams(self, config: Mapping[str, Any]) -> List[Stream]: def get_authenticator(config: Mapping[str, Any]): token = config["access_token"] return TokenAuthenticator(token=token) + + @classmethod + def _check_scopes(cls, response_json): + granted_scopes = response_json["scopes"]["granted"] + missed_scopes = cls.SCOPES - set(granted_scopes) + if missed_scopes: + return False, "missed required scopes: " + ", ".join(missed_scopes) + return True, None diff --git a/docs/integrations/sources/surveymonkey.md b/docs/integrations/sources/surveymonkey.md index 6297caf041074..d8192a45a0117 100644 --- a/docs/integrations/sources/surveymonkey.md +++ b/docs/integrations/sources/surveymonkey.md @@ -55,6 +55,7 @@ Please read this [docs](https://developer.surveymonkey.com/api/v3/#getting-start | Version | Date | Pull Request | Subject | | :--- | :--- | :--- | :--- | +| 0.1.4 | 2021-11-11 | [7868](https://github.com/airbytehq/airbyte/pull/7868) | Improve 'check' using '/users/me' API call | | 0.1.3 | 2021-11-01 | [7433](https://github.com/airbytehq/airbyte/pull/7433) | Remove unsused oAuth flow parameters | | 0.1.2 | 2021-10-27 | [7433](https://github.com/airbytehq/airbyte/pull/7433) | Add OAuth support | | 0.1.1 | 2021-09-10 | [5983](https://github.com/airbytehq/airbyte/pull/5983) | Fix caching for gzip compressed http response |