Skip to content

Commit 28c84da

Browse files
Xu Zravinitp
authored andcommitted
Added - Support for Extend Data Retention Period for OIC Instance
1 parent c4455e2 commit 28c84da

8 files changed

+139
-64
lines changed

examples/integration/main.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ variable "compartment_id" {
2020
}
2121

2222
variable "integration_instance_idcs_access_token" {
23-
23+
default = ""
2424
}
2525

2626
variable "integration_instance_consumption_model" {
@@ -61,7 +61,7 @@ resource "oci_integration_integration_instance" "test_integration_instance" {
6161
compartment_id = var.compartment_id
6262
integration_instance_type = "HEALTHCARE"
6363
shape = "DEVELOPMENT"
64-
display_name = "displayName"
64+
display_name = "DataRetention"
6565
is_byol = "false"
6666
message_packs = "10"
6767
domain_id = var.domain_id

internal/integrationtest/integration_integration_instance_test.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ var (
7878
// "network_endpoint_details": acctest.RepresentationGroup{RepType: acctest.Optional, Group: integrationInstanceNetworkEndpointDetailsRepresentation},
7979
"shape": acctest.Representation{RepType: acctest.Optional, Create: `DEVELOPMENT`},
8080
"enable_process_automation_trigger": acctest.Representation{RepType: acctest.Optional, Create: `0`, Update: `1`},
81+
"extend_data_retention_trigger": acctest.Representation{RepType: acctest.Optional, Create: `0`, Update: `1`},
8182
}
8283

8384
integrationInstanceRepresentation = map[string]interface{}{
@@ -203,14 +204,15 @@ func TestIntegrationIntegrationInstanceResource_basic(t *testing.T) {
203204
acctest.ResourceTest(t, testAccCheckIntegrationIntegrationInstanceDestroy, []resource.TestStep{
204205
// verify Create
205206
{
206-
Config: config + instanceTypeVariableStr + compartmentIdVariableStr + domainIdVariableStr + subnetIdStr + nsgIdStr + idcsAccessTokenVariableStr() + IntegrationIntegrationInstanceResourceDependencies +
207+
Config: config + instanceTypeVariableStr + compartmentIdVariableStr + subnetIdStr + domainIdVariableStr + nsgIdStr + idcsAccessTokenVariableStr() + IntegrationIntegrationInstanceResourceDependencies +
207208
acctest.GenerateResourceFromRepresentationMap("oci_integration_integration_instance", "test_integration_instance", acctest.Required, acctest.Create, integrationInstanceRepresentation) +
208209
acctest.GenerateResourceFromRepresentationMap("oci_integration_private_endpoint_outbound_connection", "integration_private_endpoint", acctest.Required, acctest.Create, integrationPrivateEndpointRepresentation),
209210
Check: acctest.ComposeAggregateTestCheckFuncWrapper(
210211
resource.TestCheckResourceAttr(resourceName, "compartment_id", compartmentId),
211212
resource.TestCheckResourceAttr(resourceName, "display_name", "displayName"),
212213
resource.TestCheckResourceAttr(resourceName, "integration_instance_type", utils.GetEnvSettingWithBlankDefault("instance_type")),
213214
resource.TestCheckResourceAttr(resourceName, "is_byol", "false"),
215+
resource.TestCheckResourceAttrSet(resourceName, "data_retention_period"),
214216
resource.TestCheckResourceAttr(resourceName, "message_packs", "1"),
215217

216218
func(s *terraform.State) (err error) {
@@ -275,6 +277,7 @@ func TestIntegrationIntegrationInstanceResource_basic(t *testing.T) {
275277
resource.TestCheckResourceAttr(resourceName, "freeform_tags.%", "1"),
276278
resource.TestCheckResourceAttrSet(resourceName, "id"),
277279
// resource.TestCheckResourceAttrSet(resourceName, "idcs_at"),
280+
resource.TestCheckResourceAttrSet(resourceName, "data_retention_period"),
278281
resource.TestCheckResourceAttrSet(resourceName, "instance_url"),
279282
resource.TestCheckResourceAttr(resourceName, "integration_instance_type", utils.GetEnvSettingWithBlankDefault("instance_type")),
280283
resource.TestCheckResourceAttr(resourceName, "is_byol", "false"),
@@ -339,6 +342,7 @@ func TestIntegrationIntegrationInstanceResource_basic(t *testing.T) {
339342
resource.TestCheckResourceAttrSet(resourceName, "domain_id"),
340343
resource.TestCheckResourceAttr(resourceName, "freeform_tags.%", "1"),
341344
resource.TestCheckResourceAttrSet(resourceName, "id"),
345+
resource.TestCheckResourceAttrSet(resourceName, "data_retention_period"),
342346
// resource.TestCheckResourceAttrSet(resourceName, "idcs_at"),
343347
resource.TestCheckResourceAttrSet(resourceName, "instance_url"),
344348
resource.TestCheckResourceAttr(resourceName, "integration_instance_type", utils.GetEnvSettingWithBlankDefault("instance_type")),
@@ -438,6 +442,7 @@ func TestIntegrationIntegrationInstanceResource_basic(t *testing.T) {
438442
// }),
439443
resource.TestCheckResourceAttr(datasourceName, "integration_instances.0.compartment_id", compartmentId),
440444
resource.TestCheckResourceAttr(datasourceName, "integration_instances.0.consumption_model", "UCM"),
445+
resource.TestCheckResourceAttrSet(datasourceName, "integration_instances.0.data_retention_period"),
441446
resource.TestCheckResourceAttr(datasourceName, "integration_instances.0.custom_endpoint.#", "0"),
442447
// resource.TestCheckResourceAttrSet(datasourceName, "integration_instances.0.custom_endpoint.0.alias"),
443448
// resource.TestCheckResourceAttrSet(datasourceName, "integration_instances.0.custom_endpoint.0.certificate_secret_id"),
@@ -485,14 +490,15 @@ func TestIntegrationIntegrationInstanceResource_basic(t *testing.T) {
485490
// }),
486491
resource.TestCheckResourceAttr(singularDatasourceName, "compartment_id", compartmentId),
487492
resource.TestCheckResourceAttr(singularDatasourceName, "consumption_model", "UCM"),
493+
resource.TestCheckResourceAttrSet(singularDatasourceName, "data_retention_period"),
488494
resource.TestCheckResourceAttr(singularDatasourceName, "custom_endpoint.#", "0"),
489495
// resource.TestCheckResourceAttrSet(singularDatasourceName, "custom_endpoint.0.alias"),
490496
// resource.TestCheckResourceAttrSet(singularDatasourceName, "custom_endpoint.0.certificate_secret_version"),
491497
// resource.TestCheckResourceAttr(singularDatasourceName, "custom_endpoint.0.hostname", "hostname2-updated.com"),
492498
resource.TestCheckResourceAttr(singularDatasourceName, "display_name", "displayName2"),
493499
resource.TestCheckResourceAttr(singularDatasourceName, "freeform_tags.%", "1"),
494500
resource.TestCheckResourceAttrSet(singularDatasourceName, "id"),
495-
resource.TestCheckResourceAttr(singularDatasourceName, "idcs_info.#", "0"),
501+
resource.TestCheckResourceAttr(singularDatasourceName, "idcs_info.#", "1"),
496502
resource.TestCheckResourceAttrSet(singularDatasourceName, "instance_url"),
497503
resource.TestCheckResourceAttr(singularDatasourceName, "integration_instance_type", utils.GetEnvSettingWithBlankDefault("instance_type")),
498504
resource.TestCheckResourceAttr(singularDatasourceName, "is_byol", "true"),

internal/service/integration/integration_integration_instance_data_source.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,8 @@ func (s *IntegrationIntegrationInstanceDataSourceCrud) SetData() error {
9090
s.D.Set("custom_endpoint", nil)
9191
}
9292

93+
s.D.Set("data_retention_period", s.Res.DataRetentionPeriod)
94+
9395
if s.Res.DefinedTags != nil {
9496
s.D.Set("defined_tags", tfresource.DefinedTagsToMap(s.Res.DefinedTags))
9597
}

internal/service/integration/integration_integration_instance_resource.go

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,11 @@ func IntegrationIntegrationInstanceResource() *schema.Resource {
250250
Type: schema.TypeInt,
251251
Optional: true,
252252
},
253+
"extend_data_retention_trigger": {
254+
Type: schema.TypeInt,
255+
Optional: true,
256+
},
257+
253258
// Computed
254259
"attachments": {
255260
Type: schema.TypeList,
@@ -284,6 +289,10 @@ func IntegrationIntegrationInstanceResource() *schema.Resource {
284289
},
285290
},
286291
},
292+
"data_retention_period": {
293+
Type: schema.TypeString,
294+
Computed: true,
295+
},
287296
"idcs_info": {
288297
Type: schema.TypeList,
289298
Computed: true,
@@ -393,6 +402,12 @@ func createIntegrationIntegrationInstance(d *schema.ResourceData, m interface{})
393402
}
394403
}
395404

405+
if _, ok := sync.D.GetOkExists("extend_data_retention_trigger"); ok {
406+
err := sync.ExtendDataRetention()
407+
if err != nil {
408+
return err
409+
}
410+
}
396411
var powerOff = false
397412
if configState, ok := sync.D.GetOkExists("state"); ok {
398413
wantedState := oci_integration.IntegrationInstanceLifecycleStateEnum(strings.ToUpper(configState.(string)))
@@ -470,6 +485,22 @@ func updateIntegrationIntegrationInstance(d *schema.ResourceData, m interface{})
470485
}
471486
}
472487

488+
if _, ok := sync.D.GetOkExists("extend_data_retention_trigger"); ok && sync.D.HasChange("extend_data_retention_trigger") {
489+
oldRaw, newRaw := sync.D.GetChange("extend_data_retention_trigger")
490+
oldValue := oldRaw.(int)
491+
newValue := newRaw.(int)
492+
if oldValue < newValue {
493+
err := sync.ExtendDataRetention()
494+
495+
if err != nil {
496+
return err
497+
}
498+
} else {
499+
sync.D.Set("extend_data_retention_trigger", oldRaw)
500+
return fmt.Errorf("new value of trigger should be greater than the old value")
501+
}
502+
}
503+
473504
if err := tfresource.UpdateResource(d, sync); err != nil {
474505
return err
475506
}
@@ -945,6 +976,8 @@ func (s *IntegrationIntegrationInstanceResourceCrud) SetData() error {
945976
s.D.Set("custom_endpoint", nil)
946977
}
947978

979+
s.D.Set("data_retention_period", s.Res.DataRetentionPeriod)
980+
948981
if s.Res.DefinedTags != nil {
949982
s.D.Set("defined_tags", tfresource.DefinedTagsToMap(s.Res.DefinedTags))
950983
}
@@ -1049,6 +1082,33 @@ func (s *IntegrationIntegrationInstanceResourceCrud) EnableProcessAutomation() e
10491082
return nil
10501083
}
10511084

1085+
func (s *IntegrationIntegrationInstanceResourceCrud) ExtendDataRetention() error {
1086+
request := oci_integration.ExtendDataRetentionRequest{}
1087+
1088+
if dataRetentionPeriod, ok := s.D.GetOkExists("data_retention_period"); ok {
1089+
request.DataRetentionPeriod = oci_integration.ExtendDataRetentionDetailsDataRetentionPeriodEnum(dataRetentionPeriod.(string))
1090+
}
1091+
1092+
idTmp := s.D.Id()
1093+
request.IntegrationInstanceId = &idTmp
1094+
1095+
request.RequestMetadata.RetryPolicy = tfresource.GetRetryPolicy(s.DisableNotFoundRetries, "integration")
1096+
1097+
_, err := s.Client.ExtendDataRetention(context.Background(), request)
1098+
if err != nil {
1099+
return err
1100+
}
1101+
1102+
if waitErr := tfresource.WaitForUpdatedState(s.D, s); waitErr != nil {
1103+
return waitErr
1104+
}
1105+
1106+
val := s.D.Get("extend_data_retention_trigger")
1107+
s.D.Set("extend_data_retention_trigger", val)
1108+
1109+
return nil
1110+
}
1111+
10521112
func AttachmentDetailsToMap(obj oci_integration.AttachmentDetails) map[string]interface{} {
10531113
result := map[string]interface{}{}
10541114

internal/service/integration/integration_integration_instances_data_source.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,8 @@ func (s *IntegrationIntegrationInstancesDataSourceCrud) SetData() error {
124124
integrationInstance["custom_endpoint"] = nil
125125
}
126126

127+
integrationInstance["data_retention_period"] = r.DataRetentionPeriod
128+
127129
if r.DefinedTags != nil {
128130
integrationInstance["defined_tags"] = tfresource.DefinedTagsToMap(r.DefinedTags)
129131
}

website/docs/d/integration_integration_instance.html.markdown

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -32,59 +32,59 @@ The following arguments are supported:
3232

3333
The following attributes are exported:
3434

35-
* `alternate_custom_endpoints` - A list of alternate custom endpoints used for the integration instance URL.
36-
* `alias` - When creating the DNS CNAME record for the custom hostname, this value must be specified in the rdata.
37-
* `certificate_secret_id` - Optional OCID of a vault/secret containing a private SSL certificate bundle to be used for the custom hostname.
38-
* `certificate_secret_version` - The secret version used for the certificate-secret-id (if certificate-secret-id is specified).
35+
* `alternate_custom_endpoints` - A list of alternate custom endpoints used for the integration instance URL.
36+
* `alias` - When creating the DNS CNAME record for the custom hostname, this value must be specified in the rdata.
37+
* `certificate_secret_id` - Optional OCID of a vault/secret containing a private SSL certificate bundle to be used for the custom hostname.
38+
* `certificate_secret_version` - The secret version used for the certificate-secret-id (if certificate-secret-id is specified).
3939
* `hostname` - A custom hostname to be used for the integration instance URL, in FQDN format.
40-
* `attachments` - A list of associated attachments to other services
41-
* `is_implicit` -
42-
* If role == `PARENT`, the attached instance was created by this service instance
43-
* If role == `CHILD`, this instance was created from attached instance on behalf of a user
40+
* `attachments` - A list of associated attachments to other services
41+
* `is_implicit` -
42+
* If role == `PARENT`, the attached instance was created by this service instance
43+
* If role == `CHILD`, this instance was created from attached instance on behalf of a user
4444
* `target_id` - The OCID of the target instance (which could be any other Oracle Cloud Infrastructure PaaS/SaaS resource), to which this instance is attached.
4545
* `target_instance_url` - The dataplane instance URL of the attached instance
46-
* `target_role` - The role of the target attachment.
47-
* `PARENT` - The target instance is the parent of this attachment.
48-
* `CHILD` - The target instance is the child of this attachment.
46+
* `target_role` - The role of the target attachment.
47+
* `PARENT` - The target instance is the parent of this attachment.
48+
* `CHILD` - The target instance is the child of this attachment.
4949
* `target_service_type` - The type of the target instance, such as "FUSION".
5050
* `compartment_id` - Compartment Identifier.
5151
* `consumption_model` - The entitlement used for billing purposes.
5252
* `custom_endpoint` - Details for a custom endpoint for the integration instance.
53-
* `alias` - When creating the DNS CNAME record for the custom hostname, this value must be specified in the rdata.
54-
* `certificate_secret_id` - Optional OCID of a vault/secret containing a private SSL certificate bundle to be used for the custom hostname.
55-
* `certificate_secret_version` - The secret version used for the certificate-secret-id (if certificate-secret-id is specified).
53+
* `alias` - When creating the DNS CNAME record for the custom hostname, this value must be specified in the rdata.
54+
* `certificate_secret_id` - Optional OCID of a vault/secret containing a private SSL certificate bundle to be used for the custom hostname.
55+
* `certificate_secret_version` - The secret version used for the certificate-secret-id (if certificate-secret-id is specified).
5656
* `hostname` - A custom hostname to be used for the integration instance URL, in FQDN format.
57-
* `defined_tags` - Usage of predefined tag keys. These predefined keys are scoped to namespaces. Example: `{"foo-namespace.bar-key": "value"}`
57+
* `data_retention_period` - Data retention period set for given integration instance
58+
* `defined_tags` - Usage of predefined tag keys. These predefined keys are scoped to namespaces. Example: `{"foo-namespace.bar-key": "value"}`
5859
* `display_name` - Integration Instance Identifier, can be renamed.
59-
* `freeform_tags` - Simple key-value pair that is applied without any predefined name, type or scope. Exists for cross-compatibility only. Example: `{"bar-key": "value"}`
60+
* `freeform_tags` - Simple key-value pair that is applied without any predefined name, type or scope. Exists for cross-compatibility only. Example: `{"bar-key": "value"}`
6061
* `id` - Unique identifier that is immutable on creation.
6162
* `idcs_info` - Information for IDCS access
6263
* `idcs_app_display_name` - The IDCS application display name associated with the instance
6364
* `idcs_app_id` - The IDCS application ID associated with the instance
6465
* `idcs_app_location_url` - URL for the location of the IDCS Application (used by IDCS APIs)
6566
* `idcs_app_name` - The IDCS application name associated with the instance
66-
* `instance_primary_audience_url` - The URL used as the primary audience for integration flows in this instance type: string
67+
* `instance_primary_audience_url` - The URL used as the primary audience for integration flows in this instance type: string
6768
* `instance_url` - The Integration Instance URL.
68-
* `integration_instance_type` - Standard or Enterprise type, Oracle Integration Generation 2 uses ENTERPRISE and STANDARD, Oracle Integration 3 uses ENTERPRISEX and STANDARDX
69+
* `integration_instance_type` - Standard or Enterprise type, Oracle Integration Generation 2 uses ENTERPRISE and STANDARD, Oracle Integration 3 uses ENTERPRISEX and STANDARDX
6970
* `is_byol` - Bring your own license.
7071
* `is_file_server_enabled` - The file server is enabled or not.
7172
* `is_visual_builder_enabled` - Visual Builder is enabled or not.
7273
* `message_packs` - The number of configured message packs (if any)
73-
* `network_endpoint_details` - Base representation of a network endpoint.
74-
* `allowlisted_http_ips` - Source IP addresses or IP address ranges ingress rules. (ex: "168.122.59.5", "10.20.30.0/26") An invalid IP or CIDR block will result in a 400 response.
75-
* `allowlisted_http_vcns` - Virtual Cloud Networks allowed to access this network endpoint.
76-
* `allowlisted_ips` - Source IP addresses or IP address ranges ingress rules. (ex: "168.122.59.5", "10.20.30.0/26") An invalid IP or CIDR block will result in a 400 response.
77-
* `id` - The Virtual Cloud Network OCID.
74+
* `network_endpoint_details` - Base representation of a network endpoint.
75+
* `allowlisted_http_ips` - Source IP addresses or IP address ranges ingress rules. (ex: "168.122.59.5", "10.20.30.0/26") An invalid IP or CIDR block will result in a 400 response.
76+
* `allowlisted_http_vcns` - Virtual Cloud Networks allowed to access this network endpoint.
77+
* `allowlisted_ips` - Source IP addresses or IP address ranges ingress rules. (ex: "168.122.59.5", "10.20.30.0/26") An invalid IP or CIDR block will result in a 400 response.
78+
* `id` - The Virtual Cloud Network OCID.
7879
* `is_integration_vcn_allowlisted` - The Integration service's VCN is allow-listed to allow integrations to call back into other integrations
7980
* `network_endpoint_type` - The type of network endpoint.
80-
* `private_endpoint_outbound_connection` - Base representation for Outbound Connection (Reverse Connection).
81+
* `shape` - Shape
82+
* `private_endpoint_outbound_connection` - Base representation for Outbound Connection (Reverse Connection).
8183
* `nsg_ids` - One or more Network security group Ids. This is an optional argument.
82-
* `outbound_connection_type` - The type of Outbound Connection.
84+
* `outbound_connection_type` - The type of Outbound Connection.
8385
* `subnet_id` - Customer Private Network VCN Subnet OCID. This is a required argument.
84-
* `shape` - Shape
8586
* `state` - The current state of the integration instance.
8687
* `state_message` - An message describing the current state in more detail. For example, can be used to provide actionable information for a resource in Failed state.
87-
* `system_tags` - Usage of system tag keys. These predefined keys are scoped to namespaces. Example: `{"orcl-cloud.free-tier-retained": "true"}`
88+
* `system_tags` - Usage of system tag keys. These predefined keys are scoped to namespaces. Example: `{"orcl-cloud.free-tier-retained": "true"}`
8889
* `time_created` - The time the the Integration Instance was created. An RFC3339 formatted datetime string.
8990
* `time_updated` - The time the IntegrationInstance was updated. An RFC3339 formatted datetime string.
90-

0 commit comments

Comments
 (0)