diff --git a/go.mod b/go.mod index de81d322f1..a6ef2a413c 100644 --- a/go.mod +++ b/go.mod @@ -7,7 +7,7 @@ toolchain go1.22.5 require ( github.com/IBM-Cloud/bluemix-go v0.0.0-20240719075425-078fcb3a55be github.com/IBM-Cloud/container-services-go-sdk v0.0.0-20240725064144-454a2ae23113 - github.com/IBM-Cloud/power-go-client v1.7.0 + github.com/IBM-Cloud/power-go-client v1.8.1 github.com/IBM/apigateway-go-sdk v0.0.0-20210714141226-a5d5d49caaca github.com/IBM/appconfiguration-go-admin-sdk v0.3.0 github.com/IBM/appid-management-go-sdk v0.0.0-20210908164609-dd0e0eaf732f diff --git a/go.sum b/go.sum index 4b4ae2f1f9..acb05206bd 100644 --- a/go.sum +++ b/go.sum @@ -118,8 +118,8 @@ github.com/IBM-Cloud/bluemix-go v0.0.0-20240719075425-078fcb3a55be/go.mod h1:/7h github.com/IBM-Cloud/container-services-go-sdk v0.0.0-20240725064144-454a2ae23113 h1:f2Erqfea1dKpaTFagTJM6W/wnD3JGq/Vn9URh8nuRwk= github.com/IBM-Cloud/container-services-go-sdk v0.0.0-20240725064144-454a2ae23113/go.mod h1:xUQL9SGAjoZFd4GNjrjjtEpjpkgU7RFXRyHesbKTjiY= github.com/IBM-Cloud/ibm-cloud-cli-sdk v0.5.3/go.mod h1:RiUvKuHKTBmBApDMUQzBL14pQUGKcx/IioKQPIcRQjs= -github.com/IBM-Cloud/power-go-client v1.7.0 h1:/GuGwPMTKoCZACfnwt7b6wKr4v32q1VO1AMFGNETRN4= -github.com/IBM-Cloud/power-go-client v1.7.0/go.mod h1:9izycYAmNQ+NAdVPXDC3fHYxqWLjlR2YiwqKYveMv5Y= +github.com/IBM-Cloud/power-go-client v1.8.1 h1:tx1aPJmIQrNru1MD1VHGNasGx3eRIs0zzPZ0KvdFQrg= +github.com/IBM-Cloud/power-go-client v1.8.1/go.mod h1:N4RxrsMUvBQjSQ/qPk0iMZ8zK+fZPRTnHi/gTaASw0g= github.com/IBM-Cloud/softlayer-go v1.0.5-tf h1:koUAyF9b6X78lLLruGYPSOmrfY2YcGYKOj/Ug9nbKNw= github.com/IBM-Cloud/softlayer-go v1.0.5-tf/go.mod h1:6HepcfAXROz0Rf63krk5hPZyHT6qyx2MNvYyHof7ik4= github.com/IBM/apigateway-go-sdk v0.0.0-20210714141226-a5d5d49caaca h1:crniVcf+YcmgF03NmmfonXwSQ73oJF+IohFYBwknMxs= diff --git a/ibm/service/power/data_source_ibm_pi_instance_snapshot.go b/ibm/service/power/data_source_ibm_pi_instance_snapshot.go index d57f666b4b..85a6a63ac8 100644 --- a/ibm/service/power/data_source_ibm_pi_instance_snapshot.go +++ b/ibm/service/power/data_source_ibm_pi_instance_snapshot.go @@ -42,6 +42,11 @@ func DataSourceIBMPIInstanceSnapshot() *schema.Resource { Description: "Date of snapshot creation.", Type: schema.TypeString, }, + Attr_CRN: { + Computed: true, + Description: "The CRN of this resource.", + Type: schema.TypeString, + }, Attr_Description: { Computed: true, Description: "The description of the snapshot.", @@ -92,6 +97,9 @@ func dataSourceIBMPIInstanceSnapshotRead(ctx context.Context, d *schema.Resource d.SetId(*snapshotData.SnapshotID) d.Set(Attr_Action, snapshotData.Action) d.Set(Attr_CreationDate, snapshotData.CreationDate.String()) + if snapshotData.Crn != "" { + d.Set(Attr_CRN, snapshotData.Crn) + } d.Set(Attr_Description, snapshotData.Description) d.Set(Attr_LastUpdatedDate, snapshotData.LastUpdateDate.String()) d.Set(Attr_Name, snapshotData.Name) diff --git a/ibm/service/power/data_source_ibm_pi_instance_snapshot_test.go b/ibm/service/power/data_source_ibm_pi_instance_snapshot_test.go index 0ef17d9344..18369bfcda 100644 --- a/ibm/service/power/data_source_ibm_pi_instance_snapshot_test.go +++ b/ibm/service/power/data_source_ibm_pi_instance_snapshot_test.go @@ -13,6 +13,7 @@ import ( ) func TestAccIBMPIInstanceSnapshotDataSource_basic(t *testing.T) { + snapshotResData := "data.ibm_pi_instance_snapshot.testacc_ds_snapshot" resource.Test(t, resource.TestCase{ PreCheck: func() { acc.TestAccPreCheck(t) }, Providers: acc.TestAccProviders, @@ -20,7 +21,7 @@ func TestAccIBMPIInstanceSnapshotDataSource_basic(t *testing.T) { { Config: testAccCheckIBMPIInstanceSnapshotDataSourceConfig(), Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttrSet("data.ibm_pi_instance_snapshot.testacc_ds_snapshot", "id"), + resource.TestCheckResourceAttrSet(snapshotResData, "id"), ), }, }, diff --git a/ibm/service/power/data_source_ibm_pi_instance_snapshots.go b/ibm/service/power/data_source_ibm_pi_instance_snapshots.go index dad1bd7f61..8f9baa8c6b 100644 --- a/ibm/service/power/data_source_ibm_pi_instance_snapshots.go +++ b/ibm/service/power/data_source_ibm_pi_instance_snapshots.go @@ -44,6 +44,11 @@ func DataSourceIBMPIInstanceSnapshots() *schema.Resource { Description: "Date of snapshot creation.", Type: schema.TypeString, }, + Attr_CRN: { + Computed: true, + Description: "The CRN of this resource.", + Type: schema.TypeString, + }, Attr_Description: { Computed: true, Description: "The description of the snapshot.", @@ -122,6 +127,9 @@ func flattenSnapshotsInstances(list []*models.Snapshot) []map[string]interface{} Attr_Status: i.Status, Attr_VolumeSnapshots: i.VolumeSnapshots, } + if i.Crn != "" { + l[Attr_CRN] = i.Crn + } result = append(result, l) } return result diff --git a/ibm/service/power/data_source_ibm_pi_instance_snapshots_test.go b/ibm/service/power/data_source_ibm_pi_instance_snapshots_test.go index f508671d50..df3b994096 100644 --- a/ibm/service/power/data_source_ibm_pi_instance_snapshots_test.go +++ b/ibm/service/power/data_source_ibm_pi_instance_snapshots_test.go @@ -13,6 +13,7 @@ import ( ) func TestAccIBMPIInstanceSnapshotsDataSource_basic(t *testing.T) { + snapshotResData := "data.ibm_pi_instance_snapshots.testacc_ds_snapshots" resource.Test(t, resource.TestCase{ PreCheck: func() { acc.TestAccPreCheck(t) }, Providers: acc.TestAccProviders, @@ -20,7 +21,7 @@ func TestAccIBMPIInstanceSnapshotsDataSource_basic(t *testing.T) { { Config: testAccCheckIBMPIInstanceSnapshotsDataSourceConfig(), Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttrSet("data.ibm_pi_instance_snapshots.testacc_ds_snapshots", "id"), + resource.TestCheckResourceAttrSet(snapshotResData, "id"), ), }, }, diff --git a/ibm/service/power/data_source_ibm_pi_pvm_snapshot.go b/ibm/service/power/data_source_ibm_pi_pvm_snapshot.go index a3e6021a6c..b32378412a 100644 --- a/ibm/service/power/data_source_ibm_pi_pvm_snapshot.go +++ b/ibm/service/power/data_source_ibm_pi_pvm_snapshot.go @@ -50,6 +50,11 @@ func DataSourceIBMPIPVMSnapshot() *schema.Resource { Description: "Date of snapshot creation.", Type: schema.TypeString, }, + Attr_CRN: { + Computed: true, + Description: "The CRN of this resource.", + Type: schema.TypeString, + }, Attr_Description: { Computed: true, Description: "The description of the snapshot.", @@ -129,6 +134,9 @@ func flattenPVMSnapshotInstances(list []*models.Snapshot) []map[string]interface Attr_Status: i.Status, Attr_VolumeSnapshots: i.VolumeSnapshots, } + if i.Crn != "" { + l[Attr_CRN] = i.Crn + } result = append(result, l) } return result diff --git a/ibm/service/power/data_source_ibm_pi_pvm_snapshot_test.go b/ibm/service/power/data_source_ibm_pi_pvm_snapshot_test.go index e5c502c1cb..0394b660a7 100644 --- a/ibm/service/power/data_source_ibm_pi_pvm_snapshot_test.go +++ b/ibm/service/power/data_source_ibm_pi_pvm_snapshot_test.go @@ -13,6 +13,7 @@ import ( ) func TestAccIBMPISnapshotDataSource_basic(t *testing.T) { + snapshotRes := "data.ibm_pi_pvm_snapshots.testacc_pi_snapshots" resource.Test(t, resource.TestCase{ PreCheck: func() { acc.TestAccPreCheck(t) }, Providers: acc.TestAccProviders, @@ -20,7 +21,7 @@ func TestAccIBMPISnapshotDataSource_basic(t *testing.T) { { Config: testAccCheckIBMPISnapshotDataSourceConfig(), Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttrSet("data.ibm_pi_pvm_snapshots.testacc_pi_snapshots", "id"), + resource.TestCheckResourceAttrSet(snapshotRes, "id"), ), }, }, diff --git a/ibm/service/power/ibm_pi_constants.go b/ibm/service/power/ibm_pi_constants.go index 6f3fff8509..248ca86d86 100644 --- a/ibm/service/power/ibm_pi_constants.go +++ b/ibm/service/power/ibm_pi_constants.go @@ -85,6 +85,7 @@ const ( Arg_SysType = "pi_sys_type" Arg_TargetStorageTier = "pi_target_storage_tier" Arg_UserData = "pi_user_data" + Arg_UserTags = "pi_user_tags" Arg_VirtualCoresAssigned = "pi_virtual_cores_assigned" Arg_VirtualOpticalDevice = "pi_virtual_optical_device" Arg_VolumeCloneName = "pi_volume_clone_name" diff --git a/ibm/service/power/resource_ibm_pi_snapshot.go b/ibm/service/power/resource_ibm_pi_snapshot.go index 37b8d232a6..58dbea5981 100644 --- a/ibm/service/power/resource_ibm_pi_snapshot.go +++ b/ibm/service/power/resource_ibm_pi_snapshot.go @@ -58,6 +58,13 @@ func ResourceIBMPISnapshot() *schema.Resource { Type: schema.TypeString, ValidateFunc: validation.NoZeroValues, }, + Arg_UserTags: { + Description: "The user tags attached to this resource.", + Elem: &schema.Schema{Type: schema.TypeString}, + ForceNew: true, + Optional: true, + Type: schema.TypeList, + }, Arg_VolumeIDs: { Description: "A list of volume IDs of the instance that will be part of the snapshot. If none are provided, then all the volumes of the instance will be part of the snapshot.", DiffSuppressFunc: flex.ApplyOnce, @@ -73,6 +80,11 @@ func ResourceIBMPISnapshot() *schema.Resource { Description: "Creation date of the snapshot.", Type: schema.TypeString, }, + Attr_CRN: { + Computed: true, + Description: "The CRN of this resource.", + Type: schema.TypeString, + }, Attr_LastUpdateDate: { Computed: true, Description: "The last updated date of the snapshot.", @@ -123,6 +135,13 @@ func resourceIBMPISnapshotCreate(ctx context.Context, d *schema.ResourceData, me log.Printf("no volumeids provided. Will snapshot the entire instance") } + if v, ok := d.GetOk(Arg_UserTags); ok { + if len(v.([]interface{})) > 0 { + snapshotBody.UserTags = flex.ExpandStringList(v.([]interface{})) + } + + } + snapshotResponse, err := client.CreatePvmSnapShot(instanceid, snapshotBody) if err != nil { log.Printf("[DEBUG] err %s", err) @@ -160,6 +179,9 @@ func resourceIBMPISnapshotRead(ctx context.Context, d *schema.ResourceData, meta d.Set(Arg_SnapShotName, snapshotdata.Name) d.Set(Attr_CreationDate, snapshotdata.CreationDate.String()) + if snapshotdata.Crn != "" { + d.Set(Attr_CRN, snapshotdata.Crn) + } d.Set(Attr_LastUpdateDate, snapshotdata.LastUpdateDate.String()) d.Set(Attr_SnapshotID, *snapshotdata.SnapshotID) d.Set(Attr_Status, snapshotdata.Status) diff --git a/website/docs/d/pi_instance_snapshot.html.markdown b/website/docs/d/pi_instance_snapshot.html.markdown index ff1f7469d0..185fd2b51d 100644 --- a/website/docs/d/pi_instance_snapshot.html.markdown +++ b/website/docs/d/pi_instance_snapshot.html.markdown @@ -42,6 +42,7 @@ In addition to all argument reference list, you can access the following attribu - `action` - (String) Action performed on the instance snapshot. - `creation_date` - (String) Date of snapshot creation. +- `crn` - (String) The CRN of this resource. - `description` - (String) The description of the snapshot. - `last_updated_date` - (String) Date of last update. - `name` - (String) The name of the Power Systems Virtual Machine instance snapshot. diff --git a/website/docs/d/pi_instance_snapshots.html.markdown b/website/docs/d/pi_instance_snapshots.html.markdown index 7d39c0d0d5..d3e117fd23 100644 --- a/website/docs/d/pi_instance_snapshots.html.markdown +++ b/website/docs/d/pi_instance_snapshots.html.markdown @@ -43,6 +43,7 @@ In addition to all argument reference list, you can access the following attribu Nested scheme for `instance_snapshots`: - `action` - (String) Action performed on the instance snapshot. - `creation_date` - (String) Date of snapshot creation. + - `crn` - (String) The CRN of this resource. - `description` - (String) The description of the snapshot. - `id` - (String) The unique identifier of the Power Systems Virtual Machine instance snapshot. - `last_updated_date` - (String) Date of last update. diff --git a/website/docs/d/pi_pvm_snapshots.html.markdown b/website/docs/d/pi_pvm_snapshots.html.markdown index 3a5fa6571a..8956524300 100644 --- a/website/docs/d/pi_pvm_snapshots.html.markdown +++ b/website/docs/d/pi_pvm_snapshots.html.markdown @@ -45,6 +45,7 @@ In addition to all argument reference list, you can access the following attribu Nested scheme for `pvm_snapshots`: - `action` - (String) Action performed on the instance snapshot. - `creation_date` - (String) Date of snapshot creation. + - `crn` - (String) The CRN of this resource. - `description` - (String) The description of the snapshot. - `id` - (String) The unique identifier of the Power Virtual Machine instance snapshot. - `last_updated_date` - (String) Date of last update. diff --git a/website/docs/r/pi_snapshot.html.markdown b/website/docs/r/pi_snapshot.html.markdown index e50423df31..db7df2a599 100644 --- a/website/docs/r/pi_snapshot.html.markdown +++ b/website/docs/r/pi_snapshot.html.markdown @@ -56,6 +56,7 @@ Review the argument references that you can specify for your resource. - `pi_description` - (Optional, String) Description of the PVM instance snapshot. - `pi_instance_name` - (Required, String) The name of the instance you want to take a snapshot of. - `pi_snap_shot_name` - (Required, String) The unique name of the snapshot. +- `pi_user_tags` - (Optional, List) The user tags attached to this resource. - `pi_volume_ids` - (Optional, String) A list of volume IDs of the instance that will be part of the snapshot. If none are provided, then all the volumes of the instance will be part of the snapshot. ## Attribute reference @@ -63,6 +64,7 @@ Review the argument references that you can specify for your resource. In addition to all argument reference list, you can access the following attribute reference after your resource is created. - `creation_date` - (String) Creation date of the snapshot. +- `crn` - (String) The CRN of this resource. - `id` - (String) The unique identifier of the snapshot. The ID is composed of /. - `last_update_date` - (String) The last updated date of the snapshot. - `snapshot_id` - (String) ID of the PVM instance snapshot.