Skip to content

Commit

Permalink
Source Twilio: shift start date for stream if it exceeds 400 days (ai…
Browse files Browse the repository at this point in the history
  • Loading branch information
roman-yermilov-gl authored and robbinhan committed Sep 29, 2022
1 parent 8cbb5d0 commit e4c9f6a
Show file tree
Hide file tree
Showing 30 changed files with 132 additions and 116 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1036,7 +1036,7 @@
- name: Twilio
sourceDefinitionId: b9dc6155-672e-42ea-b10d-9f1f1fb95ab1
dockerRepository: airbyte/source-twilio
dockerImageTag: 0.1.6
dockerImageTag: 0.1.7
documentationUrl: https://docs.airbyte.io/integrations/sources/twilio
icon: twilio.svg
sourceType: api
Expand Down
4 changes: 2 additions & 2 deletions airbyte-config/init/src/main/resources/seed/source_specs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10280,7 +10280,7 @@
oauthFlowOutputParameters:
- - "token"
- - "key"
- dockerImage: "airbyte/source-twilio:0.1.6"
- dockerImage: "airbyte/source-twilio:0.1.7"
spec:
documentationUrl: "https://docs.airbyte.io/integrations/sources/twilio"
connectionSpecification:
Expand All @@ -10291,7 +10291,7 @@
- "account_sid"
- "auth_token"
- "start_date"
additionalProperties: false
additionalProperties: true
properties:
account_sid:
title: "Account ID"
Expand Down
2 changes: 1 addition & 1 deletion airbyte-integrations/connectors/source-twilio/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ COPY main.py ./
ENV AIRBYTE_ENTRYPOINT "python /airbyte/integration_code/main.py"
ENTRYPOINT ["python", "/airbyte/integration_code/main.py"]

LABEL io.airbyte.version=0.1.6
LABEL io.airbyte.version=0.1.7
LABEL io.airbyte.name=airbyte/source-twilio
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/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)
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
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
},
"subresource_uris": {
"type": ["null", "object"],
"additionalProperties": false,
"additionalProperties": true,
"properties": {
"addresses": {
"type": ["null", "string"]
Expand Down Expand Up @@ -97,5 +97,5 @@
}
},
"type": "object",
"additionalProperties": false
"additionalProperties": true
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,5 @@
}
},
"type": "object",
"additionalProperties": false
"additionalProperties": true
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,5 @@
}
},
"type": "object",
"additionalProperties": false
"additionalProperties": true
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@
"sms_method": {
"type": ["null", "string"]
},
"public_application_connect_enabled": {
"type": ["null", "boolean"]
},
"sms_status_callback": {
"type": ["null", "string"]
},
Expand Down Expand Up @@ -64,5 +67,5 @@
}
},
"type": "object",
"additionalProperties": false
"additionalProperties": true
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
},
"subresource_uris": {
"type": ["null", "object"],
"additionalProperties": false,
"additionalProperties": true,
"properties": {
"local": {
"type": ["null", "string"]
Expand All @@ -29,5 +29,5 @@
}
},
"type": "object",
"additionalProperties": false
"additionalProperties": true
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@
}
},
"type": ["null", "object"],
"additionalProperties": false
"additionalProperties": true
}
},
"type": "object",
"additionalProperties": false
"additionalProperties": true
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@
}
},
"type": ["null", "object"],
"additionalProperties": false
"additionalProperties": true
}
},
"type": "object",
"additionalProperties": false
"additionalProperties": true
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@
}
},
"type": ["null", "object"],
"additionalProperties": false
"additionalProperties": true
}
},
"type": "object",
"additionalProperties": false
"additionalProperties": true
}
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
},
"subresource_uris": {
"type": ["null", "object"],
"additionalProperties": false,
"additionalProperties": true,
"properties": {
"recordings": {
"type": ["null", "string"]
Expand Down Expand Up @@ -114,5 +114,5 @@
}
},
"type": "object",
"additionalProperties": false
"additionalProperties": true
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,5 @@
}
},
"type": "object",
"additionalProperties": false
"additionalProperties": true
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
},
"subresource_uris": {
"type": ["null", "object"],
"additionalProperties": false,
"additionalProperties": true,
"properties": {
"participants": {
"type": ["null", "string"]
Expand All @@ -49,5 +49,5 @@
}
},
"type": "object",
"additionalProperties": false
"additionalProperties": true
}
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
}
},
"type": ["null", "object"],
"additionalProperties": false
"additionalProperties": true
},
"status_callback": {
"type": ["null", "string"]
Expand Down Expand Up @@ -94,5 +94,5 @@
}
},
"type": "object",
"additionalProperties": false
"additionalProperties": true
}
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
}
},
"type": ["null", "object"],
"additionalProperties": false
"additionalProperties": true
},
"voice_receive_mode": {
"type": ["null", "string"]
Expand Down Expand Up @@ -121,5 +121,5 @@
}
},
"type": "object",
"additionalProperties": false
"additionalProperties": true
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@
}
},
"type": "object",
"additionalProperties": false
"additionalProperties": true
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@
}
},
"type": "object",
"additionalProperties": false
"additionalProperties": true
}
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
},
"subresource_uris": {
"type": ["null", "object"],
"additionalProperties": false,
"additionalProperties": true,
"properties": {
"feedback": {
"type": ["null", "string"]
Expand All @@ -74,5 +74,5 @@
}
},
"type": "object",
"additionalProperties": false
"additionalProperties": true
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@
}
},
"type": "object",
"additionalProperties": false
"additionalProperties": true
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
},
"subresource_uris": {
"type": ["null", "object"],
"additionalProperties": false,
"additionalProperties": true,
"properties": {
"members": {
"type": ["null", "string"]
Expand All @@ -40,5 +40,5 @@
}
},
"type": "object",
"additionalProperties": false
"additionalProperties": true
}
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,11 @@
}
},
"type": ["null", "object"],
"additionalProperties": false
"additionalProperties": true
},
"subresource_uris": {
"type": ["null", "object"],
"additionalProperties": false,
"additionalProperties": true,
"properties": {
"transcriptions": {
"type": ["null", "string"]
Expand All @@ -89,5 +89,5 @@
}
},
"type": "object",
"additionalProperties": false
"additionalProperties": true
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,5 @@
}
},
"type": "object",
"additionalProperties": false
"additionalProperties": true
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
},
"subresource_uris": {
"type": ["null", "object"],
"additionalProperties": false,
"additionalProperties": true,
"properties": {
"yesterday": {
"type": ["null", "string"]
Expand Down Expand Up @@ -76,5 +76,5 @@
}
},
"type": "object",
"additionalProperties": false
"additionalProperties": true
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,5 @@
}
},
"type": "object",
"additionalProperties": false
"additionalProperties": true
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@
# Copyright (c) 2022 Airbyte, Inc., all rights reserved.
#

