diff --git a/ibm/provider/provider.go b/ibm/provider/provider.go index fd7fcbe7af..d992bbd2d4 100644 --- a/ibm/provider/provider.go +++ b/ibm/provider/provider.go @@ -602,6 +602,8 @@ func Provider() *schema.Provider { "ibm_pi_cloud_connections": power.DataSourceIBMPICloudConnections(), "ibm_pi_cloud_instance": power.DataSourceIBMPICloudInstance(), "ibm_pi_console_languages": power.DataSourceIBMPIInstanceConsoleLanguages(), + "ibm_pi_datacenter": power.DataSourceIBMPIDatacenter(), + "ibm_pi_datacenters": power.DataSourceIBMPIDatacenters(), "ibm_pi_dhcp": power.DataSourceIBMPIDhcp(), "ibm_pi_dhcps": power.DataSourceIBMPIDhcps(), "ibm_pi_disaster_recovery_location": power.DataSourceIBMPIDisasterRecoveryLocation(), @@ -609,11 +611,11 @@ func Provider() *schema.Provider { "ibm_pi_image": power.DataSourceIBMPIImage(), "ibm_pi_images": power.DataSourceIBMPIImages(), "ibm_pi_instance": power.DataSourceIBMPIInstance(), - "ibm_pi_instances": power.DataSourceIBMPIInstances(), "ibm_pi_instance_ip": power.DataSourceIBMPIInstanceIP(), "ibm_pi_instance_snapshot": power.DataSourceIBMPIInstanceSnapshot(), "ibm_pi_instance_snapshots": power.DataSourceIBMPIInstanceSnapshots(), "ibm_pi_instance_volumes": power.DataSourceIBMPIInstanceVolumes(), + "ibm_pi_instances": power.DataSourceIBMPIInstances(), "ibm_pi_key": power.DataSourceIBMPIKey(), "ibm_pi_keys": power.DataSourceIBMPIKeys(), "ibm_pi_network": power.DataSourceIBMPINetwork(), @@ -636,20 +638,18 @@ func Provider() *schema.Provider { "ibm_pi_tenant": power.DataSourceIBMPITenant(), "ibm_pi_volume": power.DataSourceIBMPIVolume(), "ibm_pi_volume_clone": power.DataSourceIBMPIVolumeClone(), + "ibm_pi_volume_flash_copy_mappings": power.DataSourceIBMPIVolumeFlashCopyMappings(), "ibm_pi_volume_group": power.DataSourceIBMPIVolumeGroup(), - "ibm_pi_volume_groups": power.DataSourceIBMPIVolumeGroups(), "ibm_pi_volume_group_details": power.DataSourceIBMPIVolumeGroupDetails(), - "ibm_pi_volume_groups_details": power.DataSourceIBMPIVolumeGroupsDetails(), - "ibm_pi_volume_group_storage_details": power.DataSourceIBMPIVolumeGroupStorageDetails(), "ibm_pi_volume_group_remote_copy_relationships": power.DataSourceIBMPIVolumeGroupRemoteCopyRelationships(), - "ibm_pi_volume_flash_copy_mappings": power.DataSourceIBMPIVolumeFlashCopyMappings(), - "ibm_pi_volume_remote_copy_relationship": power.DataSourceIBMPIVolumeRemoteCopyRelationship(), - "ibm_pi_volume_onboardings": power.DataSourceIBMPIVolumeOnboardings(), + "ibm_pi_volume_group_storage_details": power.DataSourceIBMPIVolumeGroupStorageDetails(), + "ibm_pi_volume_groups": power.DataSourceIBMPIVolumeGroups(), + "ibm_pi_volume_groups_details": power.DataSourceIBMPIVolumeGroupsDetails(), "ibm_pi_volume_onboarding": power.DataSourceIBMPIVolumeOnboarding(), + "ibm_pi_volume_onboardings": power.DataSourceIBMPIVolumeOnboardings(), + "ibm_pi_volume_remote_copy_relationship": power.DataSourceIBMPIVolumeRemoteCopyRelationship(), "ibm_pi_workspace": power.DatasourceIBMPIWorkspace(), "ibm_pi_workspaces": power.DatasourceIBMPIWorkspaces(), - "ibm_pi_datacenter": power.DataSourceIBMPIDatacenter(), - "ibm_pi_datacenters": power.DataSourceIBMPIDatacenters(), // Added for private dns zones diff --git a/ibm/service/power/data_source_ibm_pi_workspace.go b/ibm/service/power/data_source_ibm_pi_workspace.go index 0864470922..e71df4a6a1 100644 --- a/ibm/service/power/data_source_ibm_pi_workspace.go +++ b/ibm/service/power/data_source_ibm_pi_workspace.go @@ -36,9 +36,45 @@ func DatasourceIBMPIWorkspace() *schema.Resource { Type: schema.TypeMap, }, Attr_WorkspaceDetails: { - Computed: true, - Description: "Workspace information.", - Type: schema.TypeMap, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + Attr_CreationDate: { + Computed: true, + Description: "Workspace creation date.", + Type: schema.TypeString, + }, + Attr_CRN: { + Computed: true, + Description: "The Workspace crn.", + Type: schema.TypeString, + }, + Attr_PowerEdgeRouter: { + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + Attr_MigrationStatus: { + Computed: true, + Description: "The migration status of a Power Edge Router.", + Type: schema.TypeString, + }, + Attr_State: { + Computed: true, + Description: "The state of a Power Edge Router.", + Type: schema.TypeString, + }, + Attr_Type: { + Computed: true, + Description: "The Power Edge Router type.", + Type: schema.TypeString, + }, + }, + }, + Type: schema.TypeList, + }, + }, + }, + Type: schema.TypeList, }, Attr_WorkspaceLocation: { Computed: true, @@ -81,17 +117,29 @@ func dataSourceIBMPIWorkspaceRead(ctx context.Context, d *schema.ResourceData, m d.Set(Attr_WorkspaceStatus, wsData.Status) d.Set(Attr_WorkspaceType, wsData.Type) d.Set(Attr_WorkspaceCapabilities, wsData.Capabilities) - wsdetails := map[string]interface{}{ - Attr_CreationDate: wsData.Details.CreationDate.String(), - Attr_CRN: *wsData.Details.Crn, + + wsDetails := []map[string]interface{}{} + detailsData := make(map[string]interface{}) + detailsData[Attr_CreationDate] = wsData.Details.CreationDate.String() + detailsData[Attr_CRN] = *wsData.Details.Crn + + if wsData.Details.PowerEdgeRouter != nil { + wsPowerEdge := map[string]interface{}{ + Attr_MigrationStatus: wsData.Details.PowerEdgeRouter.MigrationStatus, + Attr_State: *wsData.Details.PowerEdgeRouter.State, + Attr_Type: *wsData.Details.PowerEdgeRouter.Type, + } + detailsData[Attr_PowerEdgeRouter] = []map[string]interface{}{wsPowerEdge} + wsDetails = append(wsDetails, detailsData) } - d.Set(Attr_WorkspaceDetails, flex.Flatten(wsdetails)) - wslocation := map[string]interface{}{ + + d.Set(Attr_WorkspaceDetails, wsDetails) + wsLocation := map[string]interface{}{ Attr_Region: *wsData.Location.Region, Attr_Type: wsData.Location.Type, Attr_URL: wsData.Location.URL, } - d.Set(Attr_WorkspaceLocation, flex.Flatten(wslocation)) + d.Set(Attr_WorkspaceLocation, flex.Flatten(wsLocation)) d.SetId(*wsData.ID) return nil } diff --git a/ibm/service/power/data_source_ibm_pi_workspaces.go b/ibm/service/power/data_source_ibm_pi_workspaces.go index 1208562947..58851a7bec 100644 --- a/ibm/service/power/data_source_ibm_pi_workspaces.go +++ b/ibm/service/power/data_source_ibm_pi_workspaces.go @@ -41,9 +41,45 @@ func DatasourceIBMPIWorkspaces() *schema.Resource { Type: schema.TypeMap, }, Attr_WorkspaceDetails: { - Computed: true, - Description: "Workspace information.", - Type: schema.TypeMap, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + Attr_CreationDate: { + Computed: true, + Description: "Workspace creation date.", + Type: schema.TypeString, + }, + Attr_CRN: { + Computed: true, + Description: "The Workspace crn.", + Type: schema.TypeString, + }, + Attr_PowerEdgeRouter: { + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + Attr_MigrationStatus: { + Computed: true, + Description: "The migration status of a Power Edge Router.", + Type: schema.TypeString, + }, + Attr_State: { + Computed: true, + Description: "The state of a Power Edge Router.", + Type: schema.TypeString, + }, + Attr_Type: { + Computed: true, + Description: "The Power Edge Router type.", + Type: schema.TypeString, + }, + }, + }, + Type: schema.TypeList, + }, + }, + }, + Type: schema.TypeList, }, Attr_WorkspaceID: { Computed: true, @@ -76,6 +112,7 @@ func DatasourceIBMPIWorkspaces() *schema.Resource { }, } } + func dataSourceIBMPIWorkspacesRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { sess, err := meta.(conns.ClientSession).IBMPISession() if err != nil { @@ -91,13 +128,25 @@ func dataSourceIBMPIWorkspacesRead(ctx context.Context, d *schema.ResourceData, workspaces := make([]map[string]interface{}, 0, len(wsData.Workspaces)) for _, ws := range wsData.Workspaces { if ws != nil { + wsDetails := []map[string]interface{}{} + detailsData := make(map[string]interface{}) + detailsData[Attr_CreationDate] = ws.Details.CreationDate.String() + detailsData[Attr_CRN] = *ws.Details.Crn + + if ws.Details.PowerEdgeRouter != nil { + wsPowerEdge := map[string]interface{}{ + Attr_MigrationStatus: ws.Details.PowerEdgeRouter.MigrationStatus, + Attr_State: *ws.Details.PowerEdgeRouter.State, + Attr_Type: *ws.Details.PowerEdgeRouter.Type, + } + detailsData[Attr_PowerEdgeRouter] = []map[string]interface{}{wsPowerEdge} + wsDetails = append(wsDetails, detailsData) + } + workspace := map[string]interface{}{ Attr_WorkspaceCapabilities: ws.Capabilities, - Attr_WorkspaceDetails: map[string]interface{}{ - Attr_CreationDate: ws.Details.CreationDate.String(), - Attr_CRN: *ws.Details.Crn, - }, - Attr_WorkspaceID: ws.ID, + Attr_WorkspaceDetails: wsDetails, + Attr_WorkspaceID: ws.ID, Attr_WorkspaceLocation: map[string]interface{}{ Attr_Region: *ws.Location.Region, Attr_Type: ws.Location.Type, diff --git a/ibm/service/power/ibm_pi_constants.go b/ibm/service/power/ibm_pi_constants.go index 9992df0c38..85ba00d787 100644 --- a/ibm/service/power/ibm_pi_constants.go +++ b/ibm/service/power/ibm_pi_constants.go @@ -137,6 +137,7 @@ const ( Attr_Memory = "memory" Attr_Message = "message" Attr_Metered = "metered" + Attr_MigrationStatus = "migration_status" Attr_Min = "min" Attr_MinMem = "minmem" Attr_MinProc = "minproc" @@ -160,6 +161,7 @@ const ( Attr_PoolName = "pool_name" Attr_Port = "port" Attr_PortID = "portid" + Attr_PowerEdgeRouter = "power_edge_router" Attr_PrimaryRole = "primary_role" Attr_Processors = "processors" Attr_ProcType = "proctype" diff --git a/website/docs/d/pi_workspace.html.markdown b/website/docs/d/pi_workspace.html.markdown index 6134e2a18c..ad02cb7d2a 100644 --- a/website/docs/d/pi_workspace.html.markdown +++ b/website/docs/d/pi_workspace.html.markdown @@ -44,11 +44,17 @@ In addition to all argument reference listed, you can access the following attri Some of `pi_workspace_capabilities` are: - `cloud-connections`, `power-edge-router`, `power-vpn-connections`, `transit-gateway-connection` -- `pi_workspace_details` - (Map) Workspace information. +- `pi_workspace_details` - (List) Workspace information. Nested schema for `pi_workspace_details`: - `creation_date` - (String) Date of workspace creation. - `crn` - (String) Workspace crn. + - `power_edge_router` - (List) Power Edge Router information. + + Nested schema for `power_edge_router`: + - `migration_status` - (String) The migration status of a Power Edge Router. + - `status` - (String) The state of a Power Edge Router. + - `type` - (String) The Power Edge Router type. - `pi_workspace_location` - (Map) Workspace location. Nested schema for `Workspace location`: diff --git a/website/docs/d/pi_workspaces.html.markdown b/website/docs/d/pi_workspaces.html.markdown index 0c5f6e5af2..268a6bc2dd 100644 --- a/website/docs/d/pi_workspaces.html.markdown +++ b/website/docs/d/pi_workspaces.html.markdown @@ -45,11 +45,17 @@ In addition to all argument reference listed, you can access the following attri Some of `pi_workspace_capabilities` are: - `cloud-connections`, `power-edge-router`, `power-vpn-connections`, `transit-gateway-connection` - - `pi_workspace_details` - (Map) Workspace information. + - `pi_workspace_details` - (List) Workspace information. Nested schema for `pi_workspace_details`: - `creation_date` - (String) Date of workspace creation. - `crn` - (String) Workspace crn. + - `power_edge_router` - (List) Power Edge Router information. + + Nested schema for `power_edge_router`: + - `migration_status` - (String) The migration status of a Power Edge Router. + - `status` - (String) The state of a Power Edge Router. + - `type` - (String) The Power Edge Router type. - `pi_workspace_id` - (String) Workspace ID. - `pi_workspace_location` - (Map) Workspace location.