Skip to content

Commit abed1ce

Browse files
makyashmarcosmarxmharshithmullapudi
authored
🎉New Source: Zenefits (#14809)
* New Source: Zenefits * updated Readme.md * Update spec.json * Update request headers Co-authored-by: Marcos Marx <marcosmarxm@users.noreply.github.com> * Update source.py * removed sample_files * 1. updated source_definition 2. created a new file zenefits.md * Delete TODO.md * fix: remove .class files * fix: added back source_definition * fix: rebase with origin master * fix: updated specs Co-authored-by: Marcos Marx <marcosmarxm@users.noreply.github.com> Co-authored-by: Harshith Mullapudi <harshithmullapudi@gmail.com>
1 parent 6ddcb5d commit abed1ce

35 files changed

+2220
-0
lines changed
Loading

airbyte-config/init/src/main/resources/seed/source_definitions.yaml

+8
Original file line numberDiff line numberDiff line change
@@ -1153,6 +1153,14 @@
11531153
icon: zendesk.svg
11541154
sourceType: api
11551155
releaseStage: beta
1156+
- name: Zenefits
1157+
sourceDefinitionId: 8baba53d-2fe3-4e33-bc85-210d0eb62884
1158+
dockerRepository: airbyte/source-zenefits
1159+
dockerImageTag: 0.1.0
1160+
documentationUrl: https://docs.airbyte.io/integrations/sources/zenefits
1161+
icon: zenefits.svg
1162+
sourceType: api
1163+
releaseStage: alpha
11561164
- name: Zenloop
11571165
sourceDefinitionId: f1e4c7f6-db5c-4035-981f-d35ab4998794
11581166
dockerRepository: airbyte/source-zenloop

airbyte-config/init/src/main/resources/seed/source_specs.yaml

+19
Original file line numberDiff line numberDiff line change
@@ -11834,6 +11834,25 @@
1183411834
path_in_connector_config:
1183511835
- "credentials"
1183611836
- "client_secret"
11837+
- dockerImage: "airbyte/source-zenefits:0.1.0"
11838+
spec:
11839+
documentationUrl: "https://docsurl.com"
11840+
connectionSpecification:
11841+
$schema: "http://json-schema.org/draft-07/schema#"
11842+
title: "Zenefits Integration Spec"
11843+
type: "object"
11844+
required:
11845+
- "token"
11846+
additionalProperties: false
11847+
properties:
11848+
token:
11849+
title: "token"
11850+
type: "string"
11851+
description: "Use Sync with Zenefits button on the link given on the readme\
11852+
\ file, and get the token to access the api"
11853+
supportsNormalization: false
11854+
supportsDBT: false
11855+
supported_destination_sync_modes: []
1183711856
- dockerImage: "airbyte/source-zenloop:0.1.2"
1183811857
spec:
1183911858
documentationUrl: "https://docs.airbyte.io/integrations/sources/zenloop"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
*
2+
!Dockerfile
3+
!main.py
4+
!source_zenefits
5+
!setup.py
6+
!secrets
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
FROM python:3.9.11-alpine3.15 as base
2+
3+
# build and load all requirements
4+
FROM base as builder
5+
WORKDIR /airbyte/integration_code
6+
7+
# upgrade pip to the latest version
8+
RUN apk --no-cache upgrade \
9+
&& pip install --upgrade pip \
10+
&& apk --no-cache add tzdata build-base
11+
12+
13+
COPY setup.py ./
14+
# install necessary packages to a temporary folder
15+
RUN pip install --prefix=/install .
16+
17+
# build a clean environment
18+
FROM base
19+
WORKDIR /airbyte/integration_code
20+
21+
# copy all loaded and built libraries to a pure basic image
22+
COPY --from=builder /install /usr/local
23+
# add default timezone settings
24+
COPY --from=builder /usr/share/zoneinfo/Etc/UTC /etc/localtime
25+
RUN echo "Etc/UTC" > /etc/timezone
26+
27+
# bash is installed for more convenient debugging.
28+
RUN apk --no-cache add bash
29+
30+
# copy payload code only
31+
COPY main.py ./
32+
COPY source_zenefits ./source_zenefits
33+
34+
ENV AIRBYTE_ENTRYPOINT "python /airbyte/integration_code/main.py"
35+
ENTRYPOINT ["python", "/airbyte/integration_code/main.py"]
36+
37+
LABEL io.airbyte.version=0.1.0
38+
LABEL io.airbyte.name=airbyte/source-zenefits
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
# *How to access the token from Zenefits*
2+
3+
Login into the Zenefits portal. <br>
4+
Follow the steps in the given link [Here](https://developers.zenefits.com/docs/sync-with-zenefits-button), This will generate and Bearer token for the user which can be used to interact with the API using the source-zenefits connector.
5+
6+
7+
8+
# Zenefits Source
9+
10+
This is the repository for the Zenefits source connector, written in Python.
11+
For information about how to use this connector within Airbyte, see [the documentation](https://docs.airbyte.io/integrations/sources/zenefits).
12+
13+
## Local development
14+
15+
### Prerequisites
16+
**To iterate on this connector, make sure to complete this prerequisites section.**
17+
18+
#### Minimum Python version required `= 3.7.0`
19+
20+
#### Build & Activate Virtual Environment and install dependencies
21+
From this connector directory, create a virtual environment:
22+
```
23+
python -m venv .venv
24+
```
25+
26+
This will generate a virtualenv for this module in `.venv/`. Make sure this venv is active in your
27+
development environment of choice. To activate it from the terminal, run:
28+
```
29+
source .venv/bin/activate
30+
pip install -r requirements.txt
31+
pip install '.[tests]'
32+
```
33+
If you are in an IDE, follow your IDE's instructions to activate the virtualenv.
34+
35+
Note that while we are installing dependencies from `requirements.txt`, you should only edit `setup.py` for your dependencies. `requirements.txt` is
36+
used for editable installs (`pip install -e`) to pull in Python dependencies from the monorepo and will call `setup.py`.
37+
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
38+
should work as you expect.
39+
40+
#### Building via Gradle
41+
You can also build the connector in Gradle. This is typically used in CI and not needed for your development workflow.
42+
43+
To build using Gradle, from the Airbyte repository root, run:
44+
```
45+
./gradlew :airbyte-integrations:connectors:source-zenefits:build
46+
```
47+
48+
#### Create credentials
49+
**If you are a community contributor**, follow the instructions in the [documentation](https://docs.airbyte.io/integrations/sources/zenefits)
50+
to generate the necessary credentials. Then create a file `secrets/config.json` conforming to the `source_zenefits/spec.yaml` file.
51+
Note that any directory named `secrets` is gitignored across the entire Airbyte repo, so there is no danger of accidentally checking in sensitive information.
52+
See `integration_tests/sample_config.json` for a sample config file.
53+
54+
**If you are an Airbyte core member**, copy the credentials in Lastpass under the secret name `source zenefits test creds`
55+
and place them into `secrets/config.json`.
56+
57+
### Locally running the connector
58+
```
59+
python main.py spec
60+
python main.py check --config secrets/config.json
61+
python main.py discover --config secrets/config.json
62+
python main.py read --config secrets/config.json --catalog integration_tests/configured_catalog.json
63+
```
64+
65+
### Locally running the connector docker image
66+
67+
#### Build
68+
First, make sure you build the latest Docker image:
69+
```
70+
docker build . -t airbyte/source-zenefits:dev
71+
```
72+
73+
You can also build the connector image via Gradle:
74+
```
75+
./gradlew :airbyte-integrations:connectors:source-zenefits:airbyteDocker
76+
```
77+
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
78+
the Dockerfile.
79+
80+
#### Run
81+
Then run any of the connector commands as follows:
82+
```
83+
docker run --rm airbyte/source-zenefits:dev spec
84+
docker run --rm -v $(pwd)/secrets:/secrets airbyte/source-zenefits:dev check --config /secrets/config.json
85+
docker run --rm -v $(pwd)/secrets:/secrets airbyte/source-zenefits:dev discover --config /secrets/config.json
86+
docker run --rm -v $(pwd)/secrets:/secrets -v $(pwd)/integration_tests:/integration_tests airbyte/source-zenefits:dev read --config /secrets/config.json --catalog /integration_tests/configured_catalog.json
87+
```
88+
## Testing
89+
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.
90+
First install test dependencies into your virtual environment:
91+
```
92+
pip install .[tests]
93+
```
94+
### Unit Tests
95+
To run unit tests locally, from the connector directory run:
96+
```
97+
python -m pytest unit_tests
98+
```
99+
100+
### Integration Tests
101+
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).
102+
#### Custom Integration tests
103+
Place custom tests inside `integration_tests/` folder, then, from the connector root, run
104+
```
105+
python -m pytest integration_tests
106+
```
107+
#### Acceptance Tests
108+
Customize `acceptance-test-config.yml` file to configure tests. See [Source Acceptance Tests](https://docs.airbyte.io/connector-development/testing-connectors/source-acceptance-tests-reference) for more information.
109+
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.
110+
To run your integration tests with acceptance tests, from the connector root, run
111+
```
112+
python -m pytest integration_tests -p integration_tests.acceptance
113+
```
114+
To run your integration tests with docker
115+
116+
### Using gradle to run tests
117+
All commands should be run from airbyte project root.
118+
To run unit tests:
119+
```
120+
./gradlew :airbyte-integrations:connectors:source-zenefits:unitTest
121+
```
122+
To run acceptance and custom integration tests:
123+
```
124+
./gradlew :airbyte-integrations:connectors:source-zenefits:integrationTest
125+
```
126+
127+
## Dependency Management
128+
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.
129+
We split dependencies between two groups, dependencies that are:
130+
* required for your connector to work need to go to `MAIN_REQUIREMENTS` list.
131+
* required for the testing need to go to `TEST_REQUIREMENTS` list
132+
133+
### Publishing a new version of the connector
134+
You've checked out the repo, implemented a million dollar feature, and you're ready to share your changes with the world. Now what?
135+
1. Make sure your changes are passing unit and integration tests.
136+
1. Bump the connector version in `Dockerfile` -- just increment the value of the `LABEL io.airbyte.version` appropriately (we use [SemVer](https://semver.org/)).
137+
1. Create a Pull Request.
138+
1. Pat yourself on the back for being an awesome contributor.
139+
1. Someone from Airbyte will take a look at your PR and iterate with you to merge it into master.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# See [Source Acceptance Tests](https://docs.airbyte.io/connector-development/testing-connectors/source-acceptance-tests-reference)
2+
# for more information about how to configure these tests
3+
connector_image: airbyte/source-zenefits:dev
4+
tests:
5+
spec:
6+
- spec_path: "secrets/spec.json"
7+
connection:
8+
- config_path: "secrets/config.json"
9+
status: "succeed"
10+
- config_path: "integration_tests/invalid_config.json"
11+
status: "failed"
12+
discovery:
13+
- config_path: "secrets/config.json"
14+
basic_read:
15+
- config_path: "secrets/config.json"
16+
configured_catalog_path: "integration_tests/configured_catalog.json"
17+
empty_streams: []
18+
full_refresh:
19+
- config_path: "secrets/config.json"
20+
configured_catalog_path: "integration_tests/configured_catalog.json"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/usr/bin/env sh
2+
3+
# Build latest connector image
4+
docker build . -t $(cat acceptance-test-config.yml | grep "connector_image" | head -n 1 | cut -d: -f2-)
5+
6+
# Pull latest acctest image
7+
docker pull airbyte/source-acceptance-test:latest
8+
9+
# Run
10+
docker run --rm -it \
11+
-v /var/run/docker.sock:/var/run/docker.sock \
12+
-v /tmp:/tmp \
13+
-v $(pwd):/test_input \
14+
airbyte/source-acceptance-test \
15+
--acceptance-test-config /test_input
16+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
plugins {
2+
id 'airbyte-python'
3+
id 'airbyte-docker'
4+
id 'airbyte-source-acceptance-test'
5+
}
6+
7+
airbytePython {
8+
moduleDirectory 'source_zenefits'
9+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#
2+
# Copyright (c) 2022s Airbyte, Inc., all rights reserved.
3+
#
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#
2+
# Copyright (c) 2022 Airbyte, Inc., all rights reserved.
3+
#
4+
5+
6+
import pytest
7+
8+
pytest_plugins = ("source_acceptance_test.plugin",)
9+
10+
11+
@pytest.fixture(scope="session", autouse=True)
12+
def connector_setup():
13+
14+
yield

0 commit comments

Comments
 (0)