Skip to content

Commit

Permalink
address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
sreekarbvibm committed Nov 21, 2023
1 parent 81772d8 commit 6938129
Show file tree
Hide file tree
Showing 16 changed files with 83 additions and 92 deletions.
30 changes: 16 additions & 14 deletions common/github.com/vpc-go-sdk/vpcv1/vpc_v1.go
Original file line number Diff line number Diff line change
Expand Up @@ -4930,7 +4930,7 @@ func (vpc *VpcV1) ListInstanceProfilesWithContext(ctx context.Context, listInsta
builder := core.NewRequestBuilder(core.GET)
builder = builder.WithContext(ctx)
builder.AddQuery("maturity", "development")
builder.AddQuery("version", "2023-11-20")
builder.AddQuery("version", "2023-11-21")
builder.EnableGzipCompression = vpc.GetEnableGzipCompression()
_, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/instance/profiles`, nil)
if err != nil {
Expand Down Expand Up @@ -4995,7 +4995,7 @@ func (vpc *VpcV1) GetInstanceProfileWithContext(ctx context.Context, getInstance
builder := core.NewRequestBuilder(core.GET)
builder = builder.WithContext(ctx)
builder.AddQuery("maturity", "development")
builder.AddQuery("version", "2023-11-20")
builder.AddQuery("version", "2023-11-21")
builder.EnableGzipCompression = vpc.GetEnableGzipCompression()
_, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/instance/profiles/{name}`, pathParamsMap)
if err != nil {
Expand Down Expand Up @@ -5052,7 +5052,7 @@ func (vpc *VpcV1) ListInstanceTemplatesWithContext(ctx context.Context, listInst
builder := core.NewRequestBuilder(core.GET)
builder = builder.WithContext(ctx)
builder.AddQuery("maturity", "development")
builder.AddQuery("version", "2023-11-20")
builder.AddQuery("version", "2023-11-21")
builder.EnableGzipCompression = vpc.GetEnableGzipCompression()
_, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/instance/templates`, nil)
if err != nil {
Expand Down Expand Up @@ -5117,7 +5117,7 @@ func (vpc *VpcV1) CreateInstanceTemplateWithContext(ctx context.Context, createI
builder := core.NewRequestBuilder(core.POST)
builder = builder.WithContext(ctx)
builder.AddQuery("maturity", "development")
builder.AddQuery("version", "2023-11-20")
builder.AddQuery("version", "2023-11-21")
builder.EnableGzipCompression = vpc.GetEnableGzipCompression()
_, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/instance/templates`, nil)
if err != nil {
Expand Down Expand Up @@ -5239,7 +5239,7 @@ func (vpc *VpcV1) GetInstanceTemplateWithContext(ctx context.Context, getInstanc
builder := core.NewRequestBuilder(core.GET)
builder = builder.WithContext(ctx)
builder.AddQuery("maturity", "development")
builder.AddQuery("version", "2023-11-20")
builder.AddQuery("version", "2023-11-21")
builder.EnableGzipCompression = vpc.GetEnableGzipCompression()
_, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/instance/templates/{id}`, pathParamsMap)
if err != nil {
Expand Down Expand Up @@ -5367,7 +5367,7 @@ func (vpc *VpcV1) ListInstancesWithContext(ctx context.Context, listInstancesOpt
builder := core.NewRequestBuilder(core.GET)
builder = builder.WithContext(ctx)
builder.AddQuery("maturity", "development")
builder.AddQuery("version", "2023-11-20")
builder.AddQuery("version", "2023-11-21")
builder.EnableGzipCompression = vpc.GetEnableGzipCompression()
_, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/instances`, nil)
if err != nil {
Expand Down Expand Up @@ -5478,7 +5478,7 @@ func (vpc *VpcV1) CreateInstanceWithContext(ctx context.Context, createInstanceO
builder := core.NewRequestBuilder(core.POST)
builder = builder.WithContext(ctx)
builder.AddQuery("maturity", "development")
builder.AddQuery("version", "2023-11-20")
builder.AddQuery("version", "2023-11-21")
builder.EnableGzipCompression = vpc.GetEnableGzipCompression()
_, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/instances`, nil)
if err != nil {
Expand Down Expand Up @@ -5605,7 +5605,7 @@ func (vpc *VpcV1) GetInstanceWithContext(ctx context.Context, getInstanceOptions
builder := core.NewRequestBuilder(core.GET)
builder = builder.WithContext(ctx)
builder.AddQuery("maturity", "development")
builder.AddQuery("version", "2023-11-20")
builder.AddQuery("version", "2023-11-21")
builder.EnableGzipCompression = vpc.GetEnableGzipCompression()
_, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/instances/{id}`, pathParamsMap)
if err != nil {
Expand Down Expand Up @@ -5671,7 +5671,7 @@ func (vpc *VpcV1) UpdateInstanceWithContext(ctx context.Context, updateInstanceO
builder := core.NewRequestBuilder(core.PATCH)
builder = builder.WithContext(ctx)
builder.AddQuery("maturity", "development")
builder.AddQuery("version", "2023-11-20")
builder.AddQuery("version", "2023-11-21")
builder.EnableGzipCompression = vpc.GetEnableGzipCompression()
_, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/instances/{id}`, pathParamsMap)
if err != nil {
Expand Down Expand Up @@ -8902,6 +8902,8 @@ func (vpc *VpcV1) ListReservationsWithContext(ctx context.Context, listReservati

builder := core.NewRequestBuilder(core.GET)
builder = builder.WithContext(ctx)
builder.AddQuery("maturity", "development")
builder.AddQuery("version", "2023-11-21")
builder.EnableGzipCompression = vpc.GetEnableGzipCompression()
_, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/reservations`, nil)
if err != nil {
Expand Down Expand Up @@ -8978,7 +8980,7 @@ func (vpc *VpcV1) CreateReservationWithContext(ctx context.Context, createReserv
builder := core.NewRequestBuilder(core.POST)
builder = builder.WithContext(ctx)
builder.AddQuery("maturity", "development")
builder.AddQuery("version", "2023-11-20")
builder.AddQuery("version", "2023-11-21")
builder.EnableGzipCompression = vpc.GetEnableGzipCompression()
_, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/reservations`, nil)
if err != nil {
Expand Down Expand Up @@ -9072,7 +9074,7 @@ func (vpc *VpcV1) DeleteReservationWithContext(ctx context.Context, deleteReserv
builder := core.NewRequestBuilder(core.DELETE)
builder = builder.WithContext(ctx)
builder.AddQuery("maturity", "development")
builder.AddQuery("version", "2023-11-20")
builder.AddQuery("version", "2023-11-21")
builder.EnableGzipCompression = vpc.GetEnableGzipCompression()
_, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/reservations/{id}`, pathParamsMap)
if err != nil {
Expand Down Expand Up @@ -9137,7 +9139,7 @@ func (vpc *VpcV1) GetReservationWithContext(ctx context.Context, getReservationO
builder := core.NewRequestBuilder(core.GET)
builder = builder.WithContext(ctx)
builder.AddQuery("maturity", "development")
builder.AddQuery("version", "2023-11-20")
builder.AddQuery("version", "2023-11-21")
builder.EnableGzipCompression = vpc.GetEnableGzipCompression()
_, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/reservations/{id}`, pathParamsMap)
if err != nil {
Expand Down Expand Up @@ -9203,7 +9205,7 @@ func (vpc *VpcV1) UpdateReservationWithContext(ctx context.Context, updateReserv
builder := core.NewRequestBuilder(core.PATCH)
builder = builder.WithContext(ctx)
builder.AddQuery("maturity", "development")
builder.AddQuery("version", "2023-11-20")
builder.AddQuery("version", "2023-11-21")
builder.EnableGzipCompression = vpc.GetEnableGzipCompression()
_, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/reservations/{id}`, pathParamsMap)
if err != nil {
Expand Down Expand Up @@ -9274,7 +9276,7 @@ func (vpc *VpcV1) ActivateReservationWithContext(ctx context.Context, activateRe
builder := core.NewRequestBuilder(core.POST)
builder = builder.WithContext(ctx)
builder.AddQuery("maturity", "development")
builder.AddQuery("version", "2023-11-20")
builder.AddQuery("version", "2023-11-21")
builder.EnableGzipCompression = vpc.GetEnableGzipCompression()
_, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/reservations/{id}/activate`, pathParamsMap)
if err != nil {
Expand Down
3 changes: 2 additions & 1 deletion ibm/service/vpc/data_source_ibm_is_reservation.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,8 @@ func dataSourceIBMIsReservationRead(context context.Context, d *schema.ResourceD
}
reservation = reservationInfo

} else if v, ok := d.GetOk("name"); ok {
}
if v, ok := d.GetOk("name"); ok {

name := v.(string)
start := ""
Expand Down
6 changes: 3 additions & 3 deletions ibm/service/vpc/data_source_ibm_is_reservation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,13 @@ func testDSCheckIBMISReservationConfig() string {
term = "one_year"
}
profile {
name = "ba2-2x8"
name = "cx2-2x4"
resource_type = "instance_profile"
}
zone = "us-east-3"
zone = "us-south-1"
name = "reservation-name"
}
data "ibm_is_reservation" "ds_res" {
name = ibm_is_reservation.res.id
identifier = ibm_is_reservation.res.id
}`)
}
8 changes: 4 additions & 4 deletions ibm/service/vpc/data_source_ibm_is_reservations.go
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ func dataSourceIBMIsReservationsRead(context context.Context, d *schema.Resource
resourceGroupId := d.Get("resource_group").(string)

start := ""
matchReservations := []vpcv1.Reservation{}
reservations := []vpcv1.Reservation{}

var name string
if v, ok := d.GetOk("name"); ok {
Expand Down Expand Up @@ -272,16 +272,16 @@ func dataSourceIBMIsReservationsRead(context context.Context, d *schema.Resource
break
}
start = flex.GetNext(reservationCollection.Next)
matchReservations = append(matchReservations, reservationCollection.Reservations...)
reservations = append(reservations, reservationCollection.Reservations...)
if start == "" {
break
}
}

d.SetId(dataSourceIBMIsReservationsID(d))

if matchReservations != nil {
err = d.Set("reservations", dataSourceReservationCollectionFlattenReservations(matchReservations))
if reservations != nil {
err = d.Set("reservations", dataSourceReservationCollectionFlattenReservations(reservations))
if err != nil {
return diag.FromErr(fmt.Errorf("[ERROR] Error setting reservations %s", err))
}
Expand Down
28 changes: 16 additions & 12 deletions ibm/service/vpc/resource_ibm_is_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -3779,22 +3779,26 @@ func instanceUpdate(d *schema.ResourceData, meta interface{}) error {
var resAffinityPatch = &vpcv1.InstanceReservationAffinityPatch{}
policy, ok := resAff["policy"]
policyStr := policy.(string)
idStr := ""
if policyStr != "" && ok {
resAffinityPatch.Policy = &policyStr
}
poolIntf, okPool := resAff[isReservationAffinityPool]
if okPool {
pool := poolIntf.([]interface{})[0].(map[string]interface{})
id, okId := pool["id"]
if okId {
idStr, ok := id.(string)
if idStr != "" && ok {
var resAffPool = make([]vpcv1.ReservationIdentityIntf, 1)
resAffPool[0] = &vpcv1.ReservationIdentity{
ID: &idStr,
if d.HasChange(resPool) {
poolIntf, okPool := resAff[isReservationAffinityPool]
if okPool {
pool := poolIntf.([]interface{})[0].(map[string]interface{})
id, okId := pool["id"]
if okId {
idStr, ok = id.(string)
if idStr != "" && ok {
var resAffPool = make([]vpcv1.ReservationIdentityIntf, 1)
resAffPool[0] = &vpcv1.ReservationIdentity{
ID: &idStr,
}
resAffinityPatch.Pool = resAffPool
}
resAffinityPatch.Pool = resAffPool
}

}
}

Expand All @@ -3806,7 +3810,7 @@ func instanceUpdate(d *schema.ResourceData, meta interface{}) error {
return fmt.Errorf("[ERROR] Error calling asPatch with reservation affinity: %s", err)
}
//Detaching the reservation from the reserved instance
if policyStr == "disabled" {
if policyStr == "disabled" && idStr == "" {
resAffMap := mpatch["reservation_affinity"].(map[string]interface{})
resAffMap["pool"] = nil
mpatch["reservation_affinity"] = resAffMap
Expand Down
4 changes: 2 additions & 2 deletions ibm/service/vpc/resource_ibm_is_reservation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
func TestAccIBMISReservation_basic(t *testing.T) {
var reservation string
name := fmt.Sprintf("tfres-name-%d", acctest.RandIntRange(10, 100))
zone := "us-east-3"
zone := "us-south-1"

resource.Test(t, resource.TestCase{
PreCheck: func() { acc.TestAccPreCheck(t) },
Expand Down Expand Up @@ -102,7 +102,7 @@ func testAccCheckIBMISReservationConfig(name, zone string) string {
term = "one_year"
}
profile {
name = "ba2-2x8"
name = "cx2-2x4"
resource_type = "instance_profile"
}
name = "%s"
Expand Down
22 changes: 11 additions & 11 deletions website/docs/d/is_instance.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -238,18 +238,18 @@ In addition to all argument reference list, you can access the following attribu

Nested scheme for `reservation_affinity`:
- `policy` - (String) The reservation affinity policy to use for this virtual server instance.
- `pool` - (List) The pool of reservations available for use by this virtual server instance.
- `pool` - (List) The pool of reservations available for use by this virtual server instance.

Nested `pool` blocks have the following structure:
- `crn` - (String) The CRN for this reservation.
- `deleted` - (List) If present, this property indicates the referenced resource has been deleted, and provides some supplementary information.

Nested `deleted` blocks have the following structure:
- `more_info` - (String) Link to documentation about deleted resources.
- `href` - (String) The URL for this reservation.
- `id` - (String) The unique identifier for this reservation.
- `name` - (string) The name for this reservation. The name is unique across all reservations in the region.
- `resource_type` - (string) The resource type.
Nested `pool` blocks have the following structure:
- `crn` - (String) The CRN for this reservation.
- `deleted` - (List) If present, this property indicates the referenced resource has been deleted, and provides some supplementary information.

Nested `deleted` blocks have the following structure:
- `more_info` - (String) Link to documentation about deleted resources.
- `href` - (String) The URL for this reservation.
- `id` - (String) The unique identifier for this reservation.
- `name` - (string) The name for this reservation. The name is unique across all reservations in the region.
- `resource_type` - (string) The resource type.
- `resource_controller_url` - (String) The URL of the IBM Cloud dashboard that you can use to see details for your instance.
- `resource_group` - (String) The resource group id, where the instance was created.
- `status` - (String) The status of the instance.
Expand Down
5 changes: 3 additions & 2 deletions website/docs/d/is_instance_template.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,10 @@ You can access the following attribute references after your data source is crea
- `reservation_affinity` - (Optional, List) The reservation affinity for the instance
Nested scheme for `reservation_affinity`:
- `policy` - (Optional, String) The reservation affinity policy to use for this virtual server instance.

->**policy**
</br>&#x2022; disabled: Reservations will not be used
</br>&#x2022; manual: Reservations in pool will be available for use
&#x2022; disabled: Reservations will not be used
</br>&#x2022; manual: Reservations in pool will be available for use
- `pool` - (string) The unique identifier for this reservation
- `resource_group` - (String) The resource group ID.
- `total_volume_bandwidth` - (Integer) The amount of bandwidth (in megabits per second) allocated exclusively to instance storage volumes
Expand Down
7 changes: 4 additions & 3 deletions website/docs/d/is_instance_templates.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,10 @@ You can access the following attribute references after your data source is crea
- `reservation_affinity` - (Optional, List) The reservation affinity for the instance
Nested scheme for `reservation_affinity`:
- `policy` - (Optional, String) The reservation affinity policy to use for this virtual server instance.
->**policy**
</br>&#x2022; disabled: Reservations will not be used
</br>&#x2022; manual: Reservations in pool will be available for use
->**policy**
&#x2022; disabled: Reservations will not be used
</br>&#x2022; manual: Reservations in pool will be available for use
- `pool` - (string) The unique identifier for this reservation
- `resource_group` - (String) The resource group ID.
- `total_volume_bandwidth` - (Integer) The amount of bandwidth (in megabits per second) allocated exclusively to instance storage volumes
Expand Down
23 changes: 12 additions & 11 deletions website/docs/d/is_instances.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -168,20 +168,21 @@ In addition to all argument reference list, you can access the following attribu
- `name` - (string) The name for this reservation. The name is unique across all reservations in the region.
- `resource_type` - (string) The resource type.
- `reservation_affinity`- (List) The instance reservation affinity.
Nested scheme for `reservation_affinity`:
- `policy` - (String) The reservation affinity policy to use for this virtual server instance.
- `pool` - (List) The pool of reservations available for use by this virtual server instance.

Nested `pool` blocks have the following structure:
- `crn` - (String) The CRN for this reservation.
- `deleted` - (List) If present, this property indicates the referenced resource has been deleted, and provides some supplementary information.
Nested scheme for `reservation_affinity`:
- `policy` - (String) The reservation affinity policy to use for this virtual server instance.
- `pool` - (List) The pool of reservations available for use by this virtual server instance.

Nested `pool` blocks have the following structure:
- `crn` - (String) The CRN for this reservation.
- `deleted` - (List) If present, this property indicates the referenced resource has been deleted, and provides some supplementary information.

Nested `deleted` blocks have the following structure:
- `more_info` - (String) Link to documentation about deleted resources.
- `href` - (String) The URL for this reservation.
- `id` - (String) The unique identifier for this reservation.
- `name` - (string) The name for this reservation. The name is unique across all reservations in the region.
- `resource_type` - (string) The resource type.
- `more_info` - (String) Link to documentation about deleted resources.
- `href` - (String) The URL for this reservation.
- `id` - (String) The unique identifier for this reservation.
- `name` - (string) The name for this reservation. The name is unique across all reservations in the region.
- `resource_type` - (string) The resource type.
- `status` - (String) The status of the instance.
- `status_reasons` - (List) Array of reasons for the current status.

Expand Down
2 changes: 1 addition & 1 deletion website/docs/d/is_reservation.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ VPC infrastructure services are a regional specific based endpoint, by default t

```terraform
provider "ibm" {
region = "eu-gb"
region = "us-south"
}
```

Expand Down
2 changes: 1 addition & 1 deletion website/docs/d/is_reservations.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ VPC infrastructure services are a regional specific based endpoint, by default t

```terraform
provider "ibm" {
region = "eu-gb"
region = "us-south"
}
```

Expand Down
Loading

0 comments on commit 6938129

Please sign in to comment.