Skip to content

Commit 0a9218f

Browse files
Updated schema.json files for streams (#40)
* Updated schema.json files for streams * Added parent id field in child schemas * Removed trailing newlines * Updated libraries, gitignore and ReadME documentation * Added missing newline at end of file * Enforce non-nullable primary key properties
1 parent 96a19d8 commit 0a9218f

35 files changed

+2108
-46
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,3 +127,6 @@ dmypy.json
127127

128128
# Pyre type checker
129129
.pyre/
130+
131+
config.json
132+
catalog.json

README.md

Lines changed: 185 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,190 @@
11
# tap-trello
2-
A Singer tap for extracting data from the Trello API
32

4-
This tap is currently under development.
3+
This is a [Singer](https://singer.io) tap that produces JSON-formatted data
4+
following the [Singer
5+
spec](https://github.com/singer-io/getting-started/blob/master/docs/SPEC.md).
56

7+
This tap:
8+
9+
- Pulls raw data from the [Trello API].
10+
- Extracts the following resources:
11+
- [BoardMemberships](https://developer.atlassian.com/cloud/trello/rest/api-group-boards/#api-boards-id-memberships-get)
12+
13+
- [BoardCustomFields](https://developer.atlassian.com/cloud/trello/rest/api-group-boards/#api-boards-id-customfields-get)
14+
15+
- [BoardLabels](https://developer.atlassian.com/cloud/trello/rest/api-group-boards/#api-boards-id-labels-get)
16+
17+
- [CardAttachments](https://developer.atlassian.com/cloud/trello/rest/api-group-cards/#api-cards-id-attachments-get)
18+
19+
- [CardCustomFieldItems](https://developer.atlassian.com/cloud/trello/rest/api-group-cards/#api-cards-id-customfielditems-get)
20+
21+
- [Members](https://developer.atlassian.com/cloud/trello/rest/api-group-members/#api-members-id-get)
22+
23+
- [Organizations](https://developer.atlassian.com/cloud/trello/rest/api-group-organizations/#api-organizations-id-get)
24+
25+
- [OrganizationActions](https://developer.atlassian.com/cloud/trello/rest/api-group-organizations/#api-organizations-id-actions-get)
26+
27+
- [OrganizationMembers](https://developer.atlassian.com/cloud/trello/rest/api-group-organizations/#api-organizations-id-members-get)
28+
29+
- [OrganizationMemberships](https://developer.atlassian.com/cloud/trello/rest/api-group-organizations/#api-organizations-id-memberships-get)
30+
31+
- Outputs the schema for each resource
32+
- Incrementally pulls data based on the input state
33+
34+
35+
## Streams
36+
37+
38+
**[board_memberships](https://developer.atlassian.com/cloud/trello/rest/api-group-boards/#api-boards-id-memberships-get)**
39+
- Primary keys: ['id']
40+
- Replication strategy: FULL_TABLE
41+
42+
**[board_custom_fields](https://developer.atlassian.com/cloud/trello/rest/api-group-boards/#api-boards-id-customfields-get)**
43+
- Primary keys: ['id']
44+
- Replication strategy: FULL_TABLE
45+
46+
**[board_labels](https://developer.atlassian.com/cloud/trello/rest/api-group-boards/#api-boards-id-labels-get)**
47+
- Primary keys: ['id']
48+
- Replication strategy: FULL_TABLE
49+
50+
**[card_attachments](https://developer.atlassian.com/cloud/trello/rest/api-group-cards/#api-cards-id-attachments-get)**
51+
- Primary keys: ['id']
52+
- Replication strategy: FULL_TABLE
53+
54+
**[card_custom_field_items](https://developer.atlassian.com/cloud/trello/rest/api-group-cards/#api-cards-id-customfielditems-get)**
55+
- Primary keys: ['id']
56+
- Replication strategy: FULL_TABLE
57+
58+
**[members](https://developer.atlassian.com/cloud/trello/rest/api-group-members/#api-members-id-get)**
59+
- Primary keys: ['id']
60+
- Replication strategy: FULL_TABLE
61+
62+
**[organizations](https://developer.atlassian.com/cloud/trello/rest/api-group-organizations/#api-organizations-id-get)**
63+
- Primary keys: ['id']
64+
- Replication strategy: FULL_TABLE
65+
66+
**[organization_actions](https://developer.atlassian.com/cloud/trello/rest/api-group-organizations/#api-organizations-id-actions-get)**
67+
- Primary keys: ['id']
68+
- Replication strategy: INCREMENTAL
69+
70+
**[organization_members](https://developer.atlassian.com/cloud/trello/rest/api-group-organizations/#api-organizations-id-members-get)**
71+
- Primary keys: ['id']
72+
- Replication strategy: FULL_TABLE
73+
74+
**[organization_memberships](https://developer.atlassian.com/cloud/trello/rest/api-group-organizations/#api-organizations-id-memberships-get)**
75+
- Primary keys: ['id']
76+
- Replication strategy: FULL_TABLE
77+
78+
79+
80+
## Authentication
81+
82+
## Quick Start
83+
84+
1. Install
85+
86+
Clone this repository, and then install using setup.py. We recommend using a virtualenv:
87+
88+
```bash
89+
> virtualenv -p python3 venv
90+
> source venv/bin/activate
91+
> python setup.py install
92+
OR
93+
> cd .../tap-trello
94+
> pip install -e .
95+
```
96+
2. Dependent libraries. The following dependent libraries were installed.
97+
```bash
98+
> pip install singer-python
99+
> pip install target-stitch
100+
> pip install target-json
101+
102+
```
103+
- [singer-tools](https://github.com/singer-io/singer-tools)
104+
- [target-stitch](https://github.com/singer-io/target-stitch)
105+
106+
3. Create your tap's `config.json` file. The tap config file for this tap should include these entries:
107+
- `start_date` - the default value to use if no bookmark exists for an endpoint (rfc3339 date string)
108+
- `user_agent` (string, optional): Process and email for API logging purposes. Example: `tap-trello <api_user_email@your_company.com>`
109+
- `request_timeout` (integer, `300`): Max time for which request should wait to get a response. Default request_timeout is 300 seconds.
110+
111+
```json
112+
{
113+
"start_date": "2019-01-01T00:00:00Z",
114+
"user_agent": "tap-trello <api_user_email@your_company.com>",
115+
"request_timeout": 300
116+
}
117+
```
118+
119+
Optionally, also create a `state.json` file. `currently_syncing` is an optional attribute used for identifying the last object to be synced in case the job is interrupted mid-stream. The next run would begin where the last job left off.
120+
121+
```json
122+
{
123+
"currently_syncing": "engage",
124+
"bookmarks": {
125+
"export": "2019-09-27T22:34:39.000000Z",
126+
"funnels": "2019-09-28T15:30:26.000000Z",
127+
"revenue": "2019-09-28T18:23:53Z"
128+
}
129+
}
130+
```
131+
132+
4. Run the Tap in Discovery Mode
133+
This creates a catalog.json for selecting objects/fields to integrate:
134+
```bash
135+
tap-trello --config config.json --discover > catalog.json
136+
```
137+
See the Singer docs on discovery mode
138+
[here](https://github.com/singer-io/getting-started/blob/master/docs/DISCOVERY_MODE.md#discovery-mode).
139+
140+
5. Run the Tap in Sync Mode (with catalog) and [write out to state file](https://github.com/singer-io/getting-started/blob/master/docs/RUNNING_AND_DEVELOPING.md#running-a-singer-tap-with-a-singer-target)
141+
142+
For Sync mode:
143+
```bash
144+
> tap-trello --config tap_config.json --catalog catalog.json > state.json
145+
> tail -1 state.json > state.json.tmp && mv state.json.tmp state.json
146+
```
147+
To load to json files to verify outputs:
148+
```bash
149+
> tap-trello --config tap_config.json --catalog catalog.json | target-json > state.json
150+
> tail -1 state.json > state.json.tmp && mv state.json.tmp state.json
151+
```
152+
To pseudo-load to [Stitch Import API](https://github.com/singer-io/target-stitch) with dry run:
153+
```bash
154+
> tap-trello --config tap_config.json --catalog catalog.json | target-stitch --config target_config.json --dry-run > state.json
155+
> tail -1 state.json > state.json.tmp && mv state.json.tmp state.json
156+
```
157+
158+
6. Test the Tap
159+
While developing the trello tap, the following utilities were run in accordance with Singer.io best practices:
160+
Pylint to improve [code quality](https://github.com/singer-io/getting-started/blob/master/docs/BEST_PRACTICES.md#code-quality):
161+
```bash
162+
> pylint tap_trello -d missing-docstring -d logging-format-interpolation -d too-many-locals -d too-many-arguments
163+
```
164+
Pylint test resulted in the following score:
165+
```bash
166+
Your code has been rated at 9.67/10
167+
```
168+
169+
To [check the tap](https://github.com/singer-io/singer-tools#singer-check-tap) and verify working:
170+
```bash
171+
> tap_trello --config tap_config.json --catalog catalog.json | singer-check-tap > state.json
172+
> tail -1 state.json > state.json.tmp && mv state.json.tmp state.json
173+
```
174+
175+
#### Unit Tests
176+
177+
Unit tests may be run with the following.
178+
179+
```
180+
python -m pytest --verbose
181+
```
182+
183+
Note, you may need to install test dependencies.
184+
185+
```
186+
pip install -e .'[dev]'
187+
```
6188
---
7189
8-
Copyright &copy; 2020 Stitch
190+
Copyright &copy; 2020–2025 Stitch

setup.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@
1010
classifiers=["Programming Language :: Python :: 3 :: Only"],
1111
py_modules=["tap_trello"],
1212
install_requires=[
13-
"singer-python==5.13.2",
14-
"requests==2.32.4",
13+
"singer-python==6.3.0",
14+
"requests==2.32.5",
1515
"requests-oauthlib==1.3.0",
16-
"backoff==1.10.0"
16+
"backoff==2.2.1"
1717
],
1818
extras_require={
1919
'dev': [

tap_trello/__init__.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
import sys
21
import json
2+
import sys
3+
34
import singer
5+
46
from tap_trello.client import Client
57
from tap_trello.discover import discover
68
from tap_trello.sync import sync
@@ -9,6 +11,7 @@
911

1012
REQUIRED_CONFIG_KEYS = ['consumer_key', 'consumer_secret', 'access_token', 'access_token_secret', 'start_date']
1113

14+
1215
def do_discover():
1316
"""
1417
Discover and emit the catalog to stdout
@@ -42,4 +45,3 @@ def main():
4245

4346
if __name__ == "__main__":
4447
main()
45-

tap_trello/client.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@
33
import backoff
44
import requests
55
from requests import session
6-
from requests.exceptions import Timeout, ConnectionError, ChunkedEncodingError
6+
from requests.exceptions import ChunkedEncodingError, ConnectionError, Timeout
77
from singer import get_logger, metrics
88

9-
from tap_trello.exceptions import ERROR_CODE_EXCEPTION_MAPPING, TrelloError, TrelloBackoffError
9+
from tap_trello.exceptions import (ERROR_CODE_EXCEPTION_MAPPING,
10+
TrelloError,
11+
TrelloBackoffError)
1012

1113
LOGGER = get_logger()
1214
REQUEST_TIMEOUT = 300
@@ -35,6 +37,7 @@ def raise_for_error(response: requests.Response) -> None:
3537
)
3638
raise exc(message, response) from None
3739

40+
3841
class Client:
3942
"""
4043
A Wrapper class.
@@ -119,4 +122,3 @@ def __make_request(
119122
raise ValueError(f"Unsupported method: {method}")
120123

121124
return response.json()
122-

tap_trello/discover.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import singer
22
from singer import metadata
33
from singer.catalog import Catalog, CatalogEntry, Schema
4+
45
from tap_trello.schema import get_schemas
56

67
LOGGER = singer.get_logger()
@@ -36,4 +37,3 @@ def discover() -> Catalog:
3637
)
3738

3839
return catalog
39-

tap_trello/exceptions.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,4 +103,3 @@ class TrelloServiceUnavailableError(TrelloBackoffError):
103103
"message": "API service is currently unavailable."
104104
}
105105
}
106-

tap_trello/schema.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
import os
21
import json
3-
import singer
2+
import os
43
from typing import Dict, Tuple
4+
5+
import singer
56
from singer import metadata
7+
68
from tap_trello.streams import STREAMS
79

810
LOGGER = singer.get_logger()
@@ -77,4 +79,3 @@ def get_schemas() -> Tuple[Dict, Dict]:
7779
field_metadata[stream_name] = mdata
7880

7981
return schemas, field_metadata
80-

tap_trello/schemas/actions.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
"properties": {
77
"id": {
88
"type": [
9-
"null",
109
"string"
1110
]
1211
},

0 commit comments

Comments
 (0)