Skip to content

Commit 42ded09

Browse files
committed
cron schedule support
1 parent b7a0ee5 commit 42ded09

File tree

2 files changed

+28
-2
lines changed

2 files changed

+28
-2
lines changed

docs/resources/destination_subscription.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ resource "segment_destination_subscription" "send_to_webhook" {
8686

8787
Required:
8888

89-
- `strategy` (String) Strategy supports three modes: PERIODIC, SPECIFIC_DAYS, DBT_CLOUD or MANUAL.
89+
- `strategy` (String) Strategy supports the following modes: PERIODIC, SPECIFIC_DAYS, CRON, DBT_CLOUD or MANUAL.
9090

9191
Optional:
9292

internal/provider/destination_subscription_resource.go

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ func (r *destinationSubscriptionResource) Schema(_ context.Context, _ resource.S
100100
Attributes: map[string]schema.Attribute{
101101
"strategy": schema.StringAttribute{
102102
Required: true,
103-
Description: "Strategy supports three modes: PERIODIC, SPECIFIC_DAYS, DBT_CLOUD or MANUAL.",
103+
Description: "Strategy supports the following modes: PERIODIC, SPECIFIC_DAYS, CRON, DBT_CLOUD or MANUAL.",
104104
},
105105
"config": schema.StringAttribute{
106106
Optional: true,
@@ -494,6 +494,32 @@ func getSchedule(ctx context.Context, planSchedule basetypes.ObjectValue) (*api.
494494
"Manual reverse ETL schedule strategy does not require a config",
495495
)
496496
reverseETLSchedule.Config = *api.NewNullableConfig(nil)
497+
} else if reverseETLSchedule.Strategy == "CRON" {
498+
reverseETLModelScheduleConfig := api.ReverseEtlCronScheduleConfig{}
499+
var config string
500+
err = wrappedReverseETLModelScheduleConfig.As(&config)
501+
if err != nil {
502+
diags.AddError(
503+
"Unable to decode reverse ETL schedule config",
504+
err.Error(),
505+
)
506+
507+
return nil, diags
508+
}
509+
510+
err = json.Unmarshal([]byte(config), &reverseETLModelScheduleConfig)
511+
if err != nil {
512+
diags.AddError(
513+
"Unable to decode reverse ETL schedule config",
514+
err.Error(),
515+
)
516+
517+
return nil, diags
518+
}
519+
520+
reverseETLSchedule.Config = *api.NewNullableConfig(&api.Config{
521+
ReverseEtlCronScheduleConfig: &reverseETLModelScheduleConfig,
522+
})
497523
} else if reverseETLSchedule.Strategy == "DBT_CLOUD" {
498524
reverseETLModelScheduleConfig := api.ReverseEtlDbtCloudScheduleConfig{}
499525
var config string

0 commit comments

Comments
 (0)