Skip to content

🎉 New Source: NetSuite #16093

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

Merged
merged 40 commits into from
Sep 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
2b51448
Source Netsuite - base realization with full_refresh only points
drrest Aug 29, 2022
c2e3bec
Source Netsuite - changed acceptanceTest settings
drrest Aug 29, 2022
7039a8e
Source Netsuite:
drrest Sep 1, 2022
ea6ccc9
little fixes
drrest Sep 1, 2022
5b3f4bc
Source Netsuite - fixes to schemas
drrest Sep 2, 2022
97fc8ba
Source Netsuite - base realization with full_refresh only points
drrest Sep 2, 2022
1fac4cb
Source Netsuite
drrest Sep 6, 2022
be2f6a8
Source Netsuite - acceptanceTest fix
drrest Sep 6, 2022
a6d55dd
Source Netsuite
drrest Sep 6, 2022
b4060be
Source Netsuite - changes
drrest Sep 6, 2022
2a0eac8
Source Netsuite
drrest Sep 6, 2022
d17405d
Source Netsuite
drrest Sep 7, 2022
75ccd40
Source Netsuite
drrest Sep 7, 2022
9d7487c
Source Netsuite
drrest Sep 7, 2022
7be7766
Source Netsuite
drrest Sep 7, 2022
99cd589
Source Netsuite
drrest Sep 7, 2022
a9b35de
Source Netsuite: couple of changes
drrest Sep 7, 2022
8c75e38
Source Netsuite: fixes
drrest Sep 7, 2022
370fe44
Merge remote-tracking branch 'origin/master' into 3212-source-netsuit…
Sep 9, 2022
76f91ff
refactored full-refresh part
Sep 12, 2022
e3b06ab
refactored to use REST API
Sep 14, 2022
d984352
removed schemas dir, as they are not needed anymore
Sep 14, 2022
ecf7fec
added public documentation
Sep 14, 2022
6de46f0
fixed small problem with records + formated code, documentation
Sep 15, 2022
7a55fa9
corrected spec
Sep 15, 2022
8dcfc33
updated SAT tests
Sep 15, 2022
42c9bbe
Merge remote-tracking branch 'origin/master' into 3212-source-netsuit…
Sep 15, 2022
09b9bcb
updated spec with titles
Sep 15, 2022
3fa4a9a
updated spec with order
Sep 15, 2022
a1129af
Merge remote-tracking branch 'origin/master' into 3212-source-netsuit…
Sep 15, 2022
46c04a5
updated streams generation
Sep 15, 2022
fc9c3ca
forrmated code
Sep 15, 2022
90cb078
Merge remote-tracking branch 'origin/master' into 3212-source-netsuit…
Sep 15, 2022
844b7a1
updated after review
Sep 15, 2022
5507542
fixed build.md
Sep 15, 2022
cc6b9dd
updated and formated code
Sep 16, 2022
eeab96b
updated cursor reference
Sep 16, 2022
5865198
updated request params
Sep 16, 2022
9a85678
Merge remote-tracking branch 'origin/master' into 3212-source-netsuit…
Sep 16, 2022
6008766
auto-bump connector version [ci skip]
octavia-squidington-iii Sep 21, 2022
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
Original file line number Diff line number Diff line change
Expand Up @@ -660,6 +660,14 @@
icon: mysql.svg
sourceType: database
releaseStage: alpha
- name: Netsuite
sourceDefinitionId: 4f2f093d-ce44-4121-8118-9d13b7bfccd0
dockerRepository: airbyte/source-netsuite
dockerImageTag: 0.1.0
documentationUrl: https://docs.airbyte.io/integrations/sources/netsuite
# icon: notion.svg
sourceType: api
releaseStage: alpha
- name: Notion
sourceDefinitionId: 6e00b415-b02e-4160-bf02-58176a0ae687
dockerRepository: airbyte/source-notion
Expand Down
80 changes: 80 additions & 0 deletions airbyte-config/init/src/main/resources/seed/source_specs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6854,6 +6854,86 @@
supportsNormalization: false
supportsDBT: false
supported_destination_sync_modes: []
- dockerImage: "airbyte/source-netsuite:0.1.0"
spec:
documentationUrl: "https://docsurl.com"
connectionSpecification:
$schema: "http://json-schema.org/draft-07/schema#"
title: "Netsuite Spec"
type: "object"
required:
- "realm"
- "consumer_key"
- "consumer_secret"
- "token_key"
- "token_secret"
- "start_datetime"
additionalProperties: true
properties:
realm:
type: "string"
title: "Realm (Account Id)"
description: "Netsuite realm e.g. 2344535, as for `production` or 2344535_SB1,\
\ as for the `sandbox`"
order: 0
airbyte_secret: true
consumer_key:
type: "string"
title: "Consumer Key"
description: "Consumer key associated with your integration"
order: 1
airbyte_secret: true
consumer_secret:
type: "string"
title: "Consumer Secret"
description: "Consumer secret associated with your integration"
order: 2
airbyte_secret: true
token_key:
type: "string"
title: "Token Key (Token Id)"
description: "Access token key"
order: 3
airbyte_secret: true
token_secret:
type: "string"
title: "Token Secret"
description: "Access token secret"
order: 4
airbyte_secret: true
object_types:
type: "array"
title: "Object Types (Optional)"
items:
type: "string"
description: "The API names of the Netsuite objects you want to sync. Setting\
\ this speeds up the connection setup process by limiting the number of\
\ schemas that need to be retrieved from Netsuite."
order: 5
examples:
- "customer"
- "salesorder"
- "etc"
default: []
start_datetime:
type: "string"
title: "Start Date"
description: "Starting point for your data replication, in format of \"\
YYYY-MM-DDTHH:mm:ssZ\""
order: 6
pattern: "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}Z$"
examples:
- "2017-01-25T00:00:00Z"
window_in_days:
type: "integer"
title: "Window in Days (Optional)"
description: "The amount of days used to query the data with date chunks.\
\ Set smaller value, if you have lots of data."
order: 7
default: 30
supportsNormalization: false
supportsDBT: false
supported_destination_sync_modes: []
- dockerImage: "airbyte/source-notion:0.1.8"
spec:
documentationUrl: "https://docs.airbyte.io/integrations/sources/notion"
Expand Down
1 change: 1 addition & 0 deletions airbyte-integrations/builds.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
| 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) |
| 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) |
| 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) |
| 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) |
| 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) |
| 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) |
| 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) |
Expand Down
6 changes: 6 additions & 0 deletions airbyte-integrations/connectors/source-netsuite/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
*
!Dockerfile
!main.py
!source_netsuite
!setup.py
!secrets
39 changes: 39 additions & 0 deletions airbyte-integrations/connectors/source-netsuite/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
FROM python:3.9.13-alpine3.15 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 \
&& apk --no-cache add tzdata build-base


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
# add default timezone settings
COPY --from=builder /usr/share/zoneinfo/Etc/UTC /etc/localtime
RUN echo "Etc/UTC" > /etc/timezone

