diff --git a/examples/ibm-catalog-management/README.md b/examples/ibm-catalog-management/README.md index 3de6ee97e3..ca3ed6d95e 100644 --- a/examples/ibm-catalog-management/README.md +++ b/examples/ibm-catalog-management/README.md @@ -39,7 +39,6 @@ resource "ibm_cm_catalog" "cm_catalog_instance" { resource_group_id = var.cm_catalog_resource_group_id owning_account = var.cm_catalog_owning_account catalog_filters = var.cm_catalog_catalog_filters - syndication_settings = var.cm_catalog_syndication_settings kind = var.cm_catalog_kind metadata = var.cm_catalog_metadata } @@ -225,7 +224,6 @@ data "cm_offering_instance" "cm_offering_instance_instance" { | resource_group_id | Resource group id the catalog is owned by. | `string` | false | | owning_account | Account that owns catalog. | `string` | false | | catalog_filters | Filters for account and catalog filters. | `` | false | -| syndication_settings | Feature information. | `` | false | | kind | Kind of catalog. Supported kinds are offering and vpe. | `string` | false | | metadata | Catalog specific metadata. | `map()` | false | | catalog_id | Catalog identifier. | `string` | true | diff --git a/go.mod b/go.mod index 291d5b0e1d..2677c456b1 100644 --- a/go.mod +++ b/go.mod @@ -18,13 +18,13 @@ require ( github.com/IBM/eventstreams-go-sdk v1.4.0 github.com/IBM/go-sdk-core/v3 v3.2.4 github.com/IBM/go-sdk-core/v5 v5.16.1 - github.com/IBM/ibm-cos-sdk-go v1.10.0 - github.com/IBM/ibm-cos-sdk-go-config v1.2.0 + github.com/IBM/ibm-cos-sdk-go v1.10.1 + github.com/IBM/ibm-cos-sdk-go-config/v2 v2.0.4 github.com/IBM/ibm-hpcs-tke-sdk v0.0.0-20211109141421-a4b61b05f7d1 github.com/IBM/ibm-hpcs-uko-sdk v0.0.20-beta github.com/IBM/keyprotect-go-client v0.12.2 github.com/IBM/networking-go-sdk v0.45.0 - github.com/IBM/platform-services-go-sdk v0.60.0 + github.com/IBM/platform-services-go-sdk v0.61.2 github.com/IBM/project-go-sdk v0.2.1 github.com/IBM/push-notifications-go-sdk v0.0.0-20210310100607-5790b96c47f5 github.com/IBM/scc-go-sdk/v5 v5.1.5 @@ -62,6 +62,7 @@ require ( ) require ( + github.com/IBM/go-sdk-core v1.1.0 github.com/IBM/mqcloud-go-sdk v0.0.4 github.com/IBM/sarama v1.41.2 k8s.io/utils v0.0.0-20230313181309-38a27ef9d749 diff --git a/go.sum b/go.sum index 41c0e85994..8e7ac86412 100644 --- a/go.sum +++ b/go.sum @@ -130,7 +130,8 @@ github.com/IBM/event-notifications-go-admin-sdk v0.4.0 h1:7nqtybv8GNVjuB5QBfx/ke github.com/IBM/event-notifications-go-admin-sdk v0.4.0/go.mod h1:m6WD+q9AHJhybK929vOK8Kfx4BsKO7AmROKRpR2uQP8= github.com/IBM/eventstreams-go-sdk v1.4.0 h1:yS/Ns29sBOe8W2tynQmz9HTKqQZ0ckse4Py5Oy/F2rM= github.com/IBM/eventstreams-go-sdk v1.4.0/go.mod h1:2tuAxaYLctfqfr5jvyqSrxxEQGMwYPm3yJGWSj85YVQ= -github.com/IBM/go-sdk-core/v3 v3.0.0/go.mod h1:JI5NS2+iCoY/D8Oq3JNEZNA7qO42agu6fnaUmDsRcJA= +github.com/IBM/go-sdk-core v1.1.0 h1:pV73lZqr9r1xKb3h08c1uNG3AphwoV5KzUzhS+pfEqY= +github.com/IBM/go-sdk-core v1.1.0/go.mod h1:2pcx9YWsIsZ3I7kH+1amiAkXvLTZtAq9kbxsfXilSoY= github.com/IBM/go-sdk-core/v3 v3.2.4 h1:WKYJYYKlZnw1y/gM+Qbf5EQVAL9xaoD54+ooJZz/iBQ= github.com/IBM/go-sdk-core/v3 v3.2.4/go.mod h1:lk9eOzNbNltPf3CBpcg1Ewkhw4qC3u2QCCKDRsUA2M0= github.com/IBM/go-sdk-core/v5 v5.0.0/go.mod h1:vyNdbFujJtdTj9HbihtvKwwS3k/GKSKpOx9ZIQ6MWDY= @@ -142,11 +143,10 @@ github.com/IBM/go-sdk-core/v5 v5.9.5/go.mod h1:YlOwV9LeuclmT/qi/LAK2AsobbAP42veV github.com/IBM/go-sdk-core/v5 v5.10.2/go.mod h1:WZPFasUzsKab/2mzt29xPcfruSk5js2ywAPwW4VJjdI= github.com/IBM/go-sdk-core/v5 v5.16.1 h1:vAgOxRvaXD5AmgwR7dlstjT1JFE4BA4lPcGsEFZOKGs= github.com/IBM/go-sdk-core/v5 v5.16.1/go.mod h1:aojBkkq4HXkOYdn7YZ6ve8cjPWHdcB3tt8v0b9Cbac8= -github.com/IBM/ibm-cos-sdk-go v1.3.1/go.mod h1:YLBAYobEA8bD27P7xpMwSQeNQu6W3DNBtBComXrRzRY= -github.com/IBM/ibm-cos-sdk-go v1.10.0 h1:/2VIev2/jBei39OqU2+nSZQnoWJ+KtkiSAIDkqsd7uU= -github.com/IBM/ibm-cos-sdk-go v1.10.0/go.mod h1:C8KRTRaoD3CWPPBOa6FCOpdh0ZMlUjKAAA4i3F+Q/sc= -github.com/IBM/ibm-cos-sdk-go-config v1.2.0 h1:1E93234yZgVS0ntm7eUwVb3h0AAayPGcxEhhizEN1LE= -github.com/IBM/ibm-cos-sdk-go-config v1.2.0/go.mod h1:Wetfgv6m1xyuzpZLQTTLIBsWstxjYa15h+Utj7x53Dk= +github.com/IBM/ibm-cos-sdk-go v1.10.1 h1:vQCsu61OHRVF2lL6ah+m3AmUlhnYGkI1qogukCEFULs= +github.com/IBM/ibm-cos-sdk-go v1.10.1/go.mod h1:zhcgfL2YG5DVaI5R2F6oYO2DYnvwW14vpcpFq+ybhXU= +github.com/IBM/ibm-cos-sdk-go-config/v2 v2.0.4 h1:fvy/cMKn/3BngdxaL5dXaSlUuzTANY42VuVQuW0NEYE= +github.com/IBM/ibm-cos-sdk-go-config/v2 v2.0.4/go.mod h1:Pam4aWm9Ve/pqAVrPW8nm2yCXq0h9LDeQ1Iacx5g9rU= github.com/IBM/ibm-hpcs-tke-sdk v0.0.0-20211109141421-a4b61b05f7d1 h1:T5UwRKKd+BoaPZ7UIlpJrzXzVTUEs8HcxwQ3pCIbORs= github.com/IBM/ibm-hpcs-tke-sdk v0.0.0-20211109141421-a4b61b05f7d1/go.mod h1:M2JyuyeWHPtgGNeezr6YqVRuaav2MpY8Ha4QrEYvMoI= github.com/IBM/ibm-hpcs-uko-sdk v0.0.20-beta h1:P1fdIfKsD9xvJQ5MHIEztPS9yfNf9x+VDTamaYcmqcs= @@ -158,8 +158,8 @@ github.com/IBM/mqcloud-go-sdk v0.0.4 h1:gqMpoU5a0qJ0GETG4PQrkgeEEoaQLvbxRJnEe6yt github.com/IBM/mqcloud-go-sdk v0.0.4/go.mod h1:gQptHC6D+rxfg0muRFFGvTDmvl4YfiDE0uXkaRRewRk= github.com/IBM/networking-go-sdk v0.45.0 h1:tYgDhVDpgKvELNY7tcodbZ4ny9fatpEWM6PwtQcDe20= github.com/IBM/networking-go-sdk v0.45.0/go.mod h1:NnJPA1e5GWr5opJe+5Hs6e1G6RcBIFz64TrkZsdnSp8= -github.com/IBM/platform-services-go-sdk v0.60.0 h1:DXCp5hAtFO6quUmb5qKeosQw0ln/fYE5nrKjgXbiSBU= -github.com/IBM/platform-services-go-sdk v0.60.0/go.mod h1:fcmUb29QKLjMM0UWrR5bAidC7qfKWrf96H0xxmGJHdE= +github.com/IBM/platform-services-go-sdk v0.61.2 h1:yQ7sBmowpxlyKPRZChFBqlGn1nZO7ScPc6QqjUDdbYA= +github.com/IBM/platform-services-go-sdk v0.61.2/go.mod h1:fcmUb29QKLjMM0UWrR5bAidC7qfKWrf96H0xxmGJHdE= github.com/IBM/project-go-sdk v0.2.1 h1:Xo7ITrfyfVm0eCsaC2SADlhcEjqjx9rtU37fwnzGMCI= github.com/IBM/project-go-sdk v0.2.1/go.mod h1:lqe0M4cKvABI1iHR1b+KfasVcxQL6nl2VJ8eOyQs8Ig= github.com/IBM/push-notifications-go-sdk v0.0.0-20210310100607-5790b96c47f5 h1:NPUhkoOCRuv3OFWt19PmwjXGGTKlvmbuPg9fUrBUNe4= @@ -1222,7 +1222,6 @@ github.com/onsi/ginkgo v0.0.0-20170829012221-11459a886d9c/go.mod h1:lLunBs/Ym6LB github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.8.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= -github.com/onsi/ginkgo v1.10.3/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.11.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.12.0/go.mod h1:oUhWkIvk5aDxtKvDDuw8gItl8pKl42LzjC9KZE0HfGg= github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk= diff --git a/ibm/conns/config.go b/ibm/conns/config.go index 38d3afc484..77e20c0615 100644 --- a/ibm/conns/config.go +++ b/ibm/conns/config.go @@ -27,7 +27,7 @@ import ( "github.com/IBM/cloud-databases-go-sdk/clouddatabasesv5" "github.com/IBM/container-registry-go-sdk/containerregistryv1" "github.com/IBM/go-sdk-core/v5/core" - cosconfig "github.com/IBM/ibm-cos-sdk-go-config/resourceconfigurationv1" + cosconfig "github.com/IBM/ibm-cos-sdk-go-config/v2/resourceconfigurationv1" kp "github.com/IBM/keyprotect-go-client" "github.com/IBM/mqcloud-go-sdk/mqcloudv1" cisalertsv1 "github.com/IBM/networking-go-sdk/alertsv1" diff --git a/ibm/flex/structures.go b/ibm/flex/structures.go index 629b053f45..704e310dc0 100644 --- a/ibm/flex/structures.go +++ b/ibm/flex/structures.go @@ -25,7 +25,7 @@ import ( "github.com/IBM-Cloud/terraform-provider-ibm/ibm/conns" "github.com/IBM/cloud-databases-go-sdk/clouddatabasesv5" "github.com/IBM/go-sdk-core/v5/core" - "github.com/IBM/ibm-cos-sdk-go-config/resourceconfigurationv1" + "github.com/IBM/ibm-cos-sdk-go-config/v2/resourceconfigurationv1" "github.com/IBM/ibm-cos-sdk-go/aws" "github.com/IBM/ibm-cos-sdk-go/service/s3" kp "github.com/IBM/keyprotect-go-client" diff --git a/ibm/provider/provider.go b/ibm/provider/provider.go index 2c233f46f5..ff729a9186 100644 --- a/ibm/provider/provider.go +++ b/ibm/provider/provider.go @@ -1306,7 +1306,8 @@ func Provider() *schema.Provider { "ibm_satellite_cluster_worker_pool_zone_attachment": satellite.ResourceIbmSatelliteClusterWorkerPoolZoneAttachment(), // Added for Resource Tag - "ibm_resource_tag": globaltagging.ResourceIBMResourceTag(), + "ibm_resource_tag": globaltagging.ResourceIBMResourceTag(), + "ibm_resource_access_tag": globaltagging.ResourceIBMResourceAccessTag(), // Atracker "ibm_atracker_target": atracker.ResourceIBMAtrackerTarget(), @@ -1600,6 +1601,7 @@ func Validator() validate.ValidatorDict { "ibm_resource_key": resourcecontroller.ResourceIBMResourceKeyValidator(), "ibm_is_virtual_endpoint_gateway": vpc.ResourceIBMISEndpointGatewayValidator(), "ibm_resource_tag": globaltagging.ResourceIBMResourceTagValidator(), + "ibm_resource_access_tag": globaltagging.ResourceIBMResourceAccessTagValidator(), "ibm_satellite_location": satellite.ResourceIBMSatelliteLocationValidator(), "ibm_satellite_cluster": satellite.ResourceIBMSatelliteClusterValidator(), "ibm_pi_volume": power.ResourceIBMPIVolumeValidator(), diff --git a/ibm/service/catalogmanagement/data_source_ibm_cm_catalog.go b/ibm/service/catalogmanagement/data_source_ibm_cm_catalog.go index 066bbcab4d..c534c98770 100644 --- a/ibm/service/catalogmanagement/data_source_ibm_cm_catalog.go +++ b/ibm/service/catalogmanagement/data_source_ibm_cm_catalog.go @@ -220,155 +220,6 @@ func DataSourceIBMCmCatalog() *schema.Resource { }, }, }, - "syndication_settings": &schema.Schema{ - Type: schema.TypeList, - Computed: true, - Description: "Feature information.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "remove_related_components": &schema.Schema{ - Type: schema.TypeBool, - Computed: true, - Description: "Remove related components.", - }, - "clusters": &schema.Schema{ - Type: schema.TypeList, - Computed: true, - Description: "Syndication clusters.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "region": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "Cluster region.", - }, - "id": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "Cluster ID.", - }, - "name": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "Cluster name.", - }, - "resource_group_name": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "Resource group ID.", - }, - "type": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "Syndication type.", - }, - "namespaces": &schema.Schema{ - Type: schema.TypeList, - Computed: true, - Description: "Syndicated namespaces.", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - "all_namespaces": &schema.Schema{ - Type: schema.TypeBool, - Computed: true, - Description: "Syndicated to all namespaces on cluster.", - }, - }, - }, - }, - "history": &schema.Schema{ - Type: schema.TypeList, - Computed: true, - Description: "Feature information.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "namespaces": &schema.Schema{ - Type: schema.TypeList, - Computed: true, - Description: "Array of syndicated namespaces.", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - "clusters": &schema.Schema{ - Type: schema.TypeList, - Computed: true, - Description: "Array of syndicated namespaces.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "region": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "Cluster region.", - }, - "id": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "Cluster ID.", - }, - "name": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "Cluster name.", - }, - "resource_group_name": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "Resource group ID.", - }, - "type": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "Syndication type.", - }, - "namespaces": &schema.Schema{ - Type: schema.TypeList, - Computed: true, - Description: "Syndicated namespaces.", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - "all_namespaces": &schema.Schema{ - Type: schema.TypeBool, - Computed: true, - Description: "Syndicated to all namespaces on cluster.", - }, - }, - }, - }, - "last_run": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "Date and time last syndicated.", - }, - }, - }, - }, - "authorization": &schema.Schema{ - Type: schema.TypeList, - Computed: true, - Description: "Feature information.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "token": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "Array of syndicated namespaces.", - }, - "last_run": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "Date and time last updated.", - }, - }, - }, - }, - }, - }, - }, "kind": &schema.Schema{ Type: schema.TypeString, Computed: true, @@ -563,18 +414,6 @@ func dataSourceIBMCmCatalogRead(context context.Context, d *schema.ResourceData, return diag.FromErr(fmt.Errorf("Error setting catalog_filters %s", err)) } - syndicationSettings := []map[string]interface{}{} - if catalog.SyndicationSettings != nil { - modelMap, err := dataSourceIBMCmCatalogSyndicationResourceToMap(catalog.SyndicationSettings) - if err != nil { - return diag.FromErr(err) - } - syndicationSettings = append(syndicationSettings, modelMap) - } - if err = d.Set("syndication_settings", syndicationSettings); err != nil { - return diag.FromErr(fmt.Errorf("Error setting syndication_settings %s", err)) - } - if err = d.Set("kind", catalog.Kind); err != nil { return diag.FromErr(fmt.Errorf("Error setting kind: %s", err)) } @@ -695,95 +534,3 @@ func dataSourceIBMCmCatalogIDFilterToMap(model *catalogmanagementv1.IDFilter) (m } return modelMap, nil } - -func dataSourceIBMCmCatalogSyndicationResourceToMap(model *catalogmanagementv1.SyndicationResource) (map[string]interface{}, error) { - modelMap := make(map[string]interface{}) - if model.RemoveRelatedComponents != nil { - modelMap["remove_related_components"] = *model.RemoveRelatedComponents - } - if model.Clusters != nil { - clusters := []map[string]interface{}{} - for _, clustersItem := range model.Clusters { - clustersItemMap, err := dataSourceIBMCmCatalogSyndicationClusterToMap(&clustersItem) - if err != nil { - return modelMap, err - } - clusters = append(clusters, clustersItemMap) - } - modelMap["clusters"] = clusters - } - if model.History != nil { - historyMap, err := dataSourceIBMCmCatalogSyndicationHistoryToMap(model.History) - if err != nil { - return modelMap, err - } - modelMap["history"] = []map[string]interface{}{historyMap} - } - if model.Authorization != nil { - authorizationMap, err := dataSourceIBMCmCatalogSyndicationAuthorizationToMap(model.Authorization) - if err != nil { - return modelMap, err - } - modelMap["authorization"] = []map[string]interface{}{authorizationMap} - } - return modelMap, nil -} - -func dataSourceIBMCmCatalogSyndicationClusterToMap(model *catalogmanagementv1.SyndicationCluster) (map[string]interface{}, error) { - modelMap := make(map[string]interface{}) - if model.Region != nil { - modelMap["region"] = *model.Region - } - if model.ID != nil { - modelMap["id"] = *model.ID - } - if model.Name != nil { - modelMap["name"] = *model.Name - } - if model.ResourceGroupName != nil { - modelMap["resource_group_name"] = *model.ResourceGroupName - } - if model.Type != nil { - modelMap["type"] = *model.Type - } - if model.Namespaces != nil { - modelMap["namespaces"] = model.Namespaces - } - if model.AllNamespaces != nil { - modelMap["all_namespaces"] = *model.AllNamespaces - } - return modelMap, nil -} - -func dataSourceIBMCmCatalogSyndicationHistoryToMap(model *catalogmanagementv1.SyndicationHistory) (map[string]interface{}, error) { - modelMap := make(map[string]interface{}) - if model.Namespaces != nil { - modelMap["namespaces"] = model.Namespaces - } - if model.Clusters != nil { - clusters := []map[string]interface{}{} - for _, clustersItem := range model.Clusters { - clustersItemMap, err := dataSourceIBMCmCatalogSyndicationClusterToMap(&clustersItem) - if err != nil { - return modelMap, err - } - clusters = append(clusters, clustersItemMap) - } - modelMap["clusters"] = clusters - } - if model.LastRun != nil { - modelMap["last_run"] = model.LastRun.String() - } - return modelMap, nil -} - -func dataSourceIBMCmCatalogSyndicationAuthorizationToMap(model *catalogmanagementv1.SyndicationAuthorization) (map[string]interface{}, error) { - modelMap := make(map[string]interface{}) - if model.Token != nil { - modelMap["token"] = *model.Token - } - if model.LastRun != nil { - modelMap["last_run"] = model.LastRun.String() - } - return modelMap, nil -} diff --git a/ibm/service/catalogmanagement/resource_ibm_cm_catalog.go b/ibm/service/catalogmanagement/resource_ibm_cm_catalog.go index 00f52d04e9..188df0b1bf 100644 --- a/ibm/service/catalogmanagement/resource_ibm_cm_catalog.go +++ b/ibm/service/catalogmanagement/resource_ibm_cm_catalog.go @@ -174,151 +174,6 @@ func ResourceIBMCmCatalog() *schema.Resource { }, }, }, - "syndication_settings": &schema.Schema{ - Type: schema.TypeList, - Computed: true, - Description: "Feature information.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "remove_related_components": &schema.Schema{ - Type: schema.TypeBool, - Optional: true, - Description: "Remove related components.", - }, - "clusters": &schema.Schema{ - Type: schema.TypeList, - Optional: true, - Description: "Syndication clusters.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "region": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "Cluster region.", - }, - "id": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "Cluster ID.", - }, - "name": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "Cluster name.", - }, - "resource_group_name": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "Resource group ID.", - }, - "type": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "Syndication type.", - }, - "namespaces": &schema.Schema{ - Type: schema.TypeList, - Optional: true, - Description: "Syndicated namespaces.", - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "all_namespaces": &schema.Schema{ - Type: schema.TypeBool, - Optional: true, - Description: "Syndicated to all namespaces on cluster.", - }, - }, - }, - }, - "history": &schema.Schema{ - Type: schema.TypeList, - MaxItems: 1, - Optional: true, - Description: "Feature information.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "namespaces": &schema.Schema{ - Type: schema.TypeList, - Optional: true, - Description: "Array of syndicated namespaces.", - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "clusters": &schema.Schema{ - Type: schema.TypeList, - Optional: true, - Description: "Array of syndicated namespaces.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "region": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "Cluster region.", - }, - "id": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "Cluster ID.", - }, - "name": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "Cluster name.", - }, - "resource_group_name": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "Resource group ID.", - }, - "type": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "Syndication type.", - }, - "namespaces": &schema.Schema{ - Type: schema.TypeList, - Optional: true, - Description: "Syndicated namespaces.", - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "all_namespaces": &schema.Schema{ - Type: schema.TypeBool, - Optional: true, - Description: "Syndicated to all namespaces on cluster.", - }, - }, - }, - }, - "last_run": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "Date and time last syndicated.", - }, - }, - }, - }, - "authorization": &schema.Schema{ - Type: schema.TypeList, - MaxItems: 1, - Optional: true, - Description: "Feature information.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "token": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "Array of syndicated namespaces.", - }, - "last_run": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "Date and time last updated.", - }, - }, - }, - }, - }, - }, - }, "kind": &schema.Schema{ Type: schema.TypeString, Optional: true, @@ -476,13 +331,6 @@ func resourceIBMCmCatalogCreate(context context.Context, d *schema.ResourceData, } createCatalogOptions.SetCatalogFilters(catalogFiltersModel) } - if _, ok := d.GetOk("syndication_settings"); ok { - syndicationSettingsModel, err := resourceIBMCmCatalogMapToSyndicationResource(d.Get("syndication_settings.0").(map[string]interface{})) - if err != nil { - return diag.FromErr(err) - } - createCatalogOptions.SetSyndicationSettings(syndicationSettingsModel) - } if _, ok := d.GetOk("kind"); ok { createCatalogOptions.SetKind(d.Get("kind").(string)) } @@ -580,15 +428,6 @@ func resourceIBMCmCatalogRead(context context.Context, d *schema.ResourceData, m return diag.FromErr(fmt.Errorf("Error setting catalog_filters: %s", err)) } } - if catalog.SyndicationSettings != nil { - syndicationSettingsMap, err := resourceIBMCmCatalogSyndicationResourceToMap(catalog.SyndicationSettings) - if err != nil { - return diag.FromErr(err) - } - if err = d.Set("syndication_settings", []map[string]interface{}{syndicationSettingsMap}); err != nil { - return diag.FromErr(fmt.Errorf("Error setting syndication_settings: %s", err)) - } - } if err = d.Set("kind", catalog.Kind); err != nil { return diag.FromErr(fmt.Errorf("Error setting kind: %s", err)) } @@ -694,13 +533,6 @@ func resourceIBMCmCatalogUpdate(context context.Context, d *schema.ResourceData, } replaceCatalogOptions.SetCatalogFilters(catalogFilters) } - if _, ok := d.GetOk("syndication_settings"); ok { - syndicationSettings, err := resourceIBMCmCatalogMapToSyndicationResource(d.Get("syndication_settings.0").(map[string]interface{})) - if err != nil { - return diag.FromErr(err) - } - replaceCatalogOptions.SetSyndicationSettings(syndicationSettings) - } if _, ok := d.GetOk("kind"); ok { replaceCatalogOptions.SetKind(d.Get("kind").(string)) } @@ -873,110 +705,6 @@ func resourceIBMCmCatalogMapToIDFilter(modelMap map[string]interface{}) (*catalo return model, nil } -func resourceIBMCmCatalogMapToSyndicationResource(modelMap map[string]interface{}) (*catalogmanagementv1.SyndicationResource, error) { - model := &catalogmanagementv1.SyndicationResource{} - if modelMap["remove_related_components"] != nil { - model.RemoveRelatedComponents = core.BoolPtr(modelMap["remove_related_components"].(bool)) - } - if modelMap["clusters"] != nil { - clusters := []catalogmanagementv1.SyndicationCluster{} - for _, clustersItem := range modelMap["clusters"].([]interface{}) { - clustersItemModel, err := resourceIBMCmCatalogMapToSyndicationCluster(clustersItem.(map[string]interface{})) - if err != nil { - return model, err - } - clusters = append(clusters, *clustersItemModel) - } - model.Clusters = clusters - } - if modelMap["history"] != nil && len(modelMap["history"].([]interface{})) > 0 { - var HistoryModel *catalogmanagementv1.SyndicationHistory - var err error - if modelMap["history"].([]interface{})[0] != nil { - HistoryModel, err = resourceIBMCmCatalogMapToSyndicationHistory(modelMap["history"].([]interface{})[0].(map[string]interface{})) - if err != nil { - return model, err - } - } - model.History = HistoryModel - } - if modelMap["authorization"] != nil && len(modelMap["authorization"].([]interface{})) > 0 { - AuthorizationModel, err := resourceIBMCmCatalogMapToSyndicationAuthorization(modelMap["authorization"].([]interface{})[0].(map[string]interface{})) - if err != nil { - return model, err - } - model.Authorization = AuthorizationModel - } - return model, nil -} - -func resourceIBMCmCatalogMapToSyndicationCluster(modelMap map[string]interface{}) (*catalogmanagementv1.SyndicationCluster, error) { - model := &catalogmanagementv1.SyndicationCluster{} - if modelMap["region"] != nil && modelMap["region"].(string) != "" { - model.Region = core.StringPtr(modelMap["region"].(string)) - } - if modelMap["id"] != nil && modelMap["id"].(string) != "" { - model.ID = core.StringPtr(modelMap["id"].(string)) - } - if modelMap["name"] != nil && modelMap["name"].(string) != "" { - model.Name = core.StringPtr(modelMap["name"].(string)) - } - if modelMap["resource_group_name"] != nil && modelMap["resource_group_name"].(string) != "" { - model.ResourceGroupName = core.StringPtr(modelMap["resource_group_name"].(string)) - } - if modelMap["type"] != nil && modelMap["type"].(string) != "" { - model.Type = core.StringPtr(modelMap["type"].(string)) - } - if modelMap["namespaces"] != nil { - namespaces := []string{} - for _, namespacesItem := range modelMap["namespaces"].([]interface{}) { - namespaces = append(namespaces, namespacesItem.(string)) - } - model.Namespaces = namespaces - } - if modelMap["all_namespaces"] != nil { - model.AllNamespaces = core.BoolPtr(modelMap["all_namespaces"].(bool)) - } - return model, nil -} - -func resourceIBMCmCatalogMapToSyndicationHistory(modelMap map[string]interface{}) (*catalogmanagementv1.SyndicationHistory, error) { - model := &catalogmanagementv1.SyndicationHistory{} - if modelMap["namespaces"] != nil { - namespaces := []string{} - for _, namespacesItem := range modelMap["namespaces"].([]interface{}) { - namespaces = append(namespaces, namespacesItem.(string)) - } - model.Namespaces = namespaces - } - if modelMap["clusters"] != nil { - clusters := []catalogmanagementv1.SyndicationCluster{} - for _, clustersItem := range modelMap["clusters"].([]interface{}) { - clustersItemModel, err := resourceIBMCmCatalogMapToSyndicationCluster(clustersItem.(map[string]interface{})) - if err != nil { - return model, err - } - clusters = append(clusters, *clustersItemModel) - } - model.Clusters = clusters - } - if modelMap["last_run"] != nil { - - } - return model, nil -} - -func resourceIBMCmCatalogMapToSyndicationAuthorization(modelMap map[string]interface{}) (*catalogmanagementv1.SyndicationAuthorization, error) { - model := &catalogmanagementv1.SyndicationAuthorization{} - if modelMap["token"] != nil && modelMap["token"].(string) != "" { - model.Token = core.StringPtr(modelMap["token"].(string)) - } - if modelMap["last_run"] != nil { - - } - return model, nil -} - func resourceIBMCmCatalogFeatureToMap(model *catalogmanagementv1.Feature) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) if model.Title != nil { @@ -1085,95 +813,3 @@ func resourceIBMCmCatalogIDFilterToMap(model *catalogmanagementv1.IDFilter) (map } return modelMap, nil } - -func resourceIBMCmCatalogSyndicationResourceToMap(model *catalogmanagementv1.SyndicationResource) (map[string]interface{}, error) { - modelMap := make(map[string]interface{}) - if model.RemoveRelatedComponents != nil { - modelMap["remove_related_components"] = model.RemoveRelatedComponents - } - if model.Clusters != nil { - clusters := []map[string]interface{}{} - for _, clustersItem := range model.Clusters { - clustersItemMap, err := resourceIBMCmCatalogSyndicationClusterToMap(&clustersItem) - if err != nil { - return modelMap, err - } - clusters = append(clusters, clustersItemMap) - } - modelMap["clusters"] = clusters - } - if model.History != nil { - historyMap, err := resourceIBMCmCatalogSyndicationHistoryToMap(model.History) - if err != nil { - return modelMap, err - } - modelMap["history"] = []map[string]interface{}{historyMap} - } - if model.Authorization != nil { - authorizationMap, err := resourceIBMCmCatalogSyndicationAuthorizationToMap(model.Authorization) - if err != nil { - return modelMap, err - } - modelMap["authorization"] = []map[string]interface{}{authorizationMap} - } - return modelMap, nil -} - -func resourceIBMCmCatalogSyndicationClusterToMap(model *catalogmanagementv1.SyndicationCluster) (map[string]interface{}, error) { - modelMap := make(map[string]interface{}) - if model.Region != nil { - modelMap["region"] = model.Region - } - if model.ID != nil { - modelMap["id"] = model.ID - } - if model.Name != nil { - modelMap["name"] = model.Name - } - if model.ResourceGroupName != nil { - modelMap["resource_group_name"] = model.ResourceGroupName - } - if model.Type != nil { - modelMap["type"] = model.Type - } - if model.Namespaces != nil { - modelMap["namespaces"] = model.Namespaces - } - if model.AllNamespaces != nil { - modelMap["all_namespaces"] = model.AllNamespaces - } - return modelMap, nil -} - -func resourceIBMCmCatalogSyndicationHistoryToMap(model *catalogmanagementv1.SyndicationHistory) (map[string]interface{}, error) { - modelMap := make(map[string]interface{}) - if model.Namespaces != nil { - modelMap["namespaces"] = model.Namespaces - } - if model.Clusters != nil { - clusters := []map[string]interface{}{} - for _, clustersItem := range model.Clusters { - clustersItemMap, err := resourceIBMCmCatalogSyndicationClusterToMap(&clustersItem) - if err != nil { - return modelMap, err - } - clusters = append(clusters, clustersItemMap) - } - modelMap["clusters"] = clusters - } - if model.LastRun != nil { - modelMap["last_run"] = model.LastRun.String() - } - return modelMap, nil -} - -func resourceIBMCmCatalogSyndicationAuthorizationToMap(model *catalogmanagementv1.SyndicationAuthorization) (map[string]interface{}, error) { - modelMap := make(map[string]interface{}) - if model.Token != nil { - modelMap["token"] = model.Token - } - if model.LastRun != nil { - modelMap["last_run"] = model.LastRun.String() - } - return modelMap, nil -} diff --git a/ibm/service/cos/data_source_ibm_cos_bucket.go b/ibm/service/cos/data_source_ibm_cos_bucket.go index 22c54e1c96..83f519a394 100644 --- a/ibm/service/cos/data_source_ibm_cos_bucket.go +++ b/ibm/service/cos/data_source_ibm_cos_bucket.go @@ -11,7 +11,7 @@ import ( "github.com/IBM-Cloud/terraform-provider-ibm/ibm/conns" "github.com/IBM-Cloud/terraform-provider-ibm/ibm/flex" "github.com/IBM-Cloud/terraform-provider-ibm/ibm/validate" - "github.com/IBM/ibm-cos-sdk-go-config/resourceconfigurationv1" + rcsdk "github.com/IBM/ibm-cos-sdk-go-config/v2/resourceconfigurationv1" "github.com/IBM/ibm-cos-sdk-go/aws" "github.com/IBM/ibm-cos-sdk-go/aws/credentials/ibmiam" token "github.com/IBM/ibm-cos-sdk-go/aws/credentials/ibmiam/token" @@ -707,16 +707,10 @@ func dataSourceIBMCosBucketRead(d *schema.ResourceData, meta interface{}) error d.Set("s3_endpoint_public", apiEndpoint) d.Set("s3_endpoint_private", apiEndpointPrivate) d.Set("s3_endpoint_direct", directApiEndpoint) - - getBucketConfigOptions := &resourceconfigurationv1.GetBucketConfigOptions{ - Bucket: &bucketName, - } - sess, err := meta.(conns.ClientSession).CosConfigV1API() if err != nil { return err } - if endpointType == "private" { sess.SetServiceURL("https://config.private.cloud-object-storage.cloud.ibm.com/v1") } @@ -728,10 +722,11 @@ func dataSourceIBMCosBucketRead(d *schema.ResourceData, meta interface{}) error satconfig := fmt.Sprintf("https://config.%s.%s.cloud-object-storage.appdomain.cloud/v1", serviceID, satlc_id) sess.SetServiceURL(satconfig) - } - bucketPtr, response, err := sess.GetBucketConfig(getBucketConfigOptions) + getOptions := new(rcsdk.GetBucketConfigOptions) + getOptions.SetBucket(bucketName) + bucketPtr, response, err := sess.GetBucketConfig(getOptions) if err != nil { return fmt.Errorf("[ERROR] Error in getting bucket info rule: %s\n%s", err, response) } diff --git a/ibm/service/cos/resource_ibm_cos_bucket.go b/ibm/service/cos/resource_ibm_cos_bucket.go index fabf40bc9d..299dfb77ad 100644 --- a/ibm/service/cos/resource_ibm_cos_bucket.go +++ b/ibm/service/cos/resource_ibm_cos_bucket.go @@ -14,7 +14,8 @@ import ( "github.com/IBM-Cloud/terraform-provider-ibm/ibm/conns" "github.com/IBM-Cloud/terraform-provider-ibm/ibm/flex" "github.com/IBM-Cloud/terraform-provider-ibm/ibm/validate" - "github.com/IBM/ibm-cos-sdk-go-config/resourceconfigurationv1" + "github.com/IBM/go-sdk-core/core" + rcsdk "github.com/IBM/ibm-cos-sdk-go-config/v2/resourceconfigurationv1" "github.com/IBM/ibm-cos-sdk-go/aws" "github.com/IBM/ibm-cos-sdk-go/aws/credentials/ibmiam" token "github.com/IBM/ibm-cos-sdk-go/aws/credentials/ibmiam/token" @@ -936,19 +937,18 @@ func resourceIBMCOSBucketUpdate(d *schema.ResourceData, meta interface{}) error } hasChanged := false - updateBucketConfigOptions := &resourceconfigurationv1.UpdateBucketConfigOptions{} //BucketName bucketName = d.Get("bucket_name").(string) - updateBucketConfigOptions.Bucket = &bucketName - + bucketPatchModel := new(rcsdk.BucketPatch) if d.HasChange("hard_quota") { hasChanged = true - updateBucketConfigOptions.HardQuota = aws.Int64(int64(d.Get("hard_quota").(int))) + bucketPatchModel.HardQuota = core.Int64Ptr(int64(d.Get("hard_quota").(int))) + } if d.HasChange("allowed_ip") { - firewall := &resourceconfigurationv1.Firewall{} + firewall := &rcsdk.Firewall{} var ips = make([]string, 0) if ip, ok := d.GetOk("allowed_ip"); ok && ip != nil { for _, i := range ip.([]interface{}) { @@ -959,11 +959,11 @@ func resourceIBMCOSBucketUpdate(d *schema.ResourceData, meta interface{}) error firewall.AllowedIp = []string{} } hasChanged = true - updateBucketConfigOptions.Firewall = firewall + bucketPatchModel.Firewall = firewall } if d.HasChange("activity_tracking") { - activityTracker := &resourceconfigurationv1.ActivityTracking{} + activityTracker := &rcsdk.ActivityTracking{} if activity, ok := d.GetOk("activity_tracking"); ok { activitylist := activity.([]interface{}) for _, l := range activitylist { @@ -987,11 +987,12 @@ func resourceIBMCOSBucketUpdate(d *schema.ResourceData, meta interface{}) error } } hasChanged = true - updateBucketConfigOptions.ActivityTracking = activityTracker + bucketPatchModel.ActivityTracking = activityTracker + } if d.HasChange("metrics_monitoring") { - metricsMonitor := &resourceconfigurationv1.MetricsMonitoring{} + metricsMonitoring := &rcsdk.MetricsMonitoring{} if metrics, ok := d.GetOk("metrics_monitoring"); ok { metricslist := metrics.([]interface{}) for _, l := range metricslist { @@ -1000,24 +1001,32 @@ func resourceIBMCOSBucketUpdate(d *schema.ResourceData, meta interface{}) error //metrics enabled - as its optional check for existence if metricsSet := metricsMap["usage_metrics_enabled"]; metricsSet != nil { metrics := metricsSet.(bool) - metricsMonitor.UsageMetricsEnabled = &metrics + metricsMonitoring.UsageMetricsEnabled = &metrics } // request metrics enabled - as its optional check for existence if metricsSet := metricsMap["request_metrics_enabled"]; metricsSet != nil { metrics := metricsSet.(bool) - metricsMonitor.RequestMetricsEnabled = &metrics + metricsMonitoring.RequestMetricsEnabled = &metrics } //crn - Required field crn := metricsMap["metrics_monitoring_crn"].(string) - metricsMonitor.MetricsMonitoringCrn = &crn + metricsMonitoring.MetricsMonitoringCrn = &crn } } hasChanged = true - updateBucketConfigOptions.MetricsMonitoring = metricsMonitor + bucketPatchModel.MetricsMonitoring = metricsMonitoring + } if hasChanged { - response, err := sess.UpdateBucketConfig(updateBucketConfigOptions) + bucketPatchModelAsPatch, asPatchErr := bucketPatchModel.AsPatch() + if asPatchErr != nil { + return fmt.Errorf("[ERROR] Error Update COS Bucket: %s\n%s", err, bucketPatchModelAsPatch) + } + setOptions := new(rcsdk.UpdateBucketConfigOptions) + setOptions.SetBucket(bucketName) + setOptions.BucketPatch = bucketPatchModelAsPatch + response, err := sess.UpdateBucketConfig(setOptions) if err != nil { return fmt.Errorf("[ERROR] Error Update COS Bucket: %s\n%s", err, response) } @@ -1145,11 +1154,6 @@ func resourceIBMCOSBucketRead(d *schema.ResourceData, meta interface{}) error { if endpointType != "" { d.Set("endpoint_type", endpointType) } - - getBucketConfigOptions := &resourceconfigurationv1.GetBucketConfigOptions{ - Bucket: &bucketName, - } - sess, err := meta.(conns.ClientSession).CosConfigV1API() if err != nil { return err @@ -1168,7 +1172,9 @@ func resourceIBMCOSBucketRead(d *schema.ResourceData, meta interface{}) error { sess.SetServiceURL(satconfig) } - bucketPtr, response, err := sess.GetBucketConfig(getBucketConfigOptions) + getOptions := new(rcsdk.GetBucketConfigOptions) + getOptions.SetBucket(bucketName) + bucketPtr, response, err := sess.GetBucketConfig(getOptions) if err != nil { return fmt.Errorf("[ERROR] Error in getting bucket info rule: %s\n%s", err, response) } diff --git a/ibm/service/globaltagging/resource_ibm_resource_access_tag.go b/ibm/service/globaltagging/resource_ibm_resource_access_tag.go new file mode 100644 index 0000000000..f4d1d5b9d2 --- /dev/null +++ b/ibm/service/globaltagging/resource_ibm_resource_access_tag.go @@ -0,0 +1,165 @@ +// Copyright IBM Corp. 2017, 2021 All Rights Reserved. +// Licensed under the Mozilla Public License v2.0 + +package globaltagging + +import ( + "encoding/json" + "fmt" + "log" + + "github.com/IBM-Cloud/terraform-provider-ibm/ibm/conns" + "github.com/IBM-Cloud/terraform-provider-ibm/ibm/flex" + "github.com/IBM-Cloud/terraform-provider-ibm/ibm/validate" + "github.com/IBM/platform-services-go-sdk/globaltaggingv1" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" +) + +func ResourceIBMResourceAccessTag() *schema.Resource { + return &schema.Resource{ + Create: resourceIBMResourceAccessTagCreate, + Read: resourceIBMResourceAccessTagRead, + Delete: resourceIBMResourceAccessTagDelete, + Importer: &schema.ResourceImporter{}, + + Schema: map[string]*schema.Schema{ + + "name": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: validate.InvokeValidator("ibm_resource_access_tag", "name"), + Set: flex.ResourceIBMVPCHash, + Description: "Name of the access tag", + }, + tagType: { + Type: schema.TypeString, + Computed: true, + Description: "Type of the tag(access)", + }, + }, + } +} + +func ResourceIBMResourceAccessTagValidator() *validate.ResourceValidator { + + validateSchema := make([]validate.ValidateSchema, 0) + + validateSchema = append(validateSchema, + validate.ValidateSchema{ + Identifier: "name", + ValidateFunctionIdentifier: validate.ValidateRegexpLen, + Type: validate.TypeString, + Required: true, + Regexp: `^([A-Za-z0-9_.-]|[A-Za-z0-9_.-][A-Za-z0-9_ .-]*[A-Za-z0-9_.-]):([A-Za-z0-9_.-]|[A-Za-z0-9_.-][A-Za-z0-9_ .-]*[A-Za-z0-9_.-])$`, + MinValueLength: 1, + MaxValueLength: 128}) + + ibmResourceAccessTagValidator := validate.ResourceValidator{ResourceName: "ibm_resource_access_tag", Schema: validateSchema} + return &ibmResourceAccessTagValidator +} + +func resourceIBMResourceAccessTagCreate(d *schema.ResourceData, meta interface{}) error { + + gtClient, err := meta.(conns.ClientSession).GlobalTaggingAPIv1() + if err != nil { + return fmt.Errorf("Error getting global tagging client settings: %s", err) + } + + tagName := d.Get("name").(string) + add := make([]string, 0) + add = append(add, tagName) + accessTagType := "access" + createTagOptions := &globaltaggingv1.CreateTagOptions{ + TagType: &accessTagType, + TagNames: add, + } + results, _, err := gtClient.CreateTag(createTagOptions) + if err != nil { + return err + } + if results != nil { + errMap := make([]globaltaggingv1.CreateTagResultsResultsItem, 0) + for _, res := range results.Results { + if res.IsError != nil && *res.IsError { + errMap = append(errMap, res) + } + } + if len(errMap) > 0 { + output, err := json.MarshalIndent(errMap, "", " ") + log.Printf("err is %s", err) + return fmt.Errorf("[ERROR] Error while creating access tag(%s) : %s", tagName, string(output)) + } + } + + d.SetId(tagName) + d.Set(tagType, accessTagType) + + return nil +} + +func resourceIBMResourceAccessTagRead(d *schema.ResourceData, meta interface{}) error { + tagName := d.Id() + gtClient, err := meta.(conns.ClientSession).GlobalTaggingAPIv1() + if err != nil { + return fmt.Errorf("Error getting global tagging client settings: %s", err) + } + accessTagType := "access" + listTagsOptions := &globaltaggingv1.ListTagsOptions{ + TagType: &accessTagType, + } + taggingResult, _, err := gtClient.ListTags(listTagsOptions) + if err != nil { + return err + } + + var taglist []string + for _, item := range taggingResult.Items { + taglist = append(taglist, *item.Name) + } + existingAccessTags := flex.NewStringSet(flex.ResourceIBMVPCHash, taglist) + if !existingAccessTags.Contains(tagName) { + d.SetId("") + return nil + } + d.Set("name", tagName) + d.Set(tagType, accessTagType) + return nil +} + +func resourceIBMResourceAccessTagDelete(d *schema.ResourceData, meta interface{}) error { + + gtClient, err := meta.(conns.ClientSession).GlobalTaggingAPIv1() + if err != nil { + return fmt.Errorf("[ERROR] Error getting global tagging client settings: %s", err) + } + tagName := d.Get("name").(string) + accessTagType := "access" + + deleteTagOptions := &globaltaggingv1.DeleteTagOptions{ + TagName: &tagName, + TagType: &accessTagType, + } + + results, resp, err := gtClient.DeleteTag(deleteTagOptions) + + if err != nil { + return fmt.Errorf("[ERROR] Error while deleting access tag(%s) : %v\n%v", tagName, err, resp) + } + if results != nil { + errMap := make([]globaltaggingv1.DeleteTagResultsItem, 0) + for _, res := range results.Results { + if res.IsError != nil && *res.IsError { + errMap = append(errMap, res) + } + } + if len(errMap) > 0 { + output, err := json.MarshalIndent(errMap, "", " ") + log.Printf("err is %s", err) + return fmt.Errorf("[ERROR] Error while deleting access tag(%s) : %s", tagName, string(output)) + } + } + + d.SetId("") + return nil +} diff --git a/ibm/service/globaltagging/resource_ibm_resource_access_tag_test.go b/ibm/service/globaltagging/resource_ibm_resource_access_tag_test.go new file mode 100644 index 0000000000..bc420e1b3b --- /dev/null +++ b/ibm/service/globaltagging/resource_ibm_resource_access_tag_test.go @@ -0,0 +1,143 @@ +// Copyright IBM Corp. 2017, 2021 All Rights Reserved. +// Licensed under the Mozilla Public License v2.0 + +package globaltagging_test + +import ( + "fmt" + "regexp" + "strings" + "testing" + + acc "github.com/IBM-Cloud/terraform-provider-ibm/ibm/acctest" + "github.com/IBM-Cloud/terraform-provider-ibm/ibm/conns" + "github.com/IBM-Cloud/terraform-provider-ibm/ibm/flex" + "github.com/IBM/platform-services-go-sdk/globaltaggingv1" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" +) + +const ( + accessTagRegex = "^([A-Za-z0-9_.-]|[A-Za-z0-9_.-][A-Za-z0-9_ .-]*[A-Za-z0-9_.-]):([A-Za-z0-9_.-]|[A-Za-z0-9_.-][A-Za-z0-9_ .-]*[A-Za-z0-9_.-])$" +) + +func TestAccResourceAccessTag_Basic(t *testing.T) { + name := fmt.Sprintf("tf%d:access%d", acctest.RandIntRange(10, 100), acctest.RandIntRange(10, 100)) + + resource.Test(t, resource.TestCase{ + PreCheck: func() { acc.TestAccPreCheck(t) }, + Providers: acc.TestAccProviders, + Steps: []resource.TestStep{ + + resource.TestStep{ + Config: testAccCheckResourceAccessTagCreate(name), + Check: resource.ComposeAggregateTestCheckFunc( + testAccCheckResourceAccessTagExists("ibm_resource_access_tag.tag"), + resource.TestCheckResourceAttr("ibm_resource_access_tag.tag", "id", name), + resource.TestCheckResourceAttr("ibm_resource_access_tag.tag", "name", name), + resource.TestCheckResourceAttr("ibm_resource_access_tag.tag", "tag_type", "access"), + ), + }, + }, + }) +} +func TestAccResourceAccessTag_Usage(t *testing.T) { + name := fmt.Sprintf("tf%d:access%d", acctest.RandIntRange(10, 100), acctest.RandIntRange(10, 100)) + publicKey := strings.TrimSpace(` +ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCKVmnMOlHKcZK8tpt3MP1lqOLAcqcJzhsvJcjscgVERRN7/9484SOBJ3HSKxxNG5JN8owAjy5f9yYwcUg+JaUVuytn5Pv3aeYROHGGg+5G346xaq3DAwX6Y5ykr2fvjObgncQBnuU5KHWCECO/4h8uWuwh/kfniXPVjFToc+gnkqA+3RKpAecZhFXwfalQ9mMuYGFxn+fwn8cYEApsJbsEmb0iJwPiZ5hjFC8wREuiTlhPHDgkBLOiycd20op2nXzDbHfCHInquEe/gYxEitALONxm0swBOwJZwlTDOB7C6y2dzlrtxr1L59m7pCkWI4EtTRLvleehBoj3u7jB4usR +`) + sshkeyname := fmt.Sprintf("tfssh-createname-%d", acctest.RandIntRange(10, 100)) + resource.Test(t, resource.TestCase{ + PreCheck: func() { acc.TestAccPreCheck(t) }, + Providers: acc.TestAccProviders, + Steps: []resource.TestStep{ + + resource.TestStep{ + Config: testAccCheckResourceAccessTagCreate(name), + Check: resource.ComposeAggregateTestCheckFunc( + testAccCheckResourceAccessTagExists("ibm_resource_access_tag.tag"), + resource.TestCheckResourceAttr("ibm_resource_access_tag.tag", "id", name), + resource.TestCheckResourceAttr("ibm_resource_access_tag.tag", "name", name), + resource.TestCheckResourceAttr("ibm_resource_access_tag.tag", "tag_type", "access"), + ), + }, + resource.TestStep{ + Config: testAccCheckResourceAccessTagUsage(name, sshkeyname, publicKey), + Check: resource.ComposeAggregateTestCheckFunc( + testAccCheckResourceAccessTagExists("ibm_resource_access_tag.tag"), + resource.TestCheckResourceAttr("ibm_resource_access_tag.tag", "id", name), + resource.TestCheckResourceAttr("ibm_resource_access_tag.tag", "name", name), + resource.TestCheckResourceAttr("ibm_resource_access_tag.tag", "tag_type", "access"), + resource.TestCheckResourceAttr("ibm_is_ssh_key.key", "name", sshkeyname), + resource.TestCheckResourceAttrSet("ibm_is_ssh_key.key", "access_tags.#"), + resource.TestCheckResourceAttr("ibm_is_ssh_key.key", "access_tags.0", name), + ), + }, + }, + }) +} + +func testAccCheckResourceAccessTagExists(n string) resource.TestCheckFunc { + return func(s *terraform.State) error { + var tagName string + rs, ok := s.RootModule().Resources[n] + if !ok { + return fmt.Errorf("Not found: %s", n) + } + + accessTagRegex, err := regexp.Compile(accessTagRegex) + if err != nil { + return err + } + + if accessTagRegex.MatchString(rs.Primary.ID) { + tagName = rs.Primary.ID + } + + gtClient, err := acc.TestAccProvider.Meta().(conns.ClientSession).GlobalTaggingAPIv1() + if err != nil { + return fmt.Errorf("Error getting global tagging client settings: %s", err) + } + accessTagType := "access" + listTagsOptions := &globaltaggingv1.ListTagsOptions{ + TagType: &accessTagType, + } + taggingResult, _, err := gtClient.ListTags(listTagsOptions) + if err != nil { + return err + } + + var taglist []string + for _, item := range taggingResult.Items { + taglist = append(taglist, *item.Name) + } + existingAccessTags := flex.NewStringSet(flex.ResourceIBMVPCHash, taglist) + if !existingAccessTags.Contains(tagName) { + return fmt.Errorf( + "Error on get of resource tags (%s) : %s", tagName, err) + } + return nil + } +} + +func testAccCheckResourceAccessTagCreate(name string) string { + return fmt.Sprintf(` + resource ibm_resource_access_tag tag { + name = "%s" + } +`, name) +} +func testAccCheckResourceAccessTagUsage(name, sshkeyname, publicKey string) string { + return fmt.Sprintf(` + resource ibm_resource_access_tag tag { + name = "%s" + } + resource "ibm_is_ssh_key" "key" { + name = "%s" + public_key = "%s" + access_tags = [ibm_resource_access_tag.tag.name] + } + +`, name, sshkeyname, publicKey) +} diff --git a/ibm/service/globaltagging/resource_ibm_resource_tag.go b/ibm/service/globaltagging/resource_ibm_resource_tag.go index 60c0d9761d..99587a9b5c 100644 --- a/ibm/service/globaltagging/resource_ibm_resource_tag.go +++ b/ibm/service/globaltagging/resource_ibm_resource_tag.go @@ -1,4 +1,4 @@ -// Copyright IBM Corp. 2017, 2021 All Rights Reserved. +// Copyright IBM Corp. 2017, 2024 All Rights Reserved. // Licensed under the Mozilla Public License v2.0 package globaltagging diff --git a/ibm/service/globaltagging/resource_ibm_resource_tag_test.go b/ibm/service/globaltagging/resource_ibm_resource_tag_test.go index 6e2ff26475..f35783aadc 100644 --- a/ibm/service/globaltagging/resource_ibm_resource_tag_test.go +++ b/ibm/service/globaltagging/resource_ibm_resource_tag_test.go @@ -1,4 +1,4 @@ -// Copyright IBM Corp. 2017, 2021 All Rights Reserved. +// Copyright IBM Corp. 2017, 2024 All Rights Reserved. // Licensed under the Mozilla Public License v2.0 package globaltagging_test diff --git a/ibm/service/vpc/resource_ibm_is_ssh_key.go b/ibm/service/vpc/resource_ibm_is_ssh_key.go index 3d0181b63e..a52d15ccb4 100644 --- a/ibm/service/vpc/resource_ibm_is_ssh_key.go +++ b/ibm/service/vpc/resource_ibm_is_ssh_key.go @@ -143,7 +143,7 @@ func ResourceIBMISSSHKey() *schema.Resource { Type: schema.TypeSet, Optional: true, Computed: true, - Elem: &schema.Schema{Type: schema.TypeString, ValidateFunc: validate.InvokeValidator("ibm_is_ssh_key", "accesstag")}, + Elem: &schema.Schema{Type: schema.TypeString, ValidateFunc: validate.InvokeValidator("ibm_is_ssh_key", "access_tag")}, Set: flex.ResourceIBMVPCHash, Description: "List of access management tags for SSH key", }, diff --git a/metadata/provider_metadata.json b/metadata/provider_metadata.json index ce535fcbe0..41d4aec350 100644 --- a/metadata/provider_metadata.json +++ b/metadata/provider_metadata.json @@ -11386,169 +11386,6 @@ "cloud_data_type": "resource_group", "computed": true }, - { - "name": "syndication_settings", - "type": "TypeList", - "description": "Feature information.", - "computed": true, - "elem": { - "authorization": { - "name": "authorization", - "type": "TypeList", - "description": "Feature information.", - "computed": true, - "elem": { - "last_run": { - "name": "last_run", - "type": "TypeString", - "description": "Date and time last updated.", - "computed": true - }, - "token": { - "name": "token", - "type": "TypeString", - "description": "Array of syndicated namespaces.", - "computed": true - } - } - }, - "clusters": { - "name": "clusters", - "type": "TypeList", - "description": "Syndication clusters.", - "computed": true, - "elem": { - "all_namespaces": { - "name": "all_namespaces", - "type": "TypeBool", - "description": "Syndicated to all namespaces on cluster.", - "computed": true - }, - "id": { - "name": "id", - "type": "TypeString", - "description": "Cluster ID.", - "computed": true - }, - "name": { - "name": "name", - "type": "TypeString", - "description": "Cluster name.", - "computed": true - }, - "namespaces": { - "name": "namespaces", - "type": "TypeList", - "description": "Syndicated namespaces.", - "computed": true, - "elem": { - "type": "TypeString" - } - }, - "region": { - "name": "region", - "type": "TypeString", - "description": "Cluster region.", - "computed": true - }, - "resource_group_name": { - "name": "resource_group_name", - "type": "TypeString", - "description": "Resource group ID.", - "computed": true - }, - "type": { - "name": "type", - "type": "TypeString", - "description": "Syndication type.", - "computed": true - } - } - }, - "history": { - "name": "history", - "type": "TypeList", - "description": "Feature information.", - "computed": true, - "elem": { - "clusters": { - "name": "clusters", - "type": "TypeList", - "description": "Array of syndicated namespaces.", - "computed": true, - "elem": { - "all_namespaces": { - "name": "all_namespaces", - "type": "TypeBool", - "description": "Syndicated to all namespaces on cluster.", - "computed": true - }, - "id": { - "name": "id", - "type": "TypeString", - "description": "Cluster ID.", - "computed": true - }, - "name": { - "name": "name", - "type": "TypeString", - "description": "Cluster name.", - "computed": true - }, - "namespaces": { - "name": "namespaces", - "type": "TypeList", - "description": "Syndicated namespaces.", - "computed": true, - "elem": { - "type": "TypeString" - } - }, - "region": { - "name": "region", - "type": "TypeString", - "description": "Cluster region.", - "computed": true - }, - "resource_group_name": { - "name": "resource_group_name", - "type": "TypeString", - "description": "Resource group ID.", - "computed": true - }, - "type": { - "name": "type", - "type": "TypeString", - "description": "Syndication type.", - "computed": true - } - } - }, - "last_run": { - "name": "last_run", - "type": "TypeString", - "description": "Date and time last syndicated.", - "computed": true - }, - "namespaces": { - "name": "namespaces", - "type": "TypeList", - "description": "Array of syndicated namespaces.", - "computed": true, - "elem": { - "type": "TypeString" - } - } - } - }, - "remove_related_components": { - "name": "remove_related_components", - "type": "TypeBool", - "description": "Remove related components.", - "computed": true - } - } - }, { "name": "label_i18n", "type": "TypeMap", @@ -96830,171 +96667,6 @@ "description": "Account that owns catalog.", "computed": true }, - { - "name": "syndication_settings", - "type": "TypeList", - "description": "Feature information.", - "computed": true, - "elem": { - "authorization": { - "name": "authorization", - "type": "TypeList", - "description": "Feature information.", - "optional": true, - "elem": { - "last_run": { - "name": "last_run", - "type": "TypeString", - "description": "Date and time last updated.", - "optional": true - }, - "token": { - "name": "token", - "type": "TypeString", - "description": "Array of syndicated namespaces.", - "optional": true - } - }, - "max_items": 1 - }, - "clusters": { - "name": "clusters", - "type": "TypeList", - "description": "Syndication clusters.", - "optional": true, - "elem": { - "all_namespaces": { - "name": "all_namespaces", - "type": "TypeBool", - "description": "Syndicated to all namespaces on cluster.", - "optional": true - }, - "id": { - "name": "id", - "type": "TypeString", - "description": "Cluster ID.", - "optional": true - }, - "name": { - "name": "name", - "type": "TypeString", - "description": "Cluster name.", - "optional": true - }, - "namespaces": { - "name": "namespaces", - "type": "TypeList", - "description": "Syndicated namespaces.", - "optional": true, - "elem": { - "type": "TypeString" - } - }, - "region": { - "name": "region", - "type": "TypeString", - "description": "Cluster region.", - "optional": true - }, - "resource_group_name": { - "name": "resource_group_name", - "type": "TypeString", - "description": "Resource group ID.", - "optional": true - }, - "type": { - "name": "type", - "type": "TypeString", - "description": "Syndication type.", - "optional": true - } - } - }, - "history": { - "name": "history", - "type": "TypeList", - "description": "Feature information.", - "optional": true, - "elem": { - "clusters": { - "name": "clusters", - "type": "TypeList", - "description": "Array of syndicated namespaces.", - "optional": true, - "elem": { - "all_namespaces": { - "name": "all_namespaces", - "type": "TypeBool", - "description": "Syndicated to all namespaces on cluster.", - "optional": true - }, - "id": { - "name": "id", - "type": "TypeString", - "description": "Cluster ID.", - "optional": true - }, - "name": { - "name": "name", - "type": "TypeString", - "description": "Cluster name.", - "optional": true - }, - "namespaces": { - "name": "namespaces", - "type": "TypeList", - "description": "Syndicated namespaces.", - "optional": true, - "elem": { - "type": "TypeString" - } - }, - "region": { - "name": "region", - "type": "TypeString", - "description": "Cluster region.", - "optional": true - }, - "resource_group_name": { - "name": "resource_group_name", - "type": "TypeString", - "description": "Resource group ID.", - "optional": true - }, - "type": { - "name": "type", - "type": "TypeString", - "description": "Syndication type.", - "optional": true - } - } - }, - "last_run": { - "name": "last_run", - "type": "TypeString", - "description": "Date and time last syndicated.", - "optional": true - }, - "namespaces": { - "name": "namespaces", - "type": "TypeList", - "description": "Array of syndicated namespaces.", - "optional": true, - "elem": { - "type": "TypeString" - } - } - }, - "max_items": 1 - }, - "remove_related_components": { - "name": "remove_related_components", - "type": "TypeBool", - "description": "Remove related components.", - "optional": true - } - } - }, { "name": "target_account_contexts", "type": "TypeList", diff --git a/website/docs/d/cm_catalog.html.markdown b/website/docs/d/cm_catalog.html.markdown index f0e7592d17..6fb9a9add1 100644 --- a/website/docs/d/cm_catalog.html.markdown +++ b/website/docs/d/cm_catalog.html.markdown @@ -77,36 +77,6 @@ Nested scheme for **features**: * `short_description` - (String) Description in the requested language. -* `syndication_settings` - (List) Feature information. -Nested scheme for **syndication_settings**: - * `authorization` - (List) Feature information. - Nested scheme for **authorization**: - * `last_run` - (String) Date and time last updated. - * `token` - (String) Array of syndicated namespaces. - * `clusters` - (List) Syndication clusters. - Nested scheme for **clusters**: - * `all_namespaces` - (Boolean) Syndicated to all namespaces on cluster. - * `id` - (String) Cluster ID. - * `name` - (String) Cluster name. - * `namespaces` - (List) Syndicated namespaces. - * `region` - (String) Cluster region. - * `resource_group_name` - (String) Resource group ID. - * `type` - (String) Syndication type. - * `history` - (List) Feature information. - Nested scheme for **history**: - * `clusters` - (List) Array of syndicated namespaces. - Nested scheme for **clusters**: - * `all_namespaces` - (Boolean) Syndicated to all namespaces on cluster. - * `id` - (String) Cluster ID. - * `name` - (String) Cluster name. - * `namespaces` - (List) Syndicated namespaces. - * `region` - (String) Cluster region. - * `resource_group_name` - (String) Resource group ID. - * `type` - (String) Syndication type. - * `last_run` - (String) Date and time last syndicated. - * `namespaces` - (List) Array of syndicated namespaces. - * `remove_related_components` - (Boolean) Remove related components. - * `tags` - (List) List of tags associated with this catalog. * `target_account_contexts` - (List) List of target account contexts for this catalog. diff --git a/website/docs/r/resource_access_tag.html.markdown b/website/docs/r/resource_access_tag.html.markdown new file mode 100644 index 0000000000..5500d5105f --- /dev/null +++ b/website/docs/r/resource_access_tag.html.markdown @@ -0,0 +1,66 @@ +--- +subcategory: "Global Tagging" +layout: "ibm" +page_title: "IBM : resource_access_tag" +description: |- + Manages resource access tags. +--- + +# ibm_resource_access_tag + +Create, update, or delete IBM Cloud access management tags. For more information, about tagging, see [IBM Cloud access management tags](https://cloud.ibm.com/apidocs/tagging#create-tag). + + +## Example usage +The following example enables you to create access management tags + +```terraform +resource "ibm_resource_access_tag" "example" { + name = "example:tag" +} + +``` + +## Argument reference +Review the argument references that you can specify for your resource. + +- `name` - (Required, String) The name of the access management tag. + + +## Attributes reference +In addition to all argument reference list, you can access the following attribute reference after your resource is created. + +- `id` - (String) The unique identifier of the resource tag. Same as `name`. +- `tag_type` - (String) Type of the tag(`access`) + + +## Import + +The `ibm_resource_access_tag` resource can be imported by using the resource CRN. + +**Syntax** + +``` +$ terraform import ibm_resource_access_tag.tag tag_name +``` + +**Example** + +``` +$ terraform import ibm_resource_access_tag.tag crn:v1:bluemix:public:satellite:us-east:a/ab3ed67929c2a81285fbb5f9eb22800a:c1ga7h9w0angomd44654:: + +``` + +Example for importing access tags. + +**Syntax** + +``` +$ terraform import ibm_resource_access_tag.tag tag_name +``` + +**Example** + +``` +$ terraform import ibm_resource_access_tag.tag example:test +```