Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Source Twilio: shift start date for stream if it exceeds 400 days #15972

Merged
merged 5 commits into from
Aug 29, 2022
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
@@ -1,9 +1,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 @@ -35,6 +36,9 @@
)


RETENTION_WINDOW_LIMIT = 400


class SourceTwilio(AbstractSource):
def check_connection(self, logger: AirbyteLogger, config: Mapping[str, Any]) -> Tuple[bool, Any]:
try:
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