Skip to content

Commit 274a683

Browse files
haithem-soualamarcosmarxm
authored andcommitted
🎉 New Source - Intruder [low-code cdk] (#18668)
* initial commit * fix schema * lint * add docs * add pagination * add pagination * add intruder to source def * readd ip2whois * add intruder to source def Co-authored-by: marcosmarxm <[email protected]>
1 parent a842b86 commit 274a683

29 files changed

+800
-25
lines changed

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

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -641,6 +641,13 @@
641641
icon: hubspot.svg
642642
sourceType: api
643643
releaseStage: generally_available
644+
- name: IP2Whois
645+
sourceDefinitionId: f23b7b7c-d705-49a3-9042-09add3b104a5
646+
dockerRepository: airbyte/source-ip2whois
647+
dockerImageTag: 0.1.0
648+
documentationUrl: https://docs.airbyte.com/integrations/sources/ip2whois
649+
sourceType: api
650+
releaseStage: alpha
644651
- name: IBM Db2
645652
sourceDefinitionId: 447e0381-3780-4b46-bb62-00a4e3c8b8e2
646653
dockerRepository: airbyte/source-db2
@@ -672,11 +679,11 @@
672679
icon: intercom.svg
673680
sourceType: api
674681
releaseStage: generally_available
675-
- name: IP2Whois
676-
sourceDefinitionId: f23b7b7c-d705-49a3-9042-09add3b104a5
677-
dockerRepository: airbyte/source-ip2whois
682+
- name: Intruder
683+
sourceDefinitionId: 3d15163b-11d8-412f-b808-795c9b2c3a3a
684+
dockerRepository: airbyte/source-intruder
678685
dockerImageTag: 0.1.0
679-
documentationUrl: https://docs.airbyte.com/integrations/sources/ip2whois
686+
documentationUrl: https://docs.airbyte.com/integrations/sources/intruder
680687
sourceType: api
681688
releaseStage: alpha
682689
- name: Iterable

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

Lines changed: 34 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5906,6 +5906,32 @@
59065906
- - "client_secret"
59075907
oauthFlowOutputParameters:
59085908
- - "refresh_token"
5909+
- dockerImage: "airbyte/source-ip2whois:0.1.0"
5910+
spec:
5911+
documentationUrl: "https://docs.airbyte.com/integrations/sources/ip2whois"
5912+
connectionSpecification:
5913+
$schema: "http://json-schema.org/draft-07/schema#"
5914+
title: "Ip2whois Spec"
5915+
type: "object"
5916+
additionalProperties: true
5917+
properties:
5918+
api_key:
5919+
title: "API key"
5920+
type: "string"
5921+
description: "Your API Key. See <a href=\"https://www.ip2whois.com/developers-api\"\
5922+
>here</a>."
5923+
airbyte_secret: true
5924+
domain:
5925+
title: "Domain"
5926+
type: "string"
5927+
description: "Domain name. See <a href=\"https://www.ip2whois.com/developers-api\"\
5928+
>here</a>."
5929+
examples:
5930+
- "www.google.com"
5931+
- "www.facebook.com"
5932+
supportsNormalization: false
5933+
supportsDBT: false
5934+
supported_destination_sync_modes: []
59095935
- dockerImage: "airbyte/source-db2:0.1.16"
59105936
spec:
59115937
documentationUrl: "https://docs.airbyte.com/integrations/sources/db2"
@@ -6111,29 +6137,23 @@
61116137
oauthFlowInitParameters: []
61126138
oauthFlowOutputParameters:
61136139
- - "access_token"
6114-
- dockerImage: "airbyte/source-ip2whois:0.1.0"
6140+
- dockerImage: "airbyte/source-intruder:0.1.0"
61156141
spec:
6116-
documentationUrl: "https://docs.airbyte.com/integrations/sources/ip2whois"
6142+
documentationUrl: "https://docs.airbyte.com/integrations/sources/intruder"
61176143
connectionSpecification:
61186144
$schema: "http://json-schema.org/draft-07/schema#"
6119-
title: "Ip2whois Spec"
6145+
title: "Intruder Spec"
61206146
type: "object"
6147+
required:
6148+
- "access_token"
61216149
additionalProperties: true
61226150
properties:
6123-
api_key:
6124-
title: "API key"
6151+
access_token:
6152+
title: "API Access token"
61256153
type: "string"
6126-
description: "Your API Key. See <a href=\"https://www.ip2whois.com/developers-api\"\
6154+
description: "Your API Access token. See <a href=\"https://developers.intruder.io/docs/authentication\"\
61276155
>here</a>."
61286156
airbyte_secret: true
6129-
domain:
6130-
title: "Domain"
6131-
type: "string"
6132-
description: "Domain name. See <a href=\"https://www.ip2whois.com/developers-api\"\
6133-
>here</a>."
6134-
examples:
6135-
- "www.google.com"
6136-
- "www.facebook.com"
61376157
supportsNormalization: false
61386158
supportsDBT: false
61396159
supported_destination_sync_modes: []
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_intruder
5+
!setup.py
6+
!secrets
Lines changed: 38 additions & 0 deletions
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_intruder ./source_intruder
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-intruder
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
# Intruder Source
2+
3+
This is the repository for the Intruder configuration based source connector.
4+
For information about how to use this connector within Airbyte, see [the documentation](https://docs.airbyte.io/integrations/sources/intruder).
5+
6+
## Local development
7+
8+
#### Building via Gradle
9+
You can also build the connector in Gradle. This is typically used in CI and not needed for your development workflow.
10+
11+
To build using Gradle, from the Airbyte repository root, run:
12+
```
13+
./gradlew :airbyte-integrations:connectors:source-intruder:build
14+
```
15+
16+
#### Create credentials
17+
**If you are a community contributor**, follow the instructions in the [documentation](https://docs.airbyte.io/integrations/sources/intruder)
18+
to generate the necessary credentials. Then create a file `secrets/config.json` conforming to the `source_intruder/spec.yaml` file.
19+
Note that any directory named `secrets` is gitignored across the entire Airbyte repo, so there is no danger of accidentally checking in sensitive information.
20+
See `integration_tests/sample_config.json` for a sample config file.
21+
22+
**If you are an Airbyte core member**, copy the credentials in Lastpass under the secret name `source intruder test creds`
23+
and place them into `secrets/config.json`.
24+
25+
### Locally running the connector docker image
26+
27+
#### Build
28+
First, make sure you build the latest Docker image:
29+
```
30+
docker build . -t airbyte/source-intruder:dev
31+
```
32+
33+
You can also build the connector image via Gradle:
34+
```
35+
./gradlew :airbyte-integrations:connectors:source-intruder:airbyteDocker
36+
```
37+
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
38+
the Dockerfile.
39+
40+
#### Run
41+
Then run any of the connector commands as follows:
42+
```
43+
docker run --rm airbyte/source-intruder:dev spec
44+
docker run --rm -v $(pwd)/secrets:/secrets airbyte/source-intruder:dev check --config /secrets/config.json
45+
docker run --rm -v $(pwd)/secrets:/secrets airbyte/source-intruder:dev discover --config /secrets/config.json
46+
docker run --rm -v $(pwd)/secrets:/secrets -v $(pwd)/integration_tests:/integration_tests airbyte/source-intruder:dev read --config /secrets/config.json --catalog /integration_tests/configured_catalog.json
47+
```
48+
## Testing
49+
50+
#### Acceptance Tests
51+
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.
52+
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.
53+
54+
To run your integration tests with docker
55+
56+
### Using gradle to run tests
57+
All commands should be run from airbyte project root.
58+
To run unit tests:
59+
```
60+
./gradlew :airbyte-integrations:connectors:source-intruder:unitTest
61+
```
62+
To run acceptance and custom integration tests:
63+
```
64+
./gradlew :airbyte-integrations:connectors:source-intruder:integrationTest
65+
```
66+
67+
## Dependency Management
68+
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.
69+
We split dependencies between two groups, dependencies that are:
70+
* required for your connector to work need to go to `MAIN_REQUIREMENTS` list.
71+
* required for the testing need to go to `TEST_REQUIREMENTS` list
72+
73+
### Publishing a new version of the connector
74+
You've checked out the repo, implemented a million dollar feature, and you're ready to share your changes with the world. Now what?
75+
1. Make sure your changes are passing unit and integration tests.
76+
1. Bump the connector version in `Dockerfile` -- just increment the value of the `LABEL io.airbyte.version` appropriately (we use [SemVer](https://semver.org/)).
77+
1. Create a Pull Request.
78+
1. Pat yourself on the back for being an awesome contributor.
79+
1. Someone from Airbyte will take a look at your PR and iterate with you to merge it into master.
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+
#
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# See [Source Acceptance Tests](https://docs.airbyte.com/connector-development/testing-connectors/source-acceptance-tests-reference)
2+
# for more information about how to configure these tests
3+
connector_image: airbyte/source-intruder:dev
4+
acceptance_tests:
5+
spec:
6+
tests:
7+
- spec_path: "source_intruder/spec.yaml"
8+
connection:
9+
tests:
10+
- config_path: "secrets/config.json"
11+
status: "succeed"
12+
- config_path: "integration_tests/invalid_config.json"
13+
status: "failed"
14+
discovery:
15+
tests:
16+
- config_path: "secrets/config.json"
17+
basic_read:
18+
tests:
19+
- config_path: "secrets/config.json"
20+
configured_catalog_path: "integration_tests/configured_catalog.json"
21+
empty_streams: []
22+
# TODO uncomment this block to specify that the tests should assert the connector outputs the records provided in the input file a file
23+
# expect_records:
24+
# path: "integration_tests/expected_records.txt"
25+
# extra_fields: no
26+
# exact_order: no
27+
# extra_records: yes
28+
incremental:
29+
bypass_reason: "This connector does not implement incremental sync"
30+
# TODO uncomment this block this block if your connector implements incremental sync:
31+
# tests:
32+
# - config_path: "secrets/config.json"
33+
# configured_catalog_path: "integration_tests/configured_catalog.json"
34+
# future_state_path: "integration_tests/abnormal_state.json"
35+
full_refresh:
36+
tests:
37+
- config_path: "secrets/config.json"
38+
configured_catalog_path: "integration_tests/configured_catalog.json"
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_intruder'
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+
#
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"todo-stream-name": {
3+
"todo-field-name": "todo-abnormal-value"
4+
}
5+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
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+
"""This fixture is a placeholder for external resources that acceptance test might require."""
14+
# TODO: setup test dependencies if needed. otherwise remove the TODO comments
15+
yield
16+
# TODO: clean up test dependencies
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
{
2+
"streams": [
3+
{
4+
"stream": {
5+
"name": "issues",
6+
"json_schema": {},
7+
"supported_sync_modes": ["full_refresh"]
8+
},
9+
"sync_mode": "full_refresh",
10+
"destination_sync_mode": "append",
11+
"supported_destination_sync_modes": ["overwrite", "append"]
12+
},
13+
{
14+
"stream": {
15+
"name": "occurrences_issues",
16+
"json_schema": {},
17+
"supported_sync_modes": ["full_refresh"]
18+
},
19+
"sync_mode": "full_refresh",
20+
"destination_sync_mode": "append",
21+
"supported_destination_sync_modes": ["overwrite", "append"]
22+
},
23+
{
24+
"stream": {
25+
"name": "scans",
26+
"json_schema": {},
27+
"supported_sync_modes": ["full_refresh"]
28+
},
29+
"sync_mode": "full_refresh",
30+
"destination_sync_mode": "append",
31+
"supported_destination_sync_modes": ["overwrite", "append"]
32+
},
33+
{
34+
"stream": {
35+
"name": "targets",
36+
"json_schema": {},
37+
"supported_sync_modes": ["full_refresh"]
38+
},
39+
"sync_mode": "full_refresh",
40+
"destination_sync_mode": "append",
41+
"supported_destination_sync_modes": ["overwrite", "append"]
42+
}
43+
]
44+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"access_token": ""
3+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"access_token": "kmMCJRtJ5dOrXDu9Roxtp53Nad25UE5NAi1eqTaqabk"
3+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"todo-stream-name": {
3+
"todo-field-name": "value"
4+
}
5+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#
2+
# Copyright (c) 2022 Airbyte, Inc., all rights reserved.
3+
#
4+
5+
6+
import sys
7+
8+
from airbyte_cdk.entrypoint import launch
9+
from source_intruder import SourceIntruder
10+
11+
if __name__ == "__main__":
12+
source = SourceIntruder()
13+
launch(source, sys.argv[1:])
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
-e ../../bases/source-acceptance-test
2+
-e .

0 commit comments

Comments
 (0)