Skip to content

Commit c235176

Browse files
Add data delay's fields in TF (#387)
1 parent b11ddd9 commit c235176

13 files changed

+137
-5
lines changed

docs/data-sources/connector.md

+2
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ data "fivetran_connector" "connector" {
2727
- `connected_by` (String) The unique identifier of the user who has created the connector in your account.
2828
- `created_at` (String) The timestamp of the time the connector was created in your account.
2929
- `daily_sync_time` (String) The optional parameter that defines the sync start time when the sync frequency is already set or being set by the current request to 1440. It can be specified in one hour increments starting from 00:00 to 23:00. If not specified, we will use [the baseline sync start time](https://fivetran.com/docs/getting-started/syncoverview#syncfrequencyandscheduling). This parameter has no effect on the [0 to 60 minutes offset](https://fivetran.com/docs/getting-started/syncoverview#syncstarttimesandoffsets) used to determine the actual sync start time.
30+
- `data_delay_sensitivity` (String) The level of data delay notification threshold. Possible values: LOW, NORMAL, HIGH, CUSTOM. The default value NORMAL. CUSTOM is only available for customers using the Enterprise plan or above.
31+
- `data_delay_threshold` (Number) Custom sync delay notification threshold in minutes. The default value is 0. This parameter is only used when data_delay_sensitivity set to CUSTOM.
3032
- `destination_schema` (Block, Read-only) (see [below for nested schema](#nestedblock--destination_schema))
3133
- `failed_at` (String) The timestamp of the time the connector sync failed last time.
3234
- `group_id` (String) The unique identifier for the Group (Destination) within the Fivetran system.

docs/resources/connector.md

+2
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ resource "fivetran_connector" "amplitude" {
6969

7070
- `auth` (Block, Optional) (see [below for nested schema](#nestedblock--auth))
7171
- `config` (Block, Optional) (see [below for nested schema](#nestedblock--config))
72+
- `data_delay_sensitivity` (String) The level of data delay notification threshold. Possible values: LOW, NORMAL, HIGH, CUSTOM. The default value NORMAL. CUSTOM is only available for customers using the Enterprise plan or above.
73+
- `data_delay_threshold` (Number) Custom sync delay notification threshold in minutes. The default value is 0. This parameter is only used when data_delay_sensitivity set to CUSTOM.
7274
- `destination_schema` (Block, Optional) (see [below for nested schema](#nestedblock--destination_schema))
7375
- `hybrid_deployment_agent_id` (String) The hybrid deployment agent ID that refers to the controller created for the group the connection belongs to. If the value is specified, the system will try to associate the connection with an existing agent.
7476
- `local_processing_agent_id` (String, Deprecated) (Deprecated) The hybrid deployment agent ID that refers to the controller created for the group the connection belongs to. If the value is specified, the system will try to associate the connection with an existing agent.

docs/resources/connector_schema_config.md

+2
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,7 @@ Optional:
232232

233233
- `enabled` (Boolean) The boolean value specifying whether the sync of the column into the destination is enabled.
234234
- `hashed` (Boolean) The boolean value specifying whether a column should be hashed.
235+
- `is_primary_key` (Boolean)
235236

236237

237238

@@ -260,6 +261,7 @@ Optional:
260261

261262
- `enabled` (Boolean) The boolean value specifying whether the sync of the column into the destination is enabled.
262263
- `hashed` (Boolean) The boolean value specifying whether a column should be hashed.
264+
- `is_primary_key` (Boolean)
263265

264266

265267

fivetran/framework/core/model/connector.go

+45-1
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,15 @@ type ConnectorDatasourceModel struct {
3232
Paused types.Bool `tfsdk:"paused"`
3333
PauseAfterTrial types.Bool `tfsdk:"pause_after_trial"`
3434
DailySyncTime types.String `tfsdk:"daily_sync_time"`
35+
36+
DataDelaySensitivity types.String `tfsdk:"data_delay_sensitivity"`
37+
DataDelayThreshold types.Int64 `tfsdk:"data_delay_threshold"`
3538

3639
ProxyAgentId types.String `tfsdk:"proxy_agent_id"`
3740
NetworkingMethod types.String `tfsdk:"networking_method"`
3841
HybridDeploymentAgentId types.String `tfsdk:"hybrid_deployment_agent_id"`
3942
LocalProcessingAgentId types.String `tfsdk:"local_processing_agent_id"`
40-
PrivateLinkId types.String `tfsdk:"private_link_id"`
43+
PrivateLinkId types.String `tfsdk:"private_link_id"`
4144
Status types.Object `tfsdk:"status"`
4245

4346
Config types.Object `tfsdk:"config"`
@@ -62,6 +65,14 @@ func (d *ConnectorDatasourceModel) ReadFromResponse(resp connectors.DetailsWithC
6265
d.ScheduleType = types.StringValue(resp.Data.ScheduleType)
6366
d.Paused = types.BoolValue(*resp.Data.Paused)
6467
d.PauseAfterTrial = types.BoolValue(*resp.Data.PauseAfterTrial)
68+
69+
d.DataDelaySensitivity = types.StringValue(resp.Data.DataDelaySensitivity)
70+
71+
if resp.Data.DataDelayThreshold != nil {
72+
d.DataDelayThreshold = types.Int64Value(int64(*resp.Data.DataDelayThreshold))
73+
} else {
74+
d.DataDelayThreshold = types.Int64Null()
75+
}
6576

6677
if resp.Data.DailySyncTime != "" {
6778
d.DailySyncTime = types.StringValue(resp.Data.DailySyncTime)
@@ -136,6 +147,9 @@ type ConnectorResourceModel struct {
136147
HybridDeploymentAgentId types.String `tfsdk:"hybrid_deployment_agent_id"`
137148
PrivateLinkId types.String `tfsdk:"private_link_id"`
138149

150+
DataDelaySensitivity types.String `tfsdk:"data_delay_sensitivity"`
151+
DataDelayThreshold types.Int64 `tfsdk:"data_delay_threshold"`
152+
139153
Config types.Object `tfsdk:"config"`
140154
Auth types.Object `tfsdk:"auth"`
141155
Timeouts timeouts.Value `tfsdk:"timeouts"`
@@ -206,6 +220,17 @@ func (d *ConnectorResourceModel) ReadFromContainer(c ConnectorModelContainer, fo
206220
d.GroupId = types.StringValue(c.GroupId)
207221
d.Service = types.StringValue(c.Service)
208222

223+
// as fact - this is computed attribute which user can change
224+
if !d.DataDelaySensitivity.IsUnknown() && !d.DataDelaySensitivity.IsNull() {
225+
d.DataDelaySensitivity = types.StringValue(c.DataDelaySensitivity)
226+
}
227+
228+
if c.DataDelayThreshold != nil {
229+
d.DataDelayThreshold = types.Int64Value(int64(*c.DataDelayThreshold))
230+
} else {
231+
d.DataDelayThreshold = types.Int64Null()
232+
}
233+
209234
if c.LocalProcessingAgentId != "" && !d.LocalProcessingAgentId.IsUnknown() && !d.LocalProcessingAgentId.IsNull(){
210235
d.LocalProcessingAgentId = types.StringValue(c.HybridDeploymentAgentId)
211236
} else {
@@ -251,6 +276,17 @@ func (d *ConnectorDatasourceModel) ReadFromContainer(c ConnectorModelContainer)
251276
d.GroupId = types.StringValue(c.GroupId)
252277
d.Service = types.StringValue(c.Service)
253278

279+
// as fact - this is computed attribute which user can change
280+
if !d.DataDelaySensitivity.IsUnknown() && !d.DataDelaySensitivity.IsNull() {
281+
d.DataDelaySensitivity = types.StringValue(c.DataDelaySensitivity)
282+
}
283+
284+
if c.DataDelayThreshold != nil {
285+
d.DataDelayThreshold = types.Int64Value(int64(*c.DataDelayThreshold))
286+
} else {
287+
d.DataDelayThreshold = types.Int64Null()
288+
}
289+
254290
d.DestinationSchema = getDestinationSchemaValue(c.Service, c.Schema)
255291

256292
if c.PrivateLinkId != "" {
@@ -306,6 +342,10 @@ type ConnectorModelContainer struct {
306342
HybridDeploymentAgentId string
307343
LocalProcessingAgentId string
308344
PrivateLinkId string
345+
346+
DataDelaySensitivity string
347+
DataDelayThreshold *int
348+
309349
Config map[string]interface{}
310350

311351
RunSetupTests bool
@@ -321,6 +361,10 @@ func (c *ConnectorModelContainer) ReadFromResponseData(data connectors.DetailsRe
321361
c.GroupId = data.GroupID
322362
c.Service = data.Service
323363
c.Schema = data.Schema
364+
365+
c.DataDelaySensitivity = data.DataDelaySensitivity
366+
c.DataDelayThreshold = data.DataDelayThreshold
367+
324368
c.Config = config
325369

326370
if data.ProxyAgentId != "" {

fivetran/framework/core/schema/connector.go

+8
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,14 @@ func ConnectorAttributesSchema() core.Schema {
120120
ValueType: core.String,
121121
Description: "The private link ID.",
122122
},
123+
"data_delay_sensitivity": {
124+
ValueType: core.String,
125+
Description: "The level of data delay notification threshold. Possible values: LOW, NORMAL, HIGH, CUSTOM. The default value NORMAL. CUSTOM is only available for customers using the Enterprise plan or above.",
126+
},
127+
"data_delay_threshold": {
128+
ValueType: core.Integer,
129+
Description: "Custom sync delay notification threshold in minutes. The default value is 0. This parameter is only used when data_delay_sensitivity set to CUSTOM.",
130+
},
123131
},
124132
}
125133
}

fivetran/framework/datasources/connector_test.go

+6
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ const (
2626
"failed_at": null,
2727
"sync_frequency": 5,
2828
"schedule_type": "auto",
29+
"data_delay_sensitivity": "NORMAL",
30+
"data_delay_threshold": 0,
2931
"status": {
3032
"setup_state": "incomplete",
3133
"sync_state": "paused",
@@ -101,6 +103,8 @@ func TestDataSourceConnectorConfigMappingMock(t *testing.T) {
101103
resource.TestCheckResourceAttr("data.fivetran_connector.test_connector", "sync_frequency", "5"),
102104
resource.TestCheckResourceAttr("data.fivetran_connector.test_connector", "paused", "true"),
103105
resource.TestCheckResourceAttr("data.fivetran_connector.test_connector", "pause_after_trial", "true"),
106+
resource.TestCheckResourceAttr("data.fivetran_connector.test_connector", "data_delay_sensitivity", "NORMAL"),
107+
resource.TestCheckResourceAttr("data.fivetran_connector.test_connector", "data_delay_threshold", "0"),
104108
),
105109
}
106110

@@ -156,6 +160,8 @@ func TestDataSourceConnectorMock(t *testing.T) {
156160
resource.TestCheckResourceAttr("data.fivetran_connector.test_connector", "config.reports.1.report_type", "report_2"),
157161
resource.TestCheckResourceAttr("data.fivetran_connector.test_connector", "config.reports.1.metrics.0", "metric2"),
158162
resource.TestCheckResourceAttr("data.fivetran_connector.test_connector", "config.reports.1.metrics.1", "metric3"),
163+
resource.TestCheckResourceAttr("data.fivetran_connector.test_connector", "data_delay_sensitivity", "NORMAL"),
164+
resource.TestCheckResourceAttr("data.fivetran_connector.test_connector", "data_delay_threshold", "0"),
159165
),
160166
}
161167

fivetran/framework/provider.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import (
1717
"github.com/hashicorp/terraform-plugin-framework/types"
1818
)
1919

20-
const Version = "1.4.0" // Current provider version
20+
const Version = "1.4.3" // Current provider version
2121

2222
type fivetranProvider struct {
2323
mockClient httputils.HttpClient

fivetran/framework/resources/connector.go

+18
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,15 @@ func (r *connector) Create(ctx context.Context, req resource.CreateRequest, resp
162162
svc.PrivateLinkId(data.PrivateLinkId.ValueString())
163163
}
164164

165+
if data.DataDelaySensitivity.ValueString() != "" {
166+
svc.DataDelaySensitivity(data.DataDelaySensitivity.ValueString())
167+
}
168+
169+
if !data.DataDelayThreshold.IsNull() {
170+
value := int(data.DataDelayThreshold.ValueInt64())
171+
svc.DataDelayThreshold(&value)
172+
}
173+
165174
if data.LocalProcessingAgentId.ValueString() != "" {
166175
resp.Diagnostics.AddWarning(
167176
"Field `local_processing_agent_id` is Deprecated",
@@ -381,6 +390,15 @@ func (r *connector) Update(ctx context.Context, req resource.UpdateRequest, resp
381390
svc.NetworkingMethod(plan.NetworkingMethod.ValueString())
382391
}
383392

393+
if plan.DataDelaySensitivity.ValueString() != "" {
394+
svc.DataDelaySensitivity(plan.DataDelaySensitivity.ValueString())
395+
}
396+
397+
if !plan.DataDelayThreshold.IsNull() {
398+
value := int(plan.DataDelayThreshold.ValueInt64())
399+
svc.DataDelayThreshold(&value)
400+
}
401+
384402
response, err := svc.DoCustom(ctx)
385403

386404
if err != nil {

fivetran/framework/resources/connector_migrations.go

+4
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ func upgradeConnectorState(ctx context.Context, req resource.UpgradeStateRequest
4949
"proxy_agent_id": tftypes.NewValue(tftypes.String, nil),
5050
"local_processing_agent_id": tftypes.NewValue(tftypes.String, nil),
5151
"private_link_id": tftypes.NewValue(tftypes.String, nil),
52+
"data_delay_sensitivity": tftypes.NewValue(tftypes.String, nil),
53+
"data_delay_threshold": tftypes.NewValue(tftypes.Number, nil),
5254
"hybrid_deployment_agent_id": rawState["local_processing_agent_id"],
5355
"run_setup_tests": convertStringStateValueToBool("run_setup_tests", rawState["run_setup_tests"], resp.Diagnostics),
5456
"trust_fingerprints": convertStringStateValueToBool("trust_fingerprints", rawState["trust_fingerprints"], resp.Diagnostics),
@@ -106,6 +108,8 @@ func getConnectorStateModel(version int) tftypes.Type {
106108
base["networking_method"] = tftypes.String
107109
base["local_processing_agent_id"] = tftypes.String
108110
base["private_link_id"] = tftypes.String
111+
base["data_delay_sensitivity"] = tftypes.String
112+
base["data_delay_threshold"] = tftypes.Number
109113
base["config"] = tftypes.Object{AttributeTypes: model.GetTfTypes(common.GetConfigFieldsMap(), 3)}
110114
base["auth"] = tftypes.Object{AttributeTypes: model.GetTfTypes(common.GetAuthFieldsMap(), 3)}
111115
} else {

fivetran/framework/resources/connector_test.go

+34-1
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ const (
4646
"sync_frequency": 5,
4747
"schedule_type": "auto",
4848
"networking_method": "Directly",
49+
"data_delay_sensitivity": "NORMAL",
50+
"data_delay_threshold": 0,
4951
"status": {
5052
"setup_state": "incomplete",
5153
"sync_state": "paused",
@@ -76,6 +78,8 @@ const (
7678
"sync_frequency": 5,
7779
"schedule_type": "auto",
7880
"networking_method": "Directly",
81+
"data_delay_sensitivity": "NORMAL",
82+
"data_delay_threshold": 0,
7983
"status": {
8084
"setup_state": "incomplete",
8185
"sync_state": "paused",
@@ -120,6 +124,8 @@ const (
120124
"failed_at": null,
121125
"schedule_type": "auto",
122126
"networking_method": "Directly",
127+
"data_delay_sensitivity": "NORMAL",
128+
"data_delay_threshold": 0,
123129
"status": {
124130
"setup_state": "incomplete",
125131
"sync_state": "paused",
@@ -164,6 +170,8 @@ const (
164170
"sync_frequency": 5,
165171
"schedule_type": "auto",
166172
"networking_method": "Directly",
173+
"data_delay_sensitivity": "NORMAL",
174+
"data_delay_threshold": 0,
167175
"status": {
168176
"setup_state": "incomplete",
169177
"sync_state": "paused",
@@ -239,6 +247,9 @@ const (
239247
table = "table"
240248
}
241249
250+
data_delay_sensitivity = "NORMAL"
251+
data_delay_threshold = 0
252+
242253
trust_certificates = false
243254
trust_fingerprints = false
244255
run_setup_tests = false
@@ -394,6 +405,9 @@ func TestResourceConnectorUpdateMock(t *testing.T) {
394405
group_id = "group_id"
395406
service = "postgres"
396407
408+
data_delay_sensitivity = "NORMAL"
409+
data_delay_threshold = 0
410+
397411
destination_schema {
398412
prefix = "postgres"
399413
}
@@ -439,6 +453,9 @@ func TestResourceConnectorUpdateMock(t *testing.T) {
439453
group_id = "group_id"
440454
service = "postgres"
441455
456+
data_delay_sensitivity = "NORMAL"
457+
data_delay_threshold = 0
458+
442459
destination_schema {
443460
prefix = "postgres"
444461
}
@@ -508,6 +525,9 @@ func TestResourceConnectorEmptyConfigMock(t *testing.T) {
508525
group_id = "group_id"
509526
service = "postgres"
510527
528+
data_delay_sensitivity = "NORMAL"
529+
data_delay_threshold = 0
530+
511531
destination_schema {
512532
prefix = "postgres"
513533
}
@@ -666,6 +686,9 @@ func TestResourceConnectorUnknownServiceMock(t *testing.T) {
666686
group_id = "group_id"
667687
service = "unknown-service-name"
668688
689+
data_delay_sensitivity = "NORMAL"
690+
data_delay_threshold = 0
691+
669692
destination_schema {
670693
name = "schema"
671694
}
@@ -699,6 +722,9 @@ func TestResourceConnectorMock(t *testing.T) {
699722
service = "google_ads"
700723
group_id = "group_id"
701724
725+
data_delay_sensitivity = "NORMAL"
726+
data_delay_threshold = 0
727+
702728
destination_schema {
703729
name = "adwords_schema"
704730
}
@@ -732,6 +758,8 @@ func TestResourceConnectorMock(t *testing.T) {
732758
resource.TestCheckResourceAttr("fivetran_connector.test_connector", "group_id", "group_id"),
733759
resource.TestCheckResourceAttr("fivetran_connector.test_connector", "service", "google_ads"),
734760
resource.TestCheckResourceAttr("fivetran_connector.test_connector", "destination_schema.name", "adwords_schema"),
761+
resource.TestCheckResourceAttr("fivetran_connector.test_connector", "data_delay_sensitivity", "NORMAL"),
762+
resource.TestCheckResourceAttr("fivetran_connector.test_connector", "data_delay_threshold", "0"),
735763
resource.TestCheckResourceAttr("fivetran_connector.test_connector", "config.user", "user_name"),
736764
resource.TestCheckResourceAttr("fivetran_connector.test_connector", "config.password", "password"),
737765
resource.TestCheckResourceAttr("fivetran_connector.test_connector", "config.port", "5432"),
@@ -755,6 +783,9 @@ func TestResourceConnectorMock(t *testing.T) {
755783
service = "google_ads"
756784
group_id = "group_id"
757785
786+
data_delay_sensitivity = "NORMAL"
787+
data_delay_threshold = 0
788+
758789
destination_schema {
759790
name = "adwords_schema"
760791
}
@@ -787,6 +818,8 @@ func TestResourceConnectorMock(t *testing.T) {
787818
resource.TestCheckResourceAttr("fivetran_connector.test_connector", "group_id", "group_id"),
788819
resource.TestCheckResourceAttr("fivetran_connector.test_connector", "service", "google_ads"),
789820
resource.TestCheckResourceAttr("fivetran_connector.test_connector", "destination_schema.name", "adwords_schema"),
821+
resource.TestCheckResourceAttr("fivetran_connector.test_connector", "data_delay_sensitivity", "NORMAL"),
822+
resource.TestCheckResourceAttr("fivetran_connector.test_connector", "data_delay_threshold", "0"),
790823
resource.TestCheckResourceAttr("fivetran_connector.test_connector", "config.user", "user_name_1"),
791824
resource.TestCheckResourceAttr("fivetran_connector.test_connector", "config.password", "password_1"),
792825
resource.TestCheckResourceAttr("fivetran_connector.test_connector", "config.port", "2345"),
@@ -883,7 +916,7 @@ func TestResourceConnectorMock(t *testing.T) {
883916
body := tfmock.RequestBodyToJson(t, req)
884917

885918
// Check the request
886-
tfmock.AssertEqual(t, len(body), 4)
919+
tfmock.AssertEqual(t, len(body), 6)
887920

888921
tfmock.AssertKeyExistsAndHasValue(t, body, "run_setup_tests", true)
889922
tfmock.AssertKeyExistsAndHasValue(t, body, "trust_certificates", true)

0 commit comments

Comments
 (0)