Skip to content
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

🎉 New Source: LinkedIn Ads #5285

Merged
merged 68 commits into from
Sep 24, 2021
Merged
Show file tree
Hide file tree
Changes from 64 commits
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
52e1b0a
Implemented CHECK method
bazarnov Aug 9, 2021
4fe8d03
Merge remote-tracking branch 'origin/master' into bazarnov/2589-sourc…
bazarnov Aug 9, 2021
b2d6f4d
Merge remote-tracking branch 'origin/master' into bazarnov/2589-sourc…
bazarnov Aug 10, 2021
717f96e
Merge remote-tracking branch 'origin/master' into bazarnov/2589-sourc…
bazarnov Aug 17, 2021
06a8b17
edited dockerfile to use the alpine-base image, formated source.py
bazarnov Aug 17, 2021
ec0581a
Merge remote-tracking branch 'origin/master' into bazarnov/2589-sourc…
bazarnov Aug 19, 2021
cc1700f
Merge remote-tracking branch 'origin/master' into bazarnov/2589-sourc…
bazarnov Aug 20, 2021
a8e2b6a
Merge remote-tracking branch 'origin/master' into bazarnov/2589-sourc…
bazarnov Aug 20, 2021
cf809c1
Merge remote-tracking branch 'origin/master' into bazarnov/2589-sourc…
bazarnov Aug 21, 2021
84dbce7
minor edits
bazarnov Aug 21, 2021
40e8ba7
added Accounts, CampaignGroups streams
bazarnov Aug 22, 2021
91841fe
added AccountUsers stream
bazarnov Aug 22, 2021
bc930fa
Added incremental refresh to some streams
bazarnov Aug 23, 2021
d90d8b7
Merge remote-tracking branch 'origin/master' into bazarnov/2589-sourc…
bazarnov Aug 23, 2021
3d9848d
added acceptance-test, formated code
bazarnov Aug 23, 2021
4c20c49
corrections
bazarnov Aug 24, 2021
74f42ca
Merge remote-tracking branch 'origin/master' into bazarnov/2589-sourc…
bazarnov Aug 24, 2021
89bf00b
Merge remote-tracking branch 'origin/master' into bazarnov/2589-sourc…
bazarnov Aug 24, 2021
3873b5f
Merge remote-tracking branch 'origin/master' into bazarnov/2589-sourc…
bazarnov Aug 25, 2021
30e971f
added Creatives stream, changed the StreamMixin to accept the parrent…
bazarnov Aug 25, 2021
efc320b
corrected campaigns schema
bazarnov Aug 25, 2021
72a861f
added AdSponsoredContents stream
bazarnov Aug 25, 2021
d6fd81f
added Analytics streams
bazarnov Aug 27, 2021
12243b1
edited Dockerfile, formated code
bazarnov Aug 27, 2021
9138d6c
schema changes
bazarnov Aug 28, 2021
bcdf609
Merge remote-tracking branch 'origin/master' into bazarnov/2589-sourc…
bazarnov Aug 28, 2021
5a7e990
formated
bazarnov Aug 28, 2021
1b1fa95
added seeds
bazarnov Aug 28, 2021
7fd225c
edited schemas
bazarnov Aug 28, 2021
a45b985
Merge remote-tracking branch 'refs/remotes/origin/master' into bazarn…
bazarnov Aug 30, 2021
64a5ba8
refactored utils.py, added documentation
bazarnov Aug 31, 2021
adf40d1
Merge remote-tracking branch 'origin/master' into bazarnov/2589-sourc…
bazarnov Aug 31, 2021
6c71347
added sources/documentation
bazarnov Sep 1, 2021
6c7e0d9
fixed the creatives, campaigns schemas
bazarnov Sep 1, 2021
1607b12
Merge remote-tracking branch 'origin/master' into bazarnov/2589-sourc…
bazarnov Sep 1, 2021
60b0323
Merge remote-tracking branch 'origin/master' into bazarnov/2589-sourc…
bazarnov Sep 1, 2021
53be516
added unit tests for each custom method
bazarnov Sep 1, 2021
4aab3ac
Merge remote-tracking branch 'origin/master' into bazarnov/2589-sourc…
bazarnov Sep 1, 2021
3ea98b5
formated
bazarnov Sep 1, 2021
721f0de
...
bazarnov Sep 1, 2021
2441cf6
updated test data
bazarnov Sep 1, 2021
a9105ad
Merge remote-tracking branch 'origin/master' into bazarnov/2589-sourc…
bazarnov Sep 3, 2021
b43dbd3
updated after review comments
bazarnov Sep 3, 2021
1b60a44
Merge remote-tracking branch 'origin/master' into bazarnov/2589-sourc…
bazarnov Sep 3, 2021
3902f38
Merge remote-tracking branch 'origin/master' into bazarnov/2589-sourc…
bazarnov Sep 5, 2021
56c901e
Merge remote-tracking branch 'origin/master' into bazarnov/2589-sourc…
bazarnov Sep 6, 2021
82b46b5
added additional descriptions to source.py classes
bazarnov Sep 6, 2021
2eae29f
added additional descriptions to source.py classes
bazarnov Sep 6, 2021
598565d
sorted stream calls alfabatically
bazarnov Sep 6, 2021
3bb4c2e
formated
bazarnov Sep 6, 2021
619e0ba
Merge remote-tracking branch 'origin/master' into bazarnov/2589-sourc…
bazarnov Sep 8, 2021
dbd76a0
updated after review
bazarnov Sep 8, 2021
6f2c6d6
updated after review
bazarnov Sep 8, 2021
8ef1f42
updated after review
bazarnov Sep 8, 2021
5210b68
Merge remote-tracking branch 'origin/master' into bazarnov/2589-sourc…
bazarnov Sep 8, 2021
e61e275
formated
bazarnov Sep 8, 2021
c8f9d32
updated after review
bazarnov Sep 10, 2021
2ec8412
Merge remote-tracking branch 'origin/master' into bazarnov/2589-sourc…
bazarnov Sep 10, 2021
0a647c5
updated after review
bazarnov Sep 11, 2021
cfa11d5
updated after review
bazarnov Sep 12, 2021
0b0191a
Merge remote-tracking branch 'origin/master' into bazarnov/2589-sourc…
bazarnov Sep 12, 2021
62f7f25
Merge remote-tracking branch 'origin/master' into bazarnov/2589-sourc…
bazarnov Sep 18, 2021
fdc8127
updates after review
bazarnov Sep 18, 2021
9623ce0
Merge remote-tracking branch 'origin/master' into bazarnov/2589-sourc…
bazarnov Sep 21, 2021
e441388
Merge remote-tracking branch 'origin/master' into bazarnov/2589-sourc…
bazarnov Sep 23, 2021
65e87fb
Merge remote-tracking branch 'origin/master' into bazarnov/2589-sourc…
bazarnov Sep 23, 2021
89acb7f
Merge remote-tracking branch 'origin/master' into bazarnov/2589-sourc…
bazarnov Sep 24, 2021
a451895
set airbyte-cdk==0.1.22
bazarnov Sep 24, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/publish-command.yml
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ jobs:
SOURCE_ZUORA_TEST_CREDS: ${{ secrets.SOURCE_ZUORA_TEST_CREDS }}
SOURCE_CLOSE_COM_CREDS: ${{ secrets.SOURCE_CLOSE_COM_CREDS }}
SOURCE_BAMBOO_HR_CREDS: ${{ secrets.SOURCE_BAMBOO_HR_CREDS }}
SOURCE_LINKEDIN_ADS_TEST_CREDS: ${{ secrets.SOURCE_LINKEDIN_ADS_TEST_CREDS }}
SOURCE_BIGCOMMERCE_CREDS: ${{ secrets.SOURCE_BIGCOMMERCE_CREDS }}
DESTINATION_DATABRICKS_CREDS: ${{ secrets.DESTINATION_DATABRICKS_CREDS }}
- run: |
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/test-command.yml
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ jobs:
SOURCE_ZUORA_TEST_CREDS: ${{ secrets.SOURCE_ZUORA_TEST_CREDS }}
SOURCE_CLOSE_COM_CREDS: ${{ secrets.SOURCE_CLOSE_COM_CREDS }}
SOURCE_BAMBOO_HR_CREDS: ${{ secrets.SOURCE_BAMBOO_HR_CREDS }}
SOURCE_LINKEDIN_ADS_TEST_CREDS: ${{ secrets.SOURCE_LINKEDIN_ADS_TEST_CREDS }}
SOURCE_BIGCOMMERCE_CREDS: ${{ secrets.SOURCE_BIGCOMMERCE_CREDS }}
DESTINATION_DATABRICKS_CREDS: ${{ secrets.DESTINATION_DATABRICKS_CREDS }}
- run: |
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"sourceDefinitionId": "137ece28-5434-455c-8f34-69dc3782f451",
"name": "LinkedIn Ads",
"dockerRepository": "airbyte/source-linkedin-ads",
"dockerImageTag": "0.1.0",
"documentationUrl": "https://docs.airbyte.io/integrations/sources/linkedin-ads"
}
Original file line number Diff line number Diff line change
Expand Up @@ -548,6 +548,11 @@
dockerRepository: airbyte/source-amazon-ads
dockerImageTag: 0.1.0
documentationUrl: https://docs.airbyte.io/integrations/sources/amazon-ads
- sourceDefinitionId: 137ece28-5434-455c-8f34-69dc3782f451
name: LinkedIn Ads
dockerRepository: airbyte/source-linkedin-ads
dockerImageTag: 0.1.0
documentationUrl: https://docs.airbyte.io/integrations/sources/linkedin-ads
sourceType: api
- sourceDefinitionId: b2e713cd-cc36-4c0a-b5bd-b47cb8a0561e
name: MongoDb
Expand Down
1 change: 1 addition & 0 deletions airbyte-integrations/builds.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
| Intercom | [![source-intercom](https://img.shields.io/endpoint?url=https%3A%2F%2Fdnsgjos7lj2fu.cloudfront.net%2Ftests%2Fsummary%2Fsource-intercom-singer%2Fbadge.json)](https://dnsgjos7lj2fu.cloudfront.net/tests/summary/source-intercom) |
| Iterable | [![source-iterable](https://img.shields.io/endpoint?url=https%3A%2F%2Fdnsgjos7lj2fu.cloudfront.net%2Ftests%2Fsummary%2Fsource-iterable%2Fbadge.json)](https://dnsgjos7lj2fu.cloudfront.net/tests/summary/source-iterable) |
| Jira | [![source-jira](https://img.shields.io/endpoint?url=https%3A%2F%2Fdnsgjos7lj2fu.cloudfront.net%2Ftests%2Fsummary%2Fsource-jira%2Fbadge.json)](https://dnsgjos7lj2fu.cloudfront.net/tests/summary/source-jira) |
| LinkedIn Ads | [![source-linkedin-ads](https://img.shields.io/endpoint?url=https%3A%2F%2Fdnsgjos7lj2fu.cloudfront.net%2Ftests%2Fsummary%2Fsource-linkedin-ads%2Fbadge.json)](https://dnsgjos7lj2fu.cloudfront.net/tests/summary/source-linkedin-ads) |
| Looker | [![source-looker](https://img.shields.io/endpoint?url=https%3A%2F%2Fdnsgjos7lj2fu.cloudfront.net%2Ftests%2Fsummary%2Fsource-looker%2Fbadge.json)](https://dnsgjos7lj2fu.cloudfront.net/tests/summary/source-looker) |
| Klaviyo | [![source-klaviyo](https://img.shields.io/endpoint?url=https%3A%2F%2Fdnsgjos7lj2fu.cloudfront.net%2Ftests%2Fsummary%2Fsource-klaviyo%2Fbadge.json)](https://dnsgjos7lj2fu.cloudfront.net/tests/summary/source-klaviyo) |
| Kustomer | [![source-kustomer](https://img.shields.io/endpoint?url=https%3A%2F%2Fdnsgjos7lj2fu.cloudfront.net%2Ftests%2Fsummary%2Fsource-kustomer%2Fbadge.json)](https://dnsgjos7lj2fu.cloudfront.net/tests/summary/source-kustomer-singer) |
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
*
!Dockerfile
!Dockerfile.test
!main.py
!source_linkedin_ads
!setup.py
!secrets
31 changes: 31 additions & 0 deletions airbyte-integrations/connectors/source-linkedin-ads/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
FROM python:3.7.11-alpine3.14 as base

# build and load all requirements
FROM base as builder
WORKDIR /airbyte/integration_code

# upgrade pip to the latest version
RUN apk --no-cache upgrade && pip install --upgrade pip

COPY setup.py ./
# install necessary packages to a temporary folder
RUN pip install --prefix=/install .

# build a clean environment
FROM base
WORKDIR /airbyte/integration_code

# copy all loaded and built libraries to a pure basic image
COPY --from=builder /install /usr/local

# copy payload code only
COPY main.py ./
COPY source_linkedin_ads ./source_linkedin_ads

# set the default Timezone, for use with dependent libraries like: datetime, pendullum, etc.
ENV TZ "UTC"
ENV AIRBYTE_ENTRYPOINT "python /airbyte/integration_code/main.py"
ENTRYPOINT ["python", "/airbyte/integration_code/main.py"]

LABEL io.airbyte.version=0.1.0
LABEL io.airbyte.name=airbyte/source-linkedin-ads
137 changes: 137 additions & 0 deletions airbyte-integrations/connectors/source-linkedin-ads/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
# Linkedin Ads Source Connector

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

## Local development

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

#### Minimum Python version required `= 3.7.0`

#### Build & Activate Virtual Environment and install dependencies
From this connector directory, create a virtual environment:
```
python3 -m venv .venv
```

This will generate a virtualenv for this module in `.venv/`. Make sure this venv is active in your
development environment of choice. To activate it from the terminal, run:
```
source .venv/bin/activate
pip install -r requirements.txt
```
If you are in an IDE, follow your IDE's instructions to activate the virtualenv.

Note that while we are installing dependencies from `requirements.txt`, you should only edit `setup.py` for your dependencies. `requirements.txt` is
used for editable installs (`pip install -e`) to pull in Python dependencies from the monorepo and will call `setup.py`.
If this is mumbo jumbo to you, don't worry about it, just put your deps in `setup.py` but install using `pip install -r requirements.txt` and everything
should work as you expect.

#### Building via Gradle
You can also build the connector in Gradle. This is typically used in CI and not needed for your development workflow.

To build using Gradle, from the Airbyte repository root, run:
```
./gradlew :airbyte-integrations:connectors:source-linkedin-ads:build
```

#### Create credentials
**If you are a community contributor**, follow the instructions in the [documentation](https://docs.airbyte.io/integrations/sources/linkedin-ads)
to generate the necessary credentials. Then create a file `secrets/config.json` conforming to the `source_linkedin_ads/spec.json` file.
Note that any directory named `secrets` is gitignored across the entire Airbyte repo, so there is no danger of accidentally checking in sensitive information.
See `integration_tests/sample_config.json` for a sample config file.

**If you are an Airbyte core member**, copy the credentials in Lastpass under the secret name `source linkedin-ads test creds`
and place them into `secrets/config.json`.

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

### Locally running the connector docker image

#### Build
First, make sure you build the latest Docker image:
```
docker build . -t airbyte/source-linkedin-ads:dev
```

You can also build the connector image via Gradle:
```
./gradlew clean :airbyte-integrations:connectors:source-linkedin-ads:airbyteDocker
```
When building via Gradle, the docker image name and tag, respectively, are the values of the `io.airbyte.name` and `io.airbyte.version` `LABEL`s in
the Dockerfile.

#### Run
Then run any of the connector commands as follows:
```
docker run --rm airbyte/source-linkedin-ads:dev spec
docker run --rm -v $(pwd)/secrets:/secrets airbyte/source-linkedin-ads:dev check --config /secrets/config.json
docker run --rm -v $(pwd)/secrets:/secrets airbyte/source-linkedin-ads:dev discover --config /secrets/config.json
docker run --rm -v $(pwd)/secrets:/secrets -v $(pwd)/integration_tests:/integration_tests airbyte/source-linkedin-ads:dev read --config /secrets/config.json --catalog /integration_tests/configured_catalog.json
```
## Testing
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.
First install test dependencies into your virtual environment:
```
pip install .[tests]
```
### Unit Tests
To run unit tests locally, from the connector directory run:
```
python -m pytest unit_tests
```

### Integration Tests
There are two types of integration tests: Acceptance Tests (Airbyte's test suite for all source connectors) and custom integration tests (which are specific to this connector).
#### Custom Integration tests
Place custom tests inside `integration_tests/` folder, then, from the connector root, run
```
python -m pytest integration_tests
```
#### Acceptance Tests
Customize `acceptance-test-config.yml` file to configure tests. See [Source Acceptance Tests](source-acceptance-tests.md) for more information.
If your connector requires to create or destroy resources for use during acceptance tests create fixtures for it and place them inside integration_tests/acceptance.py.
To run your integration tests with acceptance tests, from the connector root, run
```
docker build . --no-cache -t airbyte/source-linkedin-ads:dev \
&& python -m pytest -p source_acceptance_test.plugin
```

To run your acceptance-tests with pre-build connector docker image:
From `.venv` of the connector, run:
```
python -m pytest -p source_acceptance_test.plugin
```

### Using gradle to run tests
All commands should be run from airbyte project root.
To run unit tests:
```
./gradlew clean :airbyte-integrations:connectors:source-linkedin-ads:unitTest
```
To run acceptance and custom integration tests:
```
./gradlew clean :airbyte-integrations:connectors:source-linkedin-ads:integrationTest
```

## 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.
We split dependencies between two groups, dependencies that are:
* required for your connector to work need to go to `MAIN_REQUIREMENTS` list.
* required for the testing need to go to `TEST_REQUIREMENTS` list

### Publishing a new version of the connector
You've checked out the repo, implemented a million dollar feature, and you're ready to share your changes with the world. Now what?
1. Make sure your changes are passing unit and integration tests.
1. Bump the connector version in `Dockerfile` -- just increment the value of the `LABEL io.airbyte.version` appropriately (we use [SemVer](https://semver.org/)).
1. Create a Pull Request.
1. Pat yourself on the back for being an awesome contributor.
1. Someone from Airbyte will take a look at your PR and iterate with you to merge it into master.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# See [Source Acceptance Tests](https://docs.airbyte.io/contributing-to-airbyte/building-new-connector/source-acceptance-tests)
# for more information about how to configure these tests
connector_image: airbyte/source-linkedin-ads:dev
tests:
spec:
- spec_path: "source_linkedin_ads/spec.json"
connection:
- config_path: "secrets/config.json"
status: "succeed"
- config_path: "integration_tests/invalid_config.json"
status: "failed"
discovery:
- config_path: "secrets/config.json"
basic_read:
- config_path: "secrets/config.json"
configured_catalog_path: "integration_tests/configured_catalog.json"
incremental:
- config_path: "secrets/config.json"
configured_catalog_path: "integration_tests/configured_catalog.json"
future_state_path: "integration_tests/abnormal_state.json"
full_refresh:
- config_path: "secrets/config.json"
configured_catalog_path: "integration_tests/configured_catalog.json"
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/env sh

# Build latest connector image
docker build . -t $(cat acceptance-test-config.yml | grep "connector_image" | head -n 1 | cut -d: -f2)

# Pull latest acctest image
docker pull airbyte/source-acceptance-test:latest

# Run
docker run --rm -it \
-v /var/run/docker.sock:/var/run/docker.sock \
-v /tmp:/tmp \
-v $(pwd):/test_input \
airbyte/source-acceptance-test \
--acceptance-test-config /test_input

Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
plugins {
id 'airbyte-python'
id 'airbyte-docker'
id 'airbyte-source-acceptance-test'
}

airbytePython {
moduleDirectory 'source_linkedin_ads'
}

dependencies {
implementation files(project(':airbyte-integrations:bases:source-acceptance-test').airbyteDocker.outputs)
implementation files(project(':airbyte-integrations:bases:base-python').airbyteDocker.outputs)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"account_users": {
"lastModified": "2050-01-01"
},
"campaign_groups": {
"lastModified": "2050-01-01"
},
"campaigns": {
"lastModified": "2050-01-01"
},
"creatives": {
"lastModified": "2050-01-01"
},
"ad_direct_sponsored_contents": {
"lastModified": "2050-01-01"
},
"ad_campaign_analytics": {
"end_date": "2050-01-01"
},
"ad_creative_analytics": {
"end_date": "2050-01-01"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#
# 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 pytest

pytest_plugins = ("source_acceptance_test.plugin",)


@pytest.fixture(scope="session", autouse=True)
def connector_setup():
yield
Loading