Skip to content

Commit 9f1136b

Browse files
Terraform Team Automationrashik-bhasin
authored andcommitted
Added - Support for Localization support and Announcements Customization Localization support and Announcements Customization
1 parent aafb97b commit 9f1136b

8 files changed

+131
-42
lines changed

examples/announcements_service/main.tf

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ variable "user_ocid" {}
66
variable "fingerprint" {}
77
variable "private_key_path" {}
88
variable "region" {}
9-
variable "compartment_id" {}
9+
variable "compartment_ocid" {}
10+
variable "compartment_id_for_update" {}
1011

1112
variable "announcement_subscription_defined_tags_value" {
1213
default = "value"
@@ -21,11 +22,11 @@ variable "announcement_subscription_display_name" {
2122
}
2223

2324
variable "announcement_subscription_filter_groups_filters_type" {
24-
default = "COMPARTMENT_ID"
25+
default = "SERVICE"
2526
}
2627

2728
variable "announcement_subscription_filter_groups_filters_value" {
28-
default = "value"
29+
default = "Oracle Fusion Applications"
2930
}
3031

3132
variable "announcement_subscription_freeform_tags" {
@@ -60,15 +61,28 @@ provider "oci" {
6061
region = var.region
6162
}
6263

64+
// Topic creation
65+
resource "random_string" "topicname" {
66+
length = 10
67+
special = false
68+
}
69+
70+
resource "oci_ons_notification_topic" "test_notification_topic" {
71+
#Required
72+
compartment_id = var.compartment_ocid
73+
name = random_string.topicname.result
74+
}
75+
6376
// Announcement Subscription Resource
6477
resource "oci_announcements_service_announcement_subscription" "test_announcement_subscription" {
6578
#Required
66-
compartment_id = var.compartment_id
79+
compartment_id = var.compartment_ocid
6780
display_name = var.announcement_subscription_display_name
6881
ons_topic_id = oci_ons_notification_topic.test_notification_topic.id
6982

7083
#Optional
71-
defined_tags = map(oci_identity_tag_namespace.tag-namespace1.name.oci_identity_tag.tag1.name, var.announcement_subscription_defined_tags_value)
84+
#defined_tags = map(oci_identity_tag_namespace.tag-namespace1.name.oci_identity_tag.tag1.name, var.announcement_subscription_defined_tags_value)
85+
defined_tags = {"${oci_identity_tag_namespace.tag-namespace1.name}.${oci_identity_tag.tag1.name}" = "${var.announcement_subscription_defined_tags_value}"}
7286
description = var.announcement_subscription_description
7387
filter_groups {
7488
#Required
@@ -79,30 +93,15 @@ resource "oci_announcements_service_announcement_subscription" "test_announcemen
7993
}
8094
}
8195
freeform_tags = var.announcement_subscription_freeform_tags
82-
}
83-
84-
// Announcement Subscription Change Compartment Resource
85-
resource "oci_announcements_service_announcement_subscriptions_actions_change_compartment" "test_announcement_subscriptions_actions_change_compartment" {
86-
#Required
87-
announcement_subscription_id = oci_announcements_service_announcement_subscription.test_announcement_subscription.id
88-
compartment_id = var.compartment_id
89-
}
90-
91-
// Announcement Subscription Filter Group Resource
92-
resource "oci_announcements_service_announcement_subscriptions_filter_group" "test_announcement_subscriptions_filter_group" {
93-
#Required
94-
announcement_subscription_id = oci_announcements_service_announcement_subscription.test_announcement_subscription.id
95-
filters {
96-
#Required
97-
type = var.announcement_subscriptions_filter_group_filters_type
98-
value = var.announcement_subscriptions_filter_group_filters_value
96+
lifecycle {
97+
ignore_changes = [
98+
defined_tags]
9999
}
100-
name = var.announcement_subscriptions_filter_group_name
101100
}
102101

103102
data "oci_announcements_service_announcement_subscriptions" "test_announcement_subscriptions" {
104103
#Required
105-
compartment_id = var.compartment_id
104+
compartment_id = var.compartment_ocid
106105

107106
#Optional
108107
display_name = var.announcement_subscription_display_name
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved.
2+
// Licensed under the Mozilla Public License v2.0
3+
4+
variable "tag_namespace_description" {
5+
default = "This namespace contains tags that will be used for terraform testing"
6+
}
7+
8+
variable "tag_namespace_name" {
9+
default = "TerraformTestingTags"
10+
}
11+
12+
resource "oci_identity_tag_namespace" "tag-namespace1" {
13+
#Required
14+
compartment_id = var.tenancy_ocid
15+
description = var.tag_namespace_description
16+
name = var.tag_namespace_name
17+
}
18+
19+
resource "oci_identity_tag" "tag1" {
20+
#Required
21+
description = "tf example tag"
22+
name = "tf-example-tag"
23+
tag_namespace_id = oci_identity_tag_namespace.tag-namespace1.id
24+
}

internal/integrationtest/announcements_service_announcement_subscription_test.go

Lines changed: 28 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -47,21 +47,23 @@ var (
4747
}
4848

4949
AnnouncementsServiceAnnouncementSubscriptionRepresentation = map[string]interface{}{
50-
"compartment_id": acctest.Representation{RepType: acctest.Required, Create: `${var.compartment_id}`},
51-
"display_name": acctest.Representation{RepType: acctest.Required, Create: `displayName`, Update: `displayName2`},
52-
"ons_topic_id": acctest.Representation{RepType: acctest.Required, Create: `${oci_ons_notification_topic.test_notification_topic.id}`},
53-
"defined_tags": acctest.Representation{RepType: acctest.Optional, Create: `${map("${oci_identity_tag_namespace.tag-namespace1.name}.${oci_identity_tag.tag1.name}", "value")}`, Update: `${map("${oci_identity_tag_namespace.tag-namespace1.name}.${oci_identity_tag.tag1.name}", "updatedValue")}`},
54-
"description": acctest.Representation{RepType: acctest.Optional, Create: `description`, Update: `description2`},
55-
"filter_groups": acctest.RepresentationGroup{RepType: acctest.Optional, Group: AnnouncementsServiceAnnouncementSubscriptionFilterGroupsRepresentation},
56-
"freeform_tags": acctest.Representation{RepType: acctest.Optional, Create: map[string]string{"bar-key": "value"}, Update: map[string]string{"Department": "Accounting"}},
57-
"lifecycle": acctest.RepresentationGroup{RepType: acctest.Required, Group: ignoreDefinedTagsPlanChangesRepresentation},
50+
"compartment_id": acctest.Representation{RepType: acctest.Required, Create: `${var.compartment_id}`},
51+
"display_name": acctest.Representation{RepType: acctest.Required, Create: `displayName`, Update: `displayName2`},
52+
"ons_topic_id": acctest.Representation{RepType: acctest.Required, Create: `${oci_ons_notification_topic.test_notification_topic.id}`},
53+
"defined_tags": acctest.Representation{RepType: acctest.Optional, Create: `${map("${oci_identity_tag_namespace.tag-namespace1.name}.${oci_identity_tag.tag1.name}", "value")}`, Update: `${map("${oci_identity_tag_namespace.tag-namespace1.name}.${oci_identity_tag.tag1.name}", "updatedValue")}`},
54+
"description": acctest.Representation{RepType: acctest.Optional, Create: `description`, Update: `description2`},
55+
"filter_groups": acctest.RepresentationGroup{RepType: acctest.Optional, Group: AnnouncementsServiceAnnouncementSubscriptionFilterGroupsRepresentation},
56+
"freeform_tags": acctest.Representation{RepType: acctest.Optional, Create: map[string]string{"bar-key": "value"}, Update: map[string]string{"Department": "Accounting"}},
57+
"lifecycle": acctest.RepresentationGroup{RepType: acctest.Required, Group: ignoreDefinedTagsPlanChangesRepresentation},
58+
"preferred_language": acctest.Representation{RepType: acctest.Optional, Create: `en-US`, Update: `sh-RS`},
59+
"preferred_time_zone": acctest.Representation{RepType: acctest.Optional, Create: `America/Mexico_City`, Update: `America/Los_Angeles`},
5860
}
5961
AnnouncementsServiceAnnouncementSubscriptionFilterGroupsRepresentation = map[string]interface{}{
6062
"filters": acctest.RepresentationGroup{RepType: acctest.Required, Group: AnnouncementsServiceAnnouncementSubscriptionFilterGroupsFiltersRepresentation},
6163
}
6264
AnnouncementsServiceAnnouncementSubscriptionFilterGroupsFiltersRepresentation = map[string]interface{}{
63-
"type": acctest.Representation{RepType: acctest.Required, Create: `COMPARTMENT_ID`},
64-
"value": acctest.Representation{RepType: acctest.Required, Create: `${var.compartment_id}`},
65+
"type": acctest.Representation{RepType: acctest.Required, Create: `SERVICE`},
66+
"value": acctest.Representation{RepType: acctest.Required, Create: `Oracle Fusion Applications`},
6567
}
6668

6769
ignoreDefinedTagsPlanChangesRepresentation = map[string]interface{}{
@@ -124,12 +126,14 @@ func TestAnnouncementsServiceAnnouncementSubscriptionResource_basic(t *testing.T
124126
resource.TestCheckResourceAttr(resourceName, "display_name", "displayName"),
125127
resource.TestCheckResourceAttr(resourceName, "filter_groups.#", "1"),
126128
resource.TestCheckResourceAttr(resourceName, "filter_groups.0.filters.#", "1"),
127-
resource.TestCheckResourceAttr(resourceName, "filter_groups.0.filters.0.type", "COMPARTMENT_ID"),
128-
resource.TestCheckResourceAttr(resourceName, "filter_groups.0.filters.0.value", compartmentId),
129+
resource.TestCheckResourceAttr(resourceName, "filter_groups.0.filters.0.type", "SERVICE"),
130+
resource.TestCheckResourceAttr(resourceName, "filter_groups.0.filters.0.value", "Oracle Fusion Applications"),
129131
resource.TestCheckResourceAttrSet(resourceName, "filter_groups.0.name"),
130132
resource.TestCheckResourceAttr(resourceName, "freeform_tags.%", "1"),
131133
resource.TestCheckResourceAttrSet(resourceName, "id"),
132134
resource.TestCheckResourceAttrSet(resourceName, "ons_topic_id"),
135+
resource.TestCheckResourceAttr(resourceName, "preferred_language", "en-US"),
136+
resource.TestCheckResourceAttr(resourceName, "preferred_time_zone", "America/Mexico_City"),
133137
resource.TestCheckResourceAttrSet(resourceName, "state"),
134138
resource.TestCheckResourceAttrSet(resourceName, "time_created"),
135139

@@ -158,12 +162,14 @@ func TestAnnouncementsServiceAnnouncementSubscriptionResource_basic(t *testing.T
158162
resource.TestCheckResourceAttr(resourceName, "display_name", "displayName"),
159163
resource.TestCheckResourceAttr(resourceName, "filter_groups.#", "1"),
160164
resource.TestCheckResourceAttr(resourceName, "filter_groups.0.filters.#", "1"),
161-
resource.TestCheckResourceAttr(resourceName, "filter_groups.0.filters.0.type", "COMPARTMENT_ID"),
162-
resource.TestCheckResourceAttr(resourceName, "filter_groups.0.filters.0.value", compartmentId),
165+
resource.TestCheckResourceAttr(resourceName, "filter_groups.0.filters.0.type", "SERVICE"),
166+
resource.TestCheckResourceAttr(resourceName, "filter_groups.0.filters.0.value", "Oracle Fusion Applications"),
163167
resource.TestCheckResourceAttrSet(resourceName, "filter_groups.0.name"),
164168
resource.TestCheckResourceAttr(resourceName, "freeform_tags.%", "1"),
165169
resource.TestCheckResourceAttrSet(resourceName, "id"),
166170
resource.TestCheckResourceAttrSet(resourceName, "ons_topic_id"),
171+
resource.TestCheckResourceAttr(resourceName, "preferred_language", "en-US"),
172+
resource.TestCheckResourceAttr(resourceName, "preferred_time_zone", "America/Mexico_City"),
167173
resource.TestCheckResourceAttrSet(resourceName, "state"),
168174
resource.TestCheckResourceAttrSet(resourceName, "time_created"),
169175

@@ -187,12 +193,14 @@ func TestAnnouncementsServiceAnnouncementSubscriptionResource_basic(t *testing.T
187193
resource.TestCheckResourceAttr(resourceName, "display_name", "displayName2"),
188194
resource.TestCheckResourceAttr(resourceName, "filter_groups.#", "1"),
189195
resource.TestCheckResourceAttr(resourceName, "filter_groups.0.filters.#", "1"),
190-
resource.TestCheckResourceAttr(resourceName, "filter_groups.0.filters.0.type", "COMPARTMENT_ID"),
191-
resource.TestCheckResourceAttr(resourceName, "filter_groups.0.filters.0.value", compartmentId),
196+
resource.TestCheckResourceAttr(resourceName, "filter_groups.0.filters.0.type", "SERVICE"),
197+
resource.TestCheckResourceAttr(resourceName, "filter_groups.0.filters.0.value", "Oracle Fusion Applications"),
192198
resource.TestCheckResourceAttrSet(resourceName, "filter_groups.0.name"),
193199
resource.TestCheckResourceAttr(resourceName, "freeform_tags.%", "1"),
194200
resource.TestCheckResourceAttrSet(resourceName, "id"),
195201
resource.TestCheckResourceAttrSet(resourceName, "ons_topic_id"),
202+
resource.TestCheckResourceAttr(resourceName, "preferred_language", "sh-RS"),
203+
resource.TestCheckResourceAttr(resourceName, "preferred_time_zone", "America/Los_Angeles"),
196204
resource.TestCheckResourceAttrSet(resourceName, "state"),
197205
resource.TestCheckResourceAttrSet(resourceName, "time_created"),
198206

@@ -234,11 +242,13 @@ func TestAnnouncementsServiceAnnouncementSubscriptionResource_basic(t *testing.T
234242
resource.TestCheckResourceAttr(singularDatasourceName, "display_name", "displayName2"),
235243
resource.TestCheckResourceAttr(singularDatasourceName, "filter_groups.#", "1"),
236244
resource.TestCheckResourceAttr(singularDatasourceName, "filter_groups.0.filters.#", "1"),
237-
resource.TestCheckResourceAttr(singularDatasourceName, "filter_groups.0.filters.0.type", "COMPARTMENT_ID"),
238-
resource.TestCheckResourceAttr(singularDatasourceName, "filter_groups.0.filters.0.value", compartmentId),
245+
resource.TestCheckResourceAttr(singularDatasourceName, "filter_groups.0.filters.0.type", "SERVICE"),
246+
resource.TestCheckResourceAttr(singularDatasourceName, "filter_groups.0.filters.0.value", "Oracle Fusion Applications"),
239247
resource.TestCheckResourceAttrSet(singularDatasourceName, "filter_groups.0.name"),
240248
resource.TestCheckResourceAttr(singularDatasourceName, "freeform_tags.%", "1"),
241249
resource.TestCheckResourceAttrSet(singularDatasourceName, "id"),
250+
resource.TestCheckResourceAttr(singularDatasourceName, "preferred_language", "sh-RS"),
251+
resource.TestCheckResourceAttr(singularDatasourceName, "preferred_time_zone", "America/Los_Angeles"),
242252
resource.TestCheckResourceAttrSet(singularDatasourceName, "state"),
243253
resource.TestCheckResourceAttrSet(singularDatasourceName, "time_created"),
244254
resource.TestCheckResourceAttrSet(singularDatasourceName, "time_updated"),

internal/service/announcements_service/announcements_service_announcement_subscription_data_source.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,14 @@ func (s *AnnouncementsServiceAnnouncementSubscriptionDataSourceCrud) SetData() e
9898
s.D.Set("ons_topic_id", *s.Res.OnsTopicId)
9999
}
100100

101+
if s.Res.PreferredLanguage != nil {
102+
s.D.Set("preferred_language", *s.Res.PreferredLanguage)
103+
}
104+
105+
if s.Res.PreferredTimeZone != nil {
106+
s.D.Set("preferred_time_zone", *s.Res.PreferredTimeZone)
107+
}
108+
101109
s.D.Set("state", s.Res.LifecycleState)
102110

103111
if s.Res.SystemTags != nil {

internal/service/announcements_service/announcements_service_announcement_subscription_resource.go

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,16 @@ func AnnouncementsServiceAnnouncementSubscriptionResource() *schema.Resource {
104104
Computed: true,
105105
Elem: schema.TypeString,
106106
},
107+
"preferred_language": {
108+
Type: schema.TypeString,
109+
Optional: true,
110+
Computed: true,
111+
},
112+
"preferred_time_zone": {
113+
Type: schema.TypeString,
114+
Optional: true,
115+
Computed: true,
116+
},
107117

108118
// Computed
109119
"lifecycle_details": {
@@ -241,6 +251,16 @@ func (s *AnnouncementsServiceAnnouncementSubscriptionResourceCrud) Create() erro
241251
request.OnsTopicId = &tmp
242252
}
243253

254+
if preferredLanguage, ok := s.D.GetOkExists("preferred_language"); ok {
255+
tmp := preferredLanguage.(string)
256+
request.PreferredLanguage = &tmp
257+
}
258+
259+
if preferredTimeZone, ok := s.D.GetOkExists("preferred_time_zone"); ok {
260+
tmp := preferredTimeZone.(string)
261+
request.PreferredTimeZone = &tmp
262+
}
263+
244264
request.RequestMetadata.RetryPolicy = tfresource.GetRetryPolicy(s.DisableNotFoundRetries, "announcements_service")
245265

246266
response, err := s.Client.CreateAnnouncementSubscription(context.Background(), request)
@@ -311,6 +331,16 @@ func (s *AnnouncementsServiceAnnouncementSubscriptionResourceCrud) Update() erro
311331
request.OnsTopicId = &tmp
312332
}
313333

334+
if preferredLanguage, ok := s.D.GetOkExists("preferred_language"); ok {
335+
tmp := preferredLanguage.(string)
336+
request.PreferredLanguage = &tmp
337+
}
338+
339+
if preferredTimeZone, ok := s.D.GetOkExists("preferred_time_zone"); ok {
340+
tmp := preferredTimeZone.(string)
341+
request.PreferredTimeZone = &tmp
342+
}
343+
314344
request.RequestMetadata.RetryPolicy = tfresource.GetRetryPolicy(s.DisableNotFoundRetries, "announcements_service")
315345

316346
response, err := s.Client.UpdateAnnouncementSubscription(context.Background(), request)
@@ -367,6 +397,14 @@ func (s *AnnouncementsServiceAnnouncementSubscriptionResourceCrud) SetData() err
367397
s.D.Set("ons_topic_id", *s.Res.OnsTopicId)
368398
}
369399

400+
if s.Res.PreferredLanguage != nil {
401+
s.D.Set("preferred_language", *s.Res.PreferredLanguage)
402+
}
403+
404+
if s.Res.PreferredTimeZone != nil {
405+
s.D.Set("preferred_time_zone", *s.Res.PreferredTimeZone)
406+
}
407+
370408
s.D.Set("state", s.Res.LifecycleState)
371409

372410
if s.Res.SystemTags != nil {

website/docs/d/announcements_service_announcement_subscription.html.markdown

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ The following attributes are exported:
4848
* `id` - The [OCID](https://docs.cloud.oracle.com/iaas/Content/General/Concepts/identifiers.htm) of the announcement subscription.
4949
* `lifecycle_details` - A message describing the current lifecycle state in more detail. For example, details might provide required or recommended actions for a resource in a Failed state.
5050
* `ons_topic_id` - The OCID of the Notifications service topic that is the target for publishing announcements that match the configured announcement subscription.
51+
* `preferred_language` - (For announcement subscriptions with Oracle Fusion Applications configured as the service only) The language in which the user prefers to receive emailed announcements. Specify the preference with a value that uses the language tag format (x-obmcs-human-language). For example fr-FR.
52+
* `preferred_time_zone` - The time zone that the user prefers for announcement time stamps. Specify the preference with a value that uses the IANA Time Zone Database format (x-obmcs-time-zone). For example America/Los_Angeles.
5153
* `state` - The current lifecycle state of the announcement subscription.
5254
* `system_tags` - Usage of system tag keys. These predefined keys are scoped to namespaces. Example: `{"orcl-cloud.free-tier-retained": "true"}`
5355
* `time_created` - The date and time that the announcement subscription was created, expressed in [RFC 3339](https://tools.ietf.org/html/rfc3339) timestamp format.

website/docs/d/announcements_service_announcement_subscriptions.html.markdown

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ The following attributes are exported:
6262
* `id` - The [OCID](https://docs.cloud.oracle.com/iaas/Content/General/Concepts/identifiers.htm) of the announcement subscription.
6363
* `lifecycle_details` - A message describing the current lifecycle state in more detail. For example, details might provide required or recommended actions for a resource in a Failed state.
6464
* `ons_topic_id` - The OCID of the Notifications service topic that is the target for publishing announcements that match the configured announcement subscription.
65+
* `preferred_language` - (For announcement subscriptions with Oracle Fusion Applications configured as the service only) The language in which the user prefers to receive emailed announcements. Specify the preference with a value that uses the language tag format (x-obmcs-human-language). For example fr-FR.
66+
* `preferred_time_zone` - The time zone that the user prefers for announcement time stamps. Specify the preference with a value that uses the IANA Time Zone Database format (x-obmcs-time-zone). For example America/Los_Angeles.
6567
* `state` - The current lifecycle state of the announcement subscription.
6668
* `system_tags` - Usage of system tag keys. These predefined keys are scoped to namespaces. Example: `{"orcl-cloud.free-tier-retained": "true"}`
6769
* `time_created` - The date and time that the announcement subscription was created, expressed in [RFC 3339](https://tools.ietf.org/html/rfc3339) timestamp format.

0 commit comments

Comments
 (0)