Skip to content

Commit 24d7fa8

Browse files
authored
source-twilio: implement lookback windows (#13896)
1 parent fb6ddc4 commit 24d7fa8

18 files changed

+157
-83
lines changed

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -953,7 +953,7 @@
953953
- name: Twilio
954954
sourceDefinitionId: b9dc6155-672e-42ea-b10d-9f1f1fb95ab1
955955
dockerRepository: airbyte/source-twilio
956-
dockerImageTag: 0.1.4
956+
dockerImageTag: 0.1.5
957957
documentationUrl: https://docs.airbyte.io/integrations/sources/twilio
958958
icon: twilio.svg
959959
sourceType: api

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

+12-1
Original file line numberDiff line numberDiff line change
@@ -9248,7 +9248,7 @@
92489248
oauthFlowOutputParameters:
92499249
- - "token"
92509250
- - "key"
9251-
- dockerImage: "airbyte/source-twilio:0.1.4"
9251+
- dockerImage: "airbyte/source-twilio:0.1.5"
92529252
spec:
92539253
documentationUrl: "https://docs.airbyte.io/integrations/sources/twilio"
92549254
connectionSpecification:
@@ -9266,11 +9266,13 @@
92669266
description: "Twilio account SID"
92679267
airbyte_secret: true
92689268
type: "string"
9269+
order: 1
92699270
auth_token:
92709271
title: "Auth Token"
92719272
description: "Twilio Auth Token."
92729273
airbyte_secret: true
92739274
type: "string"
9275+
order: 2
92749276
start_date:
92759277
title: "Replication Start Date"
92769278
description: "UTC date and time in the format 2020-10-01T00:00:00Z. Any\
@@ -9279,6 +9281,15 @@
92799281
examples:
92809282
- "2020-10-01T00:00:00Z"
92819283
type: "string"
9284+
order: 3
9285+
lookback_window:
9286+
title: "Lookback window"
9287+
description: "How far into the past to look for records. (in minutes)"
9288+
examples:
9289+
- 60
9290+
default: 0
9291+
type: "integer"
9292+
order: 4
92829293
supportsIncremental: true
92839294
supportsNormalization: false
92849295
supportsDBT: false

airbyte-integrations/connectors/source-twilio/Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@ RUN pip install .
1212
ENV AIRBYTE_ENTRYPOINT "python /airbyte/integration_code/main.py"
1313
ENTRYPOINT ["python", "/airbyte/integration_code/main.py"]
1414

15-
LABEL io.airbyte.version=0.1.4
15+
LABEL io.airbyte.version=0.1.5
1616
LABEL io.airbyte.name=airbyte/source-twilio

airbyte-integrations/connectors/source-twilio/acceptance-test-config.yml

+5-7
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,11 @@ tests:
1818
# usage records stream produces and error if cursor date gte than current date
1919
configured_catalog_path: "integration_tests/no_empty_streams_no_usage_records_catalog.json"
2020
future_state_path: "integration_tests/abnormal_state.json"
21-
cursor_paths:
22-
calls: ["end_time"]
23-
conferences: ["date_updated"]
24-
recordings: ["date_created"]
25-
messages: ["date_sent"]
26-
message_media: ["date_created"]
27-
alerts: ["date_updated"]
21+
- config_path: "secrets/config_with_lookback.json"
22+
# usage records stream produces and error if cursor date gte than current date
23+
configured_catalog_path: "integration_tests/no_empty_streams_no_usage_records_catalog.json"
24+
future_state_path: "integration_tests/abnormal_state.json"
25+
threshold_days: 30
2826
full_refresh:
2927
- config_path: "secrets/config.json"
3028
# `constant_records_catalog.json` does not contain the available phone numbers streams,

airbyte-integrations/connectors/source-twilio/acceptance-test-docker.sh

100644100755
File mode changed.
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
{
22
"calls": {
3-
"end_time": "2220-10-01T00:00:00Z"
3+
"end_time": "2030-10-01T00:00:00Z"
44
},
55
"conferences": {
6-
"date_updated": "2220-10-01T00:00:00Z"
6+
"date_created": "2030-10-01T00:00:00Z"
77
},
88
"recordings": {
9-
"date_created": "2220-10-01T00:00:00Z"
9+
"date_created": "2030-10-01T00:00:00Z"
1010
},
1111
"messages": {
12-
"date_sent": "2220-10-01T00:00:00Z"
12+
"date_sent": "2030-10-01T00:00:00Z"
1313
},
1414
"message_media": {
15-
"date_created": "2220-10-01T00:00:00Z"
15+
"date_created": "2030-10-01T00:00:00Z"
1616
},
1717
"alerts": {
18-
"date_updated": "2220-10-01T00:00:00Z"
18+
"date_generated": "2030-10-01T00:00:00Z"
1919
}
2020
}

airbyte-integrations/connectors/source-twilio/integration_tests/configured_catalog.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,9 @@
108108
"json_schema": {},
109109
"supported_sync_modes": ["incremental", "full_refresh"],
110110
"source_defined_cursor": true,
111-
"default_cursor_field": ["date_updated"]
111+
"default_cursor_field": ["date_created"]
112112
},
113-
"cursor_field": ["date_updated"],
113+
"cursor_field": ["date_created"],
114114
"sync_mode": "incremental",
115115
"destination_sync_mode": "append"
116116
},
@@ -213,9 +213,9 @@
213213
"json_schema": {},
214214
"supported_sync_modes": ["incremental", "full_refresh"],
215215
"source_defined_cursor": true,
216-
"default_cursor_field": ["date_updated"]
216+
"default_cursor_field": ["date_created"]
217217
},
218-
"cursor_field": ["date_updated"],
218+
"cursor_field": ["date_created"],
219219
"sync_mode": "incremental",
220220
"destination_sync_mode": "append"
221221
}

