Skip to content

Commit 86695d2

Browse files
committed
source-stripe-native: Handle empty connected account list in resource
Modify resource bindings to handle cases where no connected accounts are provided. When no connected accounts are present, the methods now use a single fetch function with a None account_id instead of creating per-account fetch functions.
1 parent 929af98 commit 86695d2

File tree

3 files changed

+1504
-1117
lines changed

3 files changed

+1504
-1117
lines changed

source-stripe-native/config.yaml

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
credentials:
2-
access_token_sops: ENC[AES256_GCM,data:7iG2cZ/7379LcC/C+hKbpmfPtIZpINAvI+Kl2EmrJQS4GHygNTQmvh9k3xqgZcnPihVJmfXUcAAN9xpzKLhhtx6WX335pzgI2lIveKLxa+qaAcBauFoqnZhhiAV7MsnrxDqp69SqtdA5QbU=,iv:2ESJfwINDwLkqnAsQ1n/3ZZI9YUSO3zVO9xAE3X+Wuw=,tag:p1NZ4ejRfxAb1+3RXQmYkg==,type:str]
2+
access_token_sops: ENC[AES256_GCM,data:JLPRanyakzcBb8AMFIs0I+g5D1w7obPxQXoCi6wSV5Ot66sX2phfn1pCE34LcmTxlokAS7CSDUdAyAsw36Eltb6iZGfkHBDtJ2S3BGGz2HEen8SgnkapNkfjOJfjkvOSEFzcH/af7w1OIJQ=,iv:Qt59fJGiz9JoHltxkA7EPqWHChjB+ppXMa3izz7UqBk=,tag:mYZWNrsOQJWH7Rc+rR+u2Q==,type:str]
33
start_date: "2010-01-01T00:00:00+00:00"
4-
capture_connected_accounts: false
4+
capture_connected_accounts: true
55
sops:
66
kms: []
77
gcp_kms:
88
- resource_id: projects/estuary-theatre/locations/us-central1/keyRings/connector-keyring/cryptoKeys/connector-repository
9-
created_at: "2025-03-04T15:38:33Z"
10-
enc: CiQAdmEdwpifyiYXJmh1JpbtmbNtZcif3KHKcxPPsWtvwCNEp5sSSQCtUdBGHOd6Ai+9YMjMeIq9TzWF7v8RqkljcGFqHvOluAIUU4MqSa57wuUbTYTREgKxUynYRlpbOdBYpIFF+BZf4peGKj/NlsQ=
9+
created_at: "2025-03-07T21:20:45Z"
10+
enc: CiQAdmEdwqj7wNLmtF7bRmbZp/HTg7GH0fyXZ/0sd+HAJylZ5Q8SSQCtUdBGNtHMe91hNh4GvgqEh8NOsOj3n8uAPVtnLmgyuetL9N7hBnXzXae6bkOaZj/OehhQjTPRJrfAjJBe/FBoTPLHxMO9gbw=
1111
azure_kv: []
1212
hc_vault: []
1313
age: []
14-
lastmodified: "2025-03-04T15:38:34Z"
15-
mac: ENC[AES256_GCM,data:hFGI3Y4t8bvBqoTWx2Qa8/UQ4AH46JZ/dwUXsRRS1D3Bh7uS7javuXLf3bSRIynXV6Y+u79ZJsbH26L8Ifr5fwUBWXhn7eI94s0N0rn1F1TUklQKpHQAN3p7x9b8hn8XvFjEDBBQPXQQQFT0Hltn+g2kKhE1e+nFUvI98DV/9Bk=,iv:KA6kD6QP71Giz/uxZ1ceHuPOwImBWY3KHyGDqGrmV1U=,tag:licITgXgJHodNH+MVLuY/Q==,type:str]
14+
lastmodified: "2025-03-07T21:20:45Z"
15+
mac: ENC[AES256_GCM,data:I3mhDLPF07sAGViAGYXSZMx//Pp3pJOoFARqrEagfoR+96evSb845q818SxqEJeUVkPF0Weue6f9FwSyuAUHpu9+LPYAZrVixHr/HeFEFLfvCe/yFf0fTXO7GhsKdGiucqzrd6nRc6/byVyka75H86MzCsdrOW5zVyfwXPr0jUM=,iv:HguMQ+BM+H2AIpdUMlWW9oDWRL4zzB+JZYTLC7xQblU=,tag:B1AV7zVrP5hQ7kMrUe6m7w==,type:str]
1616
pgp: []
1717
encrypted_suffix: _sops
1818
version: 3.9.4

source-stripe-native/source_stripe_native/resources.py

+172-50
Original file line numberDiff line numberDiff line change
@@ -235,19 +235,47 @@ def open(
235235
task: Task,
236236
all_bindings,
237237
):
238-
fetch_changes_fns = {
239-
account_id: functools.partial(
240-
fetch_incremental, cls, platform_account_id, account_id, http
238+
if not connected_account_ids or len(connected_account_ids) == 0:
239+
fetch_changes_fns = functools.partial(
240+
fetch_incremental,
241+
cls,
242+
platform_account_id,
243+
None,
244+
http,
241245
)
242-
for account_id in all_account_ids
243-
}
246+
else:
247+
fetch_changes_fns = {
248+
account_id: functools.partial(
249+
fetch_incremental,
250+
cls,
251+
platform_account_id,
252+
account_id,
253+
http,
254+
)
255+
for account_id in all_account_ids
256+
}
244257

245-
fetch_page_fns = {
246-
account_id: functools.partial(
247-
fetch_backfill, cls, start_date, platform_account_id, account_id, http
258+
if not connected_account_ids or len(connected_account_ids) == 0:
259+
fetch_page_fns = functools.partial(
260+
fetch_backfill,
261+
cls,
262+
start_date,
263+
platform_account_id,
264+
None,
265+
http,
248266
)
249-
for account_id in all_account_ids
250-
}
267+
else:
268+
fetch_page_fns = {
269+
account_id: functools.partial(
270+
fetch_backfill,
271+
cls,
272+
start_date,
273+
platform_account_id,
274+
account_id,
275+
http,
276+
)
277+
for account_id in all_account_ids
278+
}
251279

252280
open_binding(
253281
binding,
@@ -293,30 +321,51 @@ def open(
293321
task: Task,
294322
all_bindings,
295323
):
296-
fetch_changes_fns = {
297-
account_id: functools.partial(
324+
if not connected_account_ids or len(connected_account_ids) == 0:
325+
fetch_changes_fns = functools.partial(
298326
fetch_incremental_substreams,
299327
cls,
300328
child_cls,
301329
platform_account_id,
302-
account_id,
330+
None,
303331
http,
304332
)
305-
for account_id in all_account_ids
306-
}
333+
else:
334+
fetch_changes_fns = {
335+
account_id: functools.partial(
336+
fetch_incremental_substreams,
337+
cls,
338+
child_cls,
339+
platform_account_id,
340+
account_id,
341+
http,
342+
)
343+
for account_id in all_account_ids
344+
}
307345

308-
fetch_page_fns = {
309-
account_id: functools.partial(
346+
if not connected_account_ids or len(connected_account_ids) == 0:
347+
fetch_page_fns = functools.partial(
310348
fetch_backfill_substreams,
311349
cls,
312350
child_cls,
313351
start_date,
314352
platform_account_id,
315-
account_id,
353+
None,
316354
http,
317355
)
318-
for account_id in all_account_ids
319-
}
356+
else:
357+
fetch_page_fns = {
358+
account_id: functools.partial(
359+
fetch_backfill_substreams,
360+
cls,
361+
child_cls,
362+
start_date,
363+
platform_account_id,
364+
account_id,
365+
http,
366+
)
367+
for account_id in all_account_ids
368+
}
320369

321370
open_binding(
322371
binding,
@@ -365,25 +414,49 @@ def open(
365414
task: Task,
366415
all_bindings,
367416
):
368-
fetch_changes_fns = {
369-
account_id: functools.partial(
370-
fetch_incremental, child_cls, platform_account_id, account_id, http
417+
if not connected_account_ids or len(connected_account_ids) == 0:
418+
fetch_changes_fns = functools.partial(
419+
fetch_incremental,
420+
child_cls,
421+
platform_account_id,
422+
None,
423+
http,
371424
)
372-
for account_id in all_account_ids
373-
}
425+
else:
426+
fetch_changes_fns = {
427+
account_id: functools.partial(
428+
fetch_incremental,
429+
child_cls,
430+
platform_account_id,
431+
account_id,
432+
http,
433+
)
434+
for account_id in all_account_ids
435+
}
374436

375-
fetch_page_fns = {
376-
account_id: functools.partial(
437+
if not connected_account_ids or len(connected_account_ids) == 0:
438+
fetch_page_fns = functools.partial(
377439
fetch_backfill_substreams,
378440
cls,
379441
child_cls,
380442
start_date,
381443
platform_account_id,
382-
account_id,
444+
None,
383445
http,
384446
)
385-
for account_id in all_account_ids
386-
}
447+
else:
448+
fetch_page_fns = {
449+
account_id: functools.partial(
450+
fetch_backfill_substreams,
451+
cls,
452+
child_cls,
453+
start_date,
454+
platform_account_id,
455+
account_id,
456+
http,
457+
)
458+
for account_id in all_account_ids
459+
}
387460

388461
open_binding(
389462
binding,
@@ -431,30 +504,51 @@ def open(
431504
task: Task,
432505
all_bindings,
433506
):
434-
fetch_changes_fns = {
435-
account_id: functools.partial(
507+
if not connected_account_ids or len(connected_account_ids) == 0:
508+
fetch_changes_fns = functools.partial(
436509
fetch_incremental_usage_records,
437510
cls,
438511
child_cls,
439512
platform_account_id,
440-
account_id,
513+
None,
441514
http,
442515
)
443-
for account_id in all_account_ids
444-
}
516+
else:
517+
fetch_changes_fns = {
518+
account_id: functools.partial(
519+
fetch_incremental_usage_records,
520+
cls,
521+
child_cls,
522+
platform_account_id,
523+
account_id,
524+
http,
525+
)
526+
for account_id in all_account_ids
527+
}
445528

446-
fetch_page_fns = {
447-
account_id: functools.partial(
529+
if not connected_account_ids or len(connected_account_ids) == 0:
530+
fetch_page_fns = functools.partial(
448531
fetch_backfill_usage_records,
449532
cls,
450533
child_cls,
451534
start_date,
452535
platform_account_id,
453-
account_id,
536+
None,
454537
http,
455538
)
456-
for account_id in all_account_ids
457-
}
539+
else:
540+
fetch_page_fns = {
541+
account_id: functools.partial(
542+
fetch_backfill_usage_records,
543+
cls,
544+
child_cls,
545+
start_date,
546+
platform_account_id,
547+
account_id,
548+
http,
549+
)
550+
for account_id in all_account_ids
551+
}
458552

459553
open_binding(
460554
binding,
@@ -502,19 +596,47 @@ def open(
502596
task: Task,
503597
all_bindings,
504598
):
505-
fetch_changes_fns = {
506-
account_id: functools.partial(
507-
fetch_incremental_no_events, cls, platform_account_id, account_id, http
599+
if not connected_account_ids or len(connected_account_ids) == 0:
600+
fetch_changes_fns = functools.partial(
601+
fetch_incremental_no_events,
602+
cls,
603+
platform_account_id,
604+
None,
605+
http,
508606
)
509-
for account_id in all_account_ids
510-
}
607+
else:
608+
fetch_changes_fns = {
609+
account_id: functools.partial(
610+
fetch_incremental_no_events,
611+
cls,
612+
platform_account_id,
613+
account_id,
614+
http,
615+
)
616+
for account_id in all_account_ids
617+
}
511618

512-
fetch_page_fns = {
513-
account_id: functools.partial(
514-
fetch_backfill, cls, start_date, platform_account_id, account_id, http
619+
if not connected_account_ids or len(connected_account_ids) == 0:
620+
fetch_page_fns = functools.partial(
621+
fetch_backfill,
622+
cls,
623+
start_date,
624+
platform_account_id,
625+
None,
626+
http,
515627
)
516-
for account_id in all_account_ids
517-
}
628+
else:
629+
fetch_page_fns = {
630+
account_id: functools.partial(
631+
fetch_backfill,
632+
cls,
633+
start_date,
634+
platform_account_id,
635+
account_id,
636+
http,
637+
)
638+
for account_id in all_account_ids
639+
}
518640

519641
open_binding(
520642
binding,

0 commit comments

Comments
 (0)