Skip to content

Commit d93a2d3

Browse files
drrestrobbinhan
authored andcommitted
🎉 New Source: NetSuite (airbytehq#16093)
1 parent 43733e1 commit d93a2d3

File tree

27 files changed

+1423
-0
lines changed

27 files changed

+1423
-0
lines changed

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -660,6 +660,14 @@
660660
icon: mysql.svg
661661
sourceType: database
662662
releaseStage: alpha
663+
- name: Netsuite
664+
sourceDefinitionId: 4f2f093d-ce44-4121-8118-9d13b7bfccd0
665+
dockerRepository: airbyte/source-netsuite
666+
dockerImageTag: 0.1.0
667+
documentationUrl: https://docs.airbyte.io/integrations/sources/netsuite
668+
# icon: notion.svg
669+
sourceType: api
670+
releaseStage: alpha
663671
- name: Notion
664672
sourceDefinitionId: 6e00b415-b02e-4160-bf02-58176a0ae687
665673
dockerRepository: airbyte/source-notion

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

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6906,6 +6906,86 @@
69066906
supportsNormalization: false
69076907
supportsDBT: false
69086908
supported_destination_sync_modes: []
6909+
- dockerImage: "airbyte/source-netsuite:0.1.0"
6910+
spec:
6911+
documentationUrl: "https://docsurl.com"
6912+
connectionSpecification:
6913+
$schema: "http://json-schema.org/draft-07/schema#"
6914+
title: "Netsuite Spec"
6915+
type: "object"
6916+
required:
6917+
- "realm"
6918+
- "consumer_key"
6919+
- "consumer_secret"
6920+
- "token_key"
6921+
- "token_secret"
6922+
- "start_datetime"
6923+
additionalProperties: true
6924+
properties:
6925+
realm:
6926+
type: "string"
6927+
title: "Realm (Account Id)"
6928+
description: "Netsuite realm e.g. 2344535, as for `production` or 2344535_SB1,\
6929+
\ as for the `sandbox`"
6930+
order: 0
6931+
airbyte_secret: true
6932+
consumer_key:
6933+
type: "string"
6934+
title: "Consumer Key"
6935+
description: "Consumer key associated with your integration"
6936+
order: 1
6937+
airbyte_secret: true
6938+
consumer_secret:
6939+
type: "string"
6940+
title: "Consumer Secret"
6941+
description: "Consumer secret associated with your integration"
6942+
order: 2
6943+
airbyte_secret: true
6944+
token_key:
6945+
type: "string"
6946+
title: "Token Key (Token Id)"
6947+
description: "Access token key"
6948+
order: 3
6949+
airbyte_secret: true
6950+
token_secret:
6951+
type: "string"
6952+
title: "Token Secret"
6953+
description: "Access token secret"
6954+
order: 4
6955+
airbyte_secret: true
6956+
object_types:
6957+
type: "array"
6958+
title: "Object Types (Optional)"
6959+
items:
6960+
type: "string"
6961+
description: "The API names of the Netsuite objects you want to sync. Setting\
6962+
\ this speeds up the connection setup process by limiting the number of\
6963+
\ schemas that need to be retrieved from Netsuite."
6964+
order: 5
6965+
examples:
6966+
- "customer"
6967+
- "salesorder"
6968+
- "etc"
6969+
default: []
6970+
start_datetime:
6971+
type: "string"
6972+
title: "Start Date"
6973+
description: "Starting point for your data replication, in format of \"\
6974+
YYYY-MM-DDTHH:mm:ssZ\""
6975+
order: 6
6976+
pattern: "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}Z$"
6977+
examples:
6978+
- "2017-01-25T00:00:00Z"
6979+
window_in_days:
6980+
type: "integer"
6981+
title: "Window in Days (Optional)"
6982+
description: "The amount of days used to query the data with date chunks.\
6983+
\ Set smaller value, if you have lots of data."
6984+
order: 7
6985+
default: 30
6986+
supportsNormalization: false
6987+
supportsDBT: false
6988+
supported_destination_sync_modes: []
69096989
- dockerImage: "airbyte/source-notion:0.1.8"
69106990
spec:
69116991
documentationUrl: "https://docs.airbyte.io/integrations/sources/notion"

airbyte-integrations/builds.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@
7272
| Monday | [![source-monday](https://img.shields.io/endpoint?url=https%3A%2F%2Fdnsgjos7lj2fu.cloudfront.net%2Ftests%2Fsummary%2Fsource-monday%2Fbadge.json)](https://dnsgjos7lj2fu.cloudfront.net/tests/summary/source-monday) |
7373
| My Hours | [![source-my-hours](https://img.shields.io/endpoint?url=https%3A%2F%2Fdnsgjos7lj2fu.cloudfront.net%2Ftests%2Fsummary%2Fsource-my-hours%2Fbadge.json)](https://dnsgjos7lj2fu.cloudfront.net/tests/summary/source-my-hours) |
7474
| MySQL | [![source-mysql](https://img.shields.io/endpoint?url=https%3A%2F%2Fdnsgjos7lj2fu.cloudfront.net%2Ftests%2Fsummary%2Fsource-mysql%2Fbadge.json)](https://dnsgjos7lj2fu.cloudfront.net/tests/summary/source-mysql) |
75+
| Netsuite | [![source-netsuite](https://img.shields.io/endpoint?url=https%3A%2F%2Fdnsgjos7lj2fu.cloudfront.net%2Ftests%2Fsummary%2Fsource-nensuite%2Fbadge.json)](https://dnsgjos7lj2fu.cloudfront.net/tests/summary/source-netsuite) |
7576
| Notion | [![source-notion](https://img.shields.io/endpoint?url=https%3A%2F%2Fdnsgjos7lj2fu.cloudfront.net%2Ftests%2Fsummary%2Fsource-notion%2Fbadge.json)](https://dnsgjos7lj2fu.cloudfront.net/tests/summary/source-notion) |
7677
| OneSignal | [![source-onesignal](https://img.shields.io/endpoint?url=https%3A%2F%2Fdnsgjos7lj2fu.cloudfront.net%2Ftests%2Fsummary%2Fsource-onesignal%2Fbadge.json)](https://dnsgjos7lj2fu.cloudfront.net/tests/summary/source-onesignal) |
7778
| OpenWeather | [![source-openweather](https://img.shields.io/endpoint?url=https%3A%2F%2Fdnsgjos7lj2fu.cloudfront.net%2Ftests%2Fsummary%2Fsource-openweather%2Fbadge.json)](https://dnsgjos7lj2fu.cloudfront.net/tests/summary/source-openweather) |
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
*
2+
!Dockerfile
3+
!main.py
4+
!source_netsuite
5+
!setup.py
6+
!secrets
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
FROM python:3.9.13-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+
33+
COPY source_netsuite ./source_netsuite
34+
35+
ENV AIRBYTE_ENTRYPOINT "python /airbyte/integration_code/main.py"
36+
ENTRYPOINT ["python", "/airbyte/integration_code/main.py"]
37+
38+
LABEL io.airbyte.version=0.1.0
39+
LABEL io.airbyte.name=airbyte/source-netsuite
Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
# Netsuite Soap Source
2+
3+
This is the repository for the Netsuite Soap source connector, written in Python.
4+
For information about how to use this connector within Airbyte, see [the documentation](https://docs.airbyte.io/integrations/sources/netsuite).
5+
6+
## Local development
7+
8+
### Prerequisites
9+
**To iterate on this connector, make sure to complete this prerequisites section.**
10+
11+
#### Minimum Python version required `= 3.9.0`
12+
13+
#### Build & Activate Virtual Environment and install dependencies
14+
From this connector directory, create a virtual environment:
15+
```
16+
python -m venv .venv
17+
```
18+
19+
This will generate a virtualenv for this module in `.venv/`. Make sure this venv is active in your
20+
development environment of choice. To activate it from the terminal, run:
21+
```
22+
source .venv/bin/activate
23+
pip install -r requirements.txt
24+
pip install '.[tests]'
25+
```
26+
If you are in an IDE, follow your IDE's instructions to activate the virtualenv.
27+
28+
Note that while we are installing dependencies from `requirements.txt`, you should only edit `setup.py` for your dependencies. `requirements.txt` is
29+
used for editable installs (`pip install -e`) to pull in Python dependencies from the monorepo and will call `setup.py`.
30+
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
31+
should work as you expect.
32+
33+
#### Building via Gradle
34+
You can also build the connector in Gradle. This is typically used in CI and not needed for your development workflow.
35+
36+
To build using Gradle, from the Airbyte repository root, run:
37+
```
38+
./gradlew :airbyte-integrations:connectors:source-netsuite:build
39+
```
40+
41+
#### Create credentials
42+
**If you are a community contributor**, follow the instructions in the [documentation](https://docs.airbyte.io/integrations/sources/netsuite)
43+
to generate the necessary credentials. Then create a file `secrets/config.json` conforming to the `source_netsuite_soap/spec.yaml` file.
44+
Note that any directory named `secrets` is gitignored across the entire Airbyte repo, so there is no danger of accidentally checking in sensitive information.
45+
See `integration_tests/sample_config.json` for a sample config file.
46+
47+
**If you are an Airbyte core member**, copy the credentials in Lastpass under the secret name `source netsuite test creds`
48+
and place them into `secrets/config.json`.
49+
50+
### Locally running the connector
51+
```
52+
python main.py spec
53+
python main.py check --config secrets/config.json
54+
python main.py discover --config secrets/config.json
55+
python main.py read --config secrets/config.json --catalog integration_tests/configured_catalog.json
56+
```
57+
58+
### Locally running the connector docker image
59+
60+
#### Build
61+
First, make sure you build the latest Docker image:
62+
```
63+
docker build . -t airbyte/source-netsuite:dev
64+
```
65+
66+
You can also build the connector image via Gradle:
67+
```
68+
./gradlew :airbyte-integrations:connectors:source-netsuite:airbyteDocker
69+
```
70+
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
71+
the Dockerfile.
72+
73+
#### Run
74+
Then run any of the connector commands as follows:
75+
```
76+
docker run --rm airbyte/source-netsuite:dev spec
77+
docker run --rm -v $(pwd)/secrets:/secrets airbyte/source-netsuite:dev check --config /secrets/config.json
78+
docker run --rm -v $(pwd)/secrets:/secrets airbyte/source-netsuite:dev discover --config /secrets/config.json
79+
docker run --rm -v $(pwd)/secrets:/secrets -v $(pwd)/integration_tests:/integration_tests airbyte/source-netsuite:dev read --config /secrets/config.json --catalog /integration_tests/configured_catalog.json
80+
```
81+
## Testing
82+
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.
83+
First install test dependencies into your virtual environment:
84+
```
85+
pip install .[tests]
86+
```
87+
### Unit Tests
88+
To run unit tests locally, from the connector directory run:
89+
```
90+
python -m pytest unit_tests
91+
```
92+
93+
### Integration Tests
94+
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).
95+
#### Custom Integration tests
96+
Place custom tests inside `integration_tests/` folder, then, from the connector root, run
97+
```
98+
python -m pytest integration_tests
99+
```
100+
#### Acceptance Tests
101+
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.
102+
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.
103+
To run your integration tests with acceptance tests, from the connector root, run
104+
```
105+
docker build . --no-cache -t airbyte/source-netsuite:dev \
106+
&& python -m pytest -p source_acceptance_test.plugin
107+
```
108+
To run your integration tests with docker
109+
110+
### Using gradle to run tests
111+
All commands should be run from airbyte project root.
112+
To run unit tests:
113+
```
114+
./gradlew :airbyte-integrations:connectors:source-netsuite:unitTest
115+
```
116+
To run acceptance and custom integration tests:
117+
```
118+
./gradlew :airbyte-integrations:connectors:source-netsuite:integrationTest
119+
```
120+
121+
## Dependency Management
122+
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.
123+
We split dependencies between two groups, dependencies that are:
124+
* required for your connector to work need to go to `MAIN_REQUIREMENTS` list.
125+
* required for the testing need to go to `TEST_REQUIREMENTS` list
126+
127+
### Publishing a new version of the connector
128+
You've checked out the repo, implemented a million dollar feature, and you're ready to share your changes with the world. Now what?
129+
1. Make sure your changes are passing unit and integration tests.
130+
1. Bump the connector version in `Dockerfile` -- just increment the value of the `LABEL io.airbyte.version` appropriately (we use [SemVer](https://semver.org/)).
131+
1. Create a Pull Request.
132+
1. Pat yourself on the back for being an awesome contributor.
133+
1. Someone from Airbyte will take a look at your PR and iterate with you to merge it into master.
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
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-netsuite:dev
4+
tests:
5+
spec:
6+
- spec_path: "source_netsuite/spec.yaml"
7+
connection:
8+
- config_path: "secrets/config.json"
9+
status: "succeed"
10+
- config_path: "sample_files/invalid_config.json"
11+
status: "failed"
12+
discovery:
13+
# Discovery stage is dynamic, so timeout iscreased
14+
- config_path: "secrets/config.json"
15+
timeout_seconds: 1200
16+
basic_read:
17+
- config_path: "secrets/config.json"
18+
# NetSuite has lots of streams available, we test the portion of them only.
19+
configured_catalog_path: "integration_tests/configured_catalog.json"
20+
empty_streams: [
21+
"customrecord01",
22+
"billingaccount",
23+
"charge",
24+
"message",
25+
"salesorder",
26+
]
27+
timeout_seconds: 3600
28+
full_refresh:
29+
- config_path: "secrets/config.json"
30+
configured_catalog_path: "integration_tests/configured_catalog.json"
31+
timeout_seconds: 3600
32+
incremental:
33+
- config_path: "secrets/config.json"
34+
configured_catalog_path: "integration_tests/configured_catalog.json"
35+
future_state_path: "integration_tests/abnormal_state.json"
36+
timeout_seconds: 3600
Lines changed: 16 additions & 0 deletions
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+
Lines changed: 9 additions & 0 deletions
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_netsuite'
9+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#
2+
# Copyright (c) 2022 Airbyte, Inc., all rights reserved.
3+
#

0 commit comments

Comments
 (0)