From 4712cab8b5304428c5447d83648155a61bd39598 Mon Sep 17 00:00:00 2001 From: helenxu1221 Date: Tue, 10 Sep 2024 22:41:43 -0700 Subject: [PATCH] add service_to_service_enabled field to atracker event streams endpoint (#5605) * add service_to_service_enabled field to atracker event streams endpoint * update example * update go mod --- examples/ibm-atracker/main.tf | 1 + go.mod | 2 +- go.sum | 4 ++-- .../data_source_ibm_atracker_targets.go | 12 ++++++++++-- .../data_source_ibm_atracker_targets_test.go | 1 + .../atracker/resource_ibm_atracker_target.go | 17 +++++++++++++---- metadata/provider_metadata.json | 18 +++++++++++++++--- website/docs/d/atracker_targets.html.markdown | 5 +++-- website/docs/r/atracker_target.html.markdown | 5 +++-- 9 files changed, 49 insertions(+), 16 deletions(-) diff --git a/examples/ibm-atracker/main.tf b/examples/ibm-atracker/main.tf index 24f67081bc..11d2323b72 100644 --- a/examples/ibm-atracker/main.tf +++ b/examples/ibm-atracker/main.tf @@ -33,6 +33,7 @@ resource "ibm_atracker_target" atracker_target_eventstreams_instance { brokers = [ "kafka-x:9094" ] topic = "my-topic" api_key = "xxxxxxxxxxxxxx" + service_to_service_enabled = false } region = var.atracker_target_region } diff --git a/go.mod b/go.mod index 2effbbf28c..b82d447ccc 100644 --- a/go.mod +++ b/go.mod @@ -30,7 +30,7 @@ require ( github.com/IBM/logs-router-go-sdk v1.0.3 github.com/IBM/mqcloud-go-sdk v0.1.0 github.com/IBM/networking-go-sdk v0.49.0 - github.com/IBM/platform-services-go-sdk v0.67.0 + github.com/IBM/platform-services-go-sdk v0.68.1 github.com/IBM/project-go-sdk v0.3.5 github.com/IBM/push-notifications-go-sdk v0.0.0-20210310100607-5790b96c47f5 github.com/IBM/sarama v1.41.2 diff --git a/go.sum b/go.sum index c3a7916418..1a10242539 100644 --- a/go.sum +++ b/go.sum @@ -173,8 +173,8 @@ github.com/IBM/mqcloud-go-sdk v0.1.0 h1:fWt4uisg5GbbsfNmAxx5/6c5gQIPM+VrEsTtnimE github.com/IBM/mqcloud-go-sdk v0.1.0/go.mod h1:LesMQlKHXvdks4jqQLZH7HfATY5lvTzHuwQU5+y7b2g= github.com/IBM/networking-go-sdk v0.49.0 h1:lPS34u3C0JVrbxH+Ulua76Nwl6Frv8BEfq6LRkyvOv0= github.com/IBM/networking-go-sdk v0.49.0/go.mod h1:G9CKbmPE8gSLjN+ABh4hIZ1bMx076enl5Eekvj6zQnA= -github.com/IBM/platform-services-go-sdk v0.67.0 h1:AGu3NiCUyvyFUqbgtmsFRh74kyXrmNbSu1yG/qwGLIM= -github.com/IBM/platform-services-go-sdk v0.67.0/go.mod h1:6rYd3stLSnotYmZlxclw45EJPaQuLmh5f7c+Mg7rOg4= +github.com/IBM/platform-services-go-sdk v0.68.1 h1:RXGzEmdllzSj5OzCJO7AoTeQ+cgTTNa20CrrpLQe5KQ= +github.com/IBM/platform-services-go-sdk v0.68.1/go.mod h1:6rYd3stLSnotYmZlxclw45EJPaQuLmh5f7c+Mg7rOg4= github.com/IBM/project-go-sdk v0.3.5 h1:L+YClFUa14foS0B/hOOY9n7sIdsT5/XQicnXOyJSpyM= github.com/IBM/project-go-sdk v0.3.5/go.mod h1:FOJM9ihQV3EEAY6YigcWiTNfVCThtdY8bLC/nhQHFvo= github.com/IBM/push-notifications-go-sdk v0.0.0-20210310100607-5790b96c47f5 h1:NPUhkoOCRuv3OFWt19PmwjXGGTKlvmbuPg9fUrBUNe4= diff --git a/ibm/service/atracker/data_source_ibm_atracker_targets.go b/ibm/service/atracker/data_source_ibm_atracker_targets.go index a377bd1a8e..f769be658e 100644 --- a/ibm/service/atracker/data_source_ibm_atracker_targets.go +++ b/ibm/service/atracker/data_source_ibm_atracker_targets.go @@ -98,7 +98,7 @@ func DataSourceIBMAtrackerTargets() *schema.Resource { "service_to_service_enabled": { Type: schema.TypeBool, Computed: true, - Description: "ATracker service is enabled to support service to service authentication. If service to service is enabled then set this flag is true and do not supply apikey.", + Description: "Determines if IBM Cloud Activity Tracker Event Routing has service to service authentication enabled. Set this flag to true if service to service is enabled and do not supply an apikey.", }, }, }, @@ -151,7 +151,12 @@ func DataSourceIBMAtrackerTargets() *schema.Resource { Type: schema.TypeString, Computed: true, Sensitive: true, - Description: "The user password (api key) for the message hub topic in the Event Streams instance.", + Description: "The user password (api key) for the message hub topic in the Event Streams instance. This is required if service_to_service is not enabled.", + }, + "service_to_service_enabled": &schema.Schema{ + Type: schema.TypeBool, + Computed: true, + Description: "Determines if IBM Cloud Activity Tracker Event Routing has service to service authentication enabled. Set this flag to true if service to service is enabled and do not supply an apikey.", }, }, }, @@ -421,6 +426,9 @@ func DataSourceIBMAtrackerTargetsEventstreamsEndpointToMap(model *atrackerv2.Eve if model.APIKey != nil { modelMap["api_key"] = *model.APIKey // pragma: allowlist secret } + if model.ServiceToServiceEnabled != nil { + modelMap["service_to_service_enabled"] = *model.ServiceToServiceEnabled + } return modelMap, nil } diff --git a/ibm/service/atracker/data_source_ibm_atracker_targets_test.go b/ibm/service/atracker/data_source_ibm_atracker_targets_test.go index 1e362707fe..389b3f5692 100644 --- a/ibm/service/atracker/data_source_ibm_atracker_targets_test.go +++ b/ibm/service/atracker/data_source_ibm_atracker_targets_test.go @@ -106,6 +106,7 @@ func testAccCheckIBMAtrackerTargetsDataSourceConfig(targetName string, targetTar brokers = [ "kafka-x:9094" ] topic = "my-topic" api_key = "%s" // pragma: allowlist secret + service_to_service_enabled = false } cloudlogs_endpoint { target_crn = "crn:v1:bluemix:public:logs:eu-es:a/11111111111111111111111111111111:22222222-2222-2222-2222-222222222222::" diff --git a/ibm/service/atracker/resource_ibm_atracker_target.go b/ibm/service/atracker/resource_ibm_atracker_target.go index 42b9684bfd..d104be2e35 100644 --- a/ibm/service/atracker/resource_ibm_atracker_target.go +++ b/ibm/service/atracker/resource_ibm_atracker_target.go @@ -75,7 +75,7 @@ func ResourceIBMAtrackerTarget() *schema.Resource { "service_to_service_enabled": { Type: schema.TypeBool, Optional: true, - Description: "ATracker service is enabled to support service to service authentication. If service to service is enabled then set this flag is true and do not supply apikey.", + Description: "Determines if IBM Cloud Activity Tracker Event Routing has service to service authentication enabled. Set this flag to true if service to service is enabled and do not supply an apikey.", }, }, }, @@ -127,10 +127,15 @@ func ResourceIBMAtrackerTarget() *schema.Resource { }, "api_key": &schema.Schema{ // pragma: allowlist secret Type: schema.TypeString, - Required: true, + Optional: true, Sensitive: true, DiffSuppressFunc: flex.ApplyOnce, - Description: "The user password (api key) for the message hub topic in the Event Streams instance.", + Description: "The user password (api key) for the message hub topic in the Event Streams instance. This is required if service_to_service is not enabled.", + }, + "service_to_service_enabled": &schema.Schema{ + Type: schema.TypeBool, + Optional: true, + Description: "Determines if IBM Cloud Activity Tracker Event Routing has service to service authentication enabled. Set this flag to true if service to service is enabled and do not supply an apikey.", }, }, }, @@ -575,7 +580,10 @@ func resourceIBMAtrackerTargetMapToEventstreamsEndpointPrototype(modelMap map[st brokers = append(brokers, brokersItem.(string)) } model.Brokers = brokers - model.APIKey = core.StringPtr(modelMap["api_key"].(string)) // pragma: whitelist secret + if modelMap["api_key"] != nil && modelMap["api_key"].(string) != "" { + model.APIKey = core.StringPtr(modelMap["api_key"].(string)) // pragma: whitelist secret + } + model.ServiceToServiceEnabled = core.BoolPtr(modelMap["service_to_service_enabled"].(bool)) return model, nil } @@ -611,6 +619,7 @@ func resourceIBMAtrackerTargetEventstreamsEndpointPrototypeToMap(model *atracker modelMap["topic"] = model.Topic // TODO: remove after deprecation modelMap["api_key"] = REDACTED_TEXT // pragma: whitelist secret + modelMap["service_to_service_enabled"] = model.ServiceToServiceEnabled return modelMap, nil } diff --git a/metadata/provider_metadata.json b/metadata/provider_metadata.json index a922094661..60f5eb3285 100644 --- a/metadata/provider_metadata.json +++ b/metadata/provider_metadata.json @@ -3296,7 +3296,7 @@ "service_to_service_enabled": { "name": "service_to_service_enabled", "type": "TypeBool", - "description": "ATracker service is enabled to support service to service authentication. If service to service is enabled then set this flag is true and do not supply apikey.", + "description": "Determines if IBM Cloud Activity Tracker Event Routing has service to service authentication enabled. Set this flag to true if service to service is enabled and do not supply an apikey.", "computed": true }, "target_crn": { @@ -3376,7 +3376,7 @@ "api_key": { "name": "api_key", "type": "TypeString", - "description": "The user password (api key) for the message hub topic in the Event Streams instance.", + "description": "The user password (api key) for the message hub topic in the Event Streams instance. This is required if service_to_service is not enabled.", "secure": true, "computed": true }, @@ -3400,6 +3400,12 @@ "type": "TypeString", "description": "The messsage hub topic defined in the Event Streams instance.", "computed": true + }, + "service_to_service_enabled": { + "name": "service_to_service_enabled", + "type": "TypeBool", + "description": "Determines if IBM Cloud Activity Tracker Event Routing has service to service authentication enabled. Set this flag to true if service to service is enabled and do not supply an apikey.", + "computed": true } } }, @@ -87721,6 +87727,12 @@ "type": "TypeString", "description": "The messsage hub topic defined in the Event Streams instance.", "required": true + }, + "service_to_service_enabled": { + "name": "service_to_service_enabled", + "type": "TypeBool", + "description": "Determines if IBM Cloud Activity Tracker Event Routing has service to service authentication enabled. Set this flag to true if service to service is enabled and do not supply an apikey.", + "optional": true } }, "max_items": 1 @@ -87817,7 +87829,7 @@ "service_to_service_enabled": { "name": "service_to_service_enabled", "type": "TypeBool", - "description": "ATracker service is enabled to support service to service authentication. If service to service is enabled then set this flag is true and do not supply apikey.", + "description": "Determines if IBM Cloud Activity Tracker Event Routing has service to service authentication enabled. Set this flag to true if service to service is enabled and do not supply an apikey.", "optional": true }, "target_crn": { diff --git a/website/docs/d/atracker_targets.html.markdown b/website/docs/d/atracker_targets.html.markdown index 1b99365572..34b5e6ab6a 100644 --- a/website/docs/d/atracker_targets.html.markdown +++ b/website/docs/d/atracker_targets.html.markdown @@ -46,7 +46,7 @@ Nested scheme for **targets**: * Constraints: The maximum length is `1000` characters. The minimum length is `3` characters. The value must match regular expression `/^[a-zA-Z0-9 -._:\/]+$/`. * `endpoint` - (String) The host name of the Cloud Object Storage endpoint. * Constraints: The maximum length is `1000` characters. The minimum length is `3` characters. The value must match regular expression `/^[a-zA-Z0-9 -._:]+$/`. - * `service_to_service_enabled` - (Boolean) ATracker service is enabled to support service to service authentication. If service to service is enabled then set this flag is true and do not supply apikey. + * `service_to_service_enabled` - (Boolean) Determines if IBM Cloud Activity Tracker Event Routing has service to service authentication enabled. Set this flag to true if service to service is enabled and do not supply an apikey. * `target_crn` - (String) The CRN of the Cloud Object Storage instance. * Constraints: The maximum length is `1000` characters. The minimum length is `3` characters. The value must match regular expression `/^[a-zA-Z0-9 -._:\/]+$/`. * `logdna_endpoint` - (List) Property values for a LogDNA Endpoint. @@ -57,12 +57,13 @@ Nested scheme for **targets**: * Constraints: The maximum length is `1000` characters. The minimum length is `3` characters. The value must match regular expression `/^[a-zA-Z0-9 -._:\/]+$/`. * `eventstreams_endpoint` - (List) Property values for Event streams Endpoint. Nested scheme for **eventstreams_endpoint**: - * `api_key` - (String) The IAM API key that has access to the Event streams instance. + * `api_key` - (String) The user password (api key) for the message hub topic in the Event Streams instance. This is required if service_to_service is not enabled.. * Constraints: The maximum length is `1000` characters. The minimum length is `3` characters. The value must match regular expression `/^[a-zA-Z0-9 -._:]+$/`. * `topic` - (String) The topic name defined under the Event streams instance. * Constraints: The maximum length is `1000` characters. The minimum length is `3` characters. The value must match regular expression `/^[a-zA-Z0-9 -._:\/]+$/`. * `brokers` - (List) The list of brokers defined under the Event streams instance and used in the event streams endpoint. * Constraints: The list items must match regular expression `/^[a-zA-Z0-9 -._:]+$/`. + * `service_to_service_enabled` - (Boolean) Determines if IBM Cloud Activity Tracker Event Routing has service to service authentication enabled. Set this flag to true if service to service is enabled and do not supply an apikey. * `target_crn` - (String) The CRN of the Event streams instance. * Constraints: The maximum length is `1000` characters. The minimum length is `3` characters. The value must match regular expression `/^[a-zA-Z0-9 -._:\/]+$/`. * `cloudlogs_endpoint` - (List) Property values for an IBM Cloud Logs endpoint. diff --git a/website/docs/r/atracker_target.html.markdown b/website/docs/r/atracker_target.html.markdown index 46bc5a398f..f933d72b94 100644 --- a/website/docs/r/atracker_target.html.markdown +++ b/website/docs/r/atracker_target.html.markdown @@ -70,7 +70,7 @@ Nested scheme for **cos_endpoint**: * Constraints: The maximum length is `1000` characters. The minimum length is `3` characters. The value must match regular expression `/^[a-zA-Z0-9 -._:\/]+$/`. * `endpoint` - (Required, String) The host name of the Cloud Object Storage endpoint. * Constraints: The maximum length is `1000` characters. The minimum length is `3` characters. The value must match regular expression `/^[a-zA-Z0-9 -._:]+$/`. - * `service_to_service_enabled` - (Optional, Boolean) ATracker service is enabled to support service to service authentication. If service to service is enabled then set this flag is true and do not supply apikey. + * `service_to_service_enabled` - (Optional, Boolean) Determines if IBM Cloud Activity Tracker Event Routing has service to service authentication enabled. Set this flag to true if service to service is enabled and do not supply an apikey. * `target_crn` - (Required, String) The CRN of the Cloud Object Storage instance. * Constraints: The maximum length is `1000` characters. The minimum length is `3` characters. The value must match regular expression `/^[a-zA-Z0-9 -._:\/]+$/`. * `logdna_endpoint` - (Optional, List) Property values for a LogDNA Endpoint. @@ -81,12 +81,13 @@ Nested scheme for **logdna_endpoint**: * Constraints: The maximum length is `1000` characters. The minimum length is `3` characters. The value must match regular expression `/^[a-zA-Z0-9 -._:\/]+$/`. * `eventstreams_endpoint` - (List) Property values for Event streams Endpoint. Nested scheme for **eventstreams_endpoint**: - * `api_key` - (String) The IAM API key that has access to the Event streams instance. + * `api_key` - (String) The user password (api key) for the message hub topic in the Event Streams instance. This is required if service_to_service is not enabled. . * Constraints: The maximum length is `1000` characters. The minimum length is `3` characters. The value must match regular expression `/^[a-zA-Z0-9 -._:]+$/`. * `topic` - (String) The topic name defined under the Event streams instance. * Constraints: The maximum length is `1000` characters. The minimum length is `3` characters. The value must match regular expression `/^[a-zA-Z0-9 -._:\/]+$/`. * `brokers` - (List) The list of brokers defined under the Event streams instance and used in the event streams endpoint. * Constraints: The list items must match regular expression `/^[a-zA-Z0-9 -._:]+$/`. + * `service_to_service_enabled` - (Optional, Boolean) Determines if IBM Cloud Activity Tracker Event Routing has service to service authentication enabled. Set this flag to true if service to service is enabled and do not supply an apikey. * `target_crn` - (String) The CRN of the Event streams instance. * Constraints: The maximum length is `1000` characters. The minimum length is `3` characters. The value must match regular expression `/^[a-zA-Z0-9 -._:\/]+$/`. * `cloudlogs_endpoint` - (Optional, List) Property Values for IBM Cloud Logs Endpoint.