airbyte-integrations/connectors/source-twilio/integration_tests/constant_records_catalog.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,9 @@
6363
"json_schema": {},
6464
"supported_sync_modes": ["incremental", "full_refresh"],
6565
"source_defined_cursor": true,
66-
"default_cursor_field": ["date_updated"]
66+
"default_cursor_field": ["date_created"]
6767
},
68-
"cursor_field": ["date_updated"],
68+
"cursor_field": ["date_created"],
6969
"sync_mode": "incremental",
7070
"destination_sync_mode": "append"
7171
},
@@ -159,9 +159,9 @@
159159
"json_schema": {},
160160
"supported_sync_modes": ["incremental", "full_refresh"],
161161
"source_defined_cursor": true,
162-
"default_cursor_field": ["date_updated"]
162+
"default_cursor_field": ["date_created"]
163163
},
164-
"cursor_field": ["date_updated"],
164+
"cursor_field": ["date_created"],
165165
"sync_mode": "incremental",
166166
"destination_sync_mode": "append"
167167
}

airbyte-integrations/connectors/source-twilio/integration_tests/no_empty_streams_catalog.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,9 @@
9999
"json_schema": {},
100100
"supported_sync_modes": ["incremental", "full_refresh"],
101101
"source_defined_cursor": true,
102-
"default_cursor_field": ["date_updated"]
102+
"default_cursor_field": ["date_created"]
103103
},
104-
"cursor_field": ["date_updated"],
104+
"cursor_field": ["date_created"],
105105
"sync_mode": "incremental",
106106
"destination_sync_mode": "append"
107107
},

airbyte-integrations/connectors/source-twilio/integration_tests/no_empty_streams_no_usage_records_catalog.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,9 @@
9999
"json_schema": {},
100100
"supported_sync_modes": ["incremental", "full_refresh"],
101101
"source_defined_cursor": true,
102-
"default_cursor_field": ["date_updated"]
102+
"default_cursor_field": ["date_created"]
103103
},
104-
"cursor_field": ["date_updated"],
104+
"cursor_field": ["date_created"],
105105
"sync_mode": "incremental",
106106
"destination_sync_mode": "append"
107107
},
@@ -183,9 +183,9 @@
183183
"json_schema": {},
184184
"supported_sync_modes": ["incremental", "full_refresh"],
185185
"source_defined_cursor": true,
186-
"default_cursor_field": ["date_updated"]
186+
"default_cursor_field": ["date_created"]
187187
},
188-
"cursor_field": ["date_updated"],
188+
"cursor_field": ["date_created"],
189189
"sync_mode": "incremental",
190190
"destination_sync_mode": "append"
191191
}

