Skip to content

Commit 3ed543b

Browse files
bleonardaskarpetserohmensing
authored
🚨🚨 Source Sendgrid: migrate to low code (#35776)
Co-authored-by: askarpets <[email protected]> Co-authored-by: Ella Rohm-Ensing <[email protected]>
1 parent b16590e commit 3ed543b

37 files changed

+1416
-1165
lines changed

airbyte-integrations/bases/connector-acceptance-test/connector_acceptance_test/conftest.py

+4
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,8 @@ async def discovered_catalog_fixture(
299299

300300
output = await docker_runner.call_discover(config=connector_config)
301301
catalogs = [message.catalog for message in output if message.type == Type.CATALOG]
302+
if len(catalogs) == 0:
303+
raise ValueError("No catalog message was emitted")
302304
return {stream.name: stream for stream in catalogs[-1].streams}
303305

304306

@@ -322,6 +324,8 @@ async def previous_discovered_catalog_fixture(
322324
)
323325
return None
324326
catalogs = [message.catalog for message in output if message.type == Type.CATALOG]
327+
if len(catalogs) == 0:
328+
raise ValueError("No catalog message was emitted")
325329
return {stream.name: stream for stream in catalogs[-1].streams}
326330

327331

Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
[run]
22
omit =
33
source_sendgrid/run.py
4+
source_sendgrid/__init__.py

airbyte-integrations/connectors/source-sendgrid/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ See `sample_files/sample_config.json` for a sample config file.
3030
poetry run source-sendgrid spec
3131
poetry run source-sendgrid check --config secrets/config.json
3232
poetry run source-sendgrid discover --config secrets/config.json
33-
poetry run source-sendgrid read --config secrets/config.json --catalog sample_files/configured_catalog.json
33+
poetry run source-sendgrid read --config secrets/config.json --catalog integration_tests/configured_catalog.json
3434
```
3535

3636
### Running unit tests

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

+14-5
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,35 @@ acceptance_tests:
44
spec:
55
tests:
66
- spec_path: "source_sendgrid/spec.json"
7+
config_path: "secrets/lowcode_config.json"
78
backward_compatibility_tests_config:
8-
disable_for_version: "0.3.0"
9+
disable_for_version: "0.5.0"
910
connection:
1011
tests:
11-
- config_path: "secrets/config.json"
12+
- config_path: "secrets/lowcode_config.json"
1213
status: "succeed"
1314
- config_path: "secrets/old_config.json"
1415
status: "succeed"
16+
- config_path: "secrets/python_config.json"
17+
status: "succeed"
1518
- config_path: "integration_tests/invalid_time.json"
1619
status: "failed"
1720
- config_path: "integration_tests/invalid_api_key.json"
1821
status: "failed"
1922
discovery:
2023
tests:
24+
- config_path: "secrets/lowcode_config.json"
25+
backward_compatibility_tests_config:
26+
disable_for_version: "1.0.0"
2127
- config_path: "secrets/config.json"
2228
backward_compatibility_tests_config:
2329
disable_for_version: "0.3.0"
30+
- config_path: "secrets/python_config.json"
31+
backward_compatibility_tests_config:
32+
disable_for_version: "0.3.0"
2433
basic_read:
2534
tests:
26-
- config_path: "secrets/config.json"
35+
- config_path: "secrets/lowcode_config.json"
2736
expect_records:
2837
path: "integration_tests/expected_records.jsonl"
2938
exact_order: no
@@ -37,11 +46,11 @@ acceptance_tests:
3746
fail_on_extra_columns: false
3847
incremental:
3948
tests:
40-
- config_path: "secrets/config.json"
49+
- config_path: "secrets/lowcode_config.json"
4150
configured_catalog_path: "integration_tests/no_spam_reports_configured_catalog.json"
4251
future_state:
4352
future_state_path: "integration_tests/abnormal_state.json"
4453
full_refresh:
4554
tests:
46-
- config_path: "secrets/config.json"
55+
- config_path: "secrets/lowcode_config.json"
4756
configured_catalog_path: "integration_tests/configured_catalog.json"

airbyte-integrations/connectors/source-sendgrid/integration_tests/abnormal_state.json

+11
Original file line numberDiff line numberDiff line change
@@ -42,5 +42,16 @@
4242
"name": "invalid_emails"
4343
}
4444
}
45+
},
46+
{
47+
"type": "STREAM",
48+
"stream": {
49+
"stream_state": {
50+
"created_at": "7270247822"
51+
},
52+
"stream_descriptor": {
53+
"name": "suppression_group_members"
54+
}
55+
}
4556
}
4657
]

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

+10-10
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,16 @@
4747
},
4848
{
4949
"stream": {
50-
"name": "single_sends",
50+
"name": "singlesends",
51+
"json_schema": {},
52+
"supported_sync_modes": ["full_refresh"]
53+
},
54+
"sync_mode": "full_refresh",
55+
"destination_sync_mode": "overwrite"
56+
},
57+
{
58+
"stream": {
59+
"name": "singlesend_stats",
5160
"json_schema": {},
5261
"supported_sync_modes": ["full_refresh"]
5362
},
@@ -140,15 +149,6 @@
140149
"sync_mode": "incremental",
141150
"cursor_field": ["created"],
142151
"destination_sync_mode": "append"
143-
},
144-
{
145-
"stream": {
146-
"name": "unsubscribe_groups",
147-
"json_schema": {},
148-
"supported_sync_modes": ["full_refresh"]
149-
},
150-
"sync_mode": "full_refresh",
151-
"destination_sync_mode": "overwrite"
152152
}
153153
]
154154
}

airbyte-integrations/connectors/source-sendgrid/integration_tests/expected_records.jsonl

+10-10
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,8 @@
104104
{"stream":"contacts","data":{"email":"[email protected]","first_name":"Fake contact","last_name":"Lastname","address_line_1":null,"address_line_2":null,"city":null,"state_province_region":null,"postal_code":"22341","country":null,"alternate_emails":null,"phone_number":null,"whatsapp":null,"line":null,"facebook":null,"unique_name":null,"created_at":"2021-02-01T12:35:27Z","updated_at":"2021-02-01T12:35:56Z","contact_id":"50b36a31-daf8-45c4-bc48-13e150f6746e"},"emitted_at":1674825613540}
105105
{"stream":"contacts","data":{"email":"[email protected]","first_name":"Fake contact","last_name":"Lastname","address_line_1":null,"address_line_2":null,"city":null,"state_province_region":null,"postal_code":"22341","country":null,"alternate_emails":null,"phone_number":null,"whatsapp":null,"line":null,"facebook":null,"unique_name":null,"created_at":"2021-02-01T12:35:14Z","updated_at":"2021-02-01T12:35:43Z","contact_id":"d1211b88-e116-4a0b-a823-0361bf059a06"},"emitted_at":1674825613540}
106106
{"stream":"contacts","data":{"email":"[email protected]","first_name":"Fake contact","last_name":"Lastname","address_line_1":null,"address_line_2":null,"city":null,"state_province_region":null,"postal_code":"22341","country":null,"alternate_emails":null,"phone_number":null,"whatsapp":null,"line":null,"facebook":null,"unique_name":null,"created_at":"2021-02-01T12:35:30Z","updated_at":"2021-02-01T12:36:00Z","contact_id":"19163421-bb29-495d-950f-edede6218081"},"emitted_at":1674825613540}
107-
{"stream": "single_sends", "data": {"ab_phase": "all", "ab_variation": "all", "aggregation": "total", "stats": {"bounce_drops": 0, "bounces": 0, "clicks": 0, "unique_clicks": 0, "delivered": 1, "invalid_emails": 0, "opens": 3, "unique_opens": 1, "requests": 1, "spam_report_drops": 0, "spam_reports": 0, "unsubscribes": 1}, "id": "3c5a9fa6-1084-11ec-ac32-4228d699bad5"}, "emitted_at": 1631093373000}
108-
{"stream": "single_sends", "data": {"ab_phase": "all", "ab_variation": "all", "aggregation": "total", "stats": {"bounce_drops": 0, "bounces": 0, "clicks": 1, "unique_clicks": 1, "delivered": 1, "invalid_emails": 0, "opens": 1, "unique_opens": 1, "requests": 1, "spam_report_drops": 0, "spam_reports": 0, "unsubscribes": 0}, "id": "c9f286fb-1083-11ec-ae03-ca0fc7f28419"}, "emitted_at": 1631093373000}
107+
{"stream": "singlesend_stats", "data": {"ab_phase": "all", "ab_variation": "all", "aggregation": "total", "stats": {"bounce_drops": 0, "bounces": 0, "clicks": 1, "unique_clicks": 1, "delivered": 1, "invalid_emails": 0, "opens": 1, "unique_opens": 1, "requests": 1, "spam_report_drops": 0, "spam_reports": 0, "unsubscribes": 0}, "id": "c9f286fb-1083-11ec-ae03-ca0fc7f28419"}, "emitted_at": 1710090955628}
108+
{"stream": "singlesend_stats", "data": {"ab_phase": "all", "ab_variation": "all", "aggregation": "total", "stats": {"bounce_drops": 0, "bounces": 0, "clicks": 0, "unique_clicks": 0, "delivered": 1, "invalid_emails": 0, "opens": 3, "unique_opens": 1, "requests": 1, "spam_report_drops": 0, "spam_reports": 0, "unsubscribes": 1}, "id": "3c5a9fa6-1084-11ec-ac32-4228d699bad5"}, "emitted_at": 1710090955627}
109109
{"stream": "templates", "data": {"id": "d-9e5be59949e043e69f3df003e715b99b", "name": "test_dynamic_template", "generation": "dynamic", "updated_at": "2021-02-03 14:56:56", "versions": []}, "emitted_at": 1631093374000}
110110
{"stream": "templates", "data": {"id": "93702a5d-4cb2-4616-8d30-c2766e2b8e18", "name": "Template number 20", "generation": "legacy", "updated_at": "2021-02-03 13:31:29", "versions": []}, "emitted_at": 1631093374000}
111111
{"stream": "templates", "data": {"id": "0fd7bcc7-7459-49e9-b9f3-4ace4f9a9ae2", "name": "Template number 19", "generation": "legacy", "updated_at": "2021-02-03 13:31:28", "versions": []}, "emitted_at": 1631093374000}
@@ -212,12 +212,12 @@
212212
{"stream": "campaigns", "data": {"created_at": "2021-02-01T12:12:25Z", "id": "be9d147f-6486-11eb-8b51-8aa6caa37fdd", "name": "Third Campaign", "status": "draft", "updated_at": "2021-02-01T12:12:25Z", "is_abtest": false, "channels": ["email"]}, "emitted_at": 1678791750592}
213213
{"stream": "campaigns", "data": {"created_at": "2021-02-01T12:12:18Z", "id": "ba43f256-6486-11eb-bb4f-823d082c01b8", "name": "Second Campaign", "status": "draft", "updated_at": "2021-02-01T12:12:18Z", "is_abtest": false, "channels": ["email"]}, "emitted_at": 1678791750593}
214214
{"stream": "campaigns", "data": {"created_at": "2021-02-01T12:10:59Z", "id": "8b17a7b7-6486-11eb-bd77-2a301ccc59da", "name": "First Campaign", "status": "draft", "updated_at": "2021-02-01T12:10:59Z", "is_abtest": false, "channels": ["email"]}, "emitted_at": 1678791750593}
215-
{"stream": "segments", "data": {"id": "37d93ee7-268e-4f6f-a103-384af7324b35", "name": "Everyone named Pol, POL or pol", "contacts_count": 0, "sample_updated_at": "2023-03-13T17:30:26Z", "next_sample_update": "2023-03-14T17:30:26Z", "created_at": "2021-02-03T13:23:13Z", "updated_at": "2021-02-03T13:23:13Z", "parent_list_id": null, "status": {"query_validation": "VALID"}}, "emitted_at": 1678791752069}
216-
{"stream": "segments", "data": {"id": "bb3309ca-c002-4085-8d3e-de142dfa317e", "name": "Everyone named Jim, JIM or jim", "contacts_count": 0, "sample_updated_at": "2023-03-14T08:31:18Z", "next_sample_update": "2023-03-15T08:31:18Z", "created_at": "2021-02-03T13:19:50Z", "updated_at": "2021-02-03T13:19:50Z", "parent_list_id": "0236d6d2-75d2-42c5-962d-603e0deaf8d1", "status": {"query_validation": "VALID"}}, "emitted_at": 1678791752069}
217-
{"stream": "segments", "data": {"id": "414d2eed-b2ba-4260-b3b4-e66369fafa43", "name": "Everyone named Bob, BOB or bob", "contacts_count": 0, "sample_updated_at": "2023-03-14T03:31:01Z", "next_sample_update": "2023-03-15T03:31:01Z", "created_at": "2021-02-03T13:18:50Z", "updated_at": "2021-02-03T13:18:50Z", "parent_list_id": "0236d6d2-75d2-42c5-962d-603e0deaf8d1", "status": {"query_validation": "VALID"}}, "emitted_at": 1678791752070}
215+
{"stream": "segments", "data": {"id": "37d93ee7-268e-4f6f-a103-384af7324b35", "name": "Everyone named Pol, POL or pol", "query_version": "1", "contacts_count": 0, "sample_updated_at": "2024-03-09T17:30:18Z", "next_sample_update": "2024-03-10T17:30:18Z", "created_at": "2021-02-03T13:23:13Z", "updated_at": "2021-02-03T13:23:13Z", "parent_list_ids": null, "status": {"query_validation": "VALID"}}, "emitted_at": 1710091076235}
216+
{"stream": "segments", "data": {"id": "bb3309ca-c002-4085-8d3e-de142dfa317e", "name": "Everyone named Jim, JIM or jim", "query_version": "1", "contacts_count": 0, "sample_updated_at": "2024-03-10T08:30:38Z", "next_sample_update": "2024-03-11T08:30:38Z", "created_at": "2021-02-03T13:19:50Z", "updated_at": "2021-02-03T13:19:50Z", "parent_list_ids": ["0236d6d2-75d2-42c5-962d-603e0deaf8d1"], "status": {"query_validation": "VALID"}}, "emitted_at": 1710091076236}
217+
{"stream": "segments", "data": {"id": "414d2eed-b2ba-4260-b3b4-e66369fafa43", "name": "Everyone named Bob, BOB or bob", "query_version": "1", "contacts_count": 0, "sample_updated_at": "2024-03-10T03:30:41Z", "next_sample_update": "2024-03-11T03:30:41Z", "created_at": "2021-02-03T13:18:50Z", "updated_at": "2021-02-03T13:18:50Z", "parent_list_ids": ["0236d6d2-75d2-42c5-962d-603e0deaf8d1"], "status": {"query_validation": "VALID"}}, "emitted_at": 1710091076236}
218218
{"stream": "stats_automations", "data": {"id": "85e3874b-6654-11eb-8a29-0e707ab27408", "step_id": "all", "aggregation": "total", "stats": {"bounce_drops": 0, "bounces": 6, "clicks": 0, "unique_clicks": 0, "delivered": 6, "invalid_emails": 0, "opens": 7, "unique_opens": 3, "requests": 12, "spam_report_drops": 0, "spam_reports": 0, "unsubscribes": 0}}, "emitted_at": 1678791758456}
219-
{"stream": "unsubscribe_groups", "data": {"name": "Test Suggestions Group 0", "id": 14760, "description": "Suggestions for testing new stream.", "is_default": false, "unsubscribes": 0}, "emitted_at": 1684520573043}
220-
{"stream": "unsubscribe_groups", "data": {"name": "Test Suggestions Group 1", "id": 14761, "description": "Suggestions for testing new stream.", "is_default": false, "unsubscribes": 0}, "emitted_at": 1684520573043}
221-
{"stream": "unsubscribe_groups", "data": {"name": "Test Suggestions Group 2", "id": 14762, "description": "Suggestions for testing new stream.", "is_default": false, "unsubscribes": 0}, "emitted_at": 1684520573044}
222-
{"stream": "unsubscribe_groups", "data": {"name": "Test Suggestions Group 3", "id": 14763, "description": "Suggestions for testing new stream.", "is_default": false, "unsubscribes": 0}, "emitted_at": 1684520573044}
223-
{"stream": "unsubscribe_groups", "data": {"name": "Test Suggestions Group 4", "id": 14764, "description": "Suggestions for testing new stream.", "is_default": false, "unsubscribes": 0}, "emitted_at": 1684520573044}
219+
{"stream": "singlesends", "data": {"id": "d497b877-6486-11eb-be53-b2a243c7228c", "name": "Campaign 18", "status": "draft", "categories": [], "send_at": null, "created_at": "2021-02-01T12:13:02Z", "updated_at": "2021-02-01T12:13:02Z", "is_abtest": false, "abtest": null}, "emitted_at": 1710090864093}
220+
{"stream": "singlesends", "data": {"id": "c9f286fb-1083-11ec-ae03-ca0fc7f28419", "name": "Copy of Untitled Single Send", "status": "triggered", "categories": ["Promotional", "Travel & Hospitality"], "send_at": "2021-09-08T09:08:32Z", "created_at": "2021-09-08T09:04:36Z", "updated_at": "2021-09-08T09:09:08Z", "is_abtest": false, "abtest": null}, "emitted_at": 1710090864093}
221+
{"stream": "singlesends", "data": {"id": "4e5be6a3-1082-11ec-8512-9afd40c324e6", "name": "Untitled Single Send", "status": "triggered", "categories": ["Promotional", "Travel & Hospitality"], "send_at": "2021-09-08T08:57:05Z", "created_at": "2021-09-08T08:53:59Z", "updated_at": "2021-09-08T08:57:08Z", "is_abtest": false, "abtest": null}, "emitted_at": 1710090864093}
222+
{"stream": "singlesends", "data": {"id": "06ee105f-1082-11ec-8245-86a627812e3d", "name": "Untitled Single Send", "status": "triggered", "categories": [], "send_at": "2021-09-08T08:54:40Z", "created_at": "2021-09-08T08:51:59Z", "updated_at": "2021-09-08T08:55:08Z", "is_abtest": false, "abtest": null}, "emitted_at": 1710090864093}
223+
{"stream": "singlesends", "data": {"id": "3c5a9fa6-1084-11ec-ac32-4228d699bad5", "name": "Untitled Single Send", "status": "triggered", "categories": ["Travel & Hospitality", "Loyalty"], "send_at": "2021-09-08T09:10:22Z", "created_at": "2021-09-08T09:07:48Z", "updated_at": "2021-09-08T09:11:08Z", "is_abtest": false, "abtest": null}, "emitted_at": 1710090864093}
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"apikey": "wrong.api.key123"
2+
"api_key": "wrong.api.key123"
33
}
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
2-
"apikey": "apikey",
3-
"start_time": "some erroneous input"
2+
"api_key": "apikey",
3+
"start_date": "some erroneous input"
44
}

airbyte-integrations/connectors/source-sendgrid/integration_tests/no_spam_reports_configured_catalog.json

+10-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,16 @@
4747
},
4848
{
4949
"stream": {
50-
"name": "single_sends",
50+
"name": "singlesends",
51+
"json_schema": {},
52+
"supported_sync_modes": ["full_refresh"]
53+
},
54+
"sync_mode": "full_refresh",
55+
"destination_sync_mode": "overwrite"
56+
},
57+
{
58+
"stream": {
59+
"name": "singlesend_stats",
5160
"json_schema": {},
5261
"supported_sync_modes": ["full_refresh"]
5362
},

airbyte-integrations/connectors/source-sendgrid/metadata.yaml

+12-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,18 @@ data:
1010
connectorSubtype: api
1111
connectorType: source
1212
definitionId: fbb5fbe2-16ad-4cf4-af7d-ff9d9c316c87
13-
dockerImageTag: 0.5.0
13+
dockerImageTag: 1.0.0
14+
releases:
15+
breakingChanges:
16+
1.0.0:
17+
message:
18+
This release makes several changes that upgrade the Sendgrid connector.
19+
The configuration options have been renamed to `api_key` and `start_date`. `start_date` is now required.
20+
The `unsubscribe_groups` stream has been removed. It was the same as `suppression_groups`. You can use that and get the same data.
21+
The `single_sends` stream has been renamed `singlesend_stats`. This is closer to the data and API.
22+
The `segments` stream has been upgraded to use the Sendgrid 2.0 API because the older one has been deprecated. The schema has changed as a result.
23+
To ensure a smooth upgrade, please refresh your schemas and reset your data before resuming syncs.
24+
upgradeDeadline: "2024-04-29"
1425
dockerRepository: airbyte/source-sendgrid
1526
documentationUrl: https://docs.airbyte.com/integrations/sources/sendgrid
1627
githubIssueLabel: source-sendgrid

0 commit comments

Comments
 (0)