Skip to content

Commit

Permalink
Add microsoft teams source (airbytehq#1422)
Browse files Browse the repository at this point in the history
  • Loading branch information
sherifnada authored Dec 22, 2020
1 parent 54ec74f commit 5b69b76
Show file tree
Hide file tree
Showing 43 changed files with 3,008 additions and 4 deletions.
1 change: 1 addition & 0 deletions .github/workflows/test-command.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ jobs:
INTERCOM_INTEGRATION_TEST_CREDS: ${{ secrets.INTERCOM_INTEGRATION_TEST_CREDS }}
JIRA_INTEGRATION_TEST_CREDS: ${{ secrets.JIRA_INTEGRATION_TEST_CREDS }}
MAILCHIMP_TEST_CREDS: ${{ secrets.MAILCHIMP_TEST_CREDS }}
MICROSOFT_TEAMS_TEST_CREDS: ${{ secrets.MICROSOFT_TEAMS_TEST_CREDS }}
MIXPANEL_INTEGRATION_TEST_CREDS: ${{ secrets.MIXPANEL_INTEGRATION_TEST_CREDS }}
SALESFORCE_INTEGRATION_TESTS_CREDS: ${{ secrets.SALESFORCE_INTEGRATION_TESTS_CREDS }}
SENDGRID_INTEGRATION_TEST_CREDS: ${{ secrets.SENDGRID_INTEGRATION_TEST_CREDS }}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"sourceDefinitionId": "eaf50f04-21dd-4620-913b-2a83f5635227",
"name": "Microsoft teams",
"dockerRepository": "airbyte/source-microsoft-teams",
"dockerImageTag": "0.1.0",
"documentationUrl": "https://hub.docker.com/r/airbyte/source-microsoft-teams"
}
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,11 @@
dockerRepository: airbyte/source-zoom-singer
dockerImageTag: 0.1.0
documentationUrl: https://hub.docker.com/r/airbyte/source-zoom-singer
- sourceDefinitionId: eaf50f04-21dd-4620-913b-2a83f5635227
name: Microsoft teams
dockerRepository: airbyte/source-microsoft-teams
dockerImageTag: 0.1.0
documentationUrl: https://hub.docker.com/r/airbyte/source-microsoft-teams
- sourceDefinitionId: 445831eb-78db-4b1f-8f1f-0d96ad8739e2
name: Drift
dockerRepository: airbyte/source-drift
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
*
!Dockerfile
!Dockerfile.test
!source_microsoft_teams
!setup.py
!sample_files
!integration_tests
!secrets
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
NEW_SOURCE_CHECKLIST.md
16 changes: 16 additions & 0 deletions airbyte-integrations/connectors/source-microsoft-teams/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
FROM airbyte/integration-base-python:dev