airbyte-integrations/connectors/source-twilio/integration_tests/sample_state.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"calls": {
3-
"end_time": "2020-01-01T00:00:00Z"
3+
"end_time": "2022-06-11T00:00:00Z"
44
},
55
"conferences": {
66
"date_updated": "2020-01-01T00:00:00Z"

airbyte-integrations/connectors/source-twilio/source_twilio/schemas/conferences.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"type": ["null", "string"]
99
},
1010
"date_updated": {
11-
"format": "date",
11+
"format": "date-time",
1212
"type": ["null", "string"]
1313
},
1414
"api_version": {

airbyte-integrations/connectors/source-twilio/source_twilio/schemas/recordings.json

+3
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@
4848
"error_code": {
4949
"type": ["null", "integer"]
5050
},
51+
"media_url": {
52+
"type": ["null", "string"]
53+
},
5154
"uri": {
5255
"type": ["null", "string"]
5356
},

airbyte-integrations/connectors/source-twilio/source_twilio/schemas/usage_records.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
"type": ["null", "number"]
6363
},
6464
"start_date": {
65-
"format": "date",
65+
"format": "date-time",
6666
"type": ["null", "string"]
6767
},
6868
"count_unit": {

airbyte-integrations/connectors/source-twilio/source_twilio/source.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,11 @@ def streams(self, config: Mapping[str, Any]) -> List[Stream]:
6161
),
6262
)
6363
full_refresh_stream_kwargs = {"authenticator": auth}
64-
incremental_stream_kwargs = {"authenticator": auth, "start_date": config["start_date"]}
64+
incremental_stream_kwargs = {
65+
"authenticator": auth,
66+
"start_date": config["start_date"],
67+
"lookback_window": config["lookback_window"],
68+
}
6569

6670
streams = [
6771
Accounts(**full_refresh_stream_kwargs),

airbyte-integrations/connectors/source-twilio/source_twilio/spec.json

+27-6
Original file line numberDiff line numberDiff line change
@@ -4,30 +4,51 @@
44
"$schema": "http://json-schema.org/draft-07/schema#",
55
"title": "Twilio Spec",
66
"type": "object",
7-
"required": ["account_sid", "auth_token", "start_date"],
7+
"required": [
8+
"account_sid",
9+
"auth_token",
10+
"start_date"
11+
],
812
"additionalProperties": false,
913
"properties": {
1014
"account_sid": {
1115
"title": "Account ID",
1216
"description": "Twilio account SID",
1317
"airbyte_secret": true,
14-
"type": "string"
18+
"type": "string",
19+
"order": 1
1520
},
1621
"auth_token": {
1722
"title": "Auth Token",
1823
"description": "Twilio Auth Token.",
1924
"airbyte_secret": true,
20-
"type": "string"
25+
"type": "string",
26+
"order": 2
2127
},
2228
"start_date": {
2329
"title": "Replication Start Date",
2430
"description": "UTC date and time in the format 2020-10-01T00:00:00Z. Any data before this date will not be replicated.",
2531
"pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}Z$",
26-
"examples": ["2020-10-01T00:00:00Z"],
27-
"type": "string"
32+
"examples": [
33+
"2020-10-01T00:00:00Z"
34+
],
35+
"type": "string",
36+
"order": 3
37+
},
38+
"lookback_window": {
39+
"title": "Lookback window",
40+
"description": "How far into the past to look for records. (in minutes)",
41+
"examples": [
42+
60
43+
],
44+
"default": 0,
45+
"type": "integer",
46+
"order": 4
2847
}
2948
}
3049
},
3150
"supportsIncremental": true,
32-
"supported_destination_sync_modes": ["append"]
51+
"supported_destination_sync_modes": [
52+
"append"
53+
]
3354
}

0 commit comments

Comments
 (0)