import datetime
from typing import Any, List, Mapping, Tuple

import pendulum
from airbyte_cdk.logger import AirbyteLogger
from airbyte_cdk.models import SyncMode
from airbyte_cdk.sources import AbstractSource
Expand Down Expand Up @@ -34,6 +36,8 @@
UsageTriggers,
)

RETENTION_WINDOW_LIMIT = 400


class SourceTwilio(AbstractSource):
def check_connection(self, logger: AirbyteLogger, config: Mapping[str, Any]) -> Tuple[bool, Any]:
Expand Down Expand Up @@ -67,6 +71,14 @@ def streams(self, config: Mapping[str, Any]) -> List[Stream]:
"lookback_window": config["lookback_window"],
}

# Fix for `Date range specified in query is partially or entirely outside of retention window of 400 days`
# See: https://app.zenhub.com/workspaces/python-connectors-6262f8b593bb82001df56c65/issues/airbytehq/airbyte/10418
incremental_stream_kwargs_message_stream = dict(**incremental_stream_kwargs)
if pendulum.now().diff(pendulum.parse(config["start_date"])).days >= RETENTION_WINDOW_LIMIT:
incremental_stream_kwargs_message_stream["start_date"] = (
pendulum.now() - datetime.timedelta(days=RETENTION_WINDOW_LIMIT - 1)
).to_iso8601_string()

streams = [
Accounts(**full_refresh_stream_kwargs),
Addresses(**full_refresh_stream_kwargs),
Expand All @@ -82,8 +94,8 @@ def streams(self, config: Mapping[str, Any]) -> List[Stream]:
DependentPhoneNumbers(**full_refresh_stream_kwargs),
IncomingPhoneNumbers(**full_refresh_stream_kwargs),
Keys(**full_refresh_stream_kwargs),
MessageMedia(**incremental_stream_kwargs),
Messages(**incremental_stream_kwargs),
MessageMedia(**incremental_stream_kwargs_message_stream),
Messages(**incremental_stream_kwargs_message_stream),
OutgoingCallerIds(**full_refresh_stream_kwargs),
Queues(**full_refresh_stream_kwargs),
Recordings(**incremental_stream_kwargs),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"title": "Twilio Spec",
"type": "object",
"required": ["account_sid", "auth_token", "start_date"],
"additionalProperties": false,
"additionalProperties": true,
"properties": {
"account_sid": {
"title": "Account ID",
Expand Down
1 change: 1 addition & 0 deletions docs/integrations/sources/twilio.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ For more information, see [the Twilio docs for rate limitations](https://support

| Version | Date | Pull Request | Subject |
|:--------|:------------|:---------------------------------------------------------|:--------------------------------------------------------------------------------------------------------|
| 0.1.7 | 2022-08-26 | [15972](https://github.com/airbytehq/airbyte/pull/15972) | Shift start date for stream if it exceeds 400 days |
| 0.1.6 | 2022-06-22 | [14000](https://github.com/airbytehq/airbyte/pull/14000) | Update Records stream schema and align tests with connectors' best practices |
| 0.1.5 | 2022-06-22 | [13896](https://github.com/airbytehq/airbyte/pull/13896) | Add lookback window parameters to fetch messages with a rolling window and catch status updates |
| 0.1.4 | 2022-04-22 | [12157](https://github.com/airbytehq/airbyte/pull/12157) | Use Retry-After header for backoff |
Expand Down

0 comments on commit e4c9f6a

Please sign in to comment.