# Bash is installed for more convenient debugging.
RUN apt-get update && apt-get install -y bash && rm -rf /var/lib/apt/lists/*

ENV CODE_PATH="source_microsoft_teams"
ENV AIRBYTE_IMPL_MODULE="source_microsoft_teams"
ENV AIRBYTE_IMPL_PATH="SourceMicrosoftTeams"

WORKDIR /airbyte/integration_code
COPY $CODE_PATH ./$CODE_PATH
COPY setup.py ./
RUN pip install ".[main]"

LABEL io.airbyte.version=0.1.0
LABEL io.airbyte.name=airbyte/source-microsoft-teams
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
FROM airbyte/base-python-test:dev

RUN apt-get update && apt-get install -y bash && rm -rf /var/lib/apt/lists/*

ENV CODE_PATH="integration_tests"
ENV AIRBYTE_TEST_MODULE="integration_tests"
ENV AIRBYTE_TEST_PATH="SourceMicrosoftTeamsStandardTest"

LABEL io.airbyte.version=0.1.0
LABEL io.airbyte.name=airbyte/source-microsoft-teams-standard-test

WORKDIR /airbyte/integration_code
COPY source_microsoft_teams source_microsoft_teams
COPY $CODE_PATH $CODE_PATH
COPY sample_files/configured_catalog.json $CODE_PATH/
COPY secrets/* $CODE_PATH/
COPY source_microsoft_teams/*.json $CODE_PATH/
COPY setup.py ./

RUN pip install ".[tests]"

WORKDIR /airbyte
64 changes: 64 additions & 0 deletions airbyte-integrations/connectors/source-microsoft-teams/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# Microsoft Teams Source

This is the repository for the Microsoft Teams source connector, written in Python.
For information about how to use this connector within Airbyte, see [the documentation](https://docs.airbyte.io/integrations/sources/microsoft-teams).

## Local development

### Prerequisites
**To iterate on this connector, make sure to complete this prerequisites section.**

#### Build & Activate Virtual Environment
First, build the module by running the following from the `airbyte` project root directory:
```
./gradlew :airbyte-integrations:connectors:source-microsoft-teams:build
```

This will generate a virtualenv for this module in `source-microsoft-teams/.venv`. Make sure this venv is active in your
development environment of choice. To activate the venv from the terminal, run:
```
cd airbyte-integrations/connectors/source-microsoft-teams # cd into the connector directory
source .venv/bin/activate
```
If you are in an IDE, follow your IDE's instructions to activate the virtualenv.

#### Create credentials
**If you are a community contributor**, follow the instructions in the [documentation](https://docs.airbyte.io/integrations/sources/microsoft-teams)
to generate the necessary credentials. Then create a file `secrets/config.json` conforming to the `source_microsoft_teams/spec.json` file.
See `sample_files/sample_config.json` for a sample config file.

**If you are an Airbyte core member**, copy the credentials in RPass under the secret name `source-microsoft-teams-integration-test-config`
and place them into `secrets/config.json`.


### Locally running the connector
```
python main_dev.py spec
python main_dev.py check --config secrets/config.json
python main_dev.py discover --config secrets/config.json
python main_dev.py read --config secrets/config.json --catalog sample_files/configured_catalog.json
```

### Unit Tests
To run unit tests locally, from the connector directory run:
```
pytest unit_tests
```

### Locally running the connector docker image
```
# in airbyte root directory
./gradlew :airbyte-integrations:connectors:source-microsoft-teams:airbyteDocker
docker run --rm airbyte/source-microsoft-teams:dev spec
docker run --rm -v $(pwd)/airbyte-integrations/connectors/source-microsoft-teams/secrets:/secrets airbyte/source-microsoft-teams:dev check --config /secrets/config.json
docker run --rm -v $(pwd)/airbyte-integrations/connectors/source-microsoft-teams/secrets:/secrets airbyte/source-microsoft-teams:dev discover --config /secrets/config.json
docker run --rm -v $(pwd)/airbyte-integrations/connectors/source-microsoft-teams/secrets:/secrets -v $(pwd)/airbyte-integrations/connectors/source-microsoft-teams/sample_files:/sample_files airbyte/source-microsoft-teams:dev read --config /secrets/config.json --catalog /sample_files/configured_catalog.json
```

### Integration Tests
1. From the airbyte project root, run `./gradlew :airbyte-integrations:connectors:source-microsoft-teams:standardSourceTestPython` to run the standard integration test suite.
1. To run additional integration tests, place your integration tests in the `integration_tests` directory and run them with `pytest integration_tests`.
Make sure to familiarize yourself with [pytest test discovery](https://docs.pytest.org/en/latest/goodpractices.html#test-discovery) to know how your test files and methods should be named.

## Dependency Management
All of your dependencies should go in `setup.py`, NOT `requirements.txt`. The requirements file is only used to connect internal Airbyte dependencies in the monorepo for local development.
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
plugins {
id 'airbyte-python'
id 'airbyte-docker'
id 'airbyte-source-test'
}

airbytePython {
moduleDirectory 'source_microsoft_teams'
}

dependencies {
implementation files(project(':airbyte-integrations:bases:base-python').airbyteDocker.outputs)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
"""
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.
"""

from .standard_source_test import SourceMicrosoftTeamsStandardTest

__all__ = ["SourceMicrosoftTeamsStandardTest"]
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
"""
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.
"""

from base_python_test import DefaultStandardSourceTest


class SourceMicrosoftTeamsStandardTest(DefaultStandardSourceTest):
pass
32 changes: 32 additions & 0 deletions airbyte-integrations/connectors/source-microsoft-teams/main_dev.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
"""
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.
"""

import sys

from base_python.entrypoint import launch
from source_microsoft_teams import SourceMicrosoftTeams

if __name__ == "__main__":
source = SourceMicrosoftTeams()
launch(source, sys.argv[1:])
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
-e ../../bases/airbyte-protocol
-e ../../bases/base-python
-e ../../bases/base-python-test
-e .
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
{
"streams": [
{
"stream": {
"name": "group_owners",
"supported_sync_modes": ["full_refresh"],
"source_defined_cursor": false,
"json_schema": {
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"properties": {
"id": {
"type": ["null", "string"]
},
"group_id": {
"type": ["null", "string"]
},
"business_phones": {
"anyOf": [
{
"type": "array",
"items": {
"type": "string"
}
},
{
"type": "null"
}
]
},
"display_name": {
"type": ["null", "string"]
},
"given_name": {
"type": ["null", "string"]
},
"job_title": {
"type": ["null", "string"]
},
"mail": {
"type": ["null", "string"]
},
"mobile_phone": {
"type": ["null", "string"]
},
"office_location": {
"type": ["null", "string"]
},
"preferred_language": {
"type": ["null", "string"]
},
"surname": {
"type": ["null", "string"]
},
"user_principal_name": {
"type": ["null", "string"]
}
}
}
},
"sync_mode": "full_refresh"
}
]
}
Loading

0 comments on commit 5b69b76

Please sign in to comment.