airbyte-source-firebase-realtime-database 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- airbyte-source-firebase-realtime-database-0.1.0/PKG-INFO +100 -0
- airbyte-source-firebase-realtime-database-0.1.0/README.md +99 -0
- airbyte-source-firebase-realtime-database-0.1.0/airbyte_source_firebase_realtime_database.egg-info/PKG-INFO +100 -0
- airbyte-source-firebase-realtime-database-0.1.0/airbyte_source_firebase_realtime_database.egg-info/SOURCES.txt +21 -0
- airbyte-source-firebase-realtime-database-0.1.0/airbyte_source_firebase_realtime_database.egg-info/dependency_links.txt +1 -0
- airbyte-source-firebase-realtime-database-0.1.0/airbyte_source_firebase_realtime_database.egg-info/entry_points.txt +2 -0
- airbyte-source-firebase-realtime-database-0.1.0/airbyte_source_firebase_realtime_database.egg-info/requires.txt +8 -0
- airbyte-source-firebase-realtime-database-0.1.0/airbyte_source_firebase_realtime_database.egg-info/top_level.txt +2 -0
- airbyte-source-firebase-realtime-database-0.1.0/integration_tests/__init__.py +3 -0
- airbyte-source-firebase-realtime-database-0.1.0/integration_tests/acceptance.py +66 -0
- airbyte-source-firebase-realtime-database-0.1.0/integration_tests/catalog.json +20 -0
- airbyte-source-firebase-realtime-database-0.1.0/integration_tests/configured_catalog.json +24 -0
- airbyte-source-firebase-realtime-database-0.1.0/integration_tests/invalid_config.json +6 -0
- airbyte-source-firebase-realtime-database-0.1.0/integration_tests/records.json +6 -0
- airbyte-source-firebase-realtime-database-0.1.0/integration_tests/sample_config.json +6 -0
- airbyte-source-firebase-realtime-database-0.1.0/setup.cfg +96 -0
- airbyte-source-firebase-realtime-database-0.1.0/setup.py +45 -0
- airbyte-source-firebase-realtime-database-0.1.0/source_firebase_realtime_database/__init__.py +8 -0
- airbyte-source-firebase-realtime-database-0.1.0/source_firebase_realtime_database/firebase_rtdb.py +85 -0
- airbyte-source-firebase-realtime-database-0.1.0/source_firebase_realtime_database/run.py +14 -0
- airbyte-source-firebase-realtime-database-0.1.0/source_firebase_realtime_database/source.py +135 -0
- airbyte-source-firebase-realtime-database-0.1.0/source_firebase_realtime_database/spec.yaml +27 -0
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: airbyte-source-firebase-realtime-database
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Source implementation for Firebase Realtime Database.
|
|
5
|
+
Author: Airbyte
|
|
6
|
+
Author-email: contact@airbyte.io
|
|
7
|
+
Description-Content-Type: text/markdown
|
|
8
|
+
Requires-Dist: airbyte-cdk
|
|
9
|
+
Requires-Dist: firebase-admin
|
|
10
|
+
Provides-Extra: tests
|
|
11
|
+
Requires-Dist: requests-mock~=1.9.3; extra == "tests"
|
|
12
|
+
Requires-Dist: pytest-mock~=3.6.1; extra == "tests"
|
|
13
|
+
Requires-Dist: pytest~=6.1; extra == "tests"
|
|
14
|
+
Requires-Dist: source-acceptance-test; extra == "tests"
|
|
15
|
+
|
|
16
|
+
# Firebase Realtime Database Source
|
|
17
|
+
|
|
18
|
+
This is the repository for the Firebase Realtime Database source connector, written in Python.
|
|
19
|
+
For information about how to use this connector within Airbyte, see [the documentation](https://docs.airbyte.io/integrations/sources/firebase-realtime-database).
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
**To iterate on this connector, make sure to complete this prerequisites section.**
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
From this connector directory, create a virtual environment:
|
|
26
|
+
```
|
|
27
|
+
python -m venv .venv
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
This will generate a virtualenv for this module in `.venv/`. Make sure this venv is active in your
|
|
31
|
+
development environment of choice. To activate it from the terminal, run:
|
|
32
|
+
```
|
|
33
|
+
source .venv/bin/activate
|
|
34
|
+
pip install -r requirements.txt
|
|
35
|
+
```
|
|
36
|
+
If you are in an IDE, follow your IDE's instructions to activate the virtualenv.
|
|
37
|
+
|
|
38
|
+
Note that while we are installing dependencies from `requirements.txt`, you should only edit `setup.py` for your dependencies. `requirements.txt` is
|
|
39
|
+
used for editable installs (`pip install -e`) to pull in Python dependencies from the monorepo and will call `setup.py`.
|
|
40
|
+
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
|
|
41
|
+
should work as you expect.
|
|
42
|
+
|
|
43
|
+
**If you are a community contributor**, follow the instructions in the [documentation](https://docs.airbyte.io/integrations/sources/firebase-realtime-database)
|
|
44
|
+
to generate the necessary credentials. Then create a file `secrets/config.json` conforming to the `source_firebase_realtime_database/spec.yaml` file.
|
|
45
|
+
Note that the `secrets` directory is gitignored by default, so there is no danger of accidentally checking in sensitive information.
|
|
46
|
+
See `integration_tests/sample_config.json` for a sample config file.
|
|
47
|
+
|
|
48
|
+
**If you are an Airbyte core member**, copy the credentials in Lastpass under the secret name `source firebase-realtime-database test creds`
|
|
49
|
+
and place them into `secrets/config.json`.
|
|
50
|
+
|
|
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
|
+
|
|
59
|
+
|
|
60
|
+
**Via [`airbyte-ci`](https://github.com/airbytehq/airbyte/blob/master/airbyte-ci/connectors/pipelines/README.md) (recommended):**
|
|
61
|
+
```bash
|
|
62
|
+
airbyte-ci connectors --name=source-firebase-realtime-database build
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
An image will be built with the tag `airbyte/source-firebase-realtime-database:dev`.
|
|
66
|
+
|
|
67
|
+
**Via `docker build`:**
|
|
68
|
+
```bash
|
|
69
|
+
docker build -t airbyte/source-firebase-realtime-database:dev .
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
Then run any of the connector commands as follows:
|
|
73
|
+
```
|
|
74
|
+
docker run --rm airbyte/source-firebase-realtime-database:dev spec
|
|
75
|
+
docker run --rm -v $(pwd)/secrets:/secrets airbyte/source-firebase-realtime-database:dev check --config /secrets/config.json
|
|
76
|
+
docker run --rm -v $(pwd)/secrets:/secrets airbyte/source-firebase-realtime-database:dev discover --config /secrets/config.json
|
|
77
|
+
docker run --rm -v $(pwd)/secrets:/secrets -v $(pwd)/integration_tests:/integration_tests airbyte/source-firebase-realtime-database:dev read --config /secrets/config.json --catalog /integration_tests/configured_catalog.json
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
You can run our full test suite locally using [`airbyte-ci`](https://github.com/airbytehq/airbyte/blob/master/airbyte-ci/connectors/pipelines/README.md):
|
|
81
|
+
```bash
|
|
82
|
+
airbyte-ci connectors --name=source-firebase-realtime-database test
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
Customize `acceptance-test-config.yml` file to configure tests. See [Connector Acceptance Tests](https://docs.airbyte.com/connector-development/testing-connectors/connector-acceptance-tests-reference) for more information.
|
|
86
|
+
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.
|
|
87
|
+
|
|
88
|
+
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.
|
|
89
|
+
We split dependencies between two groups, dependencies that are:
|
|
90
|
+
* required for your connector to work need to go to `MAIN_REQUIREMENTS` list.
|
|
91
|
+
* required for the testing need to go to `TEST_REQUIREMENTS` list
|
|
92
|
+
|
|
93
|
+
You've checked out the repo, implemented a million dollar feature, and you're ready to share your changes with the world. Now what?
|
|
94
|
+
1. Make sure your changes are passing our test suite: `airbyte-ci connectors --name=source-firebase-realtime-database test`
|
|
95
|
+
2. Bump the connector version in `metadata.yaml`: increment the `dockerImageTag` value. Please follow [semantic versioning for connectors](https://docs.airbyte.com/contributing-to-airbyte/resources/pull-requests-handbook/#semantic-versioning-for-connectors).
|
|
96
|
+
3. Make sure the `metadata.yaml` content is up to date.
|
|
97
|
+
4. Make the connector documentation and its changelog is up to date (`docs/integrations/sources/firebase-realtime-database.md`).
|
|
98
|
+
5. Create a Pull Request: use [our PR naming conventions](https://docs.airbyte.com/contributing-to-airbyte/resources/pull-requests-handbook/#pull-request-title-convention).
|
|
99
|
+
6. Pat yourself on the back for being an awesome contributor.
|
|
100
|
+
7. Someone from Airbyte will take a look at your PR and iterate with you to merge it into master.
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
# Firebase Realtime Database Source
|
|
2
|
+
|
|
3
|
+
This is the repository for the Firebase Realtime Database 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/firebase-realtime-database).
|
|
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
|
+
```
|
|
25
|
+
If you are in an IDE, follow your IDE's instructions to activate the virtualenv.
|
|
26
|
+
|
|
27
|
+
Note that while we are installing dependencies from `requirements.txt`, you should only edit `setup.py` for your dependencies. `requirements.txt` is
|
|
28
|
+
used for editable installs (`pip install -e`) to pull in Python dependencies from the monorepo and will call `setup.py`.
|
|
29
|
+
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
|
|
30
|
+
should work as you expect.
|
|
31
|
+
|
|
32
|
+
#### Create credentials
|
|
33
|
+
**If you are a community contributor**, follow the instructions in the [documentation](https://docs.airbyte.io/integrations/sources/firebase-realtime-database)
|
|
34
|
+
to generate the necessary credentials. Then create a file `secrets/config.json` conforming to the `source_firebase_realtime_database/spec.yaml` file.
|
|
35
|
+
Note that the `secrets` directory is gitignored by default, so there is no danger of accidentally checking in sensitive information.
|
|
36
|
+
See `integration_tests/sample_config.json` for a sample config file.
|
|
37
|
+
|
|
38
|
+
**If you are an Airbyte core member**, copy the credentials in Lastpass under the secret name `source firebase-realtime-database test creds`
|
|
39
|
+
and place them into `secrets/config.json`.
|
|
40
|
+
|
|
41
|
+
### Locally running the connector
|
|
42
|
+
```
|
|
43
|
+
python main.py spec
|
|
44
|
+
python main.py check --config secrets/config.json
|
|
45
|
+
python main.py discover --config secrets/config.json
|
|
46
|
+
python main.py read --config secrets/config.json --catalog integration_tests/configured_catalog.json
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
### Locally running the connector docker image
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
#### Build
|
|
53
|
+
**Via [`airbyte-ci`](https://github.com/airbytehq/airbyte/blob/master/airbyte-ci/connectors/pipelines/README.md) (recommended):**
|
|
54
|
+
```bash
|
|
55
|
+
airbyte-ci connectors --name=source-firebase-realtime-database build
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
An image will be built with the tag `airbyte/source-firebase-realtime-database:dev`.
|
|
59
|
+
|
|
60
|
+
**Via `docker build`:**
|
|
61
|
+
```bash
|
|
62
|
+
docker build -t airbyte/source-firebase-realtime-database:dev .
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
#### Run
|
|
66
|
+
Then run any of the connector commands as follows:
|
|
67
|
+
```
|
|
68
|
+
docker run --rm airbyte/source-firebase-realtime-database:dev spec
|
|
69
|
+
docker run --rm -v $(pwd)/secrets:/secrets airbyte/source-firebase-realtime-database:dev check --config /secrets/config.json
|
|
70
|
+
docker run --rm -v $(pwd)/secrets:/secrets airbyte/source-firebase-realtime-database:dev discover --config /secrets/config.json
|
|
71
|
+
docker run --rm -v $(pwd)/secrets:/secrets -v $(pwd)/integration_tests:/integration_tests airbyte/source-firebase-realtime-database:dev read --config /secrets/config.json --catalog /integration_tests/configured_catalog.json
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## Testing
|
|
75
|
+
You can run our full test suite locally using [`airbyte-ci`](https://github.com/airbytehq/airbyte/blob/master/airbyte-ci/connectors/pipelines/README.md):
|
|
76
|
+
```bash
|
|
77
|
+
airbyte-ci connectors --name=source-firebase-realtime-database test
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
### Customizing acceptance Tests
|
|
81
|
+
Customize `acceptance-test-config.yml` file to configure tests. See [Connector Acceptance Tests](https://docs.airbyte.com/connector-development/testing-connectors/connector-acceptance-tests-reference) for more information.
|
|
82
|
+
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.
|
|
83
|
+
|
|
84
|
+
## Dependency Management
|
|
85
|
+
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.
|
|
86
|
+
We split dependencies between two groups, dependencies that are:
|
|
87
|
+
* required for your connector to work need to go to `MAIN_REQUIREMENTS` list.
|
|
88
|
+
* required for the testing need to go to `TEST_REQUIREMENTS` list
|
|
89
|
+
|
|
90
|
+
### Publishing a new version of the connector
|
|
91
|
+
You've checked out the repo, implemented a million dollar feature, and you're ready to share your changes with the world. Now what?
|
|
92
|
+
1. Make sure your changes are passing our test suite: `airbyte-ci connectors --name=source-firebase-realtime-database test`
|
|
93
|
+
2. Bump the connector version in `metadata.yaml`: increment the `dockerImageTag` value. Please follow [semantic versioning for connectors](https://docs.airbyte.com/contributing-to-airbyte/resources/pull-requests-handbook/#semantic-versioning-for-connectors).
|
|
94
|
+
3. Make sure the `metadata.yaml` content is up to date.
|
|
95
|
+
4. Make the connector documentation and its changelog is up to date (`docs/integrations/sources/firebase-realtime-database.md`).
|
|
96
|
+
5. Create a Pull Request: use [our PR naming conventions](https://docs.airbyte.com/contributing-to-airbyte/resources/pull-requests-handbook/#pull-request-title-convention).
|
|
97
|
+
6. Pat yourself on the back for being an awesome contributor.
|
|
98
|
+
7. Someone from Airbyte will take a look at your PR and iterate with you to merge it into master.
|
|
99
|
+
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: airbyte-source-firebase-realtime-database
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Source implementation for Firebase Realtime Database.
|
|
5
|
+
Author: Airbyte
|
|
6
|
+
Author-email: contact@airbyte.io
|
|
7
|
+
Description-Content-Type: text/markdown
|
|
8
|
+
Requires-Dist: airbyte-cdk
|
|
9
|
+
Requires-Dist: firebase-admin
|
|
10
|
+
Provides-Extra: tests
|
|
11
|
+
Requires-Dist: requests-mock~=1.9.3; extra == "tests"
|
|
12
|
+
Requires-Dist: pytest-mock~=3.6.1; extra == "tests"
|
|
13
|
+
Requires-Dist: pytest~=6.1; extra == "tests"
|
|
14
|
+
Requires-Dist: source-acceptance-test; extra == "tests"
|
|
15
|
+
|
|
16
|
+
# Firebase Realtime Database Source
|
|
17
|
+
|
|
18
|
+
This is the repository for the Firebase Realtime Database source connector, written in Python.
|
|
19
|
+
For information about how to use this connector within Airbyte, see [the documentation](https://docs.airbyte.io/integrations/sources/firebase-realtime-database).
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
**To iterate on this connector, make sure to complete this prerequisites section.**
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
From this connector directory, create a virtual environment:
|
|
26
|
+
```
|
|
27
|
+
python -m venv .venv
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
This will generate a virtualenv for this module in `.venv/`. Make sure this venv is active in your
|
|
31
|
+
development environment of choice. To activate it from the terminal, run:
|
|
32
|
+
```
|
|
33
|
+
source .venv/bin/activate
|
|
34
|
+
pip install -r requirements.txt
|
|
35
|
+
```
|
|
36
|
+
If you are in an IDE, follow your IDE's instructions to activate the virtualenv.
|
|
37
|
+
|
|
38
|
+
Note that while we are installing dependencies from `requirements.txt`, you should only edit `setup.py` for your dependencies. `requirements.txt` is
|
|
39
|
+
used for editable installs (`pip install -e`) to pull in Python dependencies from the monorepo and will call `setup.py`.
|
|
40
|
+
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
|
|
41
|
+
should work as you expect.
|
|
42
|
+
|
|
43
|
+
**If you are a community contributor**, follow the instructions in the [documentation](https://docs.airbyte.io/integrations/sources/firebase-realtime-database)
|
|
44
|
+
to generate the necessary credentials. Then create a file `secrets/config.json` conforming to the `source_firebase_realtime_database/spec.yaml` file.
|
|
45
|
+
Note that the `secrets` directory is gitignored by default, so there is no danger of accidentally checking in sensitive information.
|
|
46
|
+
See `integration_tests/sample_config.json` for a sample config file.
|
|
47
|
+
|
|
48
|
+
**If you are an Airbyte core member**, copy the credentials in Lastpass under the secret name `source firebase-realtime-database test creds`
|
|
49
|
+
and place them into `secrets/config.json`.
|
|
50
|
+
|
|
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
|
+
|
|
59
|
+
|
|
60
|
+
**Via [`airbyte-ci`](https://github.com/airbytehq/airbyte/blob/master/airbyte-ci/connectors/pipelines/README.md) (recommended):**
|
|
61
|
+
```bash
|
|
62
|
+
airbyte-ci connectors --name=source-firebase-realtime-database build
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
An image will be built with the tag `airbyte/source-firebase-realtime-database:dev`.
|
|
66
|
+
|
|
67
|
+
**Via `docker build`:**
|
|
68
|
+
```bash
|
|
69
|
+
docker build -t airbyte/source-firebase-realtime-database:dev .
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
Then run any of the connector commands as follows:
|
|
73
|
+
```
|
|
74
|
+
docker run --rm airbyte/source-firebase-realtime-database:dev spec
|
|
75
|
+
docker run --rm -v $(pwd)/secrets:/secrets airbyte/source-firebase-realtime-database:dev check --config /secrets/config.json
|
|
76
|
+
docker run --rm -v $(pwd)/secrets:/secrets airbyte/source-firebase-realtime-database:dev discover --config /secrets/config.json
|
|
77
|
+
docker run --rm -v $(pwd)/secrets:/secrets -v $(pwd)/integration_tests:/integration_tests airbyte/source-firebase-realtime-database:dev read --config /secrets/config.json --catalog /integration_tests/configured_catalog.json
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
You can run our full test suite locally using [`airbyte-ci`](https://github.com/airbytehq/airbyte/blob/master/airbyte-ci/connectors/pipelines/README.md):
|
|
81
|
+
```bash
|
|
82
|
+
airbyte-ci connectors --name=source-firebase-realtime-database test
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
Customize `acceptance-test-config.yml` file to configure tests. See [Connector Acceptance Tests](https://docs.airbyte.com/connector-development/testing-connectors/connector-acceptance-tests-reference) for more information.
|
|
86
|
+
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.
|
|
87
|
+
|
|
88
|
+
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.
|
|
89
|
+
We split dependencies between two groups, dependencies that are:
|
|
90
|
+
* required for your connector to work need to go to `MAIN_REQUIREMENTS` list.
|
|
91
|
+
* required for the testing need to go to `TEST_REQUIREMENTS` list
|
|
92
|
+
|
|
93
|
+
You've checked out the repo, implemented a million dollar feature, and you're ready to share your changes with the world. Now what?
|
|
94
|
+
1. Make sure your changes are passing our test suite: `airbyte-ci connectors --name=source-firebase-realtime-database test`
|
|
95
|
+
2. Bump the connector version in `metadata.yaml`: increment the `dockerImageTag` value. Please follow [semantic versioning for connectors](https://docs.airbyte.com/contributing-to-airbyte/resources/pull-requests-handbook/#semantic-versioning-for-connectors).
|
|
96
|
+
3. Make sure the `metadata.yaml` content is up to date.
|
|
97
|
+
4. Make the connector documentation and its changelog is up to date (`docs/integrations/sources/firebase-realtime-database.md`).
|
|
98
|
+
5. Create a Pull Request: use [our PR naming conventions](https://docs.airbyte.com/contributing-to-airbyte/resources/pull-requests-handbook/#pull-request-title-convention).
|
|
99
|
+
6. Pat yourself on the back for being an awesome contributor.
|
|
100
|
+
7. Someone from Airbyte will take a look at your PR and iterate with you to merge it into master.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
README.md
|
|
2
|
+
setup.cfg
|
|
3
|
+
setup.py
|
|
4
|
+
airbyte_source_firebase_realtime_database.egg-info/PKG-INFO
|
|
5
|
+
airbyte_source_firebase_realtime_database.egg-info/SOURCES.txt
|
|
6
|
+
airbyte_source_firebase_realtime_database.egg-info/dependency_links.txt
|
|
7
|
+
airbyte_source_firebase_realtime_database.egg-info/entry_points.txt
|
|
8
|
+
airbyte_source_firebase_realtime_database.egg-info/requires.txt
|
|
9
|
+
airbyte_source_firebase_realtime_database.egg-info/top_level.txt
|
|
10
|
+
integration_tests/__init__.py
|
|
11
|
+
integration_tests/acceptance.py
|
|
12
|
+
integration_tests/catalog.json
|
|
13
|
+
integration_tests/configured_catalog.json
|
|
14
|
+
integration_tests/invalid_config.json
|
|
15
|
+
integration_tests/records.json
|
|
16
|
+
integration_tests/sample_config.json
|
|
17
|
+
source_firebase_realtime_database/__init__.py
|
|
18
|
+
source_firebase_realtime_database/firebase_rtdb.py
|
|
19
|
+
source_firebase_realtime_database/run.py
|
|
20
|
+
source_firebase_realtime_database/source.py
|
|
21
|
+
source_firebase_realtime_database/spec.yaml
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
#
|
|
2
|
+
# Copyright (c) 2023 Airbyte, Inc., all rights reserved.
|
|
3
|
+
#
|
|
4
|
+
|
|
5
|
+
import json
|
|
6
|
+
import os
|
|
7
|
+
import tarfile
|
|
8
|
+
from pathlib import Path
|
|
9
|
+
|
|
10
|
+
import docker
|
|
11
|
+
import pytest
|
|
12
|
+
|
|
13
|
+
pytest_plugins = ("source_acceptance_test.plugin",)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def create_setup_container(client):
|
|
17
|
+
integration_tests_dir = Path(os.path.dirname(__file__))
|
|
18
|
+
secrets_dir = integration_tests_dir.parent / "secrets"
|
|
19
|
+
|
|
20
|
+
with open(secrets_dir / "config.json") as f:
|
|
21
|
+
secrets = json.load(f)
|
|
22
|
+
database_name = secrets["database_name"]
|
|
23
|
+
|
|
24
|
+
container = client.containers.create(
|
|
25
|
+
image="gcr.io/google.com/cloudsdktool/google-cloud-cli",
|
|
26
|
+
command="/bin/sh",
|
|
27
|
+
auto_remove=True,
|
|
28
|
+
detach=True,
|
|
29
|
+
tty=True,
|
|
30
|
+
environment={"DB_NAME": database_name},
|
|
31
|
+
)
|
|
32
|
+
|
|
33
|
+
# The setup container is a docker in docker container.
|
|
34
|
+
# It is necessary to mount volumes by specifying the file path of the host
|
|
35
|
+
# that runs the container that runs the setup container, but there is no way to specify that path,
|
|
36
|
+
# so we should copy the files into the container.
|
|
37
|
+
archive_path = "./setup_files.tar"
|
|
38
|
+
try:
|
|
39
|
+
with tarfile.open(archive_path, "w") as f:
|
|
40
|
+
f.add(integration_tests_dir / "setup_data.sh", "setup_data.sh")
|
|
41
|
+
f.add(integration_tests_dir / "teardown.sh", "teardown.sh")
|
|
42
|
+
f.add(integration_tests_dir / "records.json", "records.json")
|
|
43
|
+
f.add(secrets_dir / "firebase-admin.json", "firebase-admin.json")
|
|
44
|
+
|
|
45
|
+
with open(archive_path, "rb") as f:
|
|
46
|
+
data = f.read()
|
|
47
|
+
finally:
|
|
48
|
+
os.remove(archive_path)
|
|
49
|
+
|
|
50
|
+
container.put_archive("/", data)
|
|
51
|
+
|
|
52
|
+
container.start()
|
|
53
|
+
|
|
54
|
+
return container
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
@pytest.fixture(scope="session", autouse=True)
|
|
58
|
+
def connector_setup():
|
|
59
|
+
client = docker.from_env()
|
|
60
|
+
container = create_setup_container(client)
|
|
61
|
+
container.exec_run("/setup_data.sh")
|
|
62
|
+
|
|
63
|
+
yield
|
|
64
|
+
|
|
65
|
+
container.exec_run("/teardown.sh")
|
|
66
|
+
container.stop()
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"streams": [
|
|
3
|
+
{
|
|
4
|
+
"name": "users",
|
|
5
|
+
"supported_sync_modes": ["full_refresh"],
|
|
6
|
+
"json_schema": {
|
|
7
|
+
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
8
|
+
"type": "object",
|
|
9
|
+
"properties": {
|
|
10
|
+
"key": {
|
|
11
|
+
"type": "string"
|
|
12
|
+
},
|
|
13
|
+
"value": {
|
|
14
|
+
"type": "string"
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
]
|
|
20
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"streams": [
|
|
3
|
+
{
|
|
4
|
+
"sync_mode": "full_refresh",
|
|
5
|
+
"destination_sync_mode": "overwrite",
|
|
6
|
+
"stream": {
|
|
7
|
+
"name": "users",
|
|
8
|
+
"supported_sync_modes": ["full_refresh"],
|
|
9
|
+
"json_schema": {
|
|
10
|
+
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
11
|
+
"type": "object",
|
|
12
|
+
"properties": {
|
|
13
|
+
"key": {
|
|
14
|
+
"type": "string"
|
|
15
|
+
},
|
|
16
|
+
"value": {
|
|
17
|
+
"type": "string"
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
]
|
|
24
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
{
|
|
2
|
+
"database_name": "invalid_database",
|
|
3
|
+
"google_application_credentials": "{\"type\":\"service_account\",\"project_id\":\"invalid\",\"private_key_id\":\"invalid_key_id\",\"private_key\":\"-----BEGIN PRIVATE KEY-----\\ninvalid_private_key_string\\ninvalid_private_key_string\\ninvalid_private_key_string\\ninvalid_private_key_string\\ninvalid_private_key_string\\ninvalid_private_key_string\\ninvalid_private_key_string\\ninvalid_private_key_string\\ninvalid_private_key_string\\ninvalid_private_key_string\\ninvalid_private_key_string\\ninvalid_private_key_string\\ninvalid_private_key_string\\ninvalid_private_key_string\\ninvalid_private_key_string\\ninvalid_private_key_string\\ninvalid_private_key_string\\ninvalid_private_key_string\\ninvalid_private_key_string\\ninvalid_private_key_string\\ninvalid_private_key_string\\ninvalid_private_key_string\\ninvalid_private_key_string\\ninvalid_private_key_string\\n-----END PRIVATE KEY-----\\n\",\"client_email\":\"invalid-admin@invalid-project.iam.gserviceaccount.com\",\"client_id\":\"invalid_id\",\"auth_uri\":\"https://accounts.google.com/o/oauth2/auth\",\"token_uri\":\"https://oauth2.googleapis.com/token\",\"auth_provider_x509_cert_url\":\"https://www.googleapis.com/oauth2/v1/certs\",\"client_x509_cert_url\":\"https://www.googleapis.com/robot/v1/metadata/x509/invalid-admin%40invalid-project.iam.gserviceaccount.com\"}",
|
|
4
|
+
"path": "invalid_path",
|
|
5
|
+
"buffer_size": 2
|
|
6
|
+
}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
[metadata]
|
|
2
|
+
name = airbyte-source-firebase-realtime-database
|
|
3
|
+
version = 0.1.0
|
|
4
|
+
author = Airbyte
|
|
5
|
+
author_email = contact@airbyte.io
|
|
6
|
+
long_description = # Firebase Realtime Database Source
|
|
7
|
+
|
|
8
|
+
This is the repository for the Firebase Realtime Database source connector, written in Python.
|
|
9
|
+
For information about how to use this connector within Airbyte, see [the documentation](https://docs.airbyte.io/integrations/sources/firebase-realtime-database).
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
**To iterate on this connector, make sure to complete this prerequisites section.**
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
From this connector directory, create a virtual environment:
|
|
16
|
+
```
|
|
17
|
+
python -m venv .venv
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
This will generate a virtualenv for this module in `.venv/`. Make sure this venv is active in your
|
|
21
|
+
development environment of choice. To activate it from the terminal, run:
|
|
22
|
+
```
|
|
23
|
+
source .venv/bin/activate
|
|
24
|
+
pip install -r requirements.txt
|
|
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
|
+
**If you are a community contributor**, follow the instructions in the [documentation](https://docs.airbyte.io/integrations/sources/firebase-realtime-database)
|
|
34
|
+
to generate the necessary credentials. Then create a file `secrets/config.json` conforming to the `source_firebase_realtime_database/spec.yaml` file.
|
|
35
|
+
Note that the `secrets` directory is gitignored by default, so there is no danger of accidentally checking in sensitive information.
|
|
36
|
+
See `integration_tests/sample_config.json` for a sample config file.
|
|
37
|
+
|
|
38
|
+
**If you are an Airbyte core member**, copy the credentials in Lastpass under the secret name `source firebase-realtime-database test creds`
|
|
39
|
+
and place them into `secrets/config.json`.
|
|
40
|
+
|
|
41
|
+
```
|
|
42
|
+
python main.py spec
|
|
43
|
+
python main.py check --config secrets/config.json
|
|
44
|
+
python main.py discover --config secrets/config.json
|
|
45
|
+
python main.py read --config secrets/config.json --catalog integration_tests/configured_catalog.json
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
**Via [`airbyte-ci`](https://github.com/airbytehq/airbyte/blob/master/airbyte-ci/connectors/pipelines/README.md) (recommended):**
|
|
51
|
+
```bash
|
|
52
|
+
airbyte-ci connectors --name=source-firebase-realtime-database build
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
An image will be built with the tag `airbyte/source-firebase-realtime-database:dev`.
|
|
56
|
+
|
|
57
|
+
**Via `docker build`:**
|
|
58
|
+
```bash
|
|
59
|
+
docker build -t airbyte/source-firebase-realtime-database:dev .
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
Then run any of the connector commands as follows:
|
|
63
|
+
```
|
|
64
|
+
docker run --rm airbyte/source-firebase-realtime-database:dev spec
|
|
65
|
+
docker run --rm -v $(pwd)/secrets:/secrets airbyte/source-firebase-realtime-database:dev check --config /secrets/config.json
|
|
66
|
+
docker run --rm -v $(pwd)/secrets:/secrets airbyte/source-firebase-realtime-database:dev discover --config /secrets/config.json
|
|
67
|
+
docker run --rm -v $(pwd)/secrets:/secrets -v $(pwd)/integration_tests:/integration_tests airbyte/source-firebase-realtime-database:dev read --config /secrets/config.json --catalog /integration_tests/configured_catalog.json
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
You can run our full test suite locally using [`airbyte-ci`](https://github.com/airbytehq/airbyte/blob/master/airbyte-ci/connectors/pipelines/README.md):
|
|
71
|
+
```bash
|
|
72
|
+
airbyte-ci connectors --name=source-firebase-realtime-database test
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
Customize `acceptance-test-config.yml` file to configure tests. See [Connector Acceptance Tests](https://docs.airbyte.com/connector-development/testing-connectors/connector-acceptance-tests-reference) for more information.
|
|
76
|
+
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.
|
|
77
|
+
|
|
78
|
+
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.
|
|
79
|
+
We split dependencies between two groups, dependencies that are:
|
|
80
|
+
* required for your connector to work need to go to `MAIN_REQUIREMENTS` list.
|
|
81
|
+
* required for the testing need to go to `TEST_REQUIREMENTS` list
|
|
82
|
+
|
|
83
|
+
You've checked out the repo, implemented a million dollar feature, and you're ready to share your changes with the world. Now what?
|
|
84
|
+
1. Make sure your changes are passing our test suite: `airbyte-ci connectors --name=source-firebase-realtime-database test`
|
|
85
|
+
2. Bump the connector version in `metadata.yaml`: increment the `dockerImageTag` value. Please follow [semantic versioning for connectors](https://docs.airbyte.com/contributing-to-airbyte/resources/pull-requests-handbook/#semantic-versioning-for-connectors).
|
|
86
|
+
3. Make sure the `metadata.yaml` content is up to date.
|
|
87
|
+
4. Make the connector documentation and its changelog is up to date (`docs/integrations/sources/firebase-realtime-database.md`).
|
|
88
|
+
5. Create a Pull Request: use [our PR naming conventions](https://docs.airbyte.com/contributing-to-airbyte/resources/pull-requests-handbook/#pull-request-title-convention).
|
|
89
|
+
6. Pat yourself on the back for being an awesome contributor.
|
|
90
|
+
7. Someone from Airbyte will take a look at your PR and iterate with you to merge it into master.
|
|
91
|
+
long_description_content_type = text/markdown
|
|
92
|
+
|
|
93
|
+
[egg_info]
|
|
94
|
+
tag_build =
|
|
95
|
+
tag_date = 0
|
|
96
|
+
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
#
|
|
2
|
+
# Copyright (c) 2023 Airbyte, Inc., all rights reserved.
|
|
3
|
+
#
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
from setuptools import find_packages, setup
|
|
7
|
+
|
|
8
|
+
MAIN_REQUIREMENTS = [
|
|
9
|
+
"airbyte-cdk",
|
|
10
|
+
"firebase-admin",
|
|
11
|
+
]
|
|
12
|
+
|
|
13
|
+
TEST_REQUIREMENTS = [
|
|
14
|
+
"requests-mock~=1.9.3",
|
|
15
|
+
"pytest-mock~=3.6.1",
|
|
16
|
+
"pytest~=6.1",
|
|
17
|
+
"source-acceptance-test",
|
|
18
|
+
]
|
|
19
|
+
|
|
20
|
+
setup(
|
|
21
|
+
entry_points={
|
|
22
|
+
"console_scripts": [
|
|
23
|
+
"source-firebase-realtime-database=source_firebase_realtime_database.run:run",
|
|
24
|
+
],
|
|
25
|
+
},
|
|
26
|
+
description="Source implementation for Firebase Realtime Database.",
|
|
27
|
+
packages=find_packages(),
|
|
28
|
+
install_requires=MAIN_REQUIREMENTS,
|
|
29
|
+
package_data={
|
|
30
|
+
"": [
|
|
31
|
+
# Include yaml files in the package (if any)
|
|
32
|
+
"*.yml",
|
|
33
|
+
"*.yaml",
|
|
34
|
+
# Include all json files in the package, up to 4 levels deep
|
|
35
|
+
"*.json",
|
|
36
|
+
"*/*.json",
|
|
37
|
+
"*/*/*.json",
|
|
38
|
+
"*/*/*/*.json",
|
|
39
|
+
"*/*/*/*/*.json",
|
|
40
|
+
]
|
|
41
|
+
},
|
|
42
|
+
extras_require={
|
|
43
|
+
"tests": TEST_REQUIREMENTS,
|
|
44
|
+
},
|
|
45
|
+
)
|
airbyte-source-firebase-realtime-database-0.1.0/source_firebase_realtime_database/firebase_rtdb.py
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
#
|
|
2
|
+
# Copyright (c) 2023 Airbyte, Inc., all rights reserved.
|
|
3
|
+
#
|
|
4
|
+
|
|
5
|
+
import json
|
|
6
|
+
|
|
7
|
+
import firebase_admin
|
|
8
|
+
from firebase_admin import credentials, db
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class Client:
|
|
12
|
+
def __init__(self, path="", buffer_size=10000):
|
|
13
|
+
self._path = path
|
|
14
|
+
self._buffer_size = buffer_size
|
|
15
|
+
|
|
16
|
+
def initialize(self, database_name, google_application_credentials):
|
|
17
|
+
database_url = f"https://{database_name}.firebaseio.com"
|
|
18
|
+
sa_key = json.loads(google_application_credentials)
|
|
19
|
+
|
|
20
|
+
cred = credentials.Certificate(sa_key)
|
|
21
|
+
|
|
22
|
+
firebase_admin.initialize_app(
|
|
23
|
+
cred,
|
|
24
|
+
{
|
|
25
|
+
"databaseURL": database_url,
|
|
26
|
+
},
|
|
27
|
+
)
|
|
28
|
+
self._ref = db.reference(self._path)
|
|
29
|
+
|
|
30
|
+
def check_connection(self):
|
|
31
|
+
self._ref.get(shallow=True)
|
|
32
|
+
|
|
33
|
+
def fetch_records(self, start_key=None):
|
|
34
|
+
if start_key:
|
|
35
|
+
return self._ref.order_by_key().start_at(start_key).limit_to_first(self._buffer_size).get()
|
|
36
|
+
else:
|
|
37
|
+
return self._ref.order_by_key().limit_to_first(self._buffer_size).get()
|
|
38
|
+
|
|
39
|
+
def extract(self):
|
|
40
|
+
return Records(self)
|
|
41
|
+
|
|
42
|
+
def set_records(self, records):
|
|
43
|
+
self._ref.set(records)
|
|
44
|
+
|
|
45
|
+
def delete_records(self):
|
|
46
|
+
self._ref.delete()
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
class Records:
|
|
50
|
+
def __init__(self, client):
|
|
51
|
+
self._client = client
|
|
52
|
+
|
|
53
|
+
def __iter__(self):
|
|
54
|
+
def _gen():
|
|
55
|
+
records = self._client.fetch_records()
|
|
56
|
+
if records is None or len(records) == 0:
|
|
57
|
+
return
|
|
58
|
+
|
|
59
|
+
for k, v in records.items():
|
|
60
|
+
last_key = k
|
|
61
|
+
data = {"key": k, "value": json.dumps(v)}
|
|
62
|
+
|
|
63
|
+
yield data
|
|
64
|
+
|
|
65
|
+
# fetch data start at last_key inclusive
|
|
66
|
+
while records := self._client.fetch_records(last_key):
|
|
67
|
+
num_records = len(records)
|
|
68
|
+
|
|
69
|
+
records_iter = iter(records.items())
|
|
70
|
+
first_key, first_value = next(records_iter)
|
|
71
|
+
if first_key == last_key:
|
|
72
|
+
if num_records == 1:
|
|
73
|
+
return
|
|
74
|
+
else:
|
|
75
|
+
last_key = first_key
|
|
76
|
+
data = {"key": first_key, "value": json.dumps(first_value)}
|
|
77
|
+
yield data
|
|
78
|
+
|
|
79
|
+
for k, v in records_iter:
|
|
80
|
+
last_key = k
|
|
81
|
+
data = {"key": k, "value": json.dumps(v)}
|
|
82
|
+
|
|
83
|
+
yield data
|
|
84
|
+
|
|
85
|
+
return _gen()
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#
|
|
2
|
+
# Copyright (c) 2023 Airbyte, Inc., all rights reserved.
|
|
3
|
+
#
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
import sys
|
|
7
|
+
|
|
8
|
+
from airbyte_cdk.entrypoint import launch
|
|
9
|
+
from source_firebase_realtime_database import SourceFirebaseRealtimeDatabase
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def run():
|
|
13
|
+
source = SourceFirebaseRealtimeDatabase()
|
|
14
|
+
launch(source, sys.argv[1:])
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
#
|
|
2
|
+
# Copyright (c) 2023 Airbyte, Inc., all rights reserved.
|
|
3
|
+
#
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
import json
|
|
7
|
+
from datetime import datetime
|
|
8
|
+
from typing import Dict, Generator
|
|
9
|
+
|
|
10
|
+
from airbyte_cdk.logger import AirbyteLogger
|
|
11
|
+
from airbyte_cdk.models import (
|
|
12
|
+
AirbyteCatalog,
|
|
13
|
+
AirbyteConnectionStatus,
|
|
14
|
+
AirbyteMessage,
|
|
15
|
+
AirbyteRecordMessage,
|
|
16
|
+
AirbyteStream,
|
|
17
|
+
ConfiguredAirbyteCatalog,
|
|
18
|
+
Status,
|
|
19
|
+
Type,
|
|
20
|
+
)
|
|
21
|
+
from airbyte_cdk.sources import Source
|
|
22
|
+
|
|
23
|
+
from .firebase_rtdb import Client
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
class SourceFirebaseRealtimeDatabase(Source):
|
|
27
|
+
DEFAULT_BUFFER_SIZE = 10000
|
|
28
|
+
DEFAULT_PATH = ""
|
|
29
|
+
|
|
30
|
+
@staticmethod
|
|
31
|
+
def stream_name_from(config):
|
|
32
|
+
path = config.get("path", SourceFirebaseRealtimeDatabase.DEFAULT_PATH)
|
|
33
|
+
node_name = path.rstrip("/").split("/")[-1]
|
|
34
|
+
if not node_name:
|
|
35
|
+
node_name = config["database_name"]
|
|
36
|
+
|
|
37
|
+
return node_name.replace("-", "_")
|
|
38
|
+
|
|
39
|
+
def check(self, logger: AirbyteLogger, config: json) -> AirbyteConnectionStatus:
|
|
40
|
+
"""
|
|
41
|
+
Tests if the input configuration can be used to successfully connect to Firebase Realtime Database
|
|
42
|
+
|
|
43
|
+
:param logger: Logging object to display debug/info/error to the logs
|
|
44
|
+
(logs will not be accessible via airbyte UI if they are not passed to this logger)
|
|
45
|
+
:param config: Json object containing the configuration of this source, content of this json is as specified in
|
|
46
|
+
the properties of the spec.yaml file
|
|
47
|
+
|
|
48
|
+
:return: AirbyteConnectionStatus indicating a Success or Failure
|
|
49
|
+
"""
|
|
50
|
+
try:
|
|
51
|
+
database_name = config["database_name"]
|
|
52
|
+
google_application_credentials = config["google_application_credentials"]
|
|
53
|
+
|
|
54
|
+
client = Client()
|
|
55
|
+
client.initialize(database_name, google_application_credentials)
|
|
56
|
+
|
|
57
|
+
# get root-node's keys to check connectivity
|
|
58
|
+
client.check_connection()
|
|
59
|
+
|
|
60
|
+
return AirbyteConnectionStatus(status=Status.SUCCEEDED)
|
|
61
|
+
except Exception as e:
|
|
62
|
+
return AirbyteConnectionStatus(status=Status.FAILED, message=f"An exception occurred: {str(e)}")
|
|
63
|
+
|
|
64
|
+
def discover(self, logger: AirbyteLogger, config: json) -> AirbyteCatalog:
|
|
65
|
+
"""
|
|
66
|
+
Returns an AirbyteCatalog representing the available streams and fields in the users's connection to Firebase.
|
|
67
|
+
This connector returns only one stream that is specified by `path` in the config.
|
|
68
|
+
|
|
69
|
+
:param logger: Logging object to display debug/info/error to the logs
|
|
70
|
+
(logs will not be accessible via airbyte UI if they are not passed to this logger)
|
|
71
|
+
:param config: Json object containing the configuration of this source, content of this json is as specified in
|
|
72
|
+
the properties of the spec.yaml file
|
|
73
|
+
|
|
74
|
+
:return: AirbyteCatalog is an object describing a list of all available streams in this source.
|
|
75
|
+
A stream is an AirbyteStream object that includes:
|
|
76
|
+
- its stream name (or table name in the case of Postgres)
|
|
77
|
+
- json_schema providing the specifications of expected schema for this stream (a list of columns described
|
|
78
|
+
by their names and types)
|
|
79
|
+
"""
|
|
80
|
+
streams = []
|
|
81
|
+
|
|
82
|
+
json_schema = {
|
|
83
|
+
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
84
|
+
"type": "object",
|
|
85
|
+
"properties": {
|
|
86
|
+
"key": {"type": "string"},
|
|
87
|
+
"value": {"type": "string"},
|
|
88
|
+
},
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
stream_name = self.stream_name_from(config)
|
|
92
|
+
|
|
93
|
+
streams.append(AirbyteStream(name=stream_name, json_schema=json_schema, supported_sync_modes=["full_refresh"]))
|
|
94
|
+
|
|
95
|
+
return AirbyteCatalog(streams=streams)
|
|
96
|
+
|
|
97
|
+
def read(
|
|
98
|
+
self, logger: AirbyteLogger, config: json, catalog: ConfiguredAirbyteCatalog, state: Dict[str, any]
|
|
99
|
+
) -> Generator[AirbyteMessage, None, None]:
|
|
100
|
+
"""
|
|
101
|
+
Returns a generator of the AirbyteMessages generated by reading the source with the given configuration,
|
|
102
|
+
catalog, and state.
|
|
103
|
+
|
|
104
|
+
:param logger: Logging object to display debug/info/error to the logs
|
|
105
|
+
(logs will not be accessible via airbyte UI if they are not passed to this logger)
|
|
106
|
+
:param config: Json object containing the configuration of this source, content of this json is as specified in
|
|
107
|
+
the properties of the spec.yaml file
|
|
108
|
+
:param catalog: The input catalog is a ConfiguredAirbyteCatalog which is almost the same as AirbyteCatalog
|
|
109
|
+
returned by discover(), but
|
|
110
|
+
in addition, it's been configured in the UI! For each particular stream and field, there may have been provided
|
|
111
|
+
with extra modifications such as: filtering streams and/or columns out, renaming some entities, etc
|
|
112
|
+
:param state: When a Airbyte reads data from a source, it might need to keep a checkpoint cursor to resume
|
|
113
|
+
replication in the future from that saved checkpoint.
|
|
114
|
+
This is the object that is provided with state from previous runs and avoid replicating the entire set of
|
|
115
|
+
data everytime.
|
|
116
|
+
|
|
117
|
+
:return: A generator that produces a stream of AirbyteRecordMessage contained in AirbyteMessage object.
|
|
118
|
+
"""
|
|
119
|
+
|
|
120
|
+
stream = catalog.streams[0].stream
|
|
121
|
+
stream_name = stream.name
|
|
122
|
+
|
|
123
|
+
buffer_size = config.get("buffer_size", self.DEFAULT_BUFFER_SIZE)
|
|
124
|
+
path = config.get("path", self.DEFAULT_PATH)
|
|
125
|
+
database_name = config["database_name"]
|
|
126
|
+
google_application_credentials = config["google_application_credentials"]
|
|
127
|
+
|
|
128
|
+
client = Client(path, buffer_size)
|
|
129
|
+
client.initialize(database_name, google_application_credentials)
|
|
130
|
+
|
|
131
|
+
for data in client.extract():
|
|
132
|
+
yield AirbyteMessage(
|
|
133
|
+
type=Type.RECORD,
|
|
134
|
+
record=AirbyteRecordMessage(stream=stream_name, data=data, emitted_at=int(datetime.now().timestamp()) * 1000),
|
|
135
|
+
)
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
documentationUrl: https://docs.airbyte.io/integrations/sources/firebase-realtime-database
|
|
2
|
+
supported_sync_modes: ["full_refresh"]
|
|
3
|
+
connectionSpecification:
|
|
4
|
+
$schema: http://json-schema.org/draft-07/schema#
|
|
5
|
+
title: Firebase Realtime Database Spec
|
|
6
|
+
type: object
|
|
7
|
+
required:
|
|
8
|
+
- database_name
|
|
9
|
+
- google_application_credentials
|
|
10
|
+
properties:
|
|
11
|
+
database_name:
|
|
12
|
+
title: Database Name
|
|
13
|
+
type: string
|
|
14
|
+
description: Database name (This will be part of the url pointing to the database, https://<database_name>.firebaseio.com/)
|
|
15
|
+
google_application_credentials:
|
|
16
|
+
title: Service Account Key JSON
|
|
17
|
+
type: string
|
|
18
|
+
description: Cert credentials in JSON format of Service Account with Firebase Realtime Database Viewer role. (see, https://firebase.google.com/docs/projects/iam/roles-predefined-product#realtime-database)
|
|
19
|
+
airbyte_secret: true
|
|
20
|
+
path:
|
|
21
|
+
title: Node Path
|
|
22
|
+
type: string
|
|
23
|
+
description: Path to a node in the Firebase realtime database
|
|
24
|
+
buffer_size:
|
|
25
|
+
title: Buffer Size
|
|
26
|
+
type: number
|
|
27
|
+
description: Number of records to fetch at once
|