Skip to content

Commit a7b38ad

Browse files
committed
Support for publisher maps for service connector
1 parent 6dd1afb commit a7b38ad

File tree

7 files changed

+33
-2
lines changed

7 files changed

+33
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
### Added
44
- Support for SMS notifications for ONS
5+
- Support for publisher maps for service connector
56

67
## 4.16.0 (March 03, 2021)
78

examples/service_connector_hub/main.tf

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ variable "compartment_ocid" {}
1313
// If using the log analytics target
1414
//variable "log_analytics_log_group_id" {}
1515

16+
// If using the notification target
17+
//variable "notification_topic_id" {}
18+
1619
provider "oci" {
1720
tenancy_ocid = var.tenancy_ocid
1821
user_ocid = var.user_ocid
@@ -147,6 +150,13 @@ resource "oci_sch_service_connector" "test_service_connector" {
147150
log_group_id = var.log_analytics_log_group_id
148151
}*/
149152

153+
// If using the notification target
154+
/*target {
155+
kind = "notifications"
156+
topic_id = var.notification_topic_id
157+
enable_formatted_messaging = "true"
158+
}*/
159+
150160
tasks {
151161
condition = "logContent='20'"
152162
kind = "logRule"

oci/sch_service_connector_resource.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,11 @@ func SchServiceConnectorResource() *schema.Resource {
135135
Optional: true,
136136
Computed: true,
137137
},
138+
"enable_formatted_messaging": {
139+
Type: schema.TypeBool,
140+
Optional: true,
141+
Computed: true,
142+
},
138143
"function_id": {
139144
Type: schema.TypeString,
140145
Optional: true,
@@ -944,6 +949,10 @@ func (s *SchServiceConnectorResourceCrud) mapToTargetDetails(fieldKeyFormat stri
944949
baseObject = details
945950
case strings.ToLower("notifications"):
946951
details := oci_sch.NotificationsTargetDetails{}
952+
if enableFormattedMessaging, ok := s.D.GetOkExists(fmt.Sprintf(fieldKeyFormat, "enable_formatted_messaging")); ok {
953+
tmp := enableFormattedMessaging.(bool)
954+
details.EnableFormattedMessaging = &tmp
955+
}
947956
if topicId, ok := s.D.GetOkExists(fmt.Sprintf(fieldKeyFormat, "topic_id")); ok {
948957
tmp := topicId.(string)
949958
details.TopicId = &tmp
@@ -1017,6 +1026,10 @@ func TargetDetailsToMap(obj *oci_sch.TargetDetails) map[string]interface{} {
10171026
case oci_sch.NotificationsTargetDetails:
10181027
result["kind"] = "notifications"
10191028

1029+
if v.EnableFormattedMessaging != nil {
1030+
result["enable_formatted_messaging"] = bool(*v.EnableFormattedMessaging)
1031+
}
1032+
10201033
if v.TopicId != nil {
10211034
result["topic_id"] = string(*v.TopicId)
10221035
}

oci/sch_service_connector_test.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,9 @@ var (
7676
}
7777

7878
onsTargetRepresentation = map[string]interface{}{
79-
"kind": Representation{repType: Required, create: `notifications`},
80-
"topic_id": Representation{repType: Required, create: `${oci_ons_notification_topic.test_notification_topic.id}`},
79+
"kind": Representation{repType: Required, create: `notifications`},
80+
"topic_id": Representation{repType: Required, create: `${oci_ons_notification_topic.test_notification_topic.id}`},
81+
"enable_formatted_messaging": Representation{repType: Optional, create: `true`},
8182
}
8283

8384
// create serviceConnector definitions
@@ -252,6 +253,7 @@ func TestSchServiceConnectorResource_basic(t *testing.T) {
252253
resource.TestCheckResourceAttr(resourceName, "target.#", "1"),
253254
resource.TestCheckResourceAttr(resourceName, "target.0.kind", "notifications"),
254255
resource.TestCheckResourceAttrSet(resourceName, "target.0.topic_id"),
256+
resource.TestCheckResourceAttr(resourceName, "target.0.enable_formatted_messaging", "true"),
255257

256258
func(s *terraform.State) (err error) {
257259
resId, err = fromInstanceState(s, resourceName, "id")

website/docs/d/sch_service_connector.html.markdown

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ The following attributes are exported:
5353
* `batch_rollover_time_in_ms` - The batch rollover time in milliseconds.
5454
* `bucket` - The name of the bucket. Avoid entering confidential information.
5555
* `compartment_id` - The [OCID](https://docs.cloud.oracle.com/iaas/Content/General/Concepts/identifiers.htm) of the compartment containing the metric.
56+
* `enable_formatted_messaging` - Whether to apply a simplified, user-friendly format to the message. Applies only when friendly formatting is supported by the service connector source and the subscription protocol. Example: `true`
5657
* `function_id` - The [OCID](https://docs.cloud.oracle.com/iaas/Content/General/Concepts/identifiers.htm) of the function.
5758
* `kind` - The type descriminator.
5859
* `log_group_id` - The [OCID](https://docs.cloud.oracle.com/iaas/Content/General/Concepts/identifiers.htm) of the Logging Analytics log group.

website/docs/d/sch_service_connectors.html.markdown

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ The following attributes are exported:
6565
* `batch_rollover_time_in_ms` - The batch rollover time in milliseconds.
6666
* `bucket` - The name of the bucket. Avoid entering confidential information.
6767
* `compartment_id` - The [OCID](https://docs.cloud.oracle.com/iaas/Content/General/Concepts/identifiers.htm) of the compartment containing the metric.
68+
* `enable_formatted_messaging` - Whether to apply a simplified, user-friendly format to the message. Applies only when friendly formatting is supported by the service connector source and the subscription protocol. Example: `true`
6869
* `function_id` - The [OCID](https://docs.cloud.oracle.com/iaas/Content/General/Concepts/identifiers.htm) of the function.
6970
* `kind` - The type descriminator.
7071
* `log_group_id` - The [OCID](https://docs.cloud.oracle.com/iaas/Content/General/Concepts/identifiers.htm) of the Logging Analytics log group.

website/docs/r/sch_service_connector.html.markdown

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ resource "oci_sch_service_connector" "test_service_connector" {
5858
batch_rollover_time_in_ms = var.service_connector_target_batch_rollover_time_in_ms
5959
bucket = var.service_connector_target_bucket
6060
compartment_id = var.compartment_id
61+
enable_formatted_messaging = var.service_connector_target_enable_formatted_messaging
6162
function_id = oci_functions_function.test_function.id
6263
log_group_id = oci_logging_log_group.test_log_group.id
6364
metric = var.service_connector_target_metric
@@ -100,6 +101,7 @@ The following arguments are supported:
100101
* `batch_rollover_time_in_ms` - (Applicable when kind=objectStorage) (Updatable) The batch rollover time in milliseconds.
101102
* `bucket` - (Required when kind=objectStorage) (Updatable) The name of the bucket. Avoid entering confidential information.
102103
* `compartment_id` - (Required when kind=monitoring) (Updatable) The [OCID](https://docs.cloud.oracle.com/iaas/Content/General/Concepts/identifiers.htm) of the compartment containing the metric.
104+
* `enable_formatted_messaging` - (Applicable when kind=notifications) (Updatable) Whether to apply a simplified, user-friendly format to the message. Applies only when friendly formatting is supported by the service connector source and the subscription protocol. Example: `true`
103105
* `function_id` - (Required when kind=functions) (Updatable) The [OCID](https://docs.cloud.oracle.com/iaas/Content/General/Concepts/identifiers.htm) of the function.
104106
* `kind` - (Required) (Updatable) The type descriminator.
105107
* `log_group_id` - (Required when kind=loggingAnalytics) (Updatable) The [OCID](https://docs.cloud.oracle.com/iaas/Content/General/Concepts/identifiers.htm) of the Logging Analytics log group.
@@ -142,6 +144,7 @@ The following attributes are exported:
142144
* `batch_rollover_time_in_ms` - The batch rollover time in milliseconds.
143145
* `bucket` - The name of the bucket. Avoid entering confidential information.
144146
* `compartment_id` - The [OCID](https://docs.cloud.oracle.com/iaas/Content/General/Concepts/identifiers.htm) of the compartment containing the metric.
147+
* `enable_formatted_messaging` - Whether to apply a simplified, user-friendly format to the message. Applies only when friendly formatting is supported by the service connector source and the subscription protocol. Example: `true`
145148
* `function_id` - The [OCID](https://docs.cloud.oracle.com/iaas/Content/General/Concepts/identifiers.htm) of the function.
146149
* `kind` - The type descriminator.
147150
* `log_group_id` - The [OCID](https://docs.cloud.oracle.com/iaas/Content/General/Concepts/identifiers.htm) of the Logging Analytics log group.

0 commit comments

Comments
 (0)