diff --git a/ibm/service/power/data_source_ibm_pi_disaster_recovery_location.go b/ibm/service/power/data_source_ibm_pi_disaster_recovery_location.go index f7f2f3e85c..4c839ab37f 100644 --- a/ibm/service/power/data_source_ibm_pi_disaster_recovery_location.go +++ b/ibm/service/power/data_source_ibm_pi_disaster_recovery_location.go @@ -6,47 +6,50 @@ package power import ( "context" + "github.com/IBM-Cloud/power-go-client/clients/instance" + "github.com/IBM-Cloud/terraform-provider-ibm/ibm/conns" "github.com/hashicorp/go-uuid" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" - - "github.com/IBM-Cloud/power-go-client/clients/instance" - "github.com/IBM-Cloud/power-go-client/helpers" - "github.com/IBM-Cloud/terraform-provider-ibm/ibm/conns" ) func DataSourceIBMPIDisasterRecoveryLocation() *schema.Resource { return &schema.Resource{ ReadContext: dataSourceIBMPIDisasterRecoveryLocation, Schema: map[string]*schema.Schema{ - helpers.PICloudInstanceId: { - Type: schema.TypeString, + // Arguments + Arg_CloudInstanceID: { + Description: "The GUID of the service instance associated with an account.", Required: true, + Type: schema.TypeString, ValidateFunc: validation.NoZeroValues, }, - // Computed Attributes - PIDRLocation: { - Type: schema.TypeString, + // Attributes + Attr_Location: { Computed: true, - Description: "RegionZone of a site", + Description: "The region zone of a site.", + Type: schema.TypeString, }, - "replication_sites": { - Type: schema.TypeList, - Computed: true, + Attr_ReplicationSites: { + Computed: true, + Description: "List of replication sites.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "is_active": { - Type: schema.TypeBool, - Computed: true, + Attr_IsActive: { + Computed: true, + Description: "Indicates the location is active or not, true if location is active , otherwise it is false.", + Type: schema.TypeBool, }, - PIDRLocation: { - Type: schema.TypeString, - Computed: true, + Attr_Location: { + Computed: true, + Description: "The region zone of the location.", + Type: schema.TypeString, }, }, }, + Type: schema.TypeList, }, }, } @@ -58,7 +61,7 @@ func dataSourceIBMPIDisasterRecoveryLocation(ctx context.Context, d *schema.Reso return diag.FromErr(err) } - cloudInstanceID := d.Get(helpers.PICloudInstanceId).(string) + cloudInstanceID := d.Get(Arg_CloudInstanceID).(string) drClient := instance.NewIBMPIDisasterRecoveryLocationClient(ctx, sess, cloudInstanceID) drLocationSite, err := drClient.Get() if err != nil { @@ -69,8 +72,8 @@ func dataSourceIBMPIDisasterRecoveryLocation(ctx context.Context, d *schema.Reso for _, i := range drLocationSite.ReplicationSites { if i != nil { l := map[string]interface{}{ - "is_active": i.IsActive, - PIDRLocation: i.Location, + Attr_IsActive: i.IsActive, + Attr_Location: i.Location, } result = append(result, l) } @@ -78,8 +81,8 @@ func dataSourceIBMPIDisasterRecoveryLocation(ctx context.Context, d *schema.Reso var clientgenU, _ = uuid.GenerateUUID() d.SetId(clientgenU) - d.Set(PIDRLocation, drLocationSite.Location) - d.Set("replication_sites", result) + d.Set(Attr_Location, drLocationSite.Location) + d.Set(Attr_ReplicationSites, result) return nil } diff --git a/ibm/service/power/data_source_ibm_pi_disaster_recovery_location_test.go b/ibm/service/power/data_source_ibm_pi_disaster_recovery_location_test.go index 561a451c2a..ef7f68307e 100644 --- a/ibm/service/power/data_source_ibm_pi_disaster_recovery_location_test.go +++ b/ibm/service/power/data_source_ibm_pi_disaster_recovery_location_test.go @@ -30,8 +30,7 @@ func TestAccIBMPIDisasterRecoveryLocationDataSourceBasic(t *testing.T) { func testAccCheckIBMPIDisasterRecoveryLocationDataSourceConfig() string { return fmt.Sprintf(` -data "ibm_pi_disaster_recovery_location" "testacc_disaster_recovery_location" { - pi_cloud_instance_id = "%s" -}`, acc.Pi_cloud_instance_id) - + data "ibm_pi_disaster_recovery_location" "testacc_disaster_recovery_location" { + pi_cloud_instance_id = "%s" + }`, acc.Pi_cloud_instance_id) } diff --git a/ibm/service/power/data_source_ibm_pi_disaster_recovery_locations.go b/ibm/service/power/data_source_ibm_pi_disaster_recovery_locations.go index 49d77fe170..c838348000 100644 --- a/ibm/service/power/data_source_ibm_pi_disaster_recovery_locations.go +++ b/ibm/service/power/data_source_ibm_pi_disaster_recovery_locations.go @@ -6,45 +6,46 @@ package power import ( "context" + "github.com/IBM-Cloud/power-go-client/clients/instance" + "github.com/IBM-Cloud/terraform-provider-ibm/ibm/conns" "github.com/hashicorp/go-uuid" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - - "github.com/IBM-Cloud/power-go-client/clients/instance" - "github.com/IBM-Cloud/terraform-provider-ibm/ibm/conns" ) func DataSourceIBMPIDisasterRecoveryLocations() *schema.Resource { return &schema.Resource{ ReadContext: dataSourceIBMPIDisasterRecoveryLocations, Schema: map[string]*schema.Schema{ - - // Computed Attributes - "disaster_recovery_locations": { + // Attributes + Attr_DisasterRecoveryLocations: { Type: schema.TypeList, Computed: true, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - PIDRLocation: { - Type: schema.TypeString, + Attr_Location: { Computed: true, - Description: "RegionZone of a site", + Description: "The region zone of a site.", + Type: schema.TypeString, }, - "replication_sites": { - Type: schema.TypeList, - Computed: true, + Attr_ReplicationSites: { + Computed: true, + Description: "List of Replication Sites.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "is_active": { - Type: schema.TypeBool, - Computed: true, + Attr_IsActive: { + Computed: true, + Description: "Indicates the location is active or not, true if location is active, otherwise it is false.", + Type: schema.TypeBool, }, - PIDRLocation: { - Type: schema.TypeString, - Computed: true, + Attr_Location: { + Computed: true, + Description: "The region zone of the location.", + Type: schema.TypeString, }, }, }, + Type: schema.TypeList, }, }, }, @@ -72,15 +73,15 @@ func dataSourceIBMPIDisasterRecoveryLocations(ctx context.Context, d *schema.Res for _, j := range i.ReplicationSites { if j != nil { r := map[string]interface{}{ - "is_active": j.IsActive, - PIDRLocation: j.Location, + Attr_IsActive: j.IsActive, + Attr_Location: j.Location, } replicationSites = append(replicationSites, r) } } l := map[string]interface{}{ - "location": i.Location, - "replication_sites": replicationSites, + Attr_Location: i.Location, + Attr_ReplicationSites: replicationSites, } results = append(results, l) } @@ -88,7 +89,7 @@ func dataSourceIBMPIDisasterRecoveryLocations(ctx context.Context, d *schema.Res var clientgenU, _ = uuid.GenerateUUID() d.SetId(clientgenU) - d.Set("disaster_recovery_locations", results) + d.Set(Attr_DisasterRecoveryLocations, results) return nil } diff --git a/ibm/service/power/data_source_ibm_pi_disaster_recovery_locations_test.go b/ibm/service/power/data_source_ibm_pi_disaster_recovery_locations_test.go index 6320f451b3..49b3e3b47f 100644 --- a/ibm/service/power/data_source_ibm_pi_disaster_recovery_locations_test.go +++ b/ibm/service/power/data_source_ibm_pi_disaster_recovery_locations_test.go @@ -27,5 +27,5 @@ func TestAccIBMPIDisasterRecoveryLocationsDataSourceBasic(t *testing.T) { } func testAccCheckIBMPIDisasterRecoveryLocationsDataSourceConfig() string { - return "data \"ibm_pi_disaster_recovery_locations\" \"testacc_disaster_recovery_locations\" {}" + return `data "ibm_pi_disaster_recovery_locations" "testacc_disaster_recovery_locations" {}` } diff --git a/website/docs/d/pi_disaster_recovery_location.html.markdown b/website/docs/d/pi_disaster_recovery_location.html.markdown index 171b827268..60e7415568 100644 --- a/website/docs/d/pi_disaster_recovery_location.html.markdown +++ b/website/docs/d/pi_disaster_recovery_location.html.markdown @@ -1,5 +1,4 @@ --- - subcategory: "Power Systems" layout: "ibm" page_title: "IBM: pi_disaster_recovery_location" @@ -18,20 +17,21 @@ data "ibm_pi_disaster_recovery_location" "ds_disaster_recovery_location" { pi_cloud_instance_id = "49fba6c9-23f8-40bc-9899-aca322ee7d5b" } ``` + **Notes** -* Please find [supported Regions](https://cloud.ibm.com/apidocs/power-cloud#endpoint) for endpoints. -* If a Power cloud instance is provisioned at `lon04`, The provider level attributes should be as follows: - * `region` - `lon` - * `zone` - `lon04` +- Please find [supported Regions](https://cloud.ibm.com/apidocs/power-cloud#endpoint) for endpoints. +- If a Power cloud instance is provisioned at `lon04`, The provider level attributes should be as follows: + - `region` - `lon` + - `zone` - `lon04` - Example usage: +Example usage: ```terraform provider "ibm" { region = "lon" zone = "lon04" } ``` - + ## Argument reference Review the argument references that you can specify for your data source. @@ -41,8 +41,8 @@ Review the argument references that you can specify for your data source. In addition to all argument reference list, you can access the following attribute references after your data source is created. - `location` - (String) The region zone of a site. -- `replication_sites` - List of replication sites. +- `replication_sites` - (List) List of replication sites. Nested scheme for `replication_sites`: - `is_active` - (Boolean) Indicates the location is active or not, `true` if location is active , otherwise it is `false`. - - `location` - (String) The region zone of the location. \ No newline at end of file + - `location` - (String) The region zone of the location. diff --git a/website/docs/d/pi_disaster_recovery_locations.html.markdown b/website/docs/d/pi_disaster_recovery_locations.html.markdown index 412e73a193..6ed0e43817 100644 --- a/website/docs/d/pi_disaster_recovery_locations.html.markdown +++ b/website/docs/d/pi_disaster_recovery_locations.html.markdown @@ -1,5 +1,4 @@ --- - subcategory: "Power Systems" layout: "ibm" page_title: "IBM: pi_disaster_recovery_locations" @@ -16,13 +15,14 @@ The following example retrieves information about the disaster recovery location ```terraform data "ibm_pi_disaster_recovery_locations" "ds_disaster_recovery_locations" {} ``` + **Notes** -* Please find [supported Regions](https://cloud.ibm.com/apidocs/power-cloud#endpoint) for endpoints. -* If a Power cloud instance is provisioned at `lon04`, The provider level attributes should be as follows: - * `region` - `lon` - * `zone` - `lon04` +- Please find [supported Regions](https://cloud.ibm.com/apidocs/power-cloud#endpoint) for endpoints. +- If a Power cloud instance is provisioned at `lon04`, The provider level attributes should be as follows: + - `region` - `lon` + - `zone` - `lon04` - Example usage: +Example usage: ```terraform provider "ibm" { region = "lon" @@ -39,6 +39,6 @@ In addition to all argument reference list, you can access the following attribu - `location` - (String) The region zone of a site. - `replication_sites` - List of Replication Sites. - Nested scheme for `replication_sites`: - - `is_active` - (Boolean) Indicates the location is active or not, `true` if location is active, otherwise it is `false`. - - `location` - (String) The region zone of the location. \ No newline at end of file + Nested scheme for `replication_sites`: + - `is_active` - (Boolean) Indicates the location is active or not, `true` if location is active, otherwise it is `false`. + - `location` - (String) The region zone of the location.