# bash is installed for more convenient debugging.
RUN apk --no-cache add bash

# copy payload code only
COPY main.py ./

COPY source_netsuite ./source_netsuite

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-netsuite
133 changes: 133 additions & 0 deletions airbyte-integrations/connectors/source-netsuite/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
# Netsuite Soap Source

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

## Local development

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

#### Minimum Python version required `= 3.9.0`

#### Build & Activate Virtual Environment and install dependencies
From this connector directory, create a virtual environment:
```
python -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
pip install '.[tests]'
```
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-netsuite:build
```

#### Create credentials
**If you are a community contributor**, follow the instructions in the [documentation](https://docs.airbyte.io/integrations/sources/netsuite)
to generate the necessary credentials. Then create a file `secrets/config.json` conforming to the `source_netsuite_soap/spec.yaml` 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 netsuite 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-netsuite:dev
```

You can also build the connector image via Gradle:
```
./gradlew :airbyte-integrations:connectors:source-netsuite: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-netsuite:dev spec
docker run --rm -v $(pwd)/secrets:/secrets airbyte/source-netsuite:dev check --config /secrets/config.json
docker run --rm -v $(pwd)/secrets:/secrets airbyte/source-netsuite:dev discover --config /secrets/config.json
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
```
## 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](https://docs.airbyte.io/connector-development/testing-connectors/source-acceptance-tests-reference) 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-netsuite:dev \
&& python -m pytest -p source_acceptance_test.plugin
```
To run your integration tests with docker

### Using gradle to run tests
All commands should be run from airbyte project root.
To run unit tests:
```
./gradlew :airbyte-integrations:connectors:source-netsuite:unitTest
```
To run acceptance and custom integration tests:
```
./gradlew :airbyte-integrations:connectors:source-netsuite: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,36 @@
# See [Source Acceptance Tests](https://docs.airbyte.io/connector-development/testing-connectors/source-acceptance-tests-reference)
# for more information about how to configure these tests
connector_image: airbyte/source-netsuite:dev
tests:
spec:
- spec_path: "source_netsuite/spec.yaml"
connection:
- config_path: "secrets/config.json"
status: "succeed"
- config_path: "sample_files/invalid_config.json"
status: "failed"
discovery:
# Discovery stage is dynamic, so timeout iscreased
- config_path: "secrets/config.json"
timeout_seconds: 1200
basic_read:
- config_path: "secrets/config.json"
# NetSuite has lots of streams available, we test the portion of them only.
configured_catalog_path: "integration_tests/configured_catalog.json"
empty_streams: [
"customrecord01",
"billingaccount",
"charge",
"message",
"salesorder",
]
timeout_seconds: 3600
full_refresh:
- config_path: "secrets/config.json"
configured_catalog_path: "integration_tests/configured_catalog.json"
timeout_seconds: 3600
incremental:
- config_path: "secrets/config.json"
configured_catalog_path: "integration_tests/configured_catalog.json"
future_state_path: "integration_tests/abnormal_state.json"
timeout_seconds: 3600
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,9 @@
plugins {
id 'airbyte-python'
id 'airbyte-docker'
id 'airbyte-source-acceptance-test'
}

airbytePython {
moduleDirectory 'source_netsuite'
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#
# Copyright (c) 2022 Airbyte, Inc., all rights reserved.
#
Loading