From 96871e396d3ff135dc45c0aad2d75df12668ac43 Mon Sep 17 00:00:00 2001 From: Ujjwal Kumar <78945437+ujjwal-ibm@users.noreply.github.com> Date: Wed, 6 Dec 2023 19:43:23 +0530 Subject: [PATCH] feat(spec): updated the sdk as per the api spec released on 2023-12-06 (#83) Signed-off-by: Ujjwal Kumar --- README.md | 8 +- common/version.go | 2 +- vpcv1/vpc_v1.go | 2367 ++++++++++++++++++++++++--- vpcv1/vpc_v1_examples_test.go | 135 +- vpcv1/vpc_v1_test.go | 2863 ++++++++++++++++++++++++++------- 5 files changed, 4556 insertions(+), 819 deletions(-) diff --git a/README.md b/README.md index 133052a..d6fb30b 100644 --- a/README.md +++ b/README.md @@ -3,11 +3,11 @@ ![GitHub go.mod Go version](https://img.shields.io/github/go-mod/go-version/IBM/vpc-go-sdk) [![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release) -# IBM Cloud VPC Go SDK Version 0.44.0 +# IBM Cloud VPC Go SDK Version 0.45.0 Go client library to interact with the various [IBM Cloud VPC Services APIs](https://cloud.ibm.com/apidocs?category=vpc). **Note:** Given the current version of all VPC SDKs across supported languages and the current VPC API specification, we retracted the vpc-go-sdk version 1.x to version v0.6.0, which had the same features as v1.0.1. -Consider using v0.44.0 from now on. Refrain from using commands like `go get -u ..` and `go get ..@latest` on go 1.14 and lower as you will not get the latest release. +Consider using v0.45.0 from now on. Refrain from using commands like `go get -u ..` and `go get ..@latest` on go 1.14 and lower as you will not get the latest release. This SDK uses [Semantic Versioning](https://semver.org), and as such there may be backward-incompatible changes for any new `0.y.z` version. ## Table of Contents @@ -64,7 +64,7 @@ Use this command to download and install the VPC Go SDK service to allow your Go use it: ``` -go get github.com/IBM/vpc-go-sdk@v0.44.0 +go get github.com/IBM/vpc-go-sdk@v0.45.0 ``` @@ -90,7 +90,7 @@ to your `Gopkg.toml` file. Here is an example: ``` [[constraint]] name = "github.com/IBM/vpc-go-sdk/" - version = "0.44.0" + version = "0.45.0" ``` Then run `dep ensure`. diff --git a/common/version.go b/common/version.go index 3c8b8f1..67fb889 100644 --- a/common/version.go +++ b/common/version.go @@ -1,4 +1,4 @@ package common // Version of the SDK -const Version = "0.44.0" +const Version = "0.45.0" diff --git a/vpcv1/vpc_v1.go b/vpcv1/vpc_v1.go index 5099c5c..c69c8a4 100644 --- a/vpcv1/vpc_v1.go +++ b/vpcv1/vpc_v1.go @@ -38,7 +38,7 @@ import ( // VpcV1 : The IBM Cloud Virtual Private Cloud (VPC) API can be used to programmatically provision and manage virtual // server instances, along with subnets, volumes, load balancers, and more. // -// API Version: 2023-11-22 +// API Version: 2023-12-06 type VpcV1 struct { Service *core.BaseService @@ -46,8 +46,8 @@ type VpcV1 struct { // `2`. generation *int64 - // The API version, in format `YYYY-MM-DD`. For the API behavior documented here, specify any date between `2023-10-10` - // and `2023-11-22`. + // The API version, in format `YYYY-MM-DD`. For the API behavior documented here, specify any date between `2023-12-05` + // and `2023-12-06`. Version *string } @@ -63,8 +63,8 @@ type VpcV1Options struct { URL string Authenticator core.Authenticator - // The API version, in format `YYYY-MM-DD`. For the API behavior documented here, specify any date between `2023-10-10` - // and `2023-11-22`. + // The API version, in format `YYYY-MM-DD`. For the API behavior documented here, specify any date between `2023-12-05` + // and `2023-12-06`. Version *string } @@ -122,7 +122,7 @@ func NewVpcV1(options *VpcV1Options) (service *VpcV1, err error) { } if options.Version == nil { - options.Version = core.StringPtr("2023-10-24") + options.Version = core.StringPtr("2023-12-05") } service = &VpcV1{ @@ -6638,8 +6638,13 @@ func (vpc *VpcV1) GetInstanceNetworkInterfaceFloatingIPWithContext(ctx context.C // AddInstanceNetworkInterfaceFloatingIP : Associate a floating IP with an instance network interface // This request associates the specified floating IP with the specified instance network interface, replacing any -// existing association. For this request to succeed, the existing floating IP must not be required by another resource, -// such as a public gateway. A request body is not required, and if provided, is ignored. +// existing association. +// +// The existing floating IP must: +// - not be required by another resource, such as a public gateway +// - be in the same `zone` as the instance +// +// A request body is not required, and if provided, is ignored. func (vpc *VpcV1) AddInstanceNetworkInterfaceFloatingIP(addInstanceNetworkInterfaceFloatingIPOptions *AddInstanceNetworkInterfaceFloatingIPOptions) (result *FloatingIP, response *core.DetailedResponse, err error) { return vpc.AddInstanceNetworkInterfaceFloatingIPWithContext(context.Background(), addInstanceNetworkInterfaceFloatingIPOptions) } @@ -9909,12 +9914,12 @@ func (vpc *VpcV1) ListBackupPoliciesWithContext(ctx context.Context, listBackupP // CreateBackupPolicy : Create a backup policy // This request creates a new backup policy from a backup policy prototype object. The prototype object is structured in // the same way as a retrieved backup policy, and contains the information necessary to create the new backup policy. -func (vpc *VpcV1) CreateBackupPolicy(createBackupPolicyOptions *CreateBackupPolicyOptions) (result *BackupPolicy, response *core.DetailedResponse, err error) { +func (vpc *VpcV1) CreateBackupPolicy(createBackupPolicyOptions *CreateBackupPolicyOptions) (result BackupPolicyIntf, response *core.DetailedResponse, err error) { return vpc.CreateBackupPolicyWithContext(context.Background(), createBackupPolicyOptions) } // CreateBackupPolicyWithContext is an alternate form of the CreateBackupPolicy method which supports a Context parameter -func (vpc *VpcV1) CreateBackupPolicyWithContext(ctx context.Context, createBackupPolicyOptions *CreateBackupPolicyOptions) (result *BackupPolicy, response *core.DetailedResponse, err error) { +func (vpc *VpcV1) CreateBackupPolicyWithContext(ctx context.Context, createBackupPolicyOptions *CreateBackupPolicyOptions) (result BackupPolicyIntf, response *core.DetailedResponse, err error) { err = core.ValidateNotNil(createBackupPolicyOptions, "createBackupPolicyOptions cannot be nil") if err != nil { return @@ -9946,26 +9951,7 @@ func (vpc *VpcV1) CreateBackupPolicyWithContext(ctx context.Context, createBacku builder.AddQuery("version", fmt.Sprint(*vpc.Version)) builder.AddQuery("generation", fmt.Sprint(*vpc.generation)) - body := make(map[string]interface{}) - if createBackupPolicyOptions.MatchUserTags != nil { - body["match_user_tags"] = createBackupPolicyOptions.MatchUserTags - } - if createBackupPolicyOptions.MatchResourceTypes != nil { - body["match_resource_types"] = createBackupPolicyOptions.MatchResourceTypes - } - if createBackupPolicyOptions.Name != nil { - body["name"] = createBackupPolicyOptions.Name - } - if createBackupPolicyOptions.Plans != nil { - body["plans"] = createBackupPolicyOptions.Plans - } - if createBackupPolicyOptions.ResourceGroup != nil { - body["resource_group"] = createBackupPolicyOptions.ResourceGroup - } - if createBackupPolicyOptions.Scope != nil { - body["scope"] = createBackupPolicyOptions.Scope - } - _, err = builder.SetBodyContentJSON(body) + _, err = builder.SetBodyContentJSON(createBackupPolicyOptions.BackupPolicyPrototype) if err != nil { return } @@ -10525,12 +10511,12 @@ func (vpc *VpcV1) UpdateBackupPolicyPlanWithContext(ctx context.Context, updateB // // If the request is accepted, the backup policy `status` will be set to `deleting`. Once deletion processing completes, // the backup policy will no longer be retrievable. -func (vpc *VpcV1) DeleteBackupPolicy(deleteBackupPolicyOptions *DeleteBackupPolicyOptions) (result *BackupPolicy, response *core.DetailedResponse, err error) { +func (vpc *VpcV1) DeleteBackupPolicy(deleteBackupPolicyOptions *DeleteBackupPolicyOptions) (result BackupPolicyIntf, response *core.DetailedResponse, err error) { return vpc.DeleteBackupPolicyWithContext(context.Background(), deleteBackupPolicyOptions) } // DeleteBackupPolicyWithContext is an alternate form of the DeleteBackupPolicy method which supports a Context parameter -func (vpc *VpcV1) DeleteBackupPolicyWithContext(ctx context.Context, deleteBackupPolicyOptions *DeleteBackupPolicyOptions) (result *BackupPolicy, response *core.DetailedResponse, err error) { +func (vpc *VpcV1) DeleteBackupPolicyWithContext(ctx context.Context, deleteBackupPolicyOptions *DeleteBackupPolicyOptions) (result BackupPolicyIntf, response *core.DetailedResponse, err error) { err = core.ValidateNotNil(deleteBackupPolicyOptions, "deleteBackupPolicyOptions cannot be nil") if err != nil { return @@ -10591,12 +10577,12 @@ func (vpc *VpcV1) DeleteBackupPolicyWithContext(ctx context.Context, deleteBacku // GetBackupPolicy : Retrieve a backup policy // This request retrieves a single backup policy specified by the identifier in the URL. -func (vpc *VpcV1) GetBackupPolicy(getBackupPolicyOptions *GetBackupPolicyOptions) (result *BackupPolicy, response *core.DetailedResponse, err error) { +func (vpc *VpcV1) GetBackupPolicy(getBackupPolicyOptions *GetBackupPolicyOptions) (result BackupPolicyIntf, response *core.DetailedResponse, err error) { return vpc.GetBackupPolicyWithContext(context.Background(), getBackupPolicyOptions) } // GetBackupPolicyWithContext is an alternate form of the GetBackupPolicy method which supports a Context parameter -func (vpc *VpcV1) GetBackupPolicyWithContext(ctx context.Context, getBackupPolicyOptions *GetBackupPolicyOptions) (result *BackupPolicy, response *core.DetailedResponse, err error) { +func (vpc *VpcV1) GetBackupPolicyWithContext(ctx context.Context, getBackupPolicyOptions *GetBackupPolicyOptions) (result BackupPolicyIntf, response *core.DetailedResponse, err error) { err = core.ValidateNotNil(getBackupPolicyOptions, "getBackupPolicyOptions cannot be nil") if err != nil { return @@ -10655,12 +10641,12 @@ func (vpc *VpcV1) GetBackupPolicyWithContext(ctx context.Context, getBackupPolic // UpdateBackupPolicy : Update a backup policy // This request updates a backup policy with the information in a provided backup policy patch. The backup policy patch // object is structured in the same way as a retrieved backup policy and contains only the information to be updated. -func (vpc *VpcV1) UpdateBackupPolicy(updateBackupPolicyOptions *UpdateBackupPolicyOptions) (result *BackupPolicy, response *core.DetailedResponse, err error) { +func (vpc *VpcV1) UpdateBackupPolicy(updateBackupPolicyOptions *UpdateBackupPolicyOptions) (result BackupPolicyIntf, response *core.DetailedResponse, err error) { return vpc.UpdateBackupPolicyWithContext(context.Background(), updateBackupPolicyOptions) } // UpdateBackupPolicyWithContext is an alternate form of the UpdateBackupPolicy method which supports a Context parameter -func (vpc *VpcV1) UpdateBackupPolicyWithContext(ctx context.Context, updateBackupPolicyOptions *UpdateBackupPolicyOptions) (result *BackupPolicy, response *core.DetailedResponse, err error) { +func (vpc *VpcV1) UpdateBackupPolicyWithContext(ctx context.Context, updateBackupPolicyOptions *UpdateBackupPolicyOptions) (result BackupPolicyIntf, response *core.DetailedResponse, err error) { err = core.ValidateNotNil(updateBackupPolicyOptions, "updateBackupPolicyOptions cannot be nil") if err != nil { return @@ -12145,8 +12131,13 @@ func (vpc *VpcV1) GetBareMetalServerNetworkInterfaceFloatingIPWithContext(ctx co // AddBareMetalServerNetworkInterfaceFloatingIP : Associate a floating IP with a bare metal server network interface // This request associates the specified floating IP with the specified bare metal server network interface. If // `enable_infrastructure_nat` is `false`, this adds the IP to any existing associations. If `enable_infrastructure_nat` -// is `true`, this replaces any existing association. For this request to succeed, the existing floating IP must not be -// required by another resource, such as a public gateway. A request body is not required, and if provided, is ignored. +// is `true`, this replaces any existing association. +// +// The existing floating IP must: +// - not be required by another resource, such as a public gateway +// - be in the same `zone` as the bare metal server +// +// A request body is not required, and if provided, is ignored. func (vpc *VpcV1) AddBareMetalServerNetworkInterfaceFloatingIP(addBareMetalServerNetworkInterfaceFloatingIPOptions *AddBareMetalServerNetworkInterfaceFloatingIPOptions) (result *FloatingIP, response *core.DetailedResponse, err error) { return vpc.AddBareMetalServerNetworkInterfaceFloatingIPWithContext(context.Background(), addBareMetalServerNetworkInterfaceFloatingIPOptions) } @@ -13215,6 +13206,348 @@ func (vpc *VpcV1) UpdateVolumeWithContext(ctx context.Context, updateVolumeOptio return } +// ListSnapshotConsistencyGroups : List all snapshot consistency groups +// This request lists all snapshot consistency groups in the region. A snapshot consistency group is a collection of +// individual snapshots taken at the same time. +func (vpc *VpcV1) ListSnapshotConsistencyGroups(listSnapshotConsistencyGroupsOptions *ListSnapshotConsistencyGroupsOptions) (result *SnapshotConsistencyGroupCollection, response *core.DetailedResponse, err error) { + return vpc.ListSnapshotConsistencyGroupsWithContext(context.Background(), listSnapshotConsistencyGroupsOptions) +} + +// ListSnapshotConsistencyGroupsWithContext is an alternate form of the ListSnapshotConsistencyGroups method which supports a Context parameter +func (vpc *VpcV1) ListSnapshotConsistencyGroupsWithContext(ctx context.Context, listSnapshotConsistencyGroupsOptions *ListSnapshotConsistencyGroupsOptions) (result *SnapshotConsistencyGroupCollection, response *core.DetailedResponse, err error) { + err = core.ValidateStruct(listSnapshotConsistencyGroupsOptions, "listSnapshotConsistencyGroupsOptions") + if err != nil { + return + } + + builder := core.NewRequestBuilder(core.GET) + builder = builder.WithContext(ctx) + builder.EnableGzipCompression = vpc.GetEnableGzipCompression() + _, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/snapshot_consistency_groups`, nil) + if err != nil { + return + } + + for headerName, headerValue := range listSnapshotConsistencyGroupsOptions.Headers { + builder.AddHeader(headerName, headerValue) + } + + sdkHeaders := common.GetSdkHeaders("vpc", "V1", "ListSnapshotConsistencyGroups") + for headerName, headerValue := range sdkHeaders { + builder.AddHeader(headerName, headerValue) + } + builder.AddHeader("Accept", "application/json") + + builder.AddQuery("version", fmt.Sprint(*vpc.Version)) + builder.AddQuery("generation", fmt.Sprint(*vpc.generation)) + if listSnapshotConsistencyGroupsOptions.Start != nil { + builder.AddQuery("start", fmt.Sprint(*listSnapshotConsistencyGroupsOptions.Start)) + } + if listSnapshotConsistencyGroupsOptions.Limit != nil { + builder.AddQuery("limit", fmt.Sprint(*listSnapshotConsistencyGroupsOptions.Limit)) + } + if listSnapshotConsistencyGroupsOptions.ResourceGroupID != nil { + builder.AddQuery("resource_group.id", fmt.Sprint(*listSnapshotConsistencyGroupsOptions.ResourceGroupID)) + } + if listSnapshotConsistencyGroupsOptions.Name != nil { + builder.AddQuery("name", fmt.Sprint(*listSnapshotConsistencyGroupsOptions.Name)) + } + if listSnapshotConsistencyGroupsOptions.Sort != nil { + builder.AddQuery("sort", fmt.Sprint(*listSnapshotConsistencyGroupsOptions.Sort)) + } + if listSnapshotConsistencyGroupsOptions.BackupPolicyPlanID != nil { + builder.AddQuery("backup_policy_plan.id", fmt.Sprint(*listSnapshotConsistencyGroupsOptions.BackupPolicyPlanID)) + } + + request, err := builder.Build() + if err != nil { + return + } + + var rawResponse map[string]json.RawMessage + response, err = vpc.Service.Request(request, &rawResponse) + if err != nil { + return + } + if rawResponse != nil { + err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalSnapshotConsistencyGroupCollection) + if err != nil { + return + } + response.Result = result + } + + return +} + +// CreateSnapshotConsistencyGroup : Create a snapshot consistency group +// This request creates a new snapshot consistency group from a snapshot consistency group object. The prototype object +// is structured in the same way as a retrieved consistency group, and contains the information necessary to provision +// the new snapshot consistency group. +func (vpc *VpcV1) CreateSnapshotConsistencyGroup(createSnapshotConsistencyGroupOptions *CreateSnapshotConsistencyGroupOptions) (result *SnapshotConsistencyGroup, response *core.DetailedResponse, err error) { + return vpc.CreateSnapshotConsistencyGroupWithContext(context.Background(), createSnapshotConsistencyGroupOptions) +} + +// CreateSnapshotConsistencyGroupWithContext is an alternate form of the CreateSnapshotConsistencyGroup method which supports a Context parameter +func (vpc *VpcV1) CreateSnapshotConsistencyGroupWithContext(ctx context.Context, createSnapshotConsistencyGroupOptions *CreateSnapshotConsistencyGroupOptions) (result *SnapshotConsistencyGroup, response *core.DetailedResponse, err error) { + err = core.ValidateNotNil(createSnapshotConsistencyGroupOptions, "createSnapshotConsistencyGroupOptions cannot be nil") + if err != nil { + return + } + err = core.ValidateStruct(createSnapshotConsistencyGroupOptions, "createSnapshotConsistencyGroupOptions") + if err != nil { + return + } + + builder := core.NewRequestBuilder(core.POST) + builder = builder.WithContext(ctx) + builder.EnableGzipCompression = vpc.GetEnableGzipCompression() + _, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/snapshot_consistency_groups`, nil) + if err != nil { + return + } + + for headerName, headerValue := range createSnapshotConsistencyGroupOptions.Headers { + builder.AddHeader(headerName, headerValue) + } + + sdkHeaders := common.GetSdkHeaders("vpc", "V1", "CreateSnapshotConsistencyGroup") + for headerName, headerValue := range sdkHeaders { + builder.AddHeader(headerName, headerValue) + } + builder.AddHeader("Accept", "application/json") + builder.AddHeader("Content-Type", "application/json") + + builder.AddQuery("version", fmt.Sprint(*vpc.Version)) + builder.AddQuery("generation", fmt.Sprint(*vpc.generation)) + + _, err = builder.SetBodyContentJSON(createSnapshotConsistencyGroupOptions.SnapshotConsistencyGroupPrototype) + if err != nil { + return + } + + request, err := builder.Build() + if err != nil { + return + } + + var rawResponse map[string]json.RawMessage + response, err = vpc.Service.Request(request, &rawResponse) + if err != nil { + return + } + if rawResponse != nil { + err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalSnapshotConsistencyGroup) + if err != nil { + return + } + response.Result = result + } + + return +} + +// DeleteSnapshotConsistencyGroup : Delete a snapshot consistency group +// This request deletes snapshot consistency group. This operation cannot be reversed. If the +// `delete_snapshots_on_delete` property is `true`, all snapshots in the consistency group will also be deleted. +func (vpc *VpcV1) DeleteSnapshotConsistencyGroup(deleteSnapshotConsistencyGroupOptions *DeleteSnapshotConsistencyGroupOptions) (result *SnapshotConsistencyGroup, response *core.DetailedResponse, err error) { + return vpc.DeleteSnapshotConsistencyGroupWithContext(context.Background(), deleteSnapshotConsistencyGroupOptions) +} + +// DeleteSnapshotConsistencyGroupWithContext is an alternate form of the DeleteSnapshotConsistencyGroup method which supports a Context parameter +func (vpc *VpcV1) DeleteSnapshotConsistencyGroupWithContext(ctx context.Context, deleteSnapshotConsistencyGroupOptions *DeleteSnapshotConsistencyGroupOptions) (result *SnapshotConsistencyGroup, response *core.DetailedResponse, err error) { + err = core.ValidateNotNil(deleteSnapshotConsistencyGroupOptions, "deleteSnapshotConsistencyGroupOptions cannot be nil") + if err != nil { + return + } + err = core.ValidateStruct(deleteSnapshotConsistencyGroupOptions, "deleteSnapshotConsistencyGroupOptions") + if err != nil { + return + } + + pathParamsMap := map[string]string{ + "id": *deleteSnapshotConsistencyGroupOptions.ID, + } + + builder := core.NewRequestBuilder(core.DELETE) + builder = builder.WithContext(ctx) + builder.EnableGzipCompression = vpc.GetEnableGzipCompression() + _, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/snapshot_consistency_groups/{id}`, pathParamsMap) + if err != nil { + return + } + + for headerName, headerValue := range deleteSnapshotConsistencyGroupOptions.Headers { + builder.AddHeader(headerName, headerValue) + } + + sdkHeaders := common.GetSdkHeaders("vpc", "V1", "DeleteSnapshotConsistencyGroup") + for headerName, headerValue := range sdkHeaders { + builder.AddHeader(headerName, headerValue) + } + builder.AddHeader("Accept", "application/json") + + builder.AddQuery("version", fmt.Sprint(*vpc.Version)) + builder.AddQuery("generation", fmt.Sprint(*vpc.generation)) + + request, err := builder.Build() + if err != nil { + return + } + + var rawResponse map[string]json.RawMessage + response, err = vpc.Service.Request(request, &rawResponse) + if err != nil { + return + } + if rawResponse != nil { + err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalSnapshotConsistencyGroup) + if err != nil { + return + } + response.Result = result + } + + return +} + +// GetSnapshotConsistencyGroup : Retrieve a snapshot consistency group +// This request retrieves a single snapshot consistency group specified by the identifier in the URL. +func (vpc *VpcV1) GetSnapshotConsistencyGroup(getSnapshotConsistencyGroupOptions *GetSnapshotConsistencyGroupOptions) (result *SnapshotConsistencyGroup, response *core.DetailedResponse, err error) { + return vpc.GetSnapshotConsistencyGroupWithContext(context.Background(), getSnapshotConsistencyGroupOptions) +} + +// GetSnapshotConsistencyGroupWithContext is an alternate form of the GetSnapshotConsistencyGroup method which supports a Context parameter +func (vpc *VpcV1) GetSnapshotConsistencyGroupWithContext(ctx context.Context, getSnapshotConsistencyGroupOptions *GetSnapshotConsistencyGroupOptions) (result *SnapshotConsistencyGroup, response *core.DetailedResponse, err error) { + err = core.ValidateNotNil(getSnapshotConsistencyGroupOptions, "getSnapshotConsistencyGroupOptions cannot be nil") + if err != nil { + return + } + err = core.ValidateStruct(getSnapshotConsistencyGroupOptions, "getSnapshotConsistencyGroupOptions") + if err != nil { + return + } + + pathParamsMap := map[string]string{ + "id": *getSnapshotConsistencyGroupOptions.ID, + } + + builder := core.NewRequestBuilder(core.GET) + builder = builder.WithContext(ctx) + builder.EnableGzipCompression = vpc.GetEnableGzipCompression() + _, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/snapshot_consistency_groups/{id}`, pathParamsMap) + if err != nil { + return + } + + for headerName, headerValue := range getSnapshotConsistencyGroupOptions.Headers { + builder.AddHeader(headerName, headerValue) + } + + sdkHeaders := common.GetSdkHeaders("vpc", "V1", "GetSnapshotConsistencyGroup") + for headerName, headerValue := range sdkHeaders { + builder.AddHeader(headerName, headerValue) + } + builder.AddHeader("Accept", "application/json") + + builder.AddQuery("version", fmt.Sprint(*vpc.Version)) + builder.AddQuery("generation", fmt.Sprint(*vpc.generation)) + + request, err := builder.Build() + if err != nil { + return + } + + var rawResponse map[string]json.RawMessage + response, err = vpc.Service.Request(request, &rawResponse) + if err != nil { + return + } + if rawResponse != nil { + err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalSnapshotConsistencyGroup) + if err != nil { + return + } + response.Result = result + } + + return +} + +// UpdateSnapshotConsistencyGroup : Update a snapshot consistency group +// This request updates a snapshot consistency group with the information in a provided snapshot consistency group +// patch. The snapshot consistency group patch object is structured in the same way as a retrieved snapshot consistency +// group and contains only the information to be updated. +func (vpc *VpcV1) UpdateSnapshotConsistencyGroup(updateSnapshotConsistencyGroupOptions *UpdateSnapshotConsistencyGroupOptions) (result *SnapshotConsistencyGroup, response *core.DetailedResponse, err error) { + return vpc.UpdateSnapshotConsistencyGroupWithContext(context.Background(), updateSnapshotConsistencyGroupOptions) +} + +// UpdateSnapshotConsistencyGroupWithContext is an alternate form of the UpdateSnapshotConsistencyGroup method which supports a Context parameter +func (vpc *VpcV1) UpdateSnapshotConsistencyGroupWithContext(ctx context.Context, updateSnapshotConsistencyGroupOptions *UpdateSnapshotConsistencyGroupOptions) (result *SnapshotConsistencyGroup, response *core.DetailedResponse, err error) { + err = core.ValidateNotNil(updateSnapshotConsistencyGroupOptions, "updateSnapshotConsistencyGroupOptions cannot be nil") + if err != nil { + return + } + err = core.ValidateStruct(updateSnapshotConsistencyGroupOptions, "updateSnapshotConsistencyGroupOptions") + if err != nil { + return + } + + pathParamsMap := map[string]string{ + "id": *updateSnapshotConsistencyGroupOptions.ID, + } + + builder := core.NewRequestBuilder(core.PATCH) + builder = builder.WithContext(ctx) + builder.EnableGzipCompression = vpc.GetEnableGzipCompression() + _, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/snapshot_consistency_groups/{id}`, pathParamsMap) + if err != nil { + return + } + + for headerName, headerValue := range updateSnapshotConsistencyGroupOptions.Headers { + builder.AddHeader(headerName, headerValue) + } + + sdkHeaders := common.GetSdkHeaders("vpc", "V1", "UpdateSnapshotConsistencyGroup") + for headerName, headerValue := range sdkHeaders { + builder.AddHeader(headerName, headerValue) + } + builder.AddHeader("Accept", "application/json") + builder.AddHeader("Content-Type", "application/merge-patch+json") + if updateSnapshotConsistencyGroupOptions.IfMatch != nil { + builder.AddHeader("If-Match", fmt.Sprint(*updateSnapshotConsistencyGroupOptions.IfMatch)) + } + + builder.AddQuery("version", fmt.Sprint(*vpc.Version)) + builder.AddQuery("generation", fmt.Sprint(*vpc.generation)) + + _, err = builder.SetBodyContentJSON(updateSnapshotConsistencyGroupOptions.SnapshotConsistencyGroupPatch) + if err != nil { + return + } + + request, err := builder.Build() + if err != nil { + return + } + + var rawResponse map[string]json.RawMessage + response, err = vpc.Service.Request(request, &rawResponse) + if err != nil { + return + } + if rawResponse != nil { + err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalSnapshotConsistencyGroup) + if err != nil { + return + } + response.Result = result + } + + return +} + // DeleteSnapshots : Delete a filtered collection of snapshots // This request deletes all snapshots created from a specific source volume. func (vpc *VpcV1) DeleteSnapshots(deleteSnapshotsOptions *DeleteSnapshotsOptions) (response *core.DetailedResponse, err error) { @@ -13357,6 +13690,12 @@ func (vpc *VpcV1) ListSnapshotsWithContext(ctx context.Context, listSnapshotsOpt if listSnapshotsOptions.ClonesZoneName != nil { builder.AddQuery("clones[].zone.name", fmt.Sprint(*listSnapshotsOptions.ClonesZoneName)) } + if listSnapshotsOptions.SnapshotConsistencyGroupID != nil { + builder.AddQuery("snapshot_consistency_group.id", fmt.Sprint(*listSnapshotsOptions.SnapshotConsistencyGroupID)) + } + if listSnapshotsOptions.SnapshotConsistencyGroupCRN != nil { + builder.AddQuery("snapshot_consistency_group.crn", fmt.Sprint(*listSnapshotsOptions.SnapshotConsistencyGroupCRN)) + } request, err := builder.Build() if err != nil { @@ -24262,6 +24601,9 @@ func (addressPrefixPatch *AddressPrefixPatch) AsPatch() (_patch map[string]inter } // BackupPolicy : BackupPolicy struct +// Models which "extend" this model: +// - BackupPolicyMatchResourceTypeInstance +// - BackupPolicyMatchResourceTypeVolume type BackupPolicy struct { // The date and time that the backup policy was created. CreatedAt *strfmt.DateTime `json:"created_at" validate:"required"` @@ -24299,13 +24641,13 @@ type BackupPolicy struct { // The lifecycle state of the backup policy. LifecycleState *string `json:"lifecycle_state" validate:"required"` - // The resource types this backup policy applies to. Resources that have both a matching type and a matching user tag + // The resource type this backup policy applies to. Resources that have both a matching type and a matching user tag // will be subject to the backup policy. // - // The enumerated values for this property will expand in the future. When processing this property, check for and log + // The enumerated values for this property may expand in the future. When processing this property, check for and log // unknown values. Optionally halt processing and surface the error, or bypass the backup policy on which the // unexpected property value was encountered. - MatchResourceTypes []string `json:"match_resource_types" validate:"required"` + MatchResourceType *string `json:"match_resource_type" validate:"required"` // The user tags this backup policy applies to. Resources that have both a matching user tag and a matching type will // be subject to the backup policy. @@ -24325,6 +24667,15 @@ type BackupPolicy struct { // The scope for this backup policy. Scope BackupPolicyScopeIntf `json:"scope" validate:"required"` + + // The included content for backups created using this policy: + // - `boot_volume`: Include the instance's boot volume. + // - `data_volumes`: Include the instance's data volumes. + // + // The enumerated values for this property may expand in the future. When processing this property, check for and log + // unknown values. Optionally halt processing and surface the error, or bypass the backup policy on which the + // unexpected property value was encountered. + IncludedContent []string `json:"included_content,omitempty"` } // Constants associated with the BackupPolicy.HealthState property. @@ -24354,10 +24705,16 @@ const ( BackupPolicyLifecycleStateWaitingConst = "waiting" ) -// Constants associated with the BackupPolicy.MatchResourceTypes property. -// The resource type. +// Constants associated with the BackupPolicy.MatchResourceType property. +// The resource type this backup policy applies to. Resources that have both a matching type and a matching user tag +// will be subject to the backup policy. +// +// The enumerated values for this property may expand in the future. When processing this property, check for and log +// unknown values. Optionally halt processing and surface the error, or bypass the backup policy on which the unexpected +// property value was encountered. const ( - BackupPolicyMatchResourceTypesVolumeConst = "volume" + BackupPolicyMatchResourceTypeInstanceConst = "instance" + BackupPolicyMatchResourceTypeVolumeConst = "volume" ) // Constants associated with the BackupPolicy.ResourceType property. @@ -24366,6 +24723,21 @@ const ( BackupPolicyResourceTypeBackupPolicyConst = "backup_policy" ) +// Constants associated with the BackupPolicy.IncludedContent property. +// An item to include. +const ( + BackupPolicyIncludedContentBootVolumeConst = "boot_volume" + BackupPolicyIncludedContentDataVolumesConst = "data_volumes" +) + +func (*BackupPolicy) isaBackupPolicy() bool { + return true +} + +type BackupPolicyIntf interface { + isaBackupPolicy() bool +} + // UnmarshalBackupPolicy unmarshals an instance of BackupPolicy from the specified map of raw messages. func UnmarshalBackupPolicy(m map[string]json.RawMessage, result interface{}) (err error) { obj := new(BackupPolicy) @@ -24401,7 +24773,7 @@ func UnmarshalBackupPolicy(m map[string]json.RawMessage, result interface{}) (er if err != nil { return } - err = core.UnmarshalPrimitive(m, "match_resource_types", &obj.MatchResourceTypes) + err = core.UnmarshalPrimitive(m, "match_resource_type", &obj.MatchResourceType) if err != nil { return } @@ -24429,6 +24801,10 @@ func UnmarshalBackupPolicy(m map[string]json.RawMessage, result interface{}) (er if err != nil { return } + err = core.UnmarshalPrimitive(m, "included_content", &obj.IncludedContent) + if err != nil { + return + } reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) return } @@ -24436,7 +24812,7 @@ func UnmarshalBackupPolicy(m map[string]json.RawMessage, result interface{}) (er // BackupPolicyCollection : BackupPolicyCollection struct type BackupPolicyCollection struct { // Collection of backup policies. - BackupPolicies []BackupPolicy `json:"backup_policies" validate:"required"` + BackupPolicies []BackupPolicyIntf `json:"backup_policies" validate:"required"` // A link to the first page of resources. First *BackupPolicyCollectionFirst `json:"first" validate:"required"` @@ -24807,6 +25183,7 @@ func UnmarshalBackupPolicyJobCollectionNext(m map[string]json.RawMessage, result // [deleted](https://cloud.ibm.com/apidocs/vpc#deleted-resources)). // Models which "extend" this model: // - BackupPolicyJobSourceVolumeReference +// - BackupPolicyJobSourceInstanceReference type BackupPolicyJobSource struct { // The CRN for this volume. CRN *string `json:"crn,omitempty"` @@ -24931,6 +25308,11 @@ func UnmarshalBackupPolicyJobStatusReason(m map[string]json.RawMessage, result i // BackupPolicyPatch : BackupPolicyPatch struct type BackupPolicyPatch struct { + // The included content for backups created using this policy: + // - `boot_volume`: Include the instance's boot volume. + // - `data_volumes`: Include the instance's data volumes. + IncludedContent []string `json:"included_content,omitempty"` + // The user tags this backup policy will apply to (replacing any existing tags). Resources that have both a matching // user tag and a matching type will be subject to the backup policy. MatchUserTags []string `json:"match_user_tags,omitempty"` @@ -24939,9 +25321,20 @@ type BackupPolicyPatch struct { Name *string `json:"name,omitempty"` } +// Constants associated with the BackupPolicyPatch.IncludedContent property. +// An item to include. +const ( + BackupPolicyPatchIncludedContentBootVolumeConst = "boot_volume" + BackupPolicyPatchIncludedContentDataVolumesConst = "data_volumes" +) + // UnmarshalBackupPolicyPatch unmarshals an instance of BackupPolicyPatch from the specified map of raw messages. func UnmarshalBackupPolicyPatch(m map[string]json.RawMessage, result interface{}) (err error) { obj := new(BackupPolicyPatch) + err = core.UnmarshalPrimitive(m, "included_content", &obj.IncludedContent) + if err != nil { + return + } err = core.UnmarshalPrimitive(m, "match_user_tags", &obj.MatchUserTags) if err != nil { return @@ -25584,6 +25977,99 @@ func UnmarshalBackupPolicyPlanRemoteRegionPolicyPrototype(m map[string]json.RawM return } +// BackupPolicyPrototype : BackupPolicyPrototype struct +// Models which "extend" this model: +// - BackupPolicyPrototypeBackupPolicyMatchResourceTypeVolumePrototype +// - BackupPolicyPrototypeBackupPolicyMatchResourceTypeInstancePrototype +type BackupPolicyPrototype struct { + // The resource type this backup policy will apply to. Resources that have both a matching type and a matching user tag + // will be subject to the backup policy. + MatchResourceType *string `json:"match_resource_type" validate:"required"` + + // The user tags this backup policy will apply to. Resources that have both a matching user tag and a matching type + // will be subject to the backup policy. + MatchUserTags []string `json:"match_user_tags" validate:"required"` + + // The name for this backup policy. The name must not be used by another backup policy in the region. If unspecified, + // the name will be a hyphenated list of randomly-selected words. + Name *string `json:"name,omitempty"` + + // The prototype objects for backup plans to be created for this backup policy. + Plans []BackupPolicyPlanPrototype `json:"plans,omitempty"` + + // The resource group to use. If unspecified, the account's [default resource + // group](https://cloud.ibm.com/apidocs/resource-manager#introduction) will be used. + ResourceGroup ResourceGroupIdentityIntf `json:"resource_group,omitempty"` + + // The scope to use for this backup policy. + // + // If unspecified, the policy will be scoped to the account. + Scope BackupPolicyScopePrototypeIntf `json:"scope,omitempty"` + + // The included content for backups created using this policy: + // - `boot_volume`: Include the instance's boot volume. + // - `data_volumes`: Include the instance's data volumes. + IncludedContent []string `json:"included_content,omitempty"` +} + +// Constants associated with the BackupPolicyPrototype.MatchResourceType property. +// The resource type this backup policy will apply to. Resources that have both a matching type and a matching user tag +// will be subject to the backup policy. +const ( + BackupPolicyPrototypeMatchResourceTypeInstanceConst = "instance" + BackupPolicyPrototypeMatchResourceTypeVolumeConst = "volume" +) + +// Constants associated with the BackupPolicyPrototype.IncludedContent property. +// An item to include. +const ( + BackupPolicyPrototypeIncludedContentBootVolumeConst = "boot_volume" + BackupPolicyPrototypeIncludedContentDataVolumesConst = "data_volumes" +) + +func (*BackupPolicyPrototype) isaBackupPolicyPrototype() bool { + return true +} + +type BackupPolicyPrototypeIntf interface { + isaBackupPolicyPrototype() bool +} + +// UnmarshalBackupPolicyPrototype unmarshals an instance of BackupPolicyPrototype from the specified map of raw messages. +func UnmarshalBackupPolicyPrototype(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(BackupPolicyPrototype) + err = core.UnmarshalPrimitive(m, "match_resource_type", &obj.MatchResourceType) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "match_user_tags", &obj.MatchUserTags) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "name", &obj.Name) + if err != nil { + return + } + err = core.UnmarshalModel(m, "plans", &obj.Plans, UnmarshalBackupPolicyPlanPrototype) + if err != nil { + return + } + err = core.UnmarshalModel(m, "resource_group", &obj.ResourceGroup, UnmarshalResourceGroupIdentity) + if err != nil { + return + } + err = core.UnmarshalModel(m, "scope", &obj.Scope, UnmarshalBackupPolicyScopePrototype) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "included_content", &obj.IncludedContent) + if err != nil { + return + } + reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) + return +} + // BackupPolicyScope : The scope for this backup policy. // Models which "extend" this model: // - BackupPolicyScopeEnterpriseReference @@ -28631,80 +29117,23 @@ func UnmarshalCloudObjectStorageObjectReference(m map[string]json.RawMessage, re // CreateBackupPolicyOptions : The CreateBackupPolicy options. type CreateBackupPolicyOptions struct { - // The user tags this backup policy will apply to. Resources that have both a matching user tag and a matching type - // will be subject to the backup policy. - MatchUserTags []string `json:"match_user_tags" validate:"required"` - - // The resource types this backup policy will apply to. Resources that have both a matching type and a matching user - // tag will be subject to the backup policy. - MatchResourceTypes []string `json:"match_resource_types,omitempty"` - - // The name for this backup policy. The name must not be used by another backup policy in the region. If unspecified, - // the name will be a hyphenated list of randomly-selected words. - Name *string `json:"name,omitempty"` - - // The prototype objects for backup plans to be created for this backup policy. - Plans []BackupPolicyPlanPrototype `json:"plans,omitempty"` - - // The resource group to use. If unspecified, the account's [default resource - // group](https://cloud.ibm.com/apidocs/resource-manager#introduction) will be used. - ResourceGroup ResourceGroupIdentityIntf `json:"resource_group,omitempty"` - - // The scope to use for this backup policy. - // - // If unspecified, the policy will be scoped to the account. - Scope BackupPolicyScopePrototypeIntf `json:"scope,omitempty"` + // The backup policy prototype object. + BackupPolicyPrototype BackupPolicyPrototypeIntf `json:"BackupPolicyPrototype" validate:"required"` // Allows users to set headers on API requests Headers map[string]string } -// Constants associated with the CreateBackupPolicyOptions.MatchResourceTypes property. -// The resource type. -const ( - CreateBackupPolicyOptionsMatchResourceTypesVolumeConst = "volume" -) - // NewCreateBackupPolicyOptions : Instantiate CreateBackupPolicyOptions -func (*VpcV1) NewCreateBackupPolicyOptions(matchUserTags []string) *CreateBackupPolicyOptions { +func (*VpcV1) NewCreateBackupPolicyOptions(backupPolicyPrototype BackupPolicyPrototypeIntf) *CreateBackupPolicyOptions { return &CreateBackupPolicyOptions{ - MatchUserTags: matchUserTags, + BackupPolicyPrototype: backupPolicyPrototype, } } -// SetMatchUserTags : Allow user to set MatchUserTags -func (_options *CreateBackupPolicyOptions) SetMatchUserTags(matchUserTags []string) *CreateBackupPolicyOptions { - _options.MatchUserTags = matchUserTags - return _options -} - -// SetMatchResourceTypes : Allow user to set MatchResourceTypes -func (_options *CreateBackupPolicyOptions) SetMatchResourceTypes(matchResourceTypes []string) *CreateBackupPolicyOptions { - _options.MatchResourceTypes = matchResourceTypes - return _options -} - -// SetName : Allow user to set Name -func (_options *CreateBackupPolicyOptions) SetName(name string) *CreateBackupPolicyOptions { - _options.Name = core.StringPtr(name) - return _options -} - -// SetPlans : Allow user to set Plans -func (_options *CreateBackupPolicyOptions) SetPlans(plans []BackupPolicyPlanPrototype) *CreateBackupPolicyOptions { - _options.Plans = plans - return _options -} - -// SetResourceGroup : Allow user to set ResourceGroup -func (_options *CreateBackupPolicyOptions) SetResourceGroup(resourceGroup ResourceGroupIdentityIntf) *CreateBackupPolicyOptions { - _options.ResourceGroup = resourceGroup - return _options -} - -// SetScope : Allow user to set Scope -func (_options *CreateBackupPolicyOptions) SetScope(scope BackupPolicyScopePrototypeIntf) *CreateBackupPolicyOptions { - _options.Scope = scope +// SetBackupPolicyPrototype : Allow user to set BackupPolicyPrototype +func (_options *CreateBackupPolicyOptions) SetBackupPolicyPrototype(backupPolicyPrototype BackupPolicyPrototypeIntf) *CreateBackupPolicyOptions { + _options.BackupPolicyPrototype = backupPolicyPrototype return _options } @@ -31488,6 +31917,34 @@ func (options *CreateSnapshotCloneOptions) SetHeaders(param map[string]string) * return options } +// CreateSnapshotConsistencyGroupOptions : The CreateSnapshotConsistencyGroup options. +type CreateSnapshotConsistencyGroupOptions struct { + // The snapshot consistency group prototype object. + SnapshotConsistencyGroupPrototype SnapshotConsistencyGroupPrototypeIntf `json:"SnapshotConsistencyGroupPrototype" validate:"required"` + + // Allows users to set headers on API requests + Headers map[string]string +} + +// NewCreateSnapshotConsistencyGroupOptions : Instantiate CreateSnapshotConsistencyGroupOptions +func (*VpcV1) NewCreateSnapshotConsistencyGroupOptions(snapshotConsistencyGroupPrototype SnapshotConsistencyGroupPrototypeIntf) *CreateSnapshotConsistencyGroupOptions { + return &CreateSnapshotConsistencyGroupOptions{ + SnapshotConsistencyGroupPrototype: snapshotConsistencyGroupPrototype, + } +} + +// SetSnapshotConsistencyGroupPrototype : Allow user to set SnapshotConsistencyGroupPrototype +func (_options *CreateSnapshotConsistencyGroupOptions) SetSnapshotConsistencyGroupPrototype(snapshotConsistencyGroupPrototype SnapshotConsistencyGroupPrototypeIntf) *CreateSnapshotConsistencyGroupOptions { + _options.SnapshotConsistencyGroupPrototype = snapshotConsistencyGroupPrototype + return _options +} + +// SetHeaders : Allow user to set Headers +func (options *CreateSnapshotConsistencyGroupOptions) SetHeaders(param map[string]string) *CreateSnapshotConsistencyGroupOptions { + options.Headers = param + return options +} + // CreateSnapshotOptions : The CreateSnapshot options. type CreateSnapshotOptions struct { // The snapshot prototype object. @@ -36291,6 +36748,34 @@ func (options *DeleteSnapshotCloneOptions) SetHeaders(param map[string]string) * return options } +// DeleteSnapshotConsistencyGroupOptions : The DeleteSnapshotConsistencyGroup options. +type DeleteSnapshotConsistencyGroupOptions struct { + // The snapshot consistency group identifier. + ID *string `json:"id" validate:"required,ne="` + + // Allows users to set headers on API requests + Headers map[string]string +} + +// NewDeleteSnapshotConsistencyGroupOptions : Instantiate DeleteSnapshotConsistencyGroupOptions +func (*VpcV1) NewDeleteSnapshotConsistencyGroupOptions(id string) *DeleteSnapshotConsistencyGroupOptions { + return &DeleteSnapshotConsistencyGroupOptions{ + ID: core.StringPtr(id), + } +} + +// SetID : Allow user to set ID +func (_options *DeleteSnapshotConsistencyGroupOptions) SetID(id string) *DeleteSnapshotConsistencyGroupOptions { + _options.ID = core.StringPtr(id) + return _options +} + +// SetHeaders : Allow user to set Headers +func (options *DeleteSnapshotConsistencyGroupOptions) SetHeaders(param map[string]string) *DeleteSnapshotConsistencyGroupOptions { + options.Headers = param + return options +} + // DeleteSnapshotOptions : The DeleteSnapshot options. type DeleteSnapshotOptions struct { // The snapshot identifier. @@ -37872,7 +38357,9 @@ type FloatingIPPatch struct { // resource is: // // - an instance network interface - // - a bare metal server network interface with `enable_infrastructure_nat` set to `true`. + // - a bare metal server network interface with `enable_infrastructure_nat` set to `true` + // + // Specify `null` to remove an existing binding. Target FloatingIPTargetPatchIntf `json:"target,omitempty"` } @@ -38112,7 +38599,9 @@ func UnmarshalFloatingIPTarget(m map[string]json.RawMessage, result interface{}) // The target resource must not already have a floating IP bound to it if the target resource is: // // - an instance network interface -// - a bare metal server network interface with `enable_infrastructure_nat` set to `true`. +// - a bare metal server network interface with `enable_infrastructure_nat` set to `true` +// +// Specify `null` to remove an existing binding. // Models which "extend" this model: // - FloatingIPTargetPatchBareMetalServerNetworkInterfaceIdentity // - FloatingIPTargetPatchNetworkInterfaceIdentity @@ -40668,6 +41157,34 @@ func (options *GetSnapshotCloneOptions) SetHeaders(param map[string]string) *Get return options } +// GetSnapshotConsistencyGroupOptions : The GetSnapshotConsistencyGroup options. +type GetSnapshotConsistencyGroupOptions struct { + // The snapshot consistency group identifier. + ID *string `json:"id" validate:"required,ne="` + + // Allows users to set headers on API requests + Headers map[string]string +} + +// NewGetSnapshotConsistencyGroupOptions : Instantiate GetSnapshotConsistencyGroupOptions +func (*VpcV1) NewGetSnapshotConsistencyGroupOptions(id string) *GetSnapshotConsistencyGroupOptions { + return &GetSnapshotConsistencyGroupOptions{ + ID: core.StringPtr(id), + } +} + +// SetID : Allow user to set ID +func (_options *GetSnapshotConsistencyGroupOptions) SetID(id string) *GetSnapshotConsistencyGroupOptions { + _options.ID = core.StringPtr(id) + return _options +} + +// SetHeaders : Allow user to set Headers +func (options *GetSnapshotConsistencyGroupOptions) SetHeaders(param map[string]string) *GetSnapshotConsistencyGroupOptions { + options.Headers = param + return options +} + // GetSnapshotOptions : The GetSnapshot options. type GetSnapshotOptions struct { // The snapshot identifier. @@ -52191,6 +52708,89 @@ func (options *ListSnapshotClonesOptions) SetHeaders(param map[string]string) *L return options } +// ListSnapshotConsistencyGroupsOptions : The ListSnapshotConsistencyGroups options. +type ListSnapshotConsistencyGroupsOptions struct { + // A server-provided token determining what resource to start the page on. + Start *string `json:"start,omitempty"` + + // The number of resources to return on a page. + Limit *int64 `json:"limit,omitempty"` + + // Filters the collection to resources with a `resource_group.id` property matching the specified identifier. + ResourceGroupID *string `json:"resource_group.id,omitempty"` + + // Filters the collection to resources with a `name` property matching the exact specified name. + Name *string `json:"name,omitempty"` + + // Sorts the returned collection by the specified property name in ascending order. A `-` may be prepended to the name + // to sort in descending order. For example, the value `-created_at` sorts the collection by the `created_at` property + // in descending order, and the value `name` sorts it by the `name` property in ascending order. + Sort *string `json:"sort,omitempty"` + + // Filters the collection to backup policy jobs with a `backup_policy_plan.id` property matching the specified + // identifier. + BackupPolicyPlanID *string `json:"backup_policy_plan.id,omitempty"` + + // Allows users to set headers on API requests + Headers map[string]string +} + +// Constants associated with the ListSnapshotConsistencyGroupsOptions.Sort property. +// Sorts the returned collection by the specified property name in ascending order. A `-` may be prepended to the name +// to sort in descending order. For example, the value `-created_at` sorts the collection by the `created_at` property +// in descending order, and the value `name` sorts it by the `name` property in ascending order. +const ( + ListSnapshotConsistencyGroupsOptionsSortCreatedAtConst = "created_at" + ListSnapshotConsistencyGroupsOptionsSortNameConst = "name" +) + +// NewListSnapshotConsistencyGroupsOptions : Instantiate ListSnapshotConsistencyGroupsOptions +func (*VpcV1) NewListSnapshotConsistencyGroupsOptions() *ListSnapshotConsistencyGroupsOptions { + return &ListSnapshotConsistencyGroupsOptions{} +} + +// SetStart : Allow user to set Start +func (_options *ListSnapshotConsistencyGroupsOptions) SetStart(start string) *ListSnapshotConsistencyGroupsOptions { + _options.Start = core.StringPtr(start) + return _options +} + +// SetLimit : Allow user to set Limit +func (_options *ListSnapshotConsistencyGroupsOptions) SetLimit(limit int64) *ListSnapshotConsistencyGroupsOptions { + _options.Limit = core.Int64Ptr(limit) + return _options +} + +// SetResourceGroupID : Allow user to set ResourceGroupID +func (_options *ListSnapshotConsistencyGroupsOptions) SetResourceGroupID(resourceGroupID string) *ListSnapshotConsistencyGroupsOptions { + _options.ResourceGroupID = core.StringPtr(resourceGroupID) + return _options +} + +// SetName : Allow user to set Name +func (_options *ListSnapshotConsistencyGroupsOptions) SetName(name string) *ListSnapshotConsistencyGroupsOptions { + _options.Name = core.StringPtr(name) + return _options +} + +// SetSort : Allow user to set Sort +func (_options *ListSnapshotConsistencyGroupsOptions) SetSort(sort string) *ListSnapshotConsistencyGroupsOptions { + _options.Sort = core.StringPtr(sort) + return _options +} + +// SetBackupPolicyPlanID : Allow user to set BackupPolicyPlanID +func (_options *ListSnapshotConsistencyGroupsOptions) SetBackupPolicyPlanID(backupPolicyPlanID string) *ListSnapshotConsistencyGroupsOptions { + _options.BackupPolicyPlanID = core.StringPtr(backupPolicyPlanID) + return _options +} + +// SetHeaders : Allow user to set Headers +func (options *ListSnapshotConsistencyGroupsOptions) SetHeaders(param map[string]string) *ListSnapshotConsistencyGroupsOptions { + options.Headers = param + return options +} + // ListSnapshotsOptions : The ListSnapshots options. type ListSnapshotsOptions struct { // A server-provided token determining what resource to start the page on. @@ -52270,6 +52870,14 @@ type ListSnapshotsOptions struct { // exact specified name. ClonesZoneName *string `json:"clones[].zone.name,omitempty"` + // Filters the collection to resources with a `snapshot_consistency_group.id` property matching the specified + // identifier. + SnapshotConsistencyGroupID *string `json:"snapshot_consistency_group.id,omitempty"` + + // Filters the collection to resources with a `snapshot_consistency_group.crn` property matching the specified + // identifier. + SnapshotConsistencyGroupCRN *string `json:"snapshot_consistency_group.crn,omitempty"` + // Allows users to set headers on API requests Headers map[string]string } @@ -52408,6 +53016,18 @@ func (_options *ListSnapshotsOptions) SetClonesZoneName(clonesZoneName string) * return _options } +// SetSnapshotConsistencyGroupID : Allow user to set SnapshotConsistencyGroupID +func (_options *ListSnapshotsOptions) SetSnapshotConsistencyGroupID(snapshotConsistencyGroupID string) *ListSnapshotsOptions { + _options.SnapshotConsistencyGroupID = core.StringPtr(snapshotConsistencyGroupID) + return _options +} + +// SetSnapshotConsistencyGroupCRN : Allow user to set SnapshotConsistencyGroupCRN +func (_options *ListSnapshotsOptions) SetSnapshotConsistencyGroupCRN(snapshotConsistencyGroupCRN string) *ListSnapshotsOptions { + _options.SnapshotConsistencyGroupCRN = core.StringPtr(snapshotConsistencyGroupCRN) + return _options +} + // SetHeaders : Allow user to set Headers func (options *ListSnapshotsOptions) SetHeaders(param map[string]string) *ListSnapshotsOptions { options.Headers = param @@ -65895,6 +66515,9 @@ type Snapshot struct { // The size of this snapshot rounded up to the next gigabyte. Size *int64 `json:"size" validate:"required"` + // If present, the snapshot consistency group which created this snapshot. + SnapshotConsistencyGroup *SnapshotConsistencyGroupReference `json:"snapshot_consistency_group,omitempty"` + // If present, the image from which the data on this snapshot was most directly // provisioned. SourceImage *ImageReference `json:"source_image,omitempty"` @@ -66018,6 +66641,10 @@ func UnmarshalSnapshot(m map[string]json.RawMessage, result interface{}) (err er if err != nil { return } + err = core.UnmarshalModel(m, "snapshot_consistency_group", &obj.SnapshotConsistencyGroup, UnmarshalSnapshotConsistencyGroupReference) + if err != nil { + return + } err = core.UnmarshalModel(m, "source_image", &obj.SourceImage, UnmarshalImageReference) if err != nil { return @@ -66205,46 +66832,83 @@ func UnmarshalSnapshotCollectionNext(m map[string]json.RawMessage, result interf return } -// SnapshotCopiesItem : SnapshotCopiesItem struct -type SnapshotCopiesItem struct { - // The CRN for the copied snapshot. +// SnapshotConsistencyGroup : SnapshotConsistencyGroup struct +type SnapshotConsistencyGroup struct { + // If present, the backup policy plan which created this snapshot consistency group. + BackupPolicyPlan *BackupPolicyPlanReference `json:"backup_policy_plan,omitempty"` + + // The date and time that this snapshot consistency group was created. + CreatedAt *strfmt.DateTime `json:"created_at" validate:"required"` + + // The CRN of this snapshot consistency group. CRN *string `json:"crn" validate:"required"` - // If present, this property indicates the referenced resource has been deleted, and provides - // some supplementary information. - Deleted *SnapshotReferenceDeleted `json:"deleted,omitempty"` + // Indicates whether deleting the snapshot consistency group will also delete the snapshots in the group. + DeleteSnapshotsOnDelete *bool `json:"delete_snapshots_on_delete" validate:"required"` - // The URL for the copied snapshot. + // The URL for this snapshot consistency group. Href *string `json:"href" validate:"required"` - // The unique identifier for the copied snapshot. + // The unique identifier for this snapshot consistency group. ID *string `json:"id" validate:"required"` - // The name for the copied snapshot. + // The lifecycle state of this snapshot consistency group. + LifecycleState *string `json:"lifecycle_state" validate:"required"` + + // The name for this snapshot consistency group. The name is unique across all snapshot consistency groups in the + // region. Name *string `json:"name" validate:"required"` - // If present, this property indicates that the resource associated with this reference - // is remote and therefore may not be directly retrievable. - Remote *SnapshotRemote `json:"remote,omitempty"` + // The resource group for this snapshot consistency group. + ResourceGroup *ResourceGroupReference `json:"resource_group" validate:"required"` // The resource type. ResourceType *string `json:"resource_type" validate:"required"` + + // The [service tags](https://cloud.ibm.com/apidocs/tagging#types-of-tags) associated with this snapshot consistency + // group. Each tag is prefixed with + // [is.instance:](https://cloud.ibm.com/docs/vpc?topic=vpc-snapshots-vpc-faqs). + ServiceTags []string `json:"service_tags" validate:"required"` + + // The member snapshots that are data-consistent with respect to captured time. (may be + // [deleted](https://cloud.ibm.com/apidocs/vpc#deleted-resources)). + Snapshots []SnapshotConsistencyGroupSnapshotsItem `json:"snapshots" validate:"required"` } -// Constants associated with the SnapshotCopiesItem.ResourceType property. +// Constants associated with the SnapshotConsistencyGroup.LifecycleState property. +// The lifecycle state of this snapshot consistency group. +const ( + SnapshotConsistencyGroupLifecycleStateDeletingConst = "deleting" + SnapshotConsistencyGroupLifecycleStateFailedConst = "failed" + SnapshotConsistencyGroupLifecycleStatePendingConst = "pending" + SnapshotConsistencyGroupLifecycleStateStableConst = "stable" + SnapshotConsistencyGroupLifecycleStateSuspendedConst = "suspended" + SnapshotConsistencyGroupLifecycleStateUpdatingConst = "updating" + SnapshotConsistencyGroupLifecycleStateWaitingConst = "waiting" +) + +// Constants associated with the SnapshotConsistencyGroup.ResourceType property. // The resource type. const ( - SnapshotCopiesItemResourceTypeSnapshotConst = "snapshot" + SnapshotConsistencyGroupResourceTypeSnapshotConsistencyGroupConst = "snapshot_consistency_group" ) -// UnmarshalSnapshotCopiesItem unmarshals an instance of SnapshotCopiesItem from the specified map of raw messages. -func UnmarshalSnapshotCopiesItem(m map[string]json.RawMessage, result interface{}) (err error) { - obj := new(SnapshotCopiesItem) +// UnmarshalSnapshotConsistencyGroup unmarshals an instance of SnapshotConsistencyGroup from the specified map of raw messages. +func UnmarshalSnapshotConsistencyGroup(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(SnapshotConsistencyGroup) + err = core.UnmarshalModel(m, "backup_policy_plan", &obj.BackupPolicyPlan, UnmarshalBackupPolicyPlanReference) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "created_at", &obj.CreatedAt) + if err != nil { + return + } err = core.UnmarshalPrimitive(m, "crn", &obj.CRN) if err != nil { return } - err = core.UnmarshalModel(m, "deleted", &obj.Deleted, UnmarshalSnapshotReferenceDeleted) + err = core.UnmarshalPrimitive(m, "delete_snapshots_on_delete", &obj.DeleteSnapshotsOnDelete) if err != nil { return } @@ -66256,11 +66920,15 @@ func UnmarshalSnapshotCopiesItem(m map[string]json.RawMessage, result interface{ if err != nil { return } + err = core.UnmarshalPrimitive(m, "lifecycle_state", &obj.LifecycleState) + if err != nil { + return + } err = core.UnmarshalPrimitive(m, "name", &obj.Name) if err != nil { return } - err = core.UnmarshalModel(m, "remote", &obj.Remote, UnmarshalSnapshotRemote) + err = core.UnmarshalModel(m, "resource_group", &obj.ResourceGroup, UnmarshalResourceGroupReference) if err != nil { return } @@ -66268,45 +66936,102 @@ func UnmarshalSnapshotCopiesItem(m map[string]json.RawMessage, result interface{ if err != nil { return } + err = core.UnmarshalPrimitive(m, "service_tags", &obj.ServiceTags) + if err != nil { + return + } + err = core.UnmarshalModel(m, "snapshots", &obj.Snapshots, UnmarshalSnapshotConsistencyGroupSnapshotsItem) + if err != nil { + return + } reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) return } -// SnapshotIdentity : Identifies a snapshot by a unique property. -// Models which "extend" this model: -// - SnapshotIdentityByID -// - SnapshotIdentityByCRN -// - SnapshotIdentityByHref -type SnapshotIdentity struct { - // The unique identifier for this snapshot. - ID *string `json:"id,omitempty"` +// SnapshotConsistencyGroupCollection : SnapshotConsistencyGroupCollection struct +type SnapshotConsistencyGroupCollection struct { + // A link to the first page of resources. + First *SnapshotConsistencyGroupCollectionFirst `json:"first" validate:"required"` - // The CRN of this snapshot. - CRN *string `json:"crn,omitempty"` + // The maximum number of resources that can be returned by the request. + Limit *int64 `json:"limit" validate:"required"` - // The URL for this snapshot. - Href *string `json:"href,omitempty"` -} + // A link to the next page of resources. This property is present for all pages + // except the last page. + Next *SnapshotConsistencyGroupCollectionNext `json:"next,omitempty"` -func (*SnapshotIdentity) isaSnapshotIdentity() bool { - return true -} + // Collection of snapshot consistency groups. + SnapshotConsistencyGroups []SnapshotConsistencyGroup `json:"snapshot_consistency_groups" validate:"required"` -type SnapshotIdentityIntf interface { - isaSnapshotIdentity() bool + // The total number of resources across all pages. + TotalCount *int64 `json:"total_count" validate:"required"` } -// UnmarshalSnapshotIdentity unmarshals an instance of SnapshotIdentity from the specified map of raw messages. -func UnmarshalSnapshotIdentity(m map[string]json.RawMessage, result interface{}) (err error) { - obj := new(SnapshotIdentity) - err = core.UnmarshalPrimitive(m, "id", &obj.ID) +// UnmarshalSnapshotConsistencyGroupCollection unmarshals an instance of SnapshotConsistencyGroupCollection from the specified map of raw messages. +func UnmarshalSnapshotConsistencyGroupCollection(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(SnapshotConsistencyGroupCollection) + err = core.UnmarshalModel(m, "first", &obj.First, UnmarshalSnapshotConsistencyGroupCollectionFirst) if err != nil { return } - err = core.UnmarshalPrimitive(m, "crn", &obj.CRN) + err = core.UnmarshalPrimitive(m, "limit", &obj.Limit) + if err != nil { + return + } + err = core.UnmarshalModel(m, "next", &obj.Next, UnmarshalSnapshotConsistencyGroupCollectionNext) + if err != nil { + return + } + err = core.UnmarshalModel(m, "snapshot_consistency_groups", &obj.SnapshotConsistencyGroups, UnmarshalSnapshotConsistencyGroup) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "total_count", &obj.TotalCount) + if err != nil { + return + } + reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) + return +} + +// Retrieve the value to be passed to a request to access the next page of results +func (resp *SnapshotConsistencyGroupCollection) GetNextStart() (*string, error) { + if core.IsNil(resp.Next) { + return nil, nil + } + start, err := core.GetQueryParam(resp.Next.Href, "start") + if err != nil || start == nil { + return nil, err + } + return start, nil +} + +// SnapshotConsistencyGroupCollectionFirst : A link to the first page of resources. +type SnapshotConsistencyGroupCollectionFirst struct { + // The URL for a page of resources. + Href *string `json:"href" validate:"required"` +} + +// UnmarshalSnapshotConsistencyGroupCollectionFirst unmarshals an instance of SnapshotConsistencyGroupCollectionFirst from the specified map of raw messages. +func UnmarshalSnapshotConsistencyGroupCollectionFirst(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(SnapshotConsistencyGroupCollectionFirst) + err = core.UnmarshalPrimitive(m, "href", &obj.Href) if err != nil { return } + reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) + return +} + +// SnapshotConsistencyGroupCollectionNext : A link to the next page of resources. This property is present for all pages except the last page. +type SnapshotConsistencyGroupCollectionNext struct { + // The URL for a page of resources. + Href *string `json:"href" validate:"required"` +} + +// UnmarshalSnapshotConsistencyGroupCollectionNext unmarshals an instance of SnapshotConsistencyGroupCollectionNext from the specified map of raw messages. +func UnmarshalSnapshotConsistencyGroupCollectionNext(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(SnapshotConsistencyGroupCollectionNext) err = core.UnmarshalPrimitive(m, "href", &obj.Href) if err != nil { return @@ -66315,23 +67040,24 @@ func UnmarshalSnapshotIdentity(m map[string]json.RawMessage, result interface{}) return } -// SnapshotPatch : SnapshotPatch struct -type SnapshotPatch struct { - // The name for this snapshot. The name must not be used by another snapshot in the region. - Name *string `json:"name,omitempty"` +// SnapshotConsistencyGroupPatch : SnapshotConsistencyGroupPatch struct +type SnapshotConsistencyGroupPatch struct { + // Indicates whether deleting the snapshot consistency group will also delete the snapshots in the group. + DeleteSnapshotsOnDelete *bool `json:"delete_snapshots_on_delete,omitempty"` - // The [user tags](https://cloud.ibm.com/apidocs/tagging#types-of-tags) associated with this snapshot. - UserTags []string `json:"user_tags,omitempty"` + // The name for this snapshot consistency group. The name must not be used by another snapshot consistency groups in + // the region. + Name *string `json:"name,omitempty"` } -// UnmarshalSnapshotPatch unmarshals an instance of SnapshotPatch from the specified map of raw messages. -func UnmarshalSnapshotPatch(m map[string]json.RawMessage, result interface{}) (err error) { - obj := new(SnapshotPatch) - err = core.UnmarshalPrimitive(m, "name", &obj.Name) +// UnmarshalSnapshotConsistencyGroupPatch unmarshals an instance of SnapshotConsistencyGroupPatch from the specified map of raw messages. +func UnmarshalSnapshotConsistencyGroupPatch(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(SnapshotConsistencyGroupPatch) + err = core.UnmarshalPrimitive(m, "delete_snapshots_on_delete", &obj.DeleteSnapshotsOnDelete) if err != nil { return } - err = core.UnmarshalPrimitive(m, "user_tags", &obj.UserTags) + err = core.UnmarshalPrimitive(m, "name", &obj.Name) if err != nil { return } @@ -66339,90 +67065,222 @@ func UnmarshalSnapshotPatch(m map[string]json.RawMessage, result interface{}) (e return } -// AsPatch returns a generic map representation of the SnapshotPatch -func (snapshotPatch *SnapshotPatch) AsPatch() (_patch map[string]interface{}, err error) { +// AsPatch returns a generic map representation of the SnapshotConsistencyGroupPatch +func (snapshotConsistencyGroupPatch *SnapshotConsistencyGroupPatch) AsPatch() (_patch map[string]interface{}, err error) { var jsonData []byte - jsonData, err = json.Marshal(snapshotPatch) + jsonData, err = json.Marshal(snapshotConsistencyGroupPatch) if err == nil { err = json.Unmarshal(jsonData, &_patch) } return } -// SnapshotPrototype : SnapshotPrototype struct +// SnapshotConsistencyGroupPrototype : SnapshotConsistencyGroupPrototype struct // Models which "extend" this model: -// - SnapshotPrototypeSnapshotBySourceVolume -// - SnapshotPrototypeSnapshotBySourceSnapshot -type SnapshotPrototype struct { - // Clones to create for this snapshot. - Clones []SnapshotClonePrototype `json:"clones,omitempty"` +// - SnapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshots +type SnapshotConsistencyGroupPrototype struct { + // Indicates whether deleting the snapshot consistency group will also delete the snapshots in the group. + DeleteSnapshotsOnDelete *bool `json:"delete_snapshots_on_delete,omitempty"` - // The name for this snapshot. The name must not be used by another snapshot in the region. If unspecified, the name - // will be a hyphenated list of randomly-selected words. + // The name for this snapshot consistency group. The name must be unique across all snapshot consistency groups in the + // region. + // + // If unspecified, the name will be a hyphenated list of randomly-selected words. Name *string `json:"name,omitempty"` // The resource group to use. If unspecified, the account's [default resource // group](https://cloud.ibm.com/apidocs/resource-manager#introduction) will be used. ResourceGroup ResourceGroupIdentityIntf `json:"resource_group,omitempty"` + // The data-consistent member snapshots to create. All snapshots must specify a + // `source_volume` attached to the same virtual server instance. + Snapshots []SnapshotConsistencyGroupPrototypeSnapshotsItem `json:"snapshots,omitempty"` +} + +func (*SnapshotConsistencyGroupPrototype) isaSnapshotConsistencyGroupPrototype() bool { + return true +} + +type SnapshotConsistencyGroupPrototypeIntf interface { + isaSnapshotConsistencyGroupPrototype() bool +} + +// UnmarshalSnapshotConsistencyGroupPrototype unmarshals an instance of SnapshotConsistencyGroupPrototype from the specified map of raw messages. +func UnmarshalSnapshotConsistencyGroupPrototype(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(SnapshotConsistencyGroupPrototype) + err = core.UnmarshalPrimitive(m, "delete_snapshots_on_delete", &obj.DeleteSnapshotsOnDelete) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "name", &obj.Name) + if err != nil { + return + } + err = core.UnmarshalModel(m, "resource_group", &obj.ResourceGroup, UnmarshalResourceGroupIdentity) + if err != nil { + return + } + err = core.UnmarshalModel(m, "snapshots", &obj.Snapshots, UnmarshalSnapshotConsistencyGroupPrototypeSnapshotsItem) + if err != nil { + return + } + reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) + return +} + +// SnapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshotsSnapshotsItem : SnapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshotsSnapshotsItem struct +type SnapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshotsSnapshotsItem struct { + // The name for this snapshot. The name must not be used by another snapshot in the region. If unspecified, the name + // will be a hyphenated list of randomly-selected words. + Name *string `json:"name,omitempty"` + + // The volume to create this snapshot from. + SourceVolume VolumeIdentityIntf `json:"source_volume" validate:"required"` + // The [user tags](https://cloud.ibm.com/apidocs/tagging#types-of-tags) associated with this snapshot. UserTags []string `json:"user_tags,omitempty"` +} + +// NewSnapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshotsSnapshotsItem : Instantiate SnapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshotsSnapshotsItem (Generic Model Constructor) +func (*VpcV1) NewSnapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshotsSnapshotsItem(sourceVolume VolumeIdentityIntf) (_model *SnapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshotsSnapshotsItem, err error) { + _model = &SnapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshotsSnapshotsItem{ + SourceVolume: sourceVolume, + } + err = core.ValidateStruct(_model, "required parameters") + return +} + +// UnmarshalSnapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshotsSnapshotsItem unmarshals an instance of SnapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshotsSnapshotsItem from the specified map of raw messages. +func UnmarshalSnapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshotsSnapshotsItem(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(SnapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshotsSnapshotsItem) + err = core.UnmarshalPrimitive(m, "name", &obj.Name) + if err != nil { + return + } + err = core.UnmarshalModel(m, "source_volume", &obj.SourceVolume, UnmarshalVolumeIdentity) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "user_tags", &obj.UserTags) + if err != nil { + return + } + reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) + return +} + +// SnapshotConsistencyGroupPrototypeSnapshotsItem : SnapshotConsistencyGroupPrototypeSnapshotsItem struct +type SnapshotConsistencyGroupPrototypeSnapshotsItem struct { + // The name for this snapshot. The name must not be used by another snapshot in the region. If unspecified, the name + // will be a hyphenated list of randomly-selected words. + Name *string `json:"name,omitempty"` // The volume to create this snapshot from. - SourceVolume VolumeIdentityIntf `json:"source_volume,omitempty"` + SourceVolume VolumeIdentityIntf `json:"source_volume" validate:"required"` - // The root key to use to wrap the data encryption key for this snapshot. - // - // A key must be specified if and only if the source snapshot has an `encryption` type of - // `user_managed`. To maximize snapshot availability and sharing of snapshot data, specify - // a key in the same region as the new snapshot, and use the same encryption key for all - // snapshots using the same source volume. - // - // The specified key may be in a different account, subject to IAM policies. - EncryptionKey EncryptionKeyIdentityIntf `json:"encryption_key,omitempty"` + // The [user tags](https://cloud.ibm.com/apidocs/tagging#types-of-tags) associated with this snapshot. + UserTags []string `json:"user_tags,omitempty"` +} - // The source snapshot (in another region) to create this snapshot from. - // The specified snapshot must not already be the source of another snapshot in this - // region. - SourceSnapshot *SnapshotIdentityByCRN `json:"source_snapshot,omitempty"` +// NewSnapshotConsistencyGroupPrototypeSnapshotsItem : Instantiate SnapshotConsistencyGroupPrototypeSnapshotsItem (Generic Model Constructor) +func (*VpcV1) NewSnapshotConsistencyGroupPrototypeSnapshotsItem(sourceVolume VolumeIdentityIntf) (_model *SnapshotConsistencyGroupPrototypeSnapshotsItem, err error) { + _model = &SnapshotConsistencyGroupPrototypeSnapshotsItem{ + SourceVolume: sourceVolume, + } + err = core.ValidateStruct(_model, "required parameters") + return } -func (*SnapshotPrototype) isaSnapshotPrototype() bool { - return true +// UnmarshalSnapshotConsistencyGroupPrototypeSnapshotsItem unmarshals an instance of SnapshotConsistencyGroupPrototypeSnapshotsItem from the specified map of raw messages. +func UnmarshalSnapshotConsistencyGroupPrototypeSnapshotsItem(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(SnapshotConsistencyGroupPrototypeSnapshotsItem) + err = core.UnmarshalPrimitive(m, "name", &obj.Name) + if err != nil { + return + } + err = core.UnmarshalModel(m, "source_volume", &obj.SourceVolume, UnmarshalVolumeIdentity) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "user_tags", &obj.UserTags) + if err != nil { + return + } + reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) + return } -type SnapshotPrototypeIntf interface { - isaSnapshotPrototype() bool +// SnapshotConsistencyGroupReference : SnapshotConsistencyGroupReference struct +type SnapshotConsistencyGroupReference struct { + // The CRN of this snapshot consistency group. + CRN *string `json:"crn" validate:"required"` + + // If present, this property indicates the referenced resource has been deleted, and provides + // some supplementary information. + Deleted *SnapshotConsistencyGroupReferenceDeleted `json:"deleted,omitempty"` + + // The URL for this snapshot consistency group. + Href *string `json:"href" validate:"required"` + + // The unique identifier for this snapshot consistency group. + ID *string `json:"id" validate:"required"` + + // The name for this snapshot consistency group. The name is unique across all snapshot consistency groups in the + // region. + Name *string `json:"name" validate:"required"` + + // The resource type. + ResourceType *string `json:"resource_type" validate:"required"` } -// UnmarshalSnapshotPrototype unmarshals an instance of SnapshotPrototype from the specified map of raw messages. -func UnmarshalSnapshotPrototype(m map[string]json.RawMessage, result interface{}) (err error) { - obj := new(SnapshotPrototype) - err = core.UnmarshalModel(m, "clones", &obj.Clones, UnmarshalSnapshotClonePrototype) +// Constants associated with the SnapshotConsistencyGroupReference.ResourceType property. +// The resource type. +const ( + SnapshotConsistencyGroupReferenceResourceTypeSnapshotConsistencyGroupConst = "snapshot_consistency_group" +) + +// UnmarshalSnapshotConsistencyGroupReference unmarshals an instance of SnapshotConsistencyGroupReference from the specified map of raw messages. +func UnmarshalSnapshotConsistencyGroupReference(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(SnapshotConsistencyGroupReference) + err = core.UnmarshalPrimitive(m, "crn", &obj.CRN) if err != nil { return } - err = core.UnmarshalPrimitive(m, "name", &obj.Name) + err = core.UnmarshalModel(m, "deleted", &obj.Deleted, UnmarshalSnapshotConsistencyGroupReferenceDeleted) if err != nil { return } - err = core.UnmarshalModel(m, "resource_group", &obj.ResourceGroup, UnmarshalResourceGroupIdentity) + err = core.UnmarshalPrimitive(m, "href", &obj.Href) if err != nil { return } - err = core.UnmarshalPrimitive(m, "user_tags", &obj.UserTags) + err = core.UnmarshalPrimitive(m, "id", &obj.ID) if err != nil { return } - err = core.UnmarshalModel(m, "source_volume", &obj.SourceVolume, UnmarshalVolumeIdentity) + err = core.UnmarshalPrimitive(m, "name", &obj.Name) if err != nil { return } - err = core.UnmarshalModel(m, "encryption_key", &obj.EncryptionKey, UnmarshalEncryptionKeyIdentity) + err = core.UnmarshalPrimitive(m, "resource_type", &obj.ResourceType) if err != nil { return } - err = core.UnmarshalModel(m, "source_snapshot", &obj.SourceSnapshot, UnmarshalSnapshotIdentityByCRN) + reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) + return +} + +// SnapshotConsistencyGroupReferenceDeleted : If present, this property indicates the referenced resource has been deleted, and provides some supplementary +// information. +type SnapshotConsistencyGroupReferenceDeleted struct { + // Link to documentation about deleted resources. + MoreInfo *string `json:"more_info" validate:"required"` +} + +// UnmarshalSnapshotConsistencyGroupReferenceDeleted unmarshals an instance of SnapshotConsistencyGroupReferenceDeleted from the specified map of raw messages. +func UnmarshalSnapshotConsistencyGroupReferenceDeleted(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(SnapshotConsistencyGroupReferenceDeleted) + err = core.UnmarshalPrimitive(m, "more_info", &obj.MoreInfo) if err != nil { return } @@ -66430,8 +67288,300 @@ func UnmarshalSnapshotPrototype(m map[string]json.RawMessage, result interface{} return } -// SnapshotReference : SnapshotReference struct -type SnapshotReference struct { +// SnapshotConsistencyGroupSnapshotsItem : SnapshotConsistencyGroupSnapshotsItem struct +type SnapshotConsistencyGroupSnapshotsItem struct { + // The CRN of this snapshot. + CRN *string `json:"crn" validate:"required"` + + // If present, this property indicates the referenced resource has been deleted, and provides + // some supplementary information. + Deleted *SnapshotReferenceDeleted `json:"deleted,omitempty"` + + // The URL for this snapshot. + Href *string `json:"href" validate:"required"` + + // The unique identifier for this snapshot. + ID *string `json:"id" validate:"required"` + + // The name for this snapshot. The name is unique across all snapshots in the region. + Name *string `json:"name" validate:"required"` + + // If present, this property indicates that the resource associated with this reference + // is remote and therefore may not be directly retrievable. + Remote *SnapshotRemote `json:"remote,omitempty"` + + // The resource type. + ResourceType *string `json:"resource_type" validate:"required"` +} + +// Constants associated with the SnapshotConsistencyGroupSnapshotsItem.ResourceType property. +// The resource type. +const ( + SnapshotConsistencyGroupSnapshotsItemResourceTypeSnapshotConst = "snapshot" +) + +// UnmarshalSnapshotConsistencyGroupSnapshotsItem unmarshals an instance of SnapshotConsistencyGroupSnapshotsItem from the specified map of raw messages. +func UnmarshalSnapshotConsistencyGroupSnapshotsItem(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(SnapshotConsistencyGroupSnapshotsItem) + err = core.UnmarshalPrimitive(m, "crn", &obj.CRN) + if err != nil { + return + } + err = core.UnmarshalModel(m, "deleted", &obj.Deleted, UnmarshalSnapshotReferenceDeleted) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "href", &obj.Href) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "id", &obj.ID) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "name", &obj.Name) + if err != nil { + return + } + err = core.UnmarshalModel(m, "remote", &obj.Remote, UnmarshalSnapshotRemote) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "resource_type", &obj.ResourceType) + if err != nil { + return + } + reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) + return +} + +// SnapshotCopiesItem : SnapshotCopiesItem struct +type SnapshotCopiesItem struct { + // The CRN for the copied snapshot. + CRN *string `json:"crn" validate:"required"` + + // If present, this property indicates the referenced resource has been deleted, and provides + // some supplementary information. + Deleted *SnapshotReferenceDeleted `json:"deleted,omitempty"` + + // The URL for the copied snapshot. + Href *string `json:"href" validate:"required"` + + // The unique identifier for the copied snapshot. + ID *string `json:"id" validate:"required"` + + // The name for the copied snapshot. + Name *string `json:"name" validate:"required"` + + // If present, this property indicates that the resource associated with this reference + // is remote and therefore may not be directly retrievable. + Remote *SnapshotRemote `json:"remote,omitempty"` + + // The resource type. + ResourceType *string `json:"resource_type" validate:"required"` +} + +// Constants associated with the SnapshotCopiesItem.ResourceType property. +// The resource type. +const ( + SnapshotCopiesItemResourceTypeSnapshotConst = "snapshot" +) + +// UnmarshalSnapshotCopiesItem unmarshals an instance of SnapshotCopiesItem from the specified map of raw messages. +func UnmarshalSnapshotCopiesItem(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(SnapshotCopiesItem) + err = core.UnmarshalPrimitive(m, "crn", &obj.CRN) + if err != nil { + return + } + err = core.UnmarshalModel(m, "deleted", &obj.Deleted, UnmarshalSnapshotReferenceDeleted) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "href", &obj.Href) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "id", &obj.ID) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "name", &obj.Name) + if err != nil { + return + } + err = core.UnmarshalModel(m, "remote", &obj.Remote, UnmarshalSnapshotRemote) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "resource_type", &obj.ResourceType) + if err != nil { + return + } + reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) + return +} + +// SnapshotIdentity : Identifies a snapshot by a unique property. +// Models which "extend" this model: +// - SnapshotIdentityByID +// - SnapshotIdentityByCRN +// - SnapshotIdentityByHref +type SnapshotIdentity struct { + // The unique identifier for this snapshot. + ID *string `json:"id,omitempty"` + + // The CRN of this snapshot. + CRN *string `json:"crn,omitempty"` + + // The URL for this snapshot. + Href *string `json:"href,omitempty"` +} + +func (*SnapshotIdentity) isaSnapshotIdentity() bool { + return true +} + +type SnapshotIdentityIntf interface { + isaSnapshotIdentity() bool +} + +// UnmarshalSnapshotIdentity unmarshals an instance of SnapshotIdentity from the specified map of raw messages. +func UnmarshalSnapshotIdentity(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(SnapshotIdentity) + err = core.UnmarshalPrimitive(m, "id", &obj.ID) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "crn", &obj.CRN) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "href", &obj.Href) + if err != nil { + return + } + reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) + return +} + +// SnapshotPatch : SnapshotPatch struct +type SnapshotPatch struct { + // The name for this snapshot. The name must not be used by another snapshot in the region. + Name *string `json:"name,omitempty"` + + // The [user tags](https://cloud.ibm.com/apidocs/tagging#types-of-tags) associated with this snapshot. + UserTags []string `json:"user_tags,omitempty"` +} + +// UnmarshalSnapshotPatch unmarshals an instance of SnapshotPatch from the specified map of raw messages. +func UnmarshalSnapshotPatch(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(SnapshotPatch) + err = core.UnmarshalPrimitive(m, "name", &obj.Name) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "user_tags", &obj.UserTags) + if err != nil { + return + } + reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) + return +} + +// AsPatch returns a generic map representation of the SnapshotPatch +func (snapshotPatch *SnapshotPatch) AsPatch() (_patch map[string]interface{}, err error) { + var jsonData []byte + jsonData, err = json.Marshal(snapshotPatch) + if err == nil { + err = json.Unmarshal(jsonData, &_patch) + } + return +} + +// SnapshotPrototype : SnapshotPrototype struct +// Models which "extend" this model: +// - SnapshotPrototypeSnapshotBySourceVolume +// - SnapshotPrototypeSnapshotBySourceSnapshot +type SnapshotPrototype struct { + // Clones to create for this snapshot. + Clones []SnapshotClonePrototype `json:"clones,omitempty"` + + // The name for this snapshot. The name must not be used by another snapshot in the region. If unspecified, the name + // will be a hyphenated list of randomly-selected words. + Name *string `json:"name,omitempty"` + + // The resource group to use. If unspecified, the account's [default resource + // group](https://cloud.ibm.com/apidocs/resource-manager#introduction) will be used. + ResourceGroup ResourceGroupIdentityIntf `json:"resource_group,omitempty"` + + // The [user tags](https://cloud.ibm.com/apidocs/tagging#types-of-tags) associated with this snapshot. + UserTags []string `json:"user_tags,omitempty"` + + // The volume to create this snapshot from. + SourceVolume VolumeIdentityIntf `json:"source_volume,omitempty"` + + // The root key to use to wrap the data encryption key for this snapshot. + // + // A key must be specified if and only if the source snapshot has an `encryption` type of + // `user_managed`. To maximize snapshot availability and sharing of snapshot data, specify + // a key in the same region as the new snapshot, and use the same encryption key for all + // snapshots using the same source volume. + // + // The specified key may be in a different account, subject to IAM policies. + EncryptionKey EncryptionKeyIdentityIntf `json:"encryption_key,omitempty"` + + // The source snapshot (in another region) to create this snapshot from. + // The specified snapshot must not already be the source of another snapshot in this + // region. + SourceSnapshot *SnapshotIdentityByCRN `json:"source_snapshot,omitempty"` +} + +func (*SnapshotPrototype) isaSnapshotPrototype() bool { + return true +} + +type SnapshotPrototypeIntf interface { + isaSnapshotPrototype() bool +} + +// UnmarshalSnapshotPrototype unmarshals an instance of SnapshotPrototype from the specified map of raw messages. +func UnmarshalSnapshotPrototype(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(SnapshotPrototype) + err = core.UnmarshalModel(m, "clones", &obj.Clones, UnmarshalSnapshotClonePrototype) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "name", &obj.Name) + if err != nil { + return + } + err = core.UnmarshalModel(m, "resource_group", &obj.ResourceGroup, UnmarshalResourceGroupIdentity) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "user_tags", &obj.UserTags) + if err != nil { + return + } + err = core.UnmarshalModel(m, "source_volume", &obj.SourceVolume, UnmarshalVolumeIdentity) + if err != nil { + return + } + err = core.UnmarshalModel(m, "encryption_key", &obj.EncryptionKey, UnmarshalEncryptionKeyIdentity) + if err != nil { + return + } + err = core.UnmarshalModel(m, "source_snapshot", &obj.SourceSnapshot, UnmarshalSnapshotIdentityByCRN) + if err != nil { + return + } + reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) + return +} + +// SnapshotReference : SnapshotReference struct +type SnapshotReference struct { // The CRN of this snapshot. CRN *string `json:"crn" validate:"required"` @@ -69165,6 +70315,54 @@ func (options *UpdateShareOptions) SetHeaders(param map[string]string) *UpdateSh return options } +// UpdateSnapshotConsistencyGroupOptions : The UpdateSnapshotConsistencyGroup options. +type UpdateSnapshotConsistencyGroupOptions struct { + // The snapshot consistency group identifier. + ID *string `json:"id" validate:"required,ne="` + + // The snapshot consistency group patch. + SnapshotConsistencyGroupPatch map[string]interface{} `json:"SnapshotConsistencyGroup_patch" validate:"required"` + + // If present, the request will fail if the specified ETag value does not match the resource's current ETag value. + // Required if the request body includes an array. + IfMatch *string `json:"If-Match,omitempty"` + + // Allows users to set headers on API requests + Headers map[string]string +} + +// NewUpdateSnapshotConsistencyGroupOptions : Instantiate UpdateSnapshotConsistencyGroupOptions +func (*VpcV1) NewUpdateSnapshotConsistencyGroupOptions(id string, snapshotConsistencyGroupPatch map[string]interface{}) *UpdateSnapshotConsistencyGroupOptions { + return &UpdateSnapshotConsistencyGroupOptions{ + ID: core.StringPtr(id), + SnapshotConsistencyGroupPatch: snapshotConsistencyGroupPatch, + } +} + +// SetID : Allow user to set ID +func (_options *UpdateSnapshotConsistencyGroupOptions) SetID(id string) *UpdateSnapshotConsistencyGroupOptions { + _options.ID = core.StringPtr(id) + return _options +} + +// SetSnapshotConsistencyGroupPatch : Allow user to set SnapshotConsistencyGroupPatch +func (_options *UpdateSnapshotConsistencyGroupOptions) SetSnapshotConsistencyGroupPatch(snapshotConsistencyGroupPatch map[string]interface{}) *UpdateSnapshotConsistencyGroupOptions { + _options.SnapshotConsistencyGroupPatch = snapshotConsistencyGroupPatch + return _options +} + +// SetIfMatch : Allow user to set IfMatch +func (_options *UpdateSnapshotConsistencyGroupOptions) SetIfMatch(ifMatch string) *UpdateSnapshotConsistencyGroupOptions { + _options.IfMatch = core.StringPtr(ifMatch) + return _options +} + +// SetHeaders : Allow user to set Headers +func (options *UpdateSnapshotConsistencyGroupOptions) SetHeaders(param map[string]string) *UpdateSnapshotConsistencyGroupOptions { + options.Headers = param + return options +} + // UpdateSnapshotOptions : The UpdateSnapshot options. type UpdateSnapshotOptions struct { // The snapshot identifier. @@ -72755,11 +73953,11 @@ type VPNServer struct { // The reasons for the current VPN server health_state (if any): // - `cannot_access_client_certificate`: VPN server's client certificate is inaccessible - // (verify certificate exists and that IAM policies grant `VPN server for VPC` access to - // `Secrets Manager`) + // (verify certificate exists and that IAM policies grant `VPN server for VPC` access + // to `Secrets Manager`) // - `cannot_access_server_certificate`: VPN server's server certificate is inaccessible - // (verify certificate exists and that IAM policies grant `VPN server for VPC` access to - // `Secrets Manager`) + // (verify certificate exists and that IAM policies grant `VPN server for VPC` access + // to `Secrets Manager`) // - `cannot_create_vpc_route`: VPN cannot create route (check for conflict) // - `cannot_reserve_ip_address`: IP address exhaustion (release addresses on the VPN's // subnet) @@ -76388,6 +77586,57 @@ func UnmarshalZoneReference(m map[string]json.RawMessage, result interface{}) (e return } +// BackupPolicyJobSourceInstanceReference : BackupPolicyJobSourceInstanceReference struct +// This model "extends" BackupPolicyJobSource +type BackupPolicyJobSourceInstanceReference struct { + // The CRN for this virtual server instance. + CRN *string `json:"crn" validate:"required"` + + // If present, this property indicates the referenced resource has been deleted, and provides + // some supplementary information. + Deleted *InstanceReferenceDeleted `json:"deleted,omitempty"` + + // The URL for this virtual server instance. + Href *string `json:"href" validate:"required"` + + // The unique identifier for this virtual server instance. + ID *string `json:"id" validate:"required"` + + // The name for this virtual server instance. The name is unique across all virtual server instances in the region. + Name *string `json:"name" validate:"required"` +} + +func (*BackupPolicyJobSourceInstanceReference) isaBackupPolicyJobSource() bool { + return true +} + +// UnmarshalBackupPolicyJobSourceInstanceReference unmarshals an instance of BackupPolicyJobSourceInstanceReference from the specified map of raw messages. +func UnmarshalBackupPolicyJobSourceInstanceReference(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(BackupPolicyJobSourceInstanceReference) + err = core.UnmarshalPrimitive(m, "crn", &obj.CRN) + if err != nil { + return + } + err = core.UnmarshalModel(m, "deleted", &obj.Deleted, UnmarshalInstanceReferenceDeleted) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "href", &obj.Href) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "id", &obj.ID) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "name", &obj.Name) + if err != nil { + return + } + reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) + return +} + // BackupPolicyJobSourceVolumeReference : BackupPolicyJobSourceVolumeReference struct // This model "extends" BackupPolicyJobSource type BackupPolicyJobSourceVolumeReference struct { @@ -76460,6 +77709,554 @@ func UnmarshalBackupPolicyJobSourceVolumeReference(m map[string]json.RawMessage, return } +// BackupPolicyMatchResourceTypeInstance : BackupPolicyMatchResourceTypeInstance struct +// This model "extends" BackupPolicy +type BackupPolicyMatchResourceTypeInstance struct { + // The date and time that the backup policy was created. + CreatedAt *strfmt.DateTime `json:"created_at" validate:"required"` + + // The CRN for this backup policy. + CRN *string `json:"crn" validate:"required"` + + // The reasons for the current `health_state` (if any). + // + // The enumerated reason code values for this property will expand in the future. When processing this property, check + // for and log unknown values. Optionally halt processing and surface the error, or bypass the resource on which the + // unexpected reason code was encountered. + HealthReasons []BackupPolicyHealthReason `json:"health_reasons" validate:"required"` + + // The health of this resource. + // - `ok`: No abnormal behavior detected + // - `degraded`: Experiencing compromised performance, capacity, or connectivity + // - `faulted`: Completely unreachable, inoperative, or otherwise entirely incapacitated + // - `inapplicable`: The health state does not apply because of the current lifecycle state. A resource with a + // lifecycle state of `failed` or `deleting` will have a health state of `inapplicable`. A `pending` resource may also + // have this state. + HealthState *string `json:"health_state" validate:"required"` + + // The URL for this backup policy. + Href *string `json:"href" validate:"required"` + + // The unique identifier for this backup policy. + ID *string `json:"id" validate:"required"` + + // The date and time that the most recent job for this backup policy completed. + // + // If absent, no job has yet completed for this backup policy. + LastJobCompletedAt *strfmt.DateTime `json:"last_job_completed_at,omitempty"` + + // The lifecycle state of the backup policy. + LifecycleState *string `json:"lifecycle_state" validate:"required"` + + // The user tags this backup policy applies to. Resources that have both a matching user tag and a matching type will + // be subject to the backup policy. + MatchUserTags []string `json:"match_user_tags" validate:"required"` + + // The name for this backup policy. The name is unique across all backup policies in the region. + Name *string `json:"name" validate:"required"` + + // The plans for the backup policy. + Plans []BackupPolicyPlanReference `json:"plans" validate:"required"` + + // The resource group for this backup policy. + ResourceGroup *ResourceGroupReference `json:"resource_group" validate:"required"` + + // The resource type. + ResourceType *string `json:"resource_type" validate:"required"` + + Scope BackupPolicyScopeIntf `json:"scope" validate:"required"` + + // The included content for backups created using this policy: + // - `boot_volume`: Include the instance's boot volume. + // - `data_volumes`: Include the instance's data volumes. + // + // The enumerated values for this property may expand in the future. When processing this property, check for and log + // unknown values. Optionally halt processing and surface the error, or bypass the backup policy on which the + // unexpected property value was encountered. + IncludedContent []string `json:"included_content" validate:"required"` + + // The resource type this backup policy applies to. Resources that have both a matching type and a matching user tag + // will be subject to the backup policy. + // + // The enumerated values for this property may expand in the future. When processing this property, check for and log + // unknown values. Optionally halt processing and surface the error, or bypass the backup policy on which the + // unexpected property value was encountered. + MatchResourceType *string `json:"match_resource_type" validate:"required"` +} + +// Constants associated with the BackupPolicyMatchResourceTypeInstance.HealthState property. +// The health of this resource. +// - `ok`: No abnormal behavior detected +// - `degraded`: Experiencing compromised performance, capacity, or connectivity +// - `faulted`: Completely unreachable, inoperative, or otherwise entirely incapacitated +// - `inapplicable`: The health state does not apply because of the current lifecycle state. A resource with a lifecycle +// state of `failed` or `deleting` will have a health state of `inapplicable`. A `pending` resource may also have this +// state. +const ( + BackupPolicyMatchResourceTypeInstanceHealthStateDegradedConst = "degraded" + BackupPolicyMatchResourceTypeInstanceHealthStateFaultedConst = "faulted" + BackupPolicyMatchResourceTypeInstanceHealthStateInapplicableConst = "inapplicable" + BackupPolicyMatchResourceTypeInstanceHealthStateOkConst = "ok" +) + +// Constants associated with the BackupPolicyMatchResourceTypeInstance.LifecycleState property. +// The lifecycle state of the backup policy. +const ( + BackupPolicyMatchResourceTypeInstanceLifecycleStateDeletingConst = "deleting" + BackupPolicyMatchResourceTypeInstanceLifecycleStateFailedConst = "failed" + BackupPolicyMatchResourceTypeInstanceLifecycleStatePendingConst = "pending" + BackupPolicyMatchResourceTypeInstanceLifecycleStateStableConst = "stable" + BackupPolicyMatchResourceTypeInstanceLifecycleStateSuspendedConst = "suspended" + BackupPolicyMatchResourceTypeInstanceLifecycleStateUpdatingConst = "updating" + BackupPolicyMatchResourceTypeInstanceLifecycleStateWaitingConst = "waiting" +) + +// Constants associated with the BackupPolicyMatchResourceTypeInstance.ResourceType property. +// The resource type. +const ( + BackupPolicyMatchResourceTypeInstanceResourceTypeBackupPolicyConst = "backup_policy" +) + +// Constants associated with the BackupPolicyMatchResourceTypeInstance.IncludedContent property. +// An item to include. +const ( + BackupPolicyMatchResourceTypeInstanceIncludedContentBootVolumeConst = "boot_volume" + BackupPolicyMatchResourceTypeInstanceIncludedContentDataVolumesConst = "data_volumes" +) + +// Constants associated with the BackupPolicyMatchResourceTypeInstance.MatchResourceType property. +// The resource type this backup policy applies to. Resources that have both a matching type and a matching user tag +// will be subject to the backup policy. +// +// The enumerated values for this property may expand in the future. When processing this property, check for and log +// unknown values. Optionally halt processing and surface the error, or bypass the backup policy on which the unexpected +// property value was encountered. +const ( + BackupPolicyMatchResourceTypeInstanceMatchResourceTypeInstanceConst = "instance" +) + +func (*BackupPolicyMatchResourceTypeInstance) isaBackupPolicy() bool { + return true +} + +// UnmarshalBackupPolicyMatchResourceTypeInstance unmarshals an instance of BackupPolicyMatchResourceTypeInstance from the specified map of raw messages. +func UnmarshalBackupPolicyMatchResourceTypeInstance(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(BackupPolicyMatchResourceTypeInstance) + err = core.UnmarshalPrimitive(m, "created_at", &obj.CreatedAt) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "crn", &obj.CRN) + if err != nil { + return + } + err = core.UnmarshalModel(m, "health_reasons", &obj.HealthReasons, UnmarshalBackupPolicyHealthReason) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "health_state", &obj.HealthState) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "href", &obj.Href) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "id", &obj.ID) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "last_job_completed_at", &obj.LastJobCompletedAt) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "lifecycle_state", &obj.LifecycleState) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "match_user_tags", &obj.MatchUserTags) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "name", &obj.Name) + if err != nil { + return + } + err = core.UnmarshalModel(m, "plans", &obj.Plans, UnmarshalBackupPolicyPlanReference) + if err != nil { + return + } + err = core.UnmarshalModel(m, "resource_group", &obj.ResourceGroup, UnmarshalResourceGroupReference) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "resource_type", &obj.ResourceType) + if err != nil { + return + } + err = core.UnmarshalModel(m, "scope", &obj.Scope, UnmarshalBackupPolicyScope) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "included_content", &obj.IncludedContent) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "match_resource_type", &obj.MatchResourceType) + if err != nil { + return + } + reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) + return +} + +// BackupPolicyMatchResourceTypeVolume : BackupPolicyMatchResourceTypeVolume struct +// This model "extends" BackupPolicy +type BackupPolicyMatchResourceTypeVolume struct { + // The date and time that the backup policy was created. + CreatedAt *strfmt.DateTime `json:"created_at" validate:"required"` + + // The CRN for this backup policy. + CRN *string `json:"crn" validate:"required"` + + // The reasons for the current `health_state` (if any). + // + // The enumerated reason code values for this property will expand in the future. When processing this property, check + // for and log unknown values. Optionally halt processing and surface the error, or bypass the resource on which the + // unexpected reason code was encountered. + HealthReasons []BackupPolicyHealthReason `json:"health_reasons" validate:"required"` + + // The health of this resource. + // - `ok`: No abnormal behavior detected + // - `degraded`: Experiencing compromised performance, capacity, or connectivity + // - `faulted`: Completely unreachable, inoperative, or otherwise entirely incapacitated + // - `inapplicable`: The health state does not apply because of the current lifecycle state. A resource with a + // lifecycle state of `failed` or `deleting` will have a health state of `inapplicable`. A `pending` resource may also + // have this state. + HealthState *string `json:"health_state" validate:"required"` + + // The URL for this backup policy. + Href *string `json:"href" validate:"required"` + + // The unique identifier for this backup policy. + ID *string `json:"id" validate:"required"` + + // The date and time that the most recent job for this backup policy completed. + // + // If absent, no job has yet completed for this backup policy. + LastJobCompletedAt *strfmt.DateTime `json:"last_job_completed_at,omitempty"` + + // The lifecycle state of the backup policy. + LifecycleState *string `json:"lifecycle_state" validate:"required"` + + // The user tags this backup policy applies to. Resources that have both a matching user tag and a matching type will + // be subject to the backup policy. + MatchUserTags []string `json:"match_user_tags" validate:"required"` + + // The name for this backup policy. The name is unique across all backup policies in the region. + Name *string `json:"name" validate:"required"` + + // The plans for the backup policy. + Plans []BackupPolicyPlanReference `json:"plans" validate:"required"` + + // The resource group for this backup policy. + ResourceGroup *ResourceGroupReference `json:"resource_group" validate:"required"` + + // The resource type. + ResourceType *string `json:"resource_type" validate:"required"` + + Scope BackupPolicyScopeIntf `json:"scope" validate:"required"` + + // The resource type this backup policy applies to. Resources that have both a matching type and a matching user tag + // will be subject to the backup policy. + // + // The enumerated values for this property may expand in the future. When processing this property, check for and log + // unknown values. Optionally halt processing and surface the error, or bypass the backup policy on which the + // unexpected property value was encountered. + MatchResourceType *string `json:"match_resource_type" validate:"required"` +} + +// Constants associated with the BackupPolicyMatchResourceTypeVolume.HealthState property. +// The health of this resource. +// - `ok`: No abnormal behavior detected +// - `degraded`: Experiencing compromised performance, capacity, or connectivity +// - `faulted`: Completely unreachable, inoperative, or otherwise entirely incapacitated +// - `inapplicable`: The health state does not apply because of the current lifecycle state. A resource with a lifecycle +// state of `failed` or `deleting` will have a health state of `inapplicable`. A `pending` resource may also have this +// state. +const ( + BackupPolicyMatchResourceTypeVolumeHealthStateDegradedConst = "degraded" + BackupPolicyMatchResourceTypeVolumeHealthStateFaultedConst = "faulted" + BackupPolicyMatchResourceTypeVolumeHealthStateInapplicableConst = "inapplicable" + BackupPolicyMatchResourceTypeVolumeHealthStateOkConst = "ok" +) + +// Constants associated with the BackupPolicyMatchResourceTypeVolume.LifecycleState property. +// The lifecycle state of the backup policy. +const ( + BackupPolicyMatchResourceTypeVolumeLifecycleStateDeletingConst = "deleting" + BackupPolicyMatchResourceTypeVolumeLifecycleStateFailedConst = "failed" + BackupPolicyMatchResourceTypeVolumeLifecycleStatePendingConst = "pending" + BackupPolicyMatchResourceTypeVolumeLifecycleStateStableConst = "stable" + BackupPolicyMatchResourceTypeVolumeLifecycleStateSuspendedConst = "suspended" + BackupPolicyMatchResourceTypeVolumeLifecycleStateUpdatingConst = "updating" + BackupPolicyMatchResourceTypeVolumeLifecycleStateWaitingConst = "waiting" +) + +// Constants associated with the BackupPolicyMatchResourceTypeVolume.ResourceType property. +// The resource type. +const ( + BackupPolicyMatchResourceTypeVolumeResourceTypeBackupPolicyConst = "backup_policy" +) + +// Constants associated with the BackupPolicyMatchResourceTypeVolume.MatchResourceType property. +// The resource type this backup policy applies to. Resources that have both a matching type and a matching user tag +// will be subject to the backup policy. +// +// The enumerated values for this property may expand in the future. When processing this property, check for and log +// unknown values. Optionally halt processing and surface the error, or bypass the backup policy on which the unexpected +// property value was encountered. +const ( + BackupPolicyMatchResourceTypeVolumeMatchResourceTypeVolumeConst = "volume" +) + +func (*BackupPolicyMatchResourceTypeVolume) isaBackupPolicy() bool { + return true +} + +// UnmarshalBackupPolicyMatchResourceTypeVolume unmarshals an instance of BackupPolicyMatchResourceTypeVolume from the specified map of raw messages. +func UnmarshalBackupPolicyMatchResourceTypeVolume(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(BackupPolicyMatchResourceTypeVolume) + err = core.UnmarshalPrimitive(m, "created_at", &obj.CreatedAt) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "crn", &obj.CRN) + if err != nil { + return + } + err = core.UnmarshalModel(m, "health_reasons", &obj.HealthReasons, UnmarshalBackupPolicyHealthReason) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "health_state", &obj.HealthState) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "href", &obj.Href) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "id", &obj.ID) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "last_job_completed_at", &obj.LastJobCompletedAt) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "lifecycle_state", &obj.LifecycleState) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "match_user_tags", &obj.MatchUserTags) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "name", &obj.Name) + if err != nil { + return + } + err = core.UnmarshalModel(m, "plans", &obj.Plans, UnmarshalBackupPolicyPlanReference) + if err != nil { + return + } + err = core.UnmarshalModel(m, "resource_group", &obj.ResourceGroup, UnmarshalResourceGroupReference) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "resource_type", &obj.ResourceType) + if err != nil { + return + } + err = core.UnmarshalModel(m, "scope", &obj.Scope, UnmarshalBackupPolicyScope) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "match_resource_type", &obj.MatchResourceType) + if err != nil { + return + } + reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) + return +} + +// BackupPolicyPrototypeBackupPolicyMatchResourceTypeInstancePrototype : BackupPolicyPrototypeBackupPolicyMatchResourceTypeInstancePrototype struct +// This model "extends" BackupPolicyPrototype +type BackupPolicyPrototypeBackupPolicyMatchResourceTypeInstancePrototype struct { + // The user tags this backup policy will apply to. Resources that have both a matching user tag and a matching type + // will be subject to the backup policy. + MatchUserTags []string `json:"match_user_tags" validate:"required"` + + // The name for this backup policy. The name must not be used by another backup policy in the region. If unspecified, + // the name will be a hyphenated list of randomly-selected words. + Name *string `json:"name,omitempty"` + + // The prototype objects for backup plans to be created for this backup policy. + Plans []BackupPolicyPlanPrototype `json:"plans,omitempty"` + + ResourceGroup ResourceGroupIdentityIntf `json:"resource_group,omitempty"` + + Scope BackupPolicyScopePrototypeIntf `json:"scope,omitempty"` + + // The included content for backups created using this policy: + // - `boot_volume`: Include the instance's boot volume. + // - `data_volumes`: Include the instance's data volumes. + IncludedContent []string `json:"included_content,omitempty"` + + // The resource type this backup policy will apply to. Resources that have both a matching type and a matching user tag + // will be subject to the backup policy. + MatchResourceType *string `json:"match_resource_type" validate:"required"` +} + +// Constants associated with the BackupPolicyPrototypeBackupPolicyMatchResourceTypeInstancePrototype.IncludedContent property. +// An item to include. +const ( + BackupPolicyPrototypeBackupPolicyMatchResourceTypeInstancePrototypeIncludedContentBootVolumeConst = "boot_volume" + BackupPolicyPrototypeBackupPolicyMatchResourceTypeInstancePrototypeIncludedContentDataVolumesConst = "data_volumes" +) + +// Constants associated with the BackupPolicyPrototypeBackupPolicyMatchResourceTypeInstancePrototype.MatchResourceType property. +// The resource type this backup policy will apply to. Resources that have both a matching type and a matching user tag +// will be subject to the backup policy. +const ( + BackupPolicyPrototypeBackupPolicyMatchResourceTypeInstancePrototypeMatchResourceTypeInstanceConst = "instance" +) + +// NewBackupPolicyPrototypeBackupPolicyMatchResourceTypeInstancePrototype : Instantiate BackupPolicyPrototypeBackupPolicyMatchResourceTypeInstancePrototype (Generic Model Constructor) +func (*VpcV1) NewBackupPolicyPrototypeBackupPolicyMatchResourceTypeInstancePrototype(matchUserTags []string, matchResourceType string) (_model *BackupPolicyPrototypeBackupPolicyMatchResourceTypeInstancePrototype, err error) { + _model = &BackupPolicyPrototypeBackupPolicyMatchResourceTypeInstancePrototype{ + MatchUserTags: matchUserTags, + MatchResourceType: core.StringPtr(matchResourceType), + } + err = core.ValidateStruct(_model, "required parameters") + return +} + +func (*BackupPolicyPrototypeBackupPolicyMatchResourceTypeInstancePrototype) isaBackupPolicyPrototype() bool { + return true +} + +// UnmarshalBackupPolicyPrototypeBackupPolicyMatchResourceTypeInstancePrototype unmarshals an instance of BackupPolicyPrototypeBackupPolicyMatchResourceTypeInstancePrototype from the specified map of raw messages. +func UnmarshalBackupPolicyPrototypeBackupPolicyMatchResourceTypeInstancePrototype(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(BackupPolicyPrototypeBackupPolicyMatchResourceTypeInstancePrototype) + err = core.UnmarshalPrimitive(m, "match_user_tags", &obj.MatchUserTags) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "name", &obj.Name) + if err != nil { + return + } + err = core.UnmarshalModel(m, "plans", &obj.Plans, UnmarshalBackupPolicyPlanPrototype) + if err != nil { + return + } + err = core.UnmarshalModel(m, "resource_group", &obj.ResourceGroup, UnmarshalResourceGroupIdentity) + if err != nil { + return + } + err = core.UnmarshalModel(m, "scope", &obj.Scope, UnmarshalBackupPolicyScopePrototype) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "included_content", &obj.IncludedContent) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "match_resource_type", &obj.MatchResourceType) + if err != nil { + return + } + reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) + return +} + +// BackupPolicyPrototypeBackupPolicyMatchResourceTypeVolumePrototype : BackupPolicyPrototypeBackupPolicyMatchResourceTypeVolumePrototype struct +// This model "extends" BackupPolicyPrototype +type BackupPolicyPrototypeBackupPolicyMatchResourceTypeVolumePrototype struct { + // The user tags this backup policy will apply to. Resources that have both a matching user tag and a matching type + // will be subject to the backup policy. + MatchUserTags []string `json:"match_user_tags" validate:"required"` + + // The name for this backup policy. The name must not be used by another backup policy in the region. If unspecified, + // the name will be a hyphenated list of randomly-selected words. + Name *string `json:"name,omitempty"` + + // The prototype objects for backup plans to be created for this backup policy. + Plans []BackupPolicyPlanPrototype `json:"plans,omitempty"` + + ResourceGroup ResourceGroupIdentityIntf `json:"resource_group,omitempty"` + + Scope BackupPolicyScopePrototypeIntf `json:"scope,omitempty"` + + // The resource type this backup policy will apply to. Resources that have both a matching type and a matching user tag + // will be subject to the backup policy. + MatchResourceType *string `json:"match_resource_type" validate:"required"` +} + +// Constants associated with the BackupPolicyPrototypeBackupPolicyMatchResourceTypeVolumePrototype.MatchResourceType property. +// The resource type this backup policy will apply to. Resources that have both a matching type and a matching user tag +// will be subject to the backup policy. +const ( + BackupPolicyPrototypeBackupPolicyMatchResourceTypeVolumePrototypeMatchResourceTypeVolumeConst = "volume" +) + +// NewBackupPolicyPrototypeBackupPolicyMatchResourceTypeVolumePrototype : Instantiate BackupPolicyPrototypeBackupPolicyMatchResourceTypeVolumePrototype (Generic Model Constructor) +func (*VpcV1) NewBackupPolicyPrototypeBackupPolicyMatchResourceTypeVolumePrototype(matchUserTags []string, matchResourceType string) (_model *BackupPolicyPrototypeBackupPolicyMatchResourceTypeVolumePrototype, err error) { + _model = &BackupPolicyPrototypeBackupPolicyMatchResourceTypeVolumePrototype{ + MatchUserTags: matchUserTags, + MatchResourceType: core.StringPtr(matchResourceType), + } + err = core.ValidateStruct(_model, "required parameters") + return +} + +func (*BackupPolicyPrototypeBackupPolicyMatchResourceTypeVolumePrototype) isaBackupPolicyPrototype() bool { + return true +} + +// UnmarshalBackupPolicyPrototypeBackupPolicyMatchResourceTypeVolumePrototype unmarshals an instance of BackupPolicyPrototypeBackupPolicyMatchResourceTypeVolumePrototype from the specified map of raw messages. +func UnmarshalBackupPolicyPrototypeBackupPolicyMatchResourceTypeVolumePrototype(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(BackupPolicyPrototypeBackupPolicyMatchResourceTypeVolumePrototype) + err = core.UnmarshalPrimitive(m, "match_user_tags", &obj.MatchUserTags) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "name", &obj.Name) + if err != nil { + return + } + err = core.UnmarshalModel(m, "plans", &obj.Plans, UnmarshalBackupPolicyPlanPrototype) + if err != nil { + return + } + err = core.UnmarshalModel(m, "resource_group", &obj.ResourceGroup, UnmarshalResourceGroupIdentity) + if err != nil { + return + } + err = core.UnmarshalModel(m, "scope", &obj.Scope, UnmarshalBackupPolicyScopePrototype) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "match_resource_type", &obj.MatchResourceType) + if err != nil { + return + } + reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) + return +} + // BackupPolicyScopePrototypeEnterpriseIdentity : Identifies an enterprise by a unique property. // Models which "extend" this model: // - BackupPolicyScopePrototypeEnterpriseIdentityEnterpriseIdentityByCRN @@ -92968,6 +94765,61 @@ func UnmarshalSharePrototypeShareBySourceShare(m map[string]json.RawMessage, res return } +// SnapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshots : SnapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshots struct +// This model "extends" SnapshotConsistencyGroupPrototype +type SnapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshots struct { + // Indicates whether deleting the snapshot consistency group will also delete the snapshots in the group. + DeleteSnapshotsOnDelete *bool `json:"delete_snapshots_on_delete,omitempty"` + + // The name for this snapshot consistency group. The name must be unique across all snapshot consistency groups in the + // region. + // + // If unspecified, the name will be a hyphenated list of randomly-selected words. + Name *string `json:"name,omitempty"` + + ResourceGroup ResourceGroupIdentityIntf `json:"resource_group,omitempty"` + + // The data-consistent member snapshots to create. All snapshots must specify a + // `source_volume` attached to the same virtual server instance. + Snapshots []SnapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshotsSnapshotsItem `json:"snapshots" validate:"required"` +} + +// NewSnapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshots : Instantiate SnapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshots (Generic Model Constructor) +func (*VpcV1) NewSnapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshots(snapshots []SnapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshotsSnapshotsItem) (_model *SnapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshots, err error) { + _model = &SnapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshots{ + Snapshots: snapshots, + } + err = core.ValidateStruct(_model, "required parameters") + return +} + +func (*SnapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshots) isaSnapshotConsistencyGroupPrototype() bool { + return true +} + +// UnmarshalSnapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshots unmarshals an instance of SnapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshots from the specified map of raw messages. +func UnmarshalSnapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshots(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(SnapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshots) + err = core.UnmarshalPrimitive(m, "delete_snapshots_on_delete", &obj.DeleteSnapshotsOnDelete) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "name", &obj.Name) + if err != nil { + return + } + err = core.UnmarshalModel(m, "resource_group", &obj.ResourceGroup, UnmarshalResourceGroupIdentity) + if err != nil { + return + } + err = core.UnmarshalModel(m, "snapshots", &obj.Snapshots, UnmarshalSnapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshotsSnapshotsItem) + if err != nil { + return + } + reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) + return +} + // SnapshotIdentityByCRN : SnapshotIdentityByCRN struct // This model "extends" SnapshotIdentity type SnapshotIdentityByCRN struct { @@ -101737,7 +103589,7 @@ func (pager *BackupPoliciesPager) HasNext() bool { } // GetNextWithContext returns the next page of results using the specified Context. -func (pager *BackupPoliciesPager) GetNextWithContext(ctx context.Context) (page []BackupPolicy, err error) { +func (pager *BackupPoliciesPager) GetNextWithContext(ctx context.Context) (page []BackupPolicyIntf, err error) { if !pager.HasNext() { return nil, fmt.Errorf("no more results available") } @@ -101768,9 +103620,9 @@ func (pager *BackupPoliciesPager) GetNextWithContext(ctx context.Context) (page // GetAllWithContext returns all results by invoking GetNextWithContext() repeatedly // until all pages of results have been retrieved. -func (pager *BackupPoliciesPager) GetAllWithContext(ctx context.Context) (allItems []BackupPolicy, err error) { +func (pager *BackupPoliciesPager) GetAllWithContext(ctx context.Context) (allItems []BackupPolicyIntf, err error) { for pager.HasNext() { - var nextPage []BackupPolicy + var nextPage []BackupPolicyIntf nextPage, err = pager.GetNextWithContext(ctx) if err != nil { return @@ -101781,12 +103633,12 @@ func (pager *BackupPoliciesPager) GetAllWithContext(ctx context.Context) (allIte } // GetNext invokes GetNextWithContext() using context.Background() as the Context parameter. -func (pager *BackupPoliciesPager) GetNext() (page []BackupPolicy, err error) { +func (pager *BackupPoliciesPager) GetNext() (page []BackupPolicyIntf, err error) { return pager.GetNextWithContext(context.Background()) } // GetAll invokes GetAllWithContext() using context.Background() as the Context parameter. -func (pager *BackupPoliciesPager) GetAll() (allItems []BackupPolicy, err error) { +func (pager *BackupPoliciesPager) GetAll() (allItems []BackupPolicyIntf, err error) { return pager.GetAllWithContext(context.Background()) } @@ -102385,6 +104237,91 @@ func (pager *VolumesPager) GetAll() (allItems []Volume, err error) { return pager.GetAllWithContext(context.Background()) } +// SnapshotConsistencyGroupsPager can be used to simplify the use of the "ListSnapshotConsistencyGroups" method. +type SnapshotConsistencyGroupsPager struct { + hasNext bool + options *ListSnapshotConsistencyGroupsOptions + client *VpcV1 + pageContext struct { + next *string + } +} + +// NewSnapshotConsistencyGroupsPager returns a new SnapshotConsistencyGroupsPager instance. +func (vpc *VpcV1) NewSnapshotConsistencyGroupsPager(options *ListSnapshotConsistencyGroupsOptions) (pager *SnapshotConsistencyGroupsPager, err error) { + if options.Start != nil && *options.Start != "" { + err = fmt.Errorf("the 'options.Start' field should not be set") + return + } + + var optionsCopy ListSnapshotConsistencyGroupsOptions = *options + pager = &SnapshotConsistencyGroupsPager{ + hasNext: true, + options: &optionsCopy, + client: vpc, + } + return +} + +// HasNext returns true if there are potentially more results to be retrieved. +func (pager *SnapshotConsistencyGroupsPager) HasNext() bool { + return pager.hasNext +} + +// GetNextWithContext returns the next page of results using the specified Context. +func (pager *SnapshotConsistencyGroupsPager) GetNextWithContext(ctx context.Context) (page []SnapshotConsistencyGroup, err error) { + if !pager.HasNext() { + return nil, fmt.Errorf("no more results available") + } + + pager.options.Start = pager.pageContext.next + + result, _, err := pager.client.ListSnapshotConsistencyGroupsWithContext(ctx, pager.options) + if err != nil { + return + } + + var next *string + if result.Next != nil { + var start *string + start, err = core.GetQueryParam(result.Next.Href, "start") + if err != nil { + err = fmt.Errorf("error retrieving 'start' query parameter from URL '%s': %s", *result.Next.Href, err.Error()) + return + } + next = start + } + pager.pageContext.next = next + pager.hasNext = (pager.pageContext.next != nil) + page = result.SnapshotConsistencyGroups + + return +} + +// GetAllWithContext returns all results by invoking GetNextWithContext() repeatedly +// until all pages of results have been retrieved. +func (pager *SnapshotConsistencyGroupsPager) GetAllWithContext(ctx context.Context) (allItems []SnapshotConsistencyGroup, err error) { + for pager.HasNext() { + var nextPage []SnapshotConsistencyGroup + nextPage, err = pager.GetNextWithContext(ctx) + if err != nil { + return + } + allItems = append(allItems, nextPage...) + } + return +} + +// GetNext invokes GetNextWithContext() using context.Background() as the Context parameter. +func (pager *SnapshotConsistencyGroupsPager) GetNext() (page []SnapshotConsistencyGroup, err error) { + return pager.GetNextWithContext(context.Background()) +} + +// GetAll invokes GetAllWithContext() using context.Background() as the Context parameter. +func (pager *SnapshotConsistencyGroupsPager) GetAll() (allItems []SnapshotConsistencyGroup, err error) { + return pager.GetAllWithContext(context.Background()) +} + // SnapshotsPager can be used to simplify the use of the "ListSnapshots" method. type SnapshotsPager struct { hasNext bool diff --git a/vpcv1/vpc_v1_examples_test.go b/vpcv1/vpc_v1_examples_test.go index 4fe080b..ca69f87 100644 --- a/vpcv1/vpc_v1_examples_test.go +++ b/vpcv1/vpc_v1_examples_test.go @@ -54,6 +54,7 @@ var ( floatingIPID string volumeID string snapshotID string + snapshotConsistencyGroupID string snapshotCopyCRN string snapshotCopyID string volumeAttachmentID string @@ -63,6 +64,7 @@ var ( ifMatchBackupPolicy string ifMatchBackupPolicyPlan string ifMatchBackupPolicyPlanRemoteCopy string + ifMatchSnapshotConsistencyGroup string ifMatchSnapshot string ifMatchSnapshotCopy string ifMatchVPNServer string @@ -3270,6 +3272,109 @@ var _ = Describe(`VpcV1 Examples Tests`, func() { Expect(snapshot).ToNot(BeNil()) }) + + It(`ListSnapshotConsistencyGroups request example`, func() { + fmt.Println("\nListSnapshotConsistencyGroups() result:") + // begin-list_snapshot_consistency_group + listSnapshotConsistencyGroupsOptions := vpcService.NewListSnapshotConsistencyGroupsOptions() + pager, err := vpcService.NewSnapshotConsistencyGroupsPager(listSnapshotConsistencyGroupsOptions) + if err != nil { + panic(err) + } + + var allResults []vpcv1.SnapshotConsistencyGroup + for pager.HasNext() { + nextPage, err := pager.GetNext() + if err != nil { + panic(err) + } + allResults = append(allResults, nextPage...) + } + // end-list_snapshot_consistency_group + Expect(err).To(BeNil()) + Expect(allResults).ShouldNot(BeEmpty()) + + }) + It(`CreateSnapshotConsistencyGroup request example`, func() { + fmt.Println("\nCreateSnapshotConsistencyGroup() result:") + + // begin-create_snapshot_consistency_group + name := getName("snapshotconsistencygroup") + volumeIdentityModel := &vpcv1.VolumeIdentityByID{ + ID: &volumeID, + } + snapshotConsistencyGroupPrototypeSnapshotsItem := &vpcv1.SnapshotConsistencyGroupPrototypeSnapshotsItem{ + Name: core.StringPtr("my-snapshot-1"), + SourceVolume: volumeIdentityModel, + // UserTags + } + + snapshotConsistencyGroupPrototype := &vpcv1.SnapshotConsistencyGroupPrototype{ + DeleteSnapshotsOnDelete: core.BoolPtr(true), + Name: core.StringPtr(name), + } + snapshotConsistencyGroupPrototype.Snapshots = []vpcv1.SnapshotConsistencyGroupPrototypeSnapshotsItem{*snapshotConsistencyGroupPrototypeSnapshotsItem} + + options := &vpcv1.CreateSnapshotConsistencyGroupOptions{ + SnapshotConsistencyGroupPrototype: snapshotConsistencyGroupPrototype, + } + snapshotConsistencyGroup, response, err := vpcService.CreateSnapshotConsistencyGroup(options) + + // end-create_snapshot_consistency_group + if err != nil { + panic(err) + } + Expect(err).To(BeNil()) + Expect(response.StatusCode).To(Equal(201)) + Expect(snapshotConsistencyGroup).ToNot(BeNil()) + snapshotConsistencyGroupID = *snapshotConsistencyGroup.ID + }) + It(`GetSnapshotConsistencyGroup request example`, func() { + fmt.Println("\nGetSnapshotConsistencyGroup() result:") + // begin-get_snapshot_consistency_group + + options := vpcService.NewGetSnapshotConsistencyGroupOptions( + snapshotConsistencyGroupID, + ) + snapshotConsistencyGroup, response, err := vpcService.GetSnapshotConsistencyGroup(options) + + // end-get_snapshot_consistency_group + if err != nil { + panic(err) + } + Expect(err).To(BeNil()) + Expect(response.StatusCode).To(Equal(200)) + Expect(snapshotConsistencyGroup).ToNot(BeNil()) + ifMatchSnapshotConsistencyGroup = response.GetHeaders()["Etag"][0] + }) + It(`UpdateSnapshotConsistencyGroup request example`, func() { + fmt.Println("UpdateSnapshotConsistencyGroup() result:") + name := getName("updatesnapshotconsistencygroup") + + // begin-update_snapshot_consistency_groupt + snapshotConsistencyGroupPatchModel := &vpcv1.SnapshotConsistencyGroupPatch{ + Name: &name, + DeleteSnapshotsOnDelete: core.BoolPtr(false), + } + snapshotPatchModelAsPatch, _ := snapshotConsistencyGroupPatchModel.AsPatch() + updateSnapshotConsistencyGroupOptions := &vpcv1.UpdateSnapshotConsistencyGroupOptions{ + ID: &snapshotConsistencyGroupID, + SnapshotConsistencyGroupPatch: snapshotPatchModelAsPatch, + IfMatch: &ifMatchSnapshotConsistencyGroup, + } + snapshotConsistencyGroup, response, err := vpcService.UpdateSnapshotConsistencyGroup(updateSnapshotConsistencyGroupOptions) + + // end-update_snapshot_consistency_group + if err != nil { + panic(err) + } + Expect(err).To(BeNil()) + + Expect(response.StatusCode).To(Equal(200)) + Expect(snapshotConsistencyGroup).ToNot(BeNil()) + + }) + It(`CreateSnapshotClone request example`, func() { fmt.Println("\nCreateSnapshotClone() result:") // begin-create_snapshot_clone @@ -4946,7 +5051,7 @@ var _ = Describe(`VpcV1 Examples Tests`, func() { panic(err) } - var allResults []vpcv1.BackupPolicy + var allResults []vpcv1.BackupPolicyIntf for pager.HasNext() { nextPage, err := pager.GetNext() if err != nil { @@ -4966,14 +5071,21 @@ var _ = Describe(`VpcV1 Examples Tests`, func() { // begin-create_backup_policy userTags := []string{"tag1", "tag2"} - createBackupPolicyOptions := vpcService.NewCreateBackupPolicyOptions(userTags) - createBackupPolicyOptions.SetName("my-backup-policy") - backupPolicy, response, err := vpcService.CreateBackupPolicy(createBackupPolicyOptions) + name := "my-backup-policy" + matchResourceType := "instance" + backupPolicyPrototype := &vpcv1.BackupPolicyPrototype{ + MatchUserTags: userTags, + Name: &name, + MatchResourceType: &matchResourceType, + } + createBackupPolicyOptions := vpcService.NewCreateBackupPolicyOptions(backupPolicyPrototype) + backupPolicyIntf, response, err := vpcService.CreateBackupPolicy(createBackupPolicyOptions) if err != nil { panic(err) } // end-create_backup_policy + backupPolicy := backupPolicyIntf.(*vpcv1.BackupPolicy) backupPolicyID = *backupPolicy.ID Expect(err).To(BeNil()) @@ -7102,6 +7214,21 @@ var _ = Describe(`VpcV1 Examples Tests`, func() { Expect(response.StatusCode).To(Equal(204)) }) + It(`DeleteSnapshotConsistencyGroup request example`, func() { + deleteSnapshotConsistencyGroupOptions := vpcService.NewDeleteSnapshotConsistencyGroupOptions( + snapshotConsistencyGroupID, + ) + // begin-delete_snapshot_consistency_group + _, response, err := vpcService.DeleteSnapshotConsistencyGroup(deleteSnapshotConsistencyGroupOptions) + if err != nil { + panic(err) + } + // end-delete_snapshot_consistency_group + fmt.Printf("\nDeleteSnapshotConsistencyGroup() response status code: %d\n", response.StatusCode) + + Expect(err).To(BeNil()) + Expect(response.StatusCode).To(Equal(204)) + }) It(`DeleteSnapshots request example`, func() { // begin-delete_snapshots diff --git a/vpcv1/vpc_v1_test.go b/vpcv1/vpc_v1_test.go index 5186ed3..3de888f 100644 --- a/vpcv1/vpc_v1_test.go +++ b/vpcv1/vpc_v1_test.go @@ -37552,7 +37552,7 @@ var _ = Describe(`VpcV1`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"backup_policies": [{"created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south:a/123456::backup-policy:r134-076191ba-49c2-4763-94fd-c70de73ee2e6", "health_reasons": [{"code": "missing_service_authorization_policies", "message": "One or more accounts are missing service authorization policies", "more_info": "https://cloud.ibm.com/docs/vpc?topic=vpc-backup-service-about&interface=ui"}], "health_state": "ok", "href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6", "id": "r134-076191ba-49c2-4763-94fd-c70de73ee2e6", "last_job_completed_at": "2019-01-01T12:00:00.000Z", "lifecycle_state": "stable", "match_resource_types": ["volume"], "match_user_tags": ["MatchUserTags"], "name": "my-backup-policy", "plans": [{"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6/plans/r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "id": "r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "name": "my-policy-plan", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "backup_policy_plan"}], "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "resource_type": "backup_policy", "scope": {"crn": "crn:v1:bluemix:public:enterprise::a/123456::enterprise:ebc2b430240943458b9e91e1432cfcce", "id": "fee82deba12e4c0fb69c3b09d1f12345", "resource_type": "enterprise"}}], "first": {"href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies?limit=20"}, "limit": 20, "next": {"href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies?start=9d5a91a3e2cbd233b5a5b33436855ed1&limit=20"}, "total_count": 132}`) + fmt.Fprintf(res, "%s", `{"backup_policies": [{"created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south:a/123456::backup-policy:r134-076191ba-49c2-4763-94fd-c70de73ee2e6", "health_reasons": [{"code": "missing_service_authorization_policies", "message": "One or more accounts are missing service authorization policies", "more_info": "https://cloud.ibm.com/docs/vpc?topic=vpc-backup-service-about&interface=ui"}], "health_state": "ok", "href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6", "id": "r134-076191ba-49c2-4763-94fd-c70de73ee2e6", "last_job_completed_at": "2019-01-01T12:00:00.000Z", "lifecycle_state": "stable", "match_user_tags": ["MatchUserTags"], "name": "my-backup-policy", "plans": [{"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6/plans/r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "id": "r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "name": "my-policy-plan", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "backup_policy_plan"}], "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "resource_type": "backup_policy", "scope": {"crn": "crn:v1:bluemix:public:enterprise::a/123456::enterprise:ebc2b430240943458b9e91e1432cfcce", "id": "fee82deba12e4c0fb69c3b09d1f12345", "resource_type": "enterprise"}, "included_content": ["data_volumes"], "match_resource_type": "instance"}], "first": {"href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies?limit=20"}, "limit": 20, "next": {"href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies?start=9d5a91a3e2cbd233b5a5b33436855ed1&limit=20"}, "total_count": 132}`) })) }) It(`Invoke ListBackupPolicies successfully with retries`, func() { @@ -37618,7 +37618,7 @@ var _ = Describe(`VpcV1`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"backup_policies": [{"created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south:a/123456::backup-policy:r134-076191ba-49c2-4763-94fd-c70de73ee2e6", "health_reasons": [{"code": "missing_service_authorization_policies", "message": "One or more accounts are missing service authorization policies", "more_info": "https://cloud.ibm.com/docs/vpc?topic=vpc-backup-service-about&interface=ui"}], "health_state": "ok", "href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6", "id": "r134-076191ba-49c2-4763-94fd-c70de73ee2e6", "last_job_completed_at": "2019-01-01T12:00:00.000Z", "lifecycle_state": "stable", "match_resource_types": ["volume"], "match_user_tags": ["MatchUserTags"], "name": "my-backup-policy", "plans": [{"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6/plans/r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "id": "r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "name": "my-policy-plan", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "backup_policy_plan"}], "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "resource_type": "backup_policy", "scope": {"crn": "crn:v1:bluemix:public:enterprise::a/123456::enterprise:ebc2b430240943458b9e91e1432cfcce", "id": "fee82deba12e4c0fb69c3b09d1f12345", "resource_type": "enterprise"}}], "first": {"href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies?limit=20"}, "limit": 20, "next": {"href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies?start=9d5a91a3e2cbd233b5a5b33436855ed1&limit=20"}, "total_count": 132}`) + fmt.Fprintf(res, "%s", `{"backup_policies": [{"created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south:a/123456::backup-policy:r134-076191ba-49c2-4763-94fd-c70de73ee2e6", "health_reasons": [{"code": "missing_service_authorization_policies", "message": "One or more accounts are missing service authorization policies", "more_info": "https://cloud.ibm.com/docs/vpc?topic=vpc-backup-service-about&interface=ui"}], "health_state": "ok", "href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6", "id": "r134-076191ba-49c2-4763-94fd-c70de73ee2e6", "last_job_completed_at": "2019-01-01T12:00:00.000Z", "lifecycle_state": "stable", "match_user_tags": ["MatchUserTags"], "name": "my-backup-policy", "plans": [{"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6/plans/r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "id": "r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "name": "my-policy-plan", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "backup_policy_plan"}], "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "resource_type": "backup_policy", "scope": {"crn": "crn:v1:bluemix:public:enterprise::a/123456::enterprise:ebc2b430240943458b9e91e1432cfcce", "id": "fee82deba12e4c0fb69c3b09d1f12345", "resource_type": "enterprise"}, "included_content": ["data_volumes"], "match_resource_type": "instance"}], "first": {"href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies?limit=20"}, "limit": 20, "next": {"href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies?start=9d5a91a3e2cbd233b5a5b33436855ed1&limit=20"}, "total_count": 132}`) })) }) It(`Invoke ListBackupPolicies successfully`, func() { @@ -37765,9 +37765,9 @@ var _ = Describe(`VpcV1`, func() { res.WriteHeader(200) requestNumber++ if requestNumber == 1 { - fmt.Fprintf(res, "%s", `{"next":{"href":"https://myhost.com/somePath?start=1"},"backup_policies":[{"created_at":"2019-01-01T12:00:00.000Z","crn":"crn:v1:bluemix:public:is:us-south:a/123456::backup-policy:r134-076191ba-49c2-4763-94fd-c70de73ee2e6","health_reasons":[{"code":"missing_service_authorization_policies","message":"One or more accounts are missing service authorization policies","more_info":"https://cloud.ibm.com/docs/vpc?topic=vpc-backup-service-about&interface=ui"}],"health_state":"ok","href":"https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6","id":"r134-076191ba-49c2-4763-94fd-c70de73ee2e6","last_job_completed_at":"2019-01-01T12:00:00.000Z","lifecycle_state":"stable","match_resource_types":["volume"],"match_user_tags":["MatchUserTags"],"name":"my-backup-policy","plans":[{"deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6/plans/r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178","id":"r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178","name":"my-policy-plan","remote":{"region":{"href":"https://us-south.iaas.cloud.ibm.com/v1/regions/us-south","name":"us-south"}},"resource_type":"backup_policy_plan"}],"resource_group":{"href":"https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345","id":"fee82deba12e4c0fb69c3b09d1f12345","name":"my-resource-group"},"resource_type":"backup_policy","scope":{"crn":"crn:v1:bluemix:public:enterprise::a/123456::enterprise:ebc2b430240943458b9e91e1432cfcce","id":"fee82deba12e4c0fb69c3b09d1f12345","resource_type":"enterprise"}}],"total_count":2,"limit":1}`) + fmt.Fprintf(res, "%s", `{"next":{"href":"https://myhost.com/somePath?start=1"},"backup_policies":[{"created_at":"2019-01-01T12:00:00.000Z","crn":"crn:v1:bluemix:public:is:us-south:a/123456::backup-policy:r134-076191ba-49c2-4763-94fd-c70de73ee2e6","health_reasons":[{"code":"missing_service_authorization_policies","message":"One or more accounts are missing service authorization policies","more_info":"https://cloud.ibm.com/docs/vpc?topic=vpc-backup-service-about&interface=ui"}],"health_state":"ok","href":"https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6","id":"r134-076191ba-49c2-4763-94fd-c70de73ee2e6","last_job_completed_at":"2019-01-01T12:00:00.000Z","lifecycle_state":"stable","match_user_tags":["MatchUserTags"],"name":"my-backup-policy","plans":[{"deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6/plans/r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178","id":"r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178","name":"my-policy-plan","remote":{"region":{"href":"https://us-south.iaas.cloud.ibm.com/v1/regions/us-south","name":"us-south"}},"resource_type":"backup_policy_plan"}],"resource_group":{"href":"https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345","id":"fee82deba12e4c0fb69c3b09d1f12345","name":"my-resource-group"},"resource_type":"backup_policy","scope":{"crn":"crn:v1:bluemix:public:enterprise::a/123456::enterprise:ebc2b430240943458b9e91e1432cfcce","id":"fee82deba12e4c0fb69c3b09d1f12345","resource_type":"enterprise"},"included_content":["data_volumes"],"match_resource_type":"instance"}],"total_count":2,"limit":1}`) } else if requestNumber == 2 { - fmt.Fprintf(res, "%s", `{"backup_policies":[{"created_at":"2019-01-01T12:00:00.000Z","crn":"crn:v1:bluemix:public:is:us-south:a/123456::backup-policy:r134-076191ba-49c2-4763-94fd-c70de73ee2e6","health_reasons":[{"code":"missing_service_authorization_policies","message":"One or more accounts are missing service authorization policies","more_info":"https://cloud.ibm.com/docs/vpc?topic=vpc-backup-service-about&interface=ui"}],"health_state":"ok","href":"https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6","id":"r134-076191ba-49c2-4763-94fd-c70de73ee2e6","last_job_completed_at":"2019-01-01T12:00:00.000Z","lifecycle_state":"stable","match_resource_types":["volume"],"match_user_tags":["MatchUserTags"],"name":"my-backup-policy","plans":[{"deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6/plans/r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178","id":"r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178","name":"my-policy-plan","remote":{"region":{"href":"https://us-south.iaas.cloud.ibm.com/v1/regions/us-south","name":"us-south"}},"resource_type":"backup_policy_plan"}],"resource_group":{"href":"https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345","id":"fee82deba12e4c0fb69c3b09d1f12345","name":"my-resource-group"},"resource_type":"backup_policy","scope":{"crn":"crn:v1:bluemix:public:enterprise::a/123456::enterprise:ebc2b430240943458b9e91e1432cfcce","id":"fee82deba12e4c0fb69c3b09d1f12345","resource_type":"enterprise"}}],"total_count":2,"limit":1}`) + fmt.Fprintf(res, "%s", `{"backup_policies":[{"created_at":"2019-01-01T12:00:00.000Z","crn":"crn:v1:bluemix:public:is:us-south:a/123456::backup-policy:r134-076191ba-49c2-4763-94fd-c70de73ee2e6","health_reasons":[{"code":"missing_service_authorization_policies","message":"One or more accounts are missing service authorization policies","more_info":"https://cloud.ibm.com/docs/vpc?topic=vpc-backup-service-about&interface=ui"}],"health_state":"ok","href":"https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6","id":"r134-076191ba-49c2-4763-94fd-c70de73ee2e6","last_job_completed_at":"2019-01-01T12:00:00.000Z","lifecycle_state":"stable","match_user_tags":["MatchUserTags"],"name":"my-backup-policy","plans":[{"deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6/plans/r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178","id":"r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178","name":"my-policy-plan","remote":{"region":{"href":"https://us-south.iaas.cloud.ibm.com/v1/regions/us-south","name":"us-south"}},"resource_type":"backup_policy_plan"}],"resource_group":{"href":"https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345","id":"fee82deba12e4c0fb69c3b09d1f12345","name":"my-resource-group"},"resource_type":"backup_policy","scope":{"crn":"crn:v1:bluemix:public:enterprise::a/123456::enterprise:ebc2b430240943458b9e91e1432cfcce","id":"fee82deba12e4c0fb69c3b09d1f12345","resource_type":"enterprise"},"included_content":["data_volumes"],"match_resource_type":"instance"}],"total_count":2,"limit":1}`) } else { res.WriteHeader(400) } @@ -37793,7 +37793,7 @@ var _ = Describe(`VpcV1`, func() { Expect(err).To(BeNil()) Expect(pager).ToNot(BeNil()) - var allResults []vpcv1.BackupPolicy + var allResults []vpcv1.BackupPolicyIntf for pager.HasNext() { nextPage, err := pager.GetNext() Expect(err).To(BeNil()) @@ -37903,14 +37903,18 @@ var _ = Describe(`VpcV1`, func() { backupPolicyScopePrototypeModel := new(vpcv1.BackupPolicyScopePrototypeEnterpriseIdentityEnterpriseIdentityByCRN) backupPolicyScopePrototypeModel.CRN = core.StringPtr("crn:v1:bluemix:public:enterprise::a/123456::enterprise:ebc2b430240943458b9e91e1432cfcce") + // Construct an instance of the BackupPolicyPrototypeBackupPolicyMatchResourceTypeVolumePrototype model + backupPolicyPrototypeModel := new(vpcv1.BackupPolicyPrototypeBackupPolicyMatchResourceTypeVolumePrototype) + backupPolicyPrototypeModel.MatchUserTags = []string{"my-daily-backup-policy"} + backupPolicyPrototypeModel.Name = core.StringPtr("my-backup-policy") + backupPolicyPrototypeModel.Plans = []vpcv1.BackupPolicyPlanPrototype{*backupPolicyPlanPrototypeModel} + backupPolicyPrototypeModel.ResourceGroup = resourceGroupIdentityModel + backupPolicyPrototypeModel.Scope = backupPolicyScopePrototypeModel + backupPolicyPrototypeModel.MatchResourceType = core.StringPtr("volume") + // Construct an instance of the CreateBackupPolicyOptions model createBackupPolicyOptionsModel := new(vpcv1.CreateBackupPolicyOptions) - createBackupPolicyOptionsModel.MatchUserTags = []string{"my-daily-backup-policy"} - createBackupPolicyOptionsModel.MatchResourceTypes = []string{"volume"} - createBackupPolicyOptionsModel.Name = core.StringPtr("my-backup-policy") - createBackupPolicyOptionsModel.Plans = []vpcv1.BackupPolicyPlanPrototype{*backupPolicyPlanPrototypeModel} - createBackupPolicyOptionsModel.ResourceGroup = resourceGroupIdentityModel - createBackupPolicyOptionsModel.Scope = backupPolicyScopePrototypeModel + createBackupPolicyOptionsModel.BackupPolicyPrototype = backupPolicyPrototypeModel createBackupPolicyOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Expect response parsing to fail since we are receiving a text/plain response result, response, operationErr := vpcService.CreateBackupPolicy(createBackupPolicyOptionsModel) @@ -37966,7 +37970,7 @@ var _ = Describe(`VpcV1`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(201) - fmt.Fprintf(res, "%s", `{"created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south:a/123456::backup-policy:r134-076191ba-49c2-4763-94fd-c70de73ee2e6", "health_reasons": [{"code": "missing_service_authorization_policies", "message": "One or more accounts are missing service authorization policies", "more_info": "https://cloud.ibm.com/docs/vpc?topic=vpc-backup-service-about&interface=ui"}], "health_state": "ok", "href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6", "id": "r134-076191ba-49c2-4763-94fd-c70de73ee2e6", "last_job_completed_at": "2019-01-01T12:00:00.000Z", "lifecycle_state": "stable", "match_resource_types": ["volume"], "match_user_tags": ["MatchUserTags"], "name": "my-backup-policy", "plans": [{"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6/plans/r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "id": "r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "name": "my-policy-plan", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "backup_policy_plan"}], "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "resource_type": "backup_policy", "scope": {"crn": "crn:v1:bluemix:public:enterprise::a/123456::enterprise:ebc2b430240943458b9e91e1432cfcce", "id": "fee82deba12e4c0fb69c3b09d1f12345", "resource_type": "enterprise"}}`) + fmt.Fprintf(res, "%s", `{"created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south:a/123456::backup-policy:r134-076191ba-49c2-4763-94fd-c70de73ee2e6", "health_reasons": [{"code": "missing_service_authorization_policies", "message": "One or more accounts are missing service authorization policies", "more_info": "https://cloud.ibm.com/docs/vpc?topic=vpc-backup-service-about&interface=ui"}], "health_state": "ok", "href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6", "id": "r134-076191ba-49c2-4763-94fd-c70de73ee2e6", "last_job_completed_at": "2019-01-01T12:00:00.000Z", "lifecycle_state": "stable", "match_user_tags": ["MatchUserTags"], "name": "my-backup-policy", "plans": [{"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6/plans/r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "id": "r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "name": "my-policy-plan", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "backup_policy_plan"}], "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "resource_type": "backup_policy", "scope": {"crn": "crn:v1:bluemix:public:enterprise::a/123456::enterprise:ebc2b430240943458b9e91e1432cfcce", "id": "fee82deba12e4c0fb69c3b09d1f12345", "resource_type": "enterprise"}, "included_content": ["data_volumes"], "match_resource_type": "instance"}`) })) }) It(`Invoke CreateBackupPolicy successfully with retries`, func() { @@ -38026,14 +38030,18 @@ var _ = Describe(`VpcV1`, func() { backupPolicyScopePrototypeModel := new(vpcv1.BackupPolicyScopePrototypeEnterpriseIdentityEnterpriseIdentityByCRN) backupPolicyScopePrototypeModel.CRN = core.StringPtr("crn:v1:bluemix:public:enterprise::a/123456::enterprise:ebc2b430240943458b9e91e1432cfcce") + // Construct an instance of the BackupPolicyPrototypeBackupPolicyMatchResourceTypeVolumePrototype model + backupPolicyPrototypeModel := new(vpcv1.BackupPolicyPrototypeBackupPolicyMatchResourceTypeVolumePrototype) + backupPolicyPrototypeModel.MatchUserTags = []string{"my-daily-backup-policy"} + backupPolicyPrototypeModel.Name = core.StringPtr("my-backup-policy") + backupPolicyPrototypeModel.Plans = []vpcv1.BackupPolicyPlanPrototype{*backupPolicyPlanPrototypeModel} + backupPolicyPrototypeModel.ResourceGroup = resourceGroupIdentityModel + backupPolicyPrototypeModel.Scope = backupPolicyScopePrototypeModel + backupPolicyPrototypeModel.MatchResourceType = core.StringPtr("volume") + // Construct an instance of the CreateBackupPolicyOptions model createBackupPolicyOptionsModel := new(vpcv1.CreateBackupPolicyOptions) - createBackupPolicyOptionsModel.MatchUserTags = []string{"my-daily-backup-policy"} - createBackupPolicyOptionsModel.MatchResourceTypes = []string{"volume"} - createBackupPolicyOptionsModel.Name = core.StringPtr("my-backup-policy") - createBackupPolicyOptionsModel.Plans = []vpcv1.BackupPolicyPlanPrototype{*backupPolicyPlanPrototypeModel} - createBackupPolicyOptionsModel.ResourceGroup = resourceGroupIdentityModel - createBackupPolicyOptionsModel.Scope = backupPolicyScopePrototypeModel + createBackupPolicyOptionsModel.BackupPolicyPrototype = backupPolicyPrototypeModel createBackupPolicyOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with a Context to test a timeout error @@ -38091,7 +38099,7 @@ var _ = Describe(`VpcV1`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(201) - fmt.Fprintf(res, "%s", `{"created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south:a/123456::backup-policy:r134-076191ba-49c2-4763-94fd-c70de73ee2e6", "health_reasons": [{"code": "missing_service_authorization_policies", "message": "One or more accounts are missing service authorization policies", "more_info": "https://cloud.ibm.com/docs/vpc?topic=vpc-backup-service-about&interface=ui"}], "health_state": "ok", "href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6", "id": "r134-076191ba-49c2-4763-94fd-c70de73ee2e6", "last_job_completed_at": "2019-01-01T12:00:00.000Z", "lifecycle_state": "stable", "match_resource_types": ["volume"], "match_user_tags": ["MatchUserTags"], "name": "my-backup-policy", "plans": [{"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6/plans/r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "id": "r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "name": "my-policy-plan", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "backup_policy_plan"}], "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "resource_type": "backup_policy", "scope": {"crn": "crn:v1:bluemix:public:enterprise::a/123456::enterprise:ebc2b430240943458b9e91e1432cfcce", "id": "fee82deba12e4c0fb69c3b09d1f12345", "resource_type": "enterprise"}}`) + fmt.Fprintf(res, "%s", `{"created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south:a/123456::backup-policy:r134-076191ba-49c2-4763-94fd-c70de73ee2e6", "health_reasons": [{"code": "missing_service_authorization_policies", "message": "One or more accounts are missing service authorization policies", "more_info": "https://cloud.ibm.com/docs/vpc?topic=vpc-backup-service-about&interface=ui"}], "health_state": "ok", "href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6", "id": "r134-076191ba-49c2-4763-94fd-c70de73ee2e6", "last_job_completed_at": "2019-01-01T12:00:00.000Z", "lifecycle_state": "stable", "match_user_tags": ["MatchUserTags"], "name": "my-backup-policy", "plans": [{"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6/plans/r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "id": "r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "name": "my-policy-plan", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "backup_policy_plan"}], "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "resource_type": "backup_policy", "scope": {"crn": "crn:v1:bluemix:public:enterprise::a/123456::enterprise:ebc2b430240943458b9e91e1432cfcce", "id": "fee82deba12e4c0fb69c3b09d1f12345", "resource_type": "enterprise"}, "included_content": ["data_volumes"], "match_resource_type": "instance"}`) })) }) It(`Invoke CreateBackupPolicy successfully`, func() { @@ -38156,14 +38164,18 @@ var _ = Describe(`VpcV1`, func() { backupPolicyScopePrototypeModel := new(vpcv1.BackupPolicyScopePrototypeEnterpriseIdentityEnterpriseIdentityByCRN) backupPolicyScopePrototypeModel.CRN = core.StringPtr("crn:v1:bluemix:public:enterprise::a/123456::enterprise:ebc2b430240943458b9e91e1432cfcce") + // Construct an instance of the BackupPolicyPrototypeBackupPolicyMatchResourceTypeVolumePrototype model + backupPolicyPrototypeModel := new(vpcv1.BackupPolicyPrototypeBackupPolicyMatchResourceTypeVolumePrototype) + backupPolicyPrototypeModel.MatchUserTags = []string{"my-daily-backup-policy"} + backupPolicyPrototypeModel.Name = core.StringPtr("my-backup-policy") + backupPolicyPrototypeModel.Plans = []vpcv1.BackupPolicyPlanPrototype{*backupPolicyPlanPrototypeModel} + backupPolicyPrototypeModel.ResourceGroup = resourceGroupIdentityModel + backupPolicyPrototypeModel.Scope = backupPolicyScopePrototypeModel + backupPolicyPrototypeModel.MatchResourceType = core.StringPtr("volume") + // Construct an instance of the CreateBackupPolicyOptions model createBackupPolicyOptionsModel := new(vpcv1.CreateBackupPolicyOptions) - createBackupPolicyOptionsModel.MatchUserTags = []string{"my-daily-backup-policy"} - createBackupPolicyOptionsModel.MatchResourceTypes = []string{"volume"} - createBackupPolicyOptionsModel.Name = core.StringPtr("my-backup-policy") - createBackupPolicyOptionsModel.Plans = []vpcv1.BackupPolicyPlanPrototype{*backupPolicyPlanPrototypeModel} - createBackupPolicyOptionsModel.ResourceGroup = resourceGroupIdentityModel - createBackupPolicyOptionsModel.Scope = backupPolicyScopePrototypeModel + createBackupPolicyOptionsModel.BackupPolicyPrototype = backupPolicyPrototypeModel createBackupPolicyOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with valid options model (positive test) @@ -38229,14 +38241,18 @@ var _ = Describe(`VpcV1`, func() { backupPolicyScopePrototypeModel := new(vpcv1.BackupPolicyScopePrototypeEnterpriseIdentityEnterpriseIdentityByCRN) backupPolicyScopePrototypeModel.CRN = core.StringPtr("crn:v1:bluemix:public:enterprise::a/123456::enterprise:ebc2b430240943458b9e91e1432cfcce") + // Construct an instance of the BackupPolicyPrototypeBackupPolicyMatchResourceTypeVolumePrototype model + backupPolicyPrototypeModel := new(vpcv1.BackupPolicyPrototypeBackupPolicyMatchResourceTypeVolumePrototype) + backupPolicyPrototypeModel.MatchUserTags = []string{"my-daily-backup-policy"} + backupPolicyPrototypeModel.Name = core.StringPtr("my-backup-policy") + backupPolicyPrototypeModel.Plans = []vpcv1.BackupPolicyPlanPrototype{*backupPolicyPlanPrototypeModel} + backupPolicyPrototypeModel.ResourceGroup = resourceGroupIdentityModel + backupPolicyPrototypeModel.Scope = backupPolicyScopePrototypeModel + backupPolicyPrototypeModel.MatchResourceType = core.StringPtr("volume") + // Construct an instance of the CreateBackupPolicyOptions model createBackupPolicyOptionsModel := new(vpcv1.CreateBackupPolicyOptions) - createBackupPolicyOptionsModel.MatchUserTags = []string{"my-daily-backup-policy"} - createBackupPolicyOptionsModel.MatchResourceTypes = []string{"volume"} - createBackupPolicyOptionsModel.Name = core.StringPtr("my-backup-policy") - createBackupPolicyOptionsModel.Plans = []vpcv1.BackupPolicyPlanPrototype{*backupPolicyPlanPrototypeModel} - createBackupPolicyOptionsModel.ResourceGroup = resourceGroupIdentityModel - createBackupPolicyOptionsModel.Scope = backupPolicyScopePrototypeModel + createBackupPolicyOptionsModel.BackupPolicyPrototype = backupPolicyPrototypeModel createBackupPolicyOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with empty URL (negative test) err := vpcService.SetServiceURL("") @@ -38323,14 +38339,18 @@ var _ = Describe(`VpcV1`, func() { backupPolicyScopePrototypeModel := new(vpcv1.BackupPolicyScopePrototypeEnterpriseIdentityEnterpriseIdentityByCRN) backupPolicyScopePrototypeModel.CRN = core.StringPtr("crn:v1:bluemix:public:enterprise::a/123456::enterprise:ebc2b430240943458b9e91e1432cfcce") + // Construct an instance of the BackupPolicyPrototypeBackupPolicyMatchResourceTypeVolumePrototype model + backupPolicyPrototypeModel := new(vpcv1.BackupPolicyPrototypeBackupPolicyMatchResourceTypeVolumePrototype) + backupPolicyPrototypeModel.MatchUserTags = []string{"my-daily-backup-policy"} + backupPolicyPrototypeModel.Name = core.StringPtr("my-backup-policy") + backupPolicyPrototypeModel.Plans = []vpcv1.BackupPolicyPlanPrototype{*backupPolicyPlanPrototypeModel} + backupPolicyPrototypeModel.ResourceGroup = resourceGroupIdentityModel + backupPolicyPrototypeModel.Scope = backupPolicyScopePrototypeModel + backupPolicyPrototypeModel.MatchResourceType = core.StringPtr("volume") + // Construct an instance of the CreateBackupPolicyOptions model createBackupPolicyOptionsModel := new(vpcv1.CreateBackupPolicyOptions) - createBackupPolicyOptionsModel.MatchUserTags = []string{"my-daily-backup-policy"} - createBackupPolicyOptionsModel.MatchResourceTypes = []string{"volume"} - createBackupPolicyOptionsModel.Name = core.StringPtr("my-backup-policy") - createBackupPolicyOptionsModel.Plans = []vpcv1.BackupPolicyPlanPrototype{*backupPolicyPlanPrototypeModel} - createBackupPolicyOptionsModel.ResourceGroup = resourceGroupIdentityModel - createBackupPolicyOptionsModel.Scope = backupPolicyScopePrototypeModel + createBackupPolicyOptionsModel.BackupPolicyPrototype = backupPolicyPrototypeModel createBackupPolicyOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation @@ -40678,7 +40698,7 @@ var _ = Describe(`VpcV1`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(202) - fmt.Fprintf(res, "%s", `{"created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south:a/123456::backup-policy:r134-076191ba-49c2-4763-94fd-c70de73ee2e6", "health_reasons": [{"code": "missing_service_authorization_policies", "message": "One or more accounts are missing service authorization policies", "more_info": "https://cloud.ibm.com/docs/vpc?topic=vpc-backup-service-about&interface=ui"}], "health_state": "ok", "href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6", "id": "r134-076191ba-49c2-4763-94fd-c70de73ee2e6", "last_job_completed_at": "2019-01-01T12:00:00.000Z", "lifecycle_state": "stable", "match_resource_types": ["volume"], "match_user_tags": ["MatchUserTags"], "name": "my-backup-policy", "plans": [{"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6/plans/r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "id": "r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "name": "my-policy-plan", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "backup_policy_plan"}], "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "resource_type": "backup_policy", "scope": {"crn": "crn:v1:bluemix:public:enterprise::a/123456::enterprise:ebc2b430240943458b9e91e1432cfcce", "id": "fee82deba12e4c0fb69c3b09d1f12345", "resource_type": "enterprise"}}`) + fmt.Fprintf(res, "%s", `{"created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south:a/123456::backup-policy:r134-076191ba-49c2-4763-94fd-c70de73ee2e6", "health_reasons": [{"code": "missing_service_authorization_policies", "message": "One or more accounts are missing service authorization policies", "more_info": "https://cloud.ibm.com/docs/vpc?topic=vpc-backup-service-about&interface=ui"}], "health_state": "ok", "href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6", "id": "r134-076191ba-49c2-4763-94fd-c70de73ee2e6", "last_job_completed_at": "2019-01-01T12:00:00.000Z", "lifecycle_state": "stable", "match_user_tags": ["MatchUserTags"], "name": "my-backup-policy", "plans": [{"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6/plans/r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "id": "r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "name": "my-policy-plan", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "backup_policy_plan"}], "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "resource_type": "backup_policy", "scope": {"crn": "crn:v1:bluemix:public:enterprise::a/123456::enterprise:ebc2b430240943458b9e91e1432cfcce", "id": "fee82deba12e4c0fb69c3b09d1f12345", "resource_type": "enterprise"}, "included_content": ["data_volumes"], "match_resource_type": "instance"}`) })) }) It(`Invoke DeleteBackupPolicy successfully with retries`, func() { @@ -40738,7 +40758,7 @@ var _ = Describe(`VpcV1`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(202) - fmt.Fprintf(res, "%s", `{"created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south:a/123456::backup-policy:r134-076191ba-49c2-4763-94fd-c70de73ee2e6", "health_reasons": [{"code": "missing_service_authorization_policies", "message": "One or more accounts are missing service authorization policies", "more_info": "https://cloud.ibm.com/docs/vpc?topic=vpc-backup-service-about&interface=ui"}], "health_state": "ok", "href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6", "id": "r134-076191ba-49c2-4763-94fd-c70de73ee2e6", "last_job_completed_at": "2019-01-01T12:00:00.000Z", "lifecycle_state": "stable", "match_resource_types": ["volume"], "match_user_tags": ["MatchUserTags"], "name": "my-backup-policy", "plans": [{"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6/plans/r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "id": "r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "name": "my-policy-plan", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "backup_policy_plan"}], "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "resource_type": "backup_policy", "scope": {"crn": "crn:v1:bluemix:public:enterprise::a/123456::enterprise:ebc2b430240943458b9e91e1432cfcce", "id": "fee82deba12e4c0fb69c3b09d1f12345", "resource_type": "enterprise"}}`) + fmt.Fprintf(res, "%s", `{"created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south:a/123456::backup-policy:r134-076191ba-49c2-4763-94fd-c70de73ee2e6", "health_reasons": [{"code": "missing_service_authorization_policies", "message": "One or more accounts are missing service authorization policies", "more_info": "https://cloud.ibm.com/docs/vpc?topic=vpc-backup-service-about&interface=ui"}], "health_state": "ok", "href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6", "id": "r134-076191ba-49c2-4763-94fd-c70de73ee2e6", "last_job_completed_at": "2019-01-01T12:00:00.000Z", "lifecycle_state": "stable", "match_user_tags": ["MatchUserTags"], "name": "my-backup-policy", "plans": [{"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6/plans/r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "id": "r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "name": "my-policy-plan", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "backup_policy_plan"}], "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "resource_type": "backup_policy", "scope": {"crn": "crn:v1:bluemix:public:enterprise::a/123456::enterprise:ebc2b430240943458b9e91e1432cfcce", "id": "fee82deba12e4c0fb69c3b09d1f12345", "resource_type": "enterprise"}, "included_content": ["data_volumes"], "match_resource_type": "instance"}`) })) }) It(`Invoke DeleteBackupPolicy successfully`, func() { @@ -40909,7 +40929,7 @@ var _ = Describe(`VpcV1`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south:a/123456::backup-policy:r134-076191ba-49c2-4763-94fd-c70de73ee2e6", "health_reasons": [{"code": "missing_service_authorization_policies", "message": "One or more accounts are missing service authorization policies", "more_info": "https://cloud.ibm.com/docs/vpc?topic=vpc-backup-service-about&interface=ui"}], "health_state": "ok", "href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6", "id": "r134-076191ba-49c2-4763-94fd-c70de73ee2e6", "last_job_completed_at": "2019-01-01T12:00:00.000Z", "lifecycle_state": "stable", "match_resource_types": ["volume"], "match_user_tags": ["MatchUserTags"], "name": "my-backup-policy", "plans": [{"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6/plans/r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "id": "r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "name": "my-policy-plan", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "backup_policy_plan"}], "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "resource_type": "backup_policy", "scope": {"crn": "crn:v1:bluemix:public:enterprise::a/123456::enterprise:ebc2b430240943458b9e91e1432cfcce", "id": "fee82deba12e4c0fb69c3b09d1f12345", "resource_type": "enterprise"}}`) + fmt.Fprintf(res, "%s", `{"created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south:a/123456::backup-policy:r134-076191ba-49c2-4763-94fd-c70de73ee2e6", "health_reasons": [{"code": "missing_service_authorization_policies", "message": "One or more accounts are missing service authorization policies", "more_info": "https://cloud.ibm.com/docs/vpc?topic=vpc-backup-service-about&interface=ui"}], "health_state": "ok", "href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6", "id": "r134-076191ba-49c2-4763-94fd-c70de73ee2e6", "last_job_completed_at": "2019-01-01T12:00:00.000Z", "lifecycle_state": "stable", "match_user_tags": ["MatchUserTags"], "name": "my-backup-policy", "plans": [{"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6/plans/r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "id": "r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "name": "my-policy-plan", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "backup_policy_plan"}], "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "resource_type": "backup_policy", "scope": {"crn": "crn:v1:bluemix:public:enterprise::a/123456::enterprise:ebc2b430240943458b9e91e1432cfcce", "id": "fee82deba12e4c0fb69c3b09d1f12345", "resource_type": "enterprise"}, "included_content": ["data_volumes"], "match_resource_type": "instance"}`) })) }) It(`Invoke GetBackupPolicy successfully with retries`, func() { @@ -40966,7 +40986,7 @@ var _ = Describe(`VpcV1`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south:a/123456::backup-policy:r134-076191ba-49c2-4763-94fd-c70de73ee2e6", "health_reasons": [{"code": "missing_service_authorization_policies", "message": "One or more accounts are missing service authorization policies", "more_info": "https://cloud.ibm.com/docs/vpc?topic=vpc-backup-service-about&interface=ui"}], "health_state": "ok", "href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6", "id": "r134-076191ba-49c2-4763-94fd-c70de73ee2e6", "last_job_completed_at": "2019-01-01T12:00:00.000Z", "lifecycle_state": "stable", "match_resource_types": ["volume"], "match_user_tags": ["MatchUserTags"], "name": "my-backup-policy", "plans": [{"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6/plans/r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "id": "r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "name": "my-policy-plan", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "backup_policy_plan"}], "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "resource_type": "backup_policy", "scope": {"crn": "crn:v1:bluemix:public:enterprise::a/123456::enterprise:ebc2b430240943458b9e91e1432cfcce", "id": "fee82deba12e4c0fb69c3b09d1f12345", "resource_type": "enterprise"}}`) + fmt.Fprintf(res, "%s", `{"created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south:a/123456::backup-policy:r134-076191ba-49c2-4763-94fd-c70de73ee2e6", "health_reasons": [{"code": "missing_service_authorization_policies", "message": "One or more accounts are missing service authorization policies", "more_info": "https://cloud.ibm.com/docs/vpc?topic=vpc-backup-service-about&interface=ui"}], "health_state": "ok", "href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6", "id": "r134-076191ba-49c2-4763-94fd-c70de73ee2e6", "last_job_completed_at": "2019-01-01T12:00:00.000Z", "lifecycle_state": "stable", "match_user_tags": ["MatchUserTags"], "name": "my-backup-policy", "plans": [{"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6/plans/r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "id": "r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "name": "my-policy-plan", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "backup_policy_plan"}], "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "resource_type": "backup_policy", "scope": {"crn": "crn:v1:bluemix:public:enterprise::a/123456::enterprise:ebc2b430240943458b9e91e1432cfcce", "id": "fee82deba12e4c0fb69c3b09d1f12345", "resource_type": "enterprise"}, "included_content": ["data_volumes"], "match_resource_type": "instance"}`) })) }) It(`Invoke GetBackupPolicy successfully`, func() { @@ -41096,6 +41116,7 @@ var _ = Describe(`VpcV1`, func() { // Construct an instance of the BackupPolicyPatch model backupPolicyPatchModel := new(vpcv1.BackupPolicyPatch) + backupPolicyPatchModel.IncludedContent = []string{"data_volumes"} backupPolicyPatchModel.MatchUserTags = []string{"my-daily-backup-policy"} backupPolicyPatchModel.Name = core.StringPtr("my-backup-policy") backupPolicyPatchModelAsPatch, asPatchErr := backupPolicyPatchModel.AsPatch() @@ -41163,7 +41184,7 @@ var _ = Describe(`VpcV1`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south:a/123456::backup-policy:r134-076191ba-49c2-4763-94fd-c70de73ee2e6", "health_reasons": [{"code": "missing_service_authorization_policies", "message": "One or more accounts are missing service authorization policies", "more_info": "https://cloud.ibm.com/docs/vpc?topic=vpc-backup-service-about&interface=ui"}], "health_state": "ok", "href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6", "id": "r134-076191ba-49c2-4763-94fd-c70de73ee2e6", "last_job_completed_at": "2019-01-01T12:00:00.000Z", "lifecycle_state": "stable", "match_resource_types": ["volume"], "match_user_tags": ["MatchUserTags"], "name": "my-backup-policy", "plans": [{"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6/plans/r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "id": "r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "name": "my-policy-plan", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "backup_policy_plan"}], "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "resource_type": "backup_policy", "scope": {"crn": "crn:v1:bluemix:public:enterprise::a/123456::enterprise:ebc2b430240943458b9e91e1432cfcce", "id": "fee82deba12e4c0fb69c3b09d1f12345", "resource_type": "enterprise"}}`) + fmt.Fprintf(res, "%s", `{"created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south:a/123456::backup-policy:r134-076191ba-49c2-4763-94fd-c70de73ee2e6", "health_reasons": [{"code": "missing_service_authorization_policies", "message": "One or more accounts are missing service authorization policies", "more_info": "https://cloud.ibm.com/docs/vpc?topic=vpc-backup-service-about&interface=ui"}], "health_state": "ok", "href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6", "id": "r134-076191ba-49c2-4763-94fd-c70de73ee2e6", "last_job_completed_at": "2019-01-01T12:00:00.000Z", "lifecycle_state": "stable", "match_user_tags": ["MatchUserTags"], "name": "my-backup-policy", "plans": [{"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6/plans/r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "id": "r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "name": "my-policy-plan", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "backup_policy_plan"}], "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "resource_type": "backup_policy", "scope": {"crn": "crn:v1:bluemix:public:enterprise::a/123456::enterprise:ebc2b430240943458b9e91e1432cfcce", "id": "fee82deba12e4c0fb69c3b09d1f12345", "resource_type": "enterprise"}, "included_content": ["data_volumes"], "match_resource_type": "instance"}`) })) }) It(`Invoke UpdateBackupPolicy successfully with retries`, func() { @@ -41178,6 +41199,7 @@ var _ = Describe(`VpcV1`, func() { // Construct an instance of the BackupPolicyPatch model backupPolicyPatchModel := new(vpcv1.BackupPolicyPatch) + backupPolicyPatchModel.IncludedContent = []string{"data_volumes"} backupPolicyPatchModel.MatchUserTags = []string{"my-daily-backup-policy"} backupPolicyPatchModel.Name = core.StringPtr("my-backup-policy") backupPolicyPatchModelAsPatch, asPatchErr := backupPolicyPatchModel.AsPatch() @@ -41247,7 +41269,7 @@ var _ = Describe(`VpcV1`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south:a/123456::backup-policy:r134-076191ba-49c2-4763-94fd-c70de73ee2e6", "health_reasons": [{"code": "missing_service_authorization_policies", "message": "One or more accounts are missing service authorization policies", "more_info": "https://cloud.ibm.com/docs/vpc?topic=vpc-backup-service-about&interface=ui"}], "health_state": "ok", "href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6", "id": "r134-076191ba-49c2-4763-94fd-c70de73ee2e6", "last_job_completed_at": "2019-01-01T12:00:00.000Z", "lifecycle_state": "stable", "match_resource_types": ["volume"], "match_user_tags": ["MatchUserTags"], "name": "my-backup-policy", "plans": [{"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6/plans/r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "id": "r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "name": "my-policy-plan", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "backup_policy_plan"}], "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "resource_type": "backup_policy", "scope": {"crn": "crn:v1:bluemix:public:enterprise::a/123456::enterprise:ebc2b430240943458b9e91e1432cfcce", "id": "fee82deba12e4c0fb69c3b09d1f12345", "resource_type": "enterprise"}}`) + fmt.Fprintf(res, "%s", `{"created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south:a/123456::backup-policy:r134-076191ba-49c2-4763-94fd-c70de73ee2e6", "health_reasons": [{"code": "missing_service_authorization_policies", "message": "One or more accounts are missing service authorization policies", "more_info": "https://cloud.ibm.com/docs/vpc?topic=vpc-backup-service-about&interface=ui"}], "health_state": "ok", "href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6", "id": "r134-076191ba-49c2-4763-94fd-c70de73ee2e6", "last_job_completed_at": "2019-01-01T12:00:00.000Z", "lifecycle_state": "stable", "match_user_tags": ["MatchUserTags"], "name": "my-backup-policy", "plans": [{"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6/plans/r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "id": "r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "name": "my-policy-plan", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "backup_policy_plan"}], "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "resource_type": "backup_policy", "scope": {"crn": "crn:v1:bluemix:public:enterprise::a/123456::enterprise:ebc2b430240943458b9e91e1432cfcce", "id": "fee82deba12e4c0fb69c3b09d1f12345", "resource_type": "enterprise"}, "included_content": ["data_volumes"], "match_resource_type": "instance"}`) })) }) It(`Invoke UpdateBackupPolicy successfully`, func() { @@ -41267,6 +41289,7 @@ var _ = Describe(`VpcV1`, func() { // Construct an instance of the BackupPolicyPatch model backupPolicyPatchModel := new(vpcv1.BackupPolicyPatch) + backupPolicyPatchModel.IncludedContent = []string{"data_volumes"} backupPolicyPatchModel.MatchUserTags = []string{"my-daily-backup-policy"} backupPolicyPatchModel.Name = core.StringPtr("my-backup-policy") backupPolicyPatchModelAsPatch, asPatchErr := backupPolicyPatchModel.AsPatch() @@ -41297,6 +41320,7 @@ var _ = Describe(`VpcV1`, func() { // Construct an instance of the BackupPolicyPatch model backupPolicyPatchModel := new(vpcv1.BackupPolicyPatch) + backupPolicyPatchModel.IncludedContent = []string{"data_volumes"} backupPolicyPatchModel.MatchUserTags = []string{"my-daily-backup-policy"} backupPolicyPatchModel.Name = core.StringPtr("my-backup-policy") backupPolicyPatchModelAsPatch, asPatchErr := backupPolicyPatchModel.AsPatch() @@ -41348,6 +41372,7 @@ var _ = Describe(`VpcV1`, func() { // Construct an instance of the BackupPolicyPatch model backupPolicyPatchModel := new(vpcv1.BackupPolicyPatch) + backupPolicyPatchModel.IncludedContent = []string{"data_volumes"} backupPolicyPatchModel.MatchUserTags = []string{"my-daily-backup-policy"} backupPolicyPatchModel.Name = core.StringPtr("my-backup-policy") backupPolicyPatchModelAsPatch, asPatchErr := backupPolicyPatchModel.AsPatch() @@ -50830,119 +50855,31 @@ var _ = Describe(`VpcV1`, func() { }) }) }) - Describe(`DeleteSnapshots(deleteSnapshotsOptions *DeleteSnapshotsOptions)`, func() { + Describe(`ListSnapshotConsistencyGroups(listSnapshotConsistencyGroupsOptions *ListSnapshotConsistencyGroupsOptions) - Operation response error`, func() { version := "testString" - deleteSnapshotsPath := "/snapshots" - Context(`Using mock server endpoint`, func() { - BeforeEach(func() { - testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { - defer GinkgoRecover() - - // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(deleteSnapshotsPath)) - Expect(req.Method).To(Equal("DELETE")) - - Expect(req.URL.Query()["version"]).To(Equal([]string{"testString"})) - Expect(req.URL.Query()["generation"]).To(Equal([]string{fmt.Sprint(int64(2))})) - Expect(req.URL.Query()["source_volume.id"]).To(Equal([]string{"testString"})) - res.WriteHeader(204) - })) - }) - It(`Invoke DeleteSnapshots successfully`, func() { - vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ - URL: testServer.URL, - Authenticator: &core.NoAuthAuthenticator{}, - Version: core.StringPtr(version), - }) - Expect(serviceErr).To(BeNil()) - Expect(vpcService).ToNot(BeNil()) - - // Invoke operation with nil options model (negative test) - response, operationErr := vpcService.DeleteSnapshots(nil) - Expect(operationErr).NotTo(BeNil()) - Expect(response).To(BeNil()) - - // Construct an instance of the DeleteSnapshotsOptions model - deleteSnapshotsOptionsModel := new(vpcv1.DeleteSnapshotsOptions) - deleteSnapshotsOptionsModel.SourceVolumeID = core.StringPtr("testString") - deleteSnapshotsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} - - // Invoke operation with valid options model (positive test) - response, operationErr = vpcService.DeleteSnapshots(deleteSnapshotsOptionsModel) - Expect(operationErr).To(BeNil()) - Expect(response).ToNot(BeNil()) - }) - It(`Invoke DeleteSnapshots with error: Operation validation and request error`, func() { - vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ - URL: testServer.URL, - Authenticator: &core.NoAuthAuthenticator{}, - Version: core.StringPtr(version), - }) - Expect(serviceErr).To(BeNil()) - Expect(vpcService).ToNot(BeNil()) - - // Construct an instance of the DeleteSnapshotsOptions model - deleteSnapshotsOptionsModel := new(vpcv1.DeleteSnapshotsOptions) - deleteSnapshotsOptionsModel.SourceVolumeID = core.StringPtr("testString") - deleteSnapshotsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} - // Invoke operation with empty URL (negative test) - err := vpcService.SetServiceURL("") - Expect(err).To(BeNil()) - response, operationErr := vpcService.DeleteSnapshots(deleteSnapshotsOptionsModel) - Expect(operationErr).ToNot(BeNil()) - Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING)) - Expect(response).To(BeNil()) - // Construct a second instance of the DeleteSnapshotsOptions model with no property values - deleteSnapshotsOptionsModelNew := new(vpcv1.DeleteSnapshotsOptions) - // Invoke operation with invalid model (negative test) - response, operationErr = vpcService.DeleteSnapshots(deleteSnapshotsOptionsModelNew) - Expect(operationErr).ToNot(BeNil()) - Expect(response).To(BeNil()) - }) - AfterEach(func() { - testServer.Close() - }) - }) - }) - Describe(`ListSnapshots(listSnapshotsOptions *ListSnapshotsOptions) - Operation response error`, func() { - version := "testString" - listSnapshotsPath := "/snapshots" + listSnapshotConsistencyGroupsPath := "/snapshot_consistency_groups" Context(`Using mock server endpoint with invalid JSON response`, func() { BeforeEach(func() { testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(listSnapshotsPath)) + Expect(req.URL.EscapedPath()).To(Equal(listSnapshotConsistencyGroupsPath)) Expect(req.Method).To(Equal("GET")) Expect(req.URL.Query()["version"]).To(Equal([]string{"testString"})) Expect(req.URL.Query()["generation"]).To(Equal([]string{fmt.Sprint(int64(2))})) Expect(req.URL.Query()["start"]).To(Equal([]string{"testString"})) Expect(req.URL.Query()["limit"]).To(Equal([]string{fmt.Sprint(int64(10))})) - Expect(req.URL.Query()["tag"]).To(Equal([]string{"testString"})) Expect(req.URL.Query()["resource_group.id"]).To(Equal([]string{"testString"})) Expect(req.URL.Query()["name"]).To(Equal([]string{"testString"})) - Expect(req.URL.Query()["source_volume.id"]).To(Equal([]string{"testString"})) - Expect(req.URL.Query()["source_volume.crn"]).To(Equal([]string{"crn:v1:bluemix:public:is:us-south-1:a/123456::volume:1a6b7274-678d-4dfb-8981-c71dd9d4daa5"})) - Expect(req.URL.Query()["source_image.id"]).To(Equal([]string{"testString"})) - Expect(req.URL.Query()["source_image.crn"]).To(Equal([]string{"crn:v1:bluemix:public:is:us-south:a/123456::image:72b27b5c-f4b0-48bb-b954-5becc7c1dcb8"})) Expect(req.URL.Query()["sort"]).To(Equal([]string{"name"})) Expect(req.URL.Query()["backup_policy_plan.id"]).To(Equal([]string{"testString"})) - Expect(req.URL.Query()["copies[].id"]).To(Equal([]string{"testString"})) - Expect(req.URL.Query()["copies[].name"]).To(Equal([]string{"my-snapshot-copy"})) - Expect(req.URL.Query()["copies[].crn"]).To(Equal([]string{"testString"})) - Expect(req.URL.Query()["copies[].remote.region.name"]).To(Equal([]string{"us-south"})) - Expect(req.URL.Query()["source_snapshot.id"]).To(Equal([]string{"testString"})) - Expect(req.URL.Query()["source_snapshot.remote.region.name"]).To(Equal([]string{"us-south"})) - Expect(req.URL.Query()["source_volume.remote.region.name"]).To(Equal([]string{"us-south"})) - Expect(req.URL.Query()["source_image.remote.region.name"]).To(Equal([]string{"us-south"})) - Expect(req.URL.Query()["clones[].zone.name"]).To(Equal([]string{"us-south-1"})) res.Header().Set("Content-type", "application/json") res.WriteHeader(200) fmt.Fprint(res, `} this is not valid json {`) })) }) - It(`Invoke ListSnapshots with error: Operation response processing error`, func() { + It(`Invoke ListSnapshotConsistencyGroups with error: Operation response processing error`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -50951,38 +50888,24 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the ListSnapshotsOptions model - listSnapshotsOptionsModel := new(vpcv1.ListSnapshotsOptions) - listSnapshotsOptionsModel.Start = core.StringPtr("testString") - listSnapshotsOptionsModel.Limit = core.Int64Ptr(int64(10)) - listSnapshotsOptionsModel.Tag = core.StringPtr("testString") - listSnapshotsOptionsModel.ResourceGroupID = core.StringPtr("testString") - listSnapshotsOptionsModel.Name = core.StringPtr("testString") - listSnapshotsOptionsModel.SourceVolumeID = core.StringPtr("testString") - listSnapshotsOptionsModel.SourceVolumeCRN = core.StringPtr("crn:v1:bluemix:public:is:us-south-1:a/123456::volume:1a6b7274-678d-4dfb-8981-c71dd9d4daa5") - listSnapshotsOptionsModel.SourceImageID = core.StringPtr("testString") - listSnapshotsOptionsModel.SourceImageCRN = core.StringPtr("crn:v1:bluemix:public:is:us-south:a/123456::image:72b27b5c-f4b0-48bb-b954-5becc7c1dcb8") - listSnapshotsOptionsModel.Sort = core.StringPtr("name") - listSnapshotsOptionsModel.BackupPolicyPlanID = core.StringPtr("testString") - listSnapshotsOptionsModel.CopiesID = core.StringPtr("testString") - listSnapshotsOptionsModel.CopiesName = core.StringPtr("my-snapshot-copy") - listSnapshotsOptionsModel.CopiesCRN = core.StringPtr("testString") - listSnapshotsOptionsModel.CopiesRemoteRegionName = core.StringPtr("us-south") - listSnapshotsOptionsModel.SourceSnapshotID = core.StringPtr("testString") - listSnapshotsOptionsModel.SourceSnapshotRemoteRegionName = core.StringPtr("us-south") - listSnapshotsOptionsModel.SourceVolumeRemoteRegionName = core.StringPtr("us-south") - listSnapshotsOptionsModel.SourceImageRemoteRegionName = core.StringPtr("us-south") - listSnapshotsOptionsModel.ClonesZoneName = core.StringPtr("us-south-1") - listSnapshotsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the ListSnapshotConsistencyGroupsOptions model + listSnapshotConsistencyGroupsOptionsModel := new(vpcv1.ListSnapshotConsistencyGroupsOptions) + listSnapshotConsistencyGroupsOptionsModel.Start = core.StringPtr("testString") + listSnapshotConsistencyGroupsOptionsModel.Limit = core.Int64Ptr(int64(10)) + listSnapshotConsistencyGroupsOptionsModel.ResourceGroupID = core.StringPtr("testString") + listSnapshotConsistencyGroupsOptionsModel.Name = core.StringPtr("testString") + listSnapshotConsistencyGroupsOptionsModel.Sort = core.StringPtr("name") + listSnapshotConsistencyGroupsOptionsModel.BackupPolicyPlanID = core.StringPtr("testString") + listSnapshotConsistencyGroupsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Expect response parsing to fail since we are receiving a text/plain response - result, response, operationErr := vpcService.ListSnapshots(listSnapshotsOptionsModel) + result, response, operationErr := vpcService.ListSnapshotConsistencyGroups(listSnapshotConsistencyGroupsOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).To(BeNil()) // Enable retries and test again vpcService.EnableRetries(0, 0) - result, response, operationErr = vpcService.ListSnapshots(listSnapshotsOptionsModel) + result, response, operationErr = vpcService.ListSnapshotConsistencyGroups(listSnapshotConsistencyGroupsOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).To(BeNil()) @@ -50992,50 +50915,36 @@ var _ = Describe(`VpcV1`, func() { }) }) }) - Describe(`ListSnapshots(listSnapshotsOptions *ListSnapshotsOptions)`, func() { + Describe(`ListSnapshotConsistencyGroups(listSnapshotConsistencyGroupsOptions *ListSnapshotConsistencyGroupsOptions)`, func() { version := "testString" - listSnapshotsPath := "/snapshots" + listSnapshotConsistencyGroupsPath := "/snapshot_consistency_groups" Context(`Using mock server endpoint with timeout`, func() { BeforeEach(func() { testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(listSnapshotsPath)) + Expect(req.URL.EscapedPath()).To(Equal(listSnapshotConsistencyGroupsPath)) Expect(req.Method).To(Equal("GET")) Expect(req.URL.Query()["version"]).To(Equal([]string{"testString"})) Expect(req.URL.Query()["generation"]).To(Equal([]string{fmt.Sprint(int64(2))})) Expect(req.URL.Query()["start"]).To(Equal([]string{"testString"})) Expect(req.URL.Query()["limit"]).To(Equal([]string{fmt.Sprint(int64(10))})) - Expect(req.URL.Query()["tag"]).To(Equal([]string{"testString"})) Expect(req.URL.Query()["resource_group.id"]).To(Equal([]string{"testString"})) Expect(req.URL.Query()["name"]).To(Equal([]string{"testString"})) - Expect(req.URL.Query()["source_volume.id"]).To(Equal([]string{"testString"})) - Expect(req.URL.Query()["source_volume.crn"]).To(Equal([]string{"crn:v1:bluemix:public:is:us-south-1:a/123456::volume:1a6b7274-678d-4dfb-8981-c71dd9d4daa5"})) - Expect(req.URL.Query()["source_image.id"]).To(Equal([]string{"testString"})) - Expect(req.URL.Query()["source_image.crn"]).To(Equal([]string{"crn:v1:bluemix:public:is:us-south:a/123456::image:72b27b5c-f4b0-48bb-b954-5becc7c1dcb8"})) Expect(req.URL.Query()["sort"]).To(Equal([]string{"name"})) Expect(req.URL.Query()["backup_policy_plan.id"]).To(Equal([]string{"testString"})) - Expect(req.URL.Query()["copies[].id"]).To(Equal([]string{"testString"})) - Expect(req.URL.Query()["copies[].name"]).To(Equal([]string{"my-snapshot-copy"})) - Expect(req.URL.Query()["copies[].crn"]).To(Equal([]string{"testString"})) - Expect(req.URL.Query()["copies[].remote.region.name"]).To(Equal([]string{"us-south"})) - Expect(req.URL.Query()["source_snapshot.id"]).To(Equal([]string{"testString"})) - Expect(req.URL.Query()["source_snapshot.remote.region.name"]).To(Equal([]string{"us-south"})) - Expect(req.URL.Query()["source_volume.remote.region.name"]).To(Equal([]string{"us-south"})) - Expect(req.URL.Query()["source_image.remote.region.name"]).To(Equal([]string{"us-south"})) - Expect(req.URL.Query()["clones[].zone.name"]).To(Equal([]string{"us-south-1"})) // Sleep a short time to support a timeout test time.Sleep(100 * time.Millisecond) // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"first": {"href": "https://us-south.iaas.cloud.ibm.com/v1/snapshots?limit=20"}, "limit": 20, "next": {"href": "https://us-south.iaas.cloud.ibm.com/v1/snapshots?start=9d5a91a3e2cbd233b5a5b33436855ed1&limit=20"}, "snapshots": [{"backup_policy_plan": {"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6/plans/r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "id": "r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "name": "my-policy-plan", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "backup_policy_plan"}, "bootable": true, "captured_at": "2019-01-01T12:00:00.000Z", "clones": [{"available": false, "created_at": "2019-01-01T12:00:00.000Z", "zone": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south/zones/us-south-1", "name": "us-south-1"}}], "copies": [{"crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "id": "r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "name": "my-snapshot", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "snapshot"}], "created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "deletable": false, "encryption": "provider_managed", "encryption_key": {"crn": "crn:v1:bluemix:public:kms:us-south:a/123456:e4a29d1a-2ef0-42a6-8fd2-350deb1c647e:key:5437653b-c4b1-447f-9646-b2a2a4cd6179"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "id": "r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "lifecycle_state": "stable", "minimum_capacity": 1, "name": "my-snapshot", "operating_system": {"architecture": "amd64", "dedicated_host_only": false, "display_name": "Ubuntu Server 16.04 LTS amd64", "family": "Ubuntu Server", "href": "https://us-south.iaas.cloud.ibm.com/v1/operating_systems/ubuntu-16-amd64", "name": "ubuntu-16-amd64", "vendor": "Canonical", "version": "16.04 LTS"}, "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "resource_type": "snapshot", "service_tags": ["ServiceTags"], "size": 1, "source_image": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::image:72b27b5c-f4b0-48bb-b954-5becc7c1dcb8", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/images/72b27b5c-f4b0-48bb-b954-5becc7c1dcb8", "id": "72b27b5c-f4b0-48bb-b954-5becc7c1dcb8", "name": "my-image", "remote": {"account": {"id": "aa2432b1fa4d4ace891e9b80fc104e34", "resource_type": "account"}, "region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "image"}, "source_snapshot": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "id": "r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "name": "my-snapshot", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "snapshot"}, "source_volume": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::volume:1a6b7274-678d-4dfb-8981-c71dd9d4daa5", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/volumes/1a6b7274-678d-4dfb-8981-c71dd9d4daa5", "id": "1a6b7274-678d-4dfb-8981-c71dd9d4daa5", "name": "my-volume", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "volume"}, "user_tags": ["UserTags"]}], "total_count": 132}`) + fmt.Fprintf(res, "%s", `{"first": {"href": "https://us-south.iaas.cloud.ibm.com/v1/snapshot_consistency_groups?limit=20"}, "limit": 20, "next": {"href": "https://us-south.iaas.cloud.ibm.com/v1/snapshot_consistency_groups?start=9d5a91a3e2cbd233b5a5b33436855ed1&limit=20"}, "snapshot_consistency_groups": [{"backup_policy_plan": {"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6/plans/r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "id": "r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "name": "my-policy-plan", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "backup_policy_plan"}, "created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot-consistency-group:r134-fa329f6b-0e36-433f-a3bb-0df632e79263", "delete_snapshots_on_delete": false, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshot_consistency_groups/r134-fa329f6b-0e36-433f-a3bb-0df632e79263", "id": "r134-fa329f6b-0e36-433f-a3bb-0df632e79263", "lifecycle_state": "stable", "name": "my-snapshot-consistency-group", "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "resource_type": "snapshot_consistency_group", "service_tags": ["ServiceTags"], "snapshots": [{"crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "id": "r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "name": "my-snapshot", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "snapshot"}]}], "total_count": 132}`) })) }) - It(`Invoke ListSnapshots successfully with retries`, func() { + It(`Invoke ListSnapshotConsistencyGroups successfully with retries`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -51045,40 +50954,26 @@ var _ = Describe(`VpcV1`, func() { Expect(vpcService).ToNot(BeNil()) vpcService.EnableRetries(0, 0) - // Construct an instance of the ListSnapshotsOptions model - listSnapshotsOptionsModel := new(vpcv1.ListSnapshotsOptions) - listSnapshotsOptionsModel.Start = core.StringPtr("testString") - listSnapshotsOptionsModel.Limit = core.Int64Ptr(int64(10)) - listSnapshotsOptionsModel.Tag = core.StringPtr("testString") - listSnapshotsOptionsModel.ResourceGroupID = core.StringPtr("testString") - listSnapshotsOptionsModel.Name = core.StringPtr("testString") - listSnapshotsOptionsModel.SourceVolumeID = core.StringPtr("testString") - listSnapshotsOptionsModel.SourceVolumeCRN = core.StringPtr("crn:v1:bluemix:public:is:us-south-1:a/123456::volume:1a6b7274-678d-4dfb-8981-c71dd9d4daa5") - listSnapshotsOptionsModel.SourceImageID = core.StringPtr("testString") - listSnapshotsOptionsModel.SourceImageCRN = core.StringPtr("crn:v1:bluemix:public:is:us-south:a/123456::image:72b27b5c-f4b0-48bb-b954-5becc7c1dcb8") - listSnapshotsOptionsModel.Sort = core.StringPtr("name") - listSnapshotsOptionsModel.BackupPolicyPlanID = core.StringPtr("testString") - listSnapshotsOptionsModel.CopiesID = core.StringPtr("testString") - listSnapshotsOptionsModel.CopiesName = core.StringPtr("my-snapshot-copy") - listSnapshotsOptionsModel.CopiesCRN = core.StringPtr("testString") - listSnapshotsOptionsModel.CopiesRemoteRegionName = core.StringPtr("us-south") - listSnapshotsOptionsModel.SourceSnapshotID = core.StringPtr("testString") - listSnapshotsOptionsModel.SourceSnapshotRemoteRegionName = core.StringPtr("us-south") - listSnapshotsOptionsModel.SourceVolumeRemoteRegionName = core.StringPtr("us-south") - listSnapshotsOptionsModel.SourceImageRemoteRegionName = core.StringPtr("us-south") - listSnapshotsOptionsModel.ClonesZoneName = core.StringPtr("us-south-1") - listSnapshotsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the ListSnapshotConsistencyGroupsOptions model + listSnapshotConsistencyGroupsOptionsModel := new(vpcv1.ListSnapshotConsistencyGroupsOptions) + listSnapshotConsistencyGroupsOptionsModel.Start = core.StringPtr("testString") + listSnapshotConsistencyGroupsOptionsModel.Limit = core.Int64Ptr(int64(10)) + listSnapshotConsistencyGroupsOptionsModel.ResourceGroupID = core.StringPtr("testString") + listSnapshotConsistencyGroupsOptionsModel.Name = core.StringPtr("testString") + listSnapshotConsistencyGroupsOptionsModel.Sort = core.StringPtr("name") + listSnapshotConsistencyGroupsOptionsModel.BackupPolicyPlanID = core.StringPtr("testString") + listSnapshotConsistencyGroupsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with a Context to test a timeout error ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond) defer cancelFunc() - _, _, operationErr := vpcService.ListSnapshotsWithContext(ctx, listSnapshotsOptionsModel) + _, _, operationErr := vpcService.ListSnapshotConsistencyGroupsWithContext(ctx, listSnapshotConsistencyGroupsOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) // Disable retries and test again vpcService.DisableRetries() - result, response, operationErr := vpcService.ListSnapshots(listSnapshotsOptionsModel) + result, response, operationErr := vpcService.ListSnapshotConsistencyGroups(listSnapshotConsistencyGroupsOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) @@ -51086,7 +50981,7 @@ var _ = Describe(`VpcV1`, func() { // Re-test the timeout error with retries disabled ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond) defer cancelFunc2() - _, _, operationErr = vpcService.ListSnapshotsWithContext(ctx, listSnapshotsOptionsModel) + _, _, operationErr = vpcService.ListSnapshotConsistencyGroupsWithContext(ctx, listSnapshotConsistencyGroupsOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) }) @@ -51100,38 +50995,24 @@ var _ = Describe(`VpcV1`, func() { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(listSnapshotsPath)) + Expect(req.URL.EscapedPath()).To(Equal(listSnapshotConsistencyGroupsPath)) Expect(req.Method).To(Equal("GET")) Expect(req.URL.Query()["version"]).To(Equal([]string{"testString"})) Expect(req.URL.Query()["generation"]).To(Equal([]string{fmt.Sprint(int64(2))})) Expect(req.URL.Query()["start"]).To(Equal([]string{"testString"})) Expect(req.URL.Query()["limit"]).To(Equal([]string{fmt.Sprint(int64(10))})) - Expect(req.URL.Query()["tag"]).To(Equal([]string{"testString"})) Expect(req.URL.Query()["resource_group.id"]).To(Equal([]string{"testString"})) Expect(req.URL.Query()["name"]).To(Equal([]string{"testString"})) - Expect(req.URL.Query()["source_volume.id"]).To(Equal([]string{"testString"})) - Expect(req.URL.Query()["source_volume.crn"]).To(Equal([]string{"crn:v1:bluemix:public:is:us-south-1:a/123456::volume:1a6b7274-678d-4dfb-8981-c71dd9d4daa5"})) - Expect(req.URL.Query()["source_image.id"]).To(Equal([]string{"testString"})) - Expect(req.URL.Query()["source_image.crn"]).To(Equal([]string{"crn:v1:bluemix:public:is:us-south:a/123456::image:72b27b5c-f4b0-48bb-b954-5becc7c1dcb8"})) Expect(req.URL.Query()["sort"]).To(Equal([]string{"name"})) Expect(req.URL.Query()["backup_policy_plan.id"]).To(Equal([]string{"testString"})) - Expect(req.URL.Query()["copies[].id"]).To(Equal([]string{"testString"})) - Expect(req.URL.Query()["copies[].name"]).To(Equal([]string{"my-snapshot-copy"})) - Expect(req.URL.Query()["copies[].crn"]).To(Equal([]string{"testString"})) - Expect(req.URL.Query()["copies[].remote.region.name"]).To(Equal([]string{"us-south"})) - Expect(req.URL.Query()["source_snapshot.id"]).To(Equal([]string{"testString"})) - Expect(req.URL.Query()["source_snapshot.remote.region.name"]).To(Equal([]string{"us-south"})) - Expect(req.URL.Query()["source_volume.remote.region.name"]).To(Equal([]string{"us-south"})) - Expect(req.URL.Query()["source_image.remote.region.name"]).To(Equal([]string{"us-south"})) - Expect(req.URL.Query()["clones[].zone.name"]).To(Equal([]string{"us-south-1"})) // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"first": {"href": "https://us-south.iaas.cloud.ibm.com/v1/snapshots?limit=20"}, "limit": 20, "next": {"href": "https://us-south.iaas.cloud.ibm.com/v1/snapshots?start=9d5a91a3e2cbd233b5a5b33436855ed1&limit=20"}, "snapshots": [{"backup_policy_plan": {"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6/plans/r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "id": "r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "name": "my-policy-plan", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "backup_policy_plan"}, "bootable": true, "captured_at": "2019-01-01T12:00:00.000Z", "clones": [{"available": false, "created_at": "2019-01-01T12:00:00.000Z", "zone": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south/zones/us-south-1", "name": "us-south-1"}}], "copies": [{"crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "id": "r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "name": "my-snapshot", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "snapshot"}], "created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "deletable": false, "encryption": "provider_managed", "encryption_key": {"crn": "crn:v1:bluemix:public:kms:us-south:a/123456:e4a29d1a-2ef0-42a6-8fd2-350deb1c647e:key:5437653b-c4b1-447f-9646-b2a2a4cd6179"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "id": "r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "lifecycle_state": "stable", "minimum_capacity": 1, "name": "my-snapshot", "operating_system": {"architecture": "amd64", "dedicated_host_only": false, "display_name": "Ubuntu Server 16.04 LTS amd64", "family": "Ubuntu Server", "href": "https://us-south.iaas.cloud.ibm.com/v1/operating_systems/ubuntu-16-amd64", "name": "ubuntu-16-amd64", "vendor": "Canonical", "version": "16.04 LTS"}, "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "resource_type": "snapshot", "service_tags": ["ServiceTags"], "size": 1, "source_image": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::image:72b27b5c-f4b0-48bb-b954-5becc7c1dcb8", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/images/72b27b5c-f4b0-48bb-b954-5becc7c1dcb8", "id": "72b27b5c-f4b0-48bb-b954-5becc7c1dcb8", "name": "my-image", "remote": {"account": {"id": "aa2432b1fa4d4ace891e9b80fc104e34", "resource_type": "account"}, "region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "image"}, "source_snapshot": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "id": "r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "name": "my-snapshot", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "snapshot"}, "source_volume": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::volume:1a6b7274-678d-4dfb-8981-c71dd9d4daa5", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/volumes/1a6b7274-678d-4dfb-8981-c71dd9d4daa5", "id": "1a6b7274-678d-4dfb-8981-c71dd9d4daa5", "name": "my-volume", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "volume"}, "user_tags": ["UserTags"]}], "total_count": 132}`) + fmt.Fprintf(res, "%s", `{"first": {"href": "https://us-south.iaas.cloud.ibm.com/v1/snapshot_consistency_groups?limit=20"}, "limit": 20, "next": {"href": "https://us-south.iaas.cloud.ibm.com/v1/snapshot_consistency_groups?start=9d5a91a3e2cbd233b5a5b33436855ed1&limit=20"}, "snapshot_consistency_groups": [{"backup_policy_plan": {"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6/plans/r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "id": "r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "name": "my-policy-plan", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "backup_policy_plan"}, "created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot-consistency-group:r134-fa329f6b-0e36-433f-a3bb-0df632e79263", "delete_snapshots_on_delete": false, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshot_consistency_groups/r134-fa329f6b-0e36-433f-a3bb-0df632e79263", "id": "r134-fa329f6b-0e36-433f-a3bb-0df632e79263", "lifecycle_state": "stable", "name": "my-snapshot-consistency-group", "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "resource_type": "snapshot_consistency_group", "service_tags": ["ServiceTags"], "snapshots": [{"crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "id": "r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "name": "my-snapshot", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "snapshot"}]}], "total_count": 132}`) })) }) - It(`Invoke ListSnapshots successfully`, func() { + It(`Invoke ListSnapshotConsistencyGroups successfully`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -51141,43 +51022,29 @@ var _ = Describe(`VpcV1`, func() { Expect(vpcService).ToNot(BeNil()) // Invoke operation with nil options model (negative test) - result, response, operationErr := vpcService.ListSnapshots(nil) + result, response, operationErr := vpcService.ListSnapshotConsistencyGroups(nil) Expect(operationErr).NotTo(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) - // Construct an instance of the ListSnapshotsOptions model - listSnapshotsOptionsModel := new(vpcv1.ListSnapshotsOptions) - listSnapshotsOptionsModel.Start = core.StringPtr("testString") - listSnapshotsOptionsModel.Limit = core.Int64Ptr(int64(10)) - listSnapshotsOptionsModel.Tag = core.StringPtr("testString") - listSnapshotsOptionsModel.ResourceGroupID = core.StringPtr("testString") - listSnapshotsOptionsModel.Name = core.StringPtr("testString") - listSnapshotsOptionsModel.SourceVolumeID = core.StringPtr("testString") - listSnapshotsOptionsModel.SourceVolumeCRN = core.StringPtr("crn:v1:bluemix:public:is:us-south-1:a/123456::volume:1a6b7274-678d-4dfb-8981-c71dd9d4daa5") - listSnapshotsOptionsModel.SourceImageID = core.StringPtr("testString") - listSnapshotsOptionsModel.SourceImageCRN = core.StringPtr("crn:v1:bluemix:public:is:us-south:a/123456::image:72b27b5c-f4b0-48bb-b954-5becc7c1dcb8") - listSnapshotsOptionsModel.Sort = core.StringPtr("name") - listSnapshotsOptionsModel.BackupPolicyPlanID = core.StringPtr("testString") - listSnapshotsOptionsModel.CopiesID = core.StringPtr("testString") - listSnapshotsOptionsModel.CopiesName = core.StringPtr("my-snapshot-copy") - listSnapshotsOptionsModel.CopiesCRN = core.StringPtr("testString") - listSnapshotsOptionsModel.CopiesRemoteRegionName = core.StringPtr("us-south") - listSnapshotsOptionsModel.SourceSnapshotID = core.StringPtr("testString") - listSnapshotsOptionsModel.SourceSnapshotRemoteRegionName = core.StringPtr("us-south") - listSnapshotsOptionsModel.SourceVolumeRemoteRegionName = core.StringPtr("us-south") - listSnapshotsOptionsModel.SourceImageRemoteRegionName = core.StringPtr("us-south") - listSnapshotsOptionsModel.ClonesZoneName = core.StringPtr("us-south-1") - listSnapshotsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the ListSnapshotConsistencyGroupsOptions model + listSnapshotConsistencyGroupsOptionsModel := new(vpcv1.ListSnapshotConsistencyGroupsOptions) + listSnapshotConsistencyGroupsOptionsModel.Start = core.StringPtr("testString") + listSnapshotConsistencyGroupsOptionsModel.Limit = core.Int64Ptr(int64(10)) + listSnapshotConsistencyGroupsOptionsModel.ResourceGroupID = core.StringPtr("testString") + listSnapshotConsistencyGroupsOptionsModel.Name = core.StringPtr("testString") + listSnapshotConsistencyGroupsOptionsModel.Sort = core.StringPtr("name") + listSnapshotConsistencyGroupsOptionsModel.BackupPolicyPlanID = core.StringPtr("testString") + listSnapshotConsistencyGroupsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with valid options model (positive test) - result, response, operationErr = vpcService.ListSnapshots(listSnapshotsOptionsModel) + result, response, operationErr = vpcService.ListSnapshotConsistencyGroups(listSnapshotConsistencyGroupsOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) }) - It(`Invoke ListSnapshots with error: Operation request error`, func() { + It(`Invoke ListSnapshotConsistencyGroups with error: Operation request error`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -51186,33 +51053,19 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the ListSnapshotsOptions model - listSnapshotsOptionsModel := new(vpcv1.ListSnapshotsOptions) - listSnapshotsOptionsModel.Start = core.StringPtr("testString") - listSnapshotsOptionsModel.Limit = core.Int64Ptr(int64(10)) - listSnapshotsOptionsModel.Tag = core.StringPtr("testString") - listSnapshotsOptionsModel.ResourceGroupID = core.StringPtr("testString") - listSnapshotsOptionsModel.Name = core.StringPtr("testString") - listSnapshotsOptionsModel.SourceVolumeID = core.StringPtr("testString") - listSnapshotsOptionsModel.SourceVolumeCRN = core.StringPtr("crn:v1:bluemix:public:is:us-south-1:a/123456::volume:1a6b7274-678d-4dfb-8981-c71dd9d4daa5") - listSnapshotsOptionsModel.SourceImageID = core.StringPtr("testString") - listSnapshotsOptionsModel.SourceImageCRN = core.StringPtr("crn:v1:bluemix:public:is:us-south:a/123456::image:72b27b5c-f4b0-48bb-b954-5becc7c1dcb8") - listSnapshotsOptionsModel.Sort = core.StringPtr("name") - listSnapshotsOptionsModel.BackupPolicyPlanID = core.StringPtr("testString") - listSnapshotsOptionsModel.CopiesID = core.StringPtr("testString") - listSnapshotsOptionsModel.CopiesName = core.StringPtr("my-snapshot-copy") - listSnapshotsOptionsModel.CopiesCRN = core.StringPtr("testString") - listSnapshotsOptionsModel.CopiesRemoteRegionName = core.StringPtr("us-south") - listSnapshotsOptionsModel.SourceSnapshotID = core.StringPtr("testString") - listSnapshotsOptionsModel.SourceSnapshotRemoteRegionName = core.StringPtr("us-south") - listSnapshotsOptionsModel.SourceVolumeRemoteRegionName = core.StringPtr("us-south") - listSnapshotsOptionsModel.SourceImageRemoteRegionName = core.StringPtr("us-south") - listSnapshotsOptionsModel.ClonesZoneName = core.StringPtr("us-south-1") - listSnapshotsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the ListSnapshotConsistencyGroupsOptions model + listSnapshotConsistencyGroupsOptionsModel := new(vpcv1.ListSnapshotConsistencyGroupsOptions) + listSnapshotConsistencyGroupsOptionsModel.Start = core.StringPtr("testString") + listSnapshotConsistencyGroupsOptionsModel.Limit = core.Int64Ptr(int64(10)) + listSnapshotConsistencyGroupsOptionsModel.ResourceGroupID = core.StringPtr("testString") + listSnapshotConsistencyGroupsOptionsModel.Name = core.StringPtr("testString") + listSnapshotConsistencyGroupsOptionsModel.Sort = core.StringPtr("name") + listSnapshotConsistencyGroupsOptionsModel.BackupPolicyPlanID = core.StringPtr("testString") + listSnapshotConsistencyGroupsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with empty URL (negative test) err := vpcService.SetServiceURL("") Expect(err).To(BeNil()) - result, response, operationErr := vpcService.ListSnapshots(listSnapshotsOptionsModel) + result, response, operationErr := vpcService.ListSnapshotConsistencyGroups(listSnapshotConsistencyGroupsOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING)) Expect(response).To(BeNil()) @@ -51231,7 +51084,7 @@ var _ = Describe(`VpcV1`, func() { res.WriteHeader(200) })) }) - It(`Invoke ListSnapshots successfully`, func() { + It(`Invoke ListSnapshotConsistencyGroups successfully`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -51240,32 +51093,18 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the ListSnapshotsOptions model - listSnapshotsOptionsModel := new(vpcv1.ListSnapshotsOptions) - listSnapshotsOptionsModel.Start = core.StringPtr("testString") - listSnapshotsOptionsModel.Limit = core.Int64Ptr(int64(10)) - listSnapshotsOptionsModel.Tag = core.StringPtr("testString") - listSnapshotsOptionsModel.ResourceGroupID = core.StringPtr("testString") - listSnapshotsOptionsModel.Name = core.StringPtr("testString") - listSnapshotsOptionsModel.SourceVolumeID = core.StringPtr("testString") - listSnapshotsOptionsModel.SourceVolumeCRN = core.StringPtr("crn:v1:bluemix:public:is:us-south-1:a/123456::volume:1a6b7274-678d-4dfb-8981-c71dd9d4daa5") - listSnapshotsOptionsModel.SourceImageID = core.StringPtr("testString") - listSnapshotsOptionsModel.SourceImageCRN = core.StringPtr("crn:v1:bluemix:public:is:us-south:a/123456::image:72b27b5c-f4b0-48bb-b954-5becc7c1dcb8") - listSnapshotsOptionsModel.Sort = core.StringPtr("name") - listSnapshotsOptionsModel.BackupPolicyPlanID = core.StringPtr("testString") - listSnapshotsOptionsModel.CopiesID = core.StringPtr("testString") - listSnapshotsOptionsModel.CopiesName = core.StringPtr("my-snapshot-copy") - listSnapshotsOptionsModel.CopiesCRN = core.StringPtr("testString") - listSnapshotsOptionsModel.CopiesRemoteRegionName = core.StringPtr("us-south") - listSnapshotsOptionsModel.SourceSnapshotID = core.StringPtr("testString") - listSnapshotsOptionsModel.SourceSnapshotRemoteRegionName = core.StringPtr("us-south") - listSnapshotsOptionsModel.SourceVolumeRemoteRegionName = core.StringPtr("us-south") - listSnapshotsOptionsModel.SourceImageRemoteRegionName = core.StringPtr("us-south") - listSnapshotsOptionsModel.ClonesZoneName = core.StringPtr("us-south-1") - listSnapshotsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the ListSnapshotConsistencyGroupsOptions model + listSnapshotConsistencyGroupsOptionsModel := new(vpcv1.ListSnapshotConsistencyGroupsOptions) + listSnapshotConsistencyGroupsOptionsModel.Start = core.StringPtr("testString") + listSnapshotConsistencyGroupsOptionsModel.Limit = core.Int64Ptr(int64(10)) + listSnapshotConsistencyGroupsOptionsModel.ResourceGroupID = core.StringPtr("testString") + listSnapshotConsistencyGroupsOptionsModel.Name = core.StringPtr("testString") + listSnapshotConsistencyGroupsOptionsModel.Sort = core.StringPtr("name") + listSnapshotConsistencyGroupsOptionsModel.BackupPolicyPlanID = core.StringPtr("testString") + listSnapshotConsistencyGroupsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation - result, response, operationErr := vpcService.ListSnapshots(listSnapshotsOptionsModel) + result, response, operationErr := vpcService.ListSnapshotConsistencyGroups(listSnapshotConsistencyGroupsOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) @@ -51278,8 +51117,8 @@ var _ = Describe(`VpcV1`, func() { }) Context(`Test pagination helper method on response`, func() { It(`Invoke GetNextStart successfully`, func() { - responseObject := new(vpcv1.SnapshotCollection) - nextObject := new(vpcv1.SnapshotCollectionNext) + responseObject := new(vpcv1.SnapshotConsistencyGroupCollection) + nextObject := new(vpcv1.SnapshotConsistencyGroupCollectionNext) nextObject.Href = core.StringPtr("ibm.com?start=abc-123") responseObject.Next = nextObject @@ -51288,15 +51127,15 @@ var _ = Describe(`VpcV1`, func() { Expect(value).To(Equal(core.StringPtr("abc-123"))) }) It(`Invoke GetNextStart without a "Next" property in the response`, func() { - responseObject := new(vpcv1.SnapshotCollection) + responseObject := new(vpcv1.SnapshotConsistencyGroupCollection) value, err := responseObject.GetNextStart() Expect(err).To(BeNil()) Expect(value).To(BeNil()) }) It(`Invoke GetNextStart without any query params in the "Next" URL`, func() { - responseObject := new(vpcv1.SnapshotCollection) - nextObject := new(vpcv1.SnapshotCollectionNext) + responseObject := new(vpcv1.SnapshotConsistencyGroupCollection) + nextObject := new(vpcv1.SnapshotConsistencyGroupCollectionNext) nextObject.Href = core.StringPtr("ibm.com") responseObject.Next = nextObject @@ -51312,7 +51151,7 @@ var _ = Describe(`VpcV1`, func() { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(listSnapshotsPath)) + Expect(req.URL.EscapedPath()).To(Equal(listSnapshotConsistencyGroupsPath)) Expect(req.Method).To(Equal("GET")) // Set mock response @@ -51320,15 +51159,15 @@ var _ = Describe(`VpcV1`, func() { res.WriteHeader(200) requestNumber++ if requestNumber == 1 { - fmt.Fprintf(res, "%s", `{"snapshots":[{"backup_policy_plan":{"deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6/plans/r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178","id":"r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178","name":"my-policy-plan","remote":{"region":{"href":"https://us-south.iaas.cloud.ibm.com/v1/regions/us-south","name":"us-south"}},"resource_type":"backup_policy_plan"},"bootable":true,"captured_at":"2019-01-01T12:00:00.000Z","clones":[{"available":false,"created_at":"2019-01-01T12:00:00.000Z","zone":{"href":"https://us-south.iaas.cloud.ibm.com/v1/regions/us-south/zones/us-south-1","name":"us-south-1"}}],"copies":[{"crn":"crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263","deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263","id":"r134-f6bfa329-0e36-433f-a3bb-0df632e79263","name":"my-snapshot","remote":{"region":{"href":"https://us-south.iaas.cloud.ibm.com/v1/regions/us-south","name":"us-south"}},"resource_type":"snapshot"}],"created_at":"2019-01-01T12:00:00.000Z","crn":"crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263","deletable":false,"encryption":"provider_managed","encryption_key":{"crn":"crn:v1:bluemix:public:kms:us-south:a/123456:e4a29d1a-2ef0-42a6-8fd2-350deb1c647e:key:5437653b-c4b1-447f-9646-b2a2a4cd6179"},"href":"https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263","id":"r134-f6bfa329-0e36-433f-a3bb-0df632e79263","lifecycle_state":"stable","minimum_capacity":1,"name":"my-snapshot","operating_system":{"architecture":"amd64","dedicated_host_only":false,"display_name":"Ubuntu Server 16.04 LTS amd64","family":"Ubuntu Server","href":"https://us-south.iaas.cloud.ibm.com/v1/operating_systems/ubuntu-16-amd64","name":"ubuntu-16-amd64","vendor":"Canonical","version":"16.04 LTS"},"resource_group":{"href":"https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345","id":"fee82deba12e4c0fb69c3b09d1f12345","name":"my-resource-group"},"resource_type":"snapshot","service_tags":["ServiceTags"],"size":1,"source_image":{"crn":"crn:v1:bluemix:public:is:us-south:a/123456::image:72b27b5c-f4b0-48bb-b954-5becc7c1dcb8","deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/images/72b27b5c-f4b0-48bb-b954-5becc7c1dcb8","id":"72b27b5c-f4b0-48bb-b954-5becc7c1dcb8","name":"my-image","remote":{"account":{"id":"aa2432b1fa4d4ace891e9b80fc104e34","resource_type":"account"},"region":{"href":"https://us-south.iaas.cloud.ibm.com/v1/regions/us-south","name":"us-south"}},"resource_type":"image"},"source_snapshot":{"crn":"crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263","deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263","id":"r134-f6bfa329-0e36-433f-a3bb-0df632e79263","name":"my-snapshot","remote":{"region":{"href":"https://us-south.iaas.cloud.ibm.com/v1/regions/us-south","name":"us-south"}},"resource_type":"snapshot"},"source_volume":{"crn":"crn:v1:bluemix:public:is:us-south-1:a/123456::volume:1a6b7274-678d-4dfb-8981-c71dd9d4daa5","deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/volumes/1a6b7274-678d-4dfb-8981-c71dd9d4daa5","id":"1a6b7274-678d-4dfb-8981-c71dd9d4daa5","name":"my-volume","remote":{"region":{"href":"https://us-south.iaas.cloud.ibm.com/v1/regions/us-south","name":"us-south"}},"resource_type":"volume"},"user_tags":["UserTags"]}],"next":{"href":"https://myhost.com/somePath?start=1"},"total_count":2,"limit":1}`) + fmt.Fprintf(res, "%s", `{"next":{"href":"https://myhost.com/somePath?start=1"},"snapshot_consistency_groups":[{"backup_policy_plan":{"deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6/plans/r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178","id":"r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178","name":"my-policy-plan","remote":{"region":{"href":"https://us-south.iaas.cloud.ibm.com/v1/regions/us-south","name":"us-south"}},"resource_type":"backup_policy_plan"},"created_at":"2019-01-01T12:00:00.000Z","crn":"crn:v1:bluemix:public:is:us-south:a/123456::snapshot-consistency-group:r134-fa329f6b-0e36-433f-a3bb-0df632e79263","delete_snapshots_on_delete":false,"href":"https://us-south.iaas.cloud.ibm.com/v1/snapshot_consistency_groups/r134-fa329f6b-0e36-433f-a3bb-0df632e79263","id":"r134-fa329f6b-0e36-433f-a3bb-0df632e79263","lifecycle_state":"stable","name":"my-snapshot-consistency-group","resource_group":{"href":"https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345","id":"fee82deba12e4c0fb69c3b09d1f12345","name":"my-resource-group"},"resource_type":"snapshot_consistency_group","service_tags":["ServiceTags"],"snapshots":[{"crn":"crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263","deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263","id":"r134-f6bfa329-0e36-433f-a3bb-0df632e79263","name":"my-snapshot","remote":{"region":{"href":"https://us-south.iaas.cloud.ibm.com/v1/regions/us-south","name":"us-south"}},"resource_type":"snapshot"}]}],"total_count":2,"limit":1}`) } else if requestNumber == 2 { - fmt.Fprintf(res, "%s", `{"snapshots":[{"backup_policy_plan":{"deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6/plans/r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178","id":"r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178","name":"my-policy-plan","remote":{"region":{"href":"https://us-south.iaas.cloud.ibm.com/v1/regions/us-south","name":"us-south"}},"resource_type":"backup_policy_plan"},"bootable":true,"captured_at":"2019-01-01T12:00:00.000Z","clones":[{"available":false,"created_at":"2019-01-01T12:00:00.000Z","zone":{"href":"https://us-south.iaas.cloud.ibm.com/v1/regions/us-south/zones/us-south-1","name":"us-south-1"}}],"copies":[{"crn":"crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263","deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263","id":"r134-f6bfa329-0e36-433f-a3bb-0df632e79263","name":"my-snapshot","remote":{"region":{"href":"https://us-south.iaas.cloud.ibm.com/v1/regions/us-south","name":"us-south"}},"resource_type":"snapshot"}],"created_at":"2019-01-01T12:00:00.000Z","crn":"crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263","deletable":false,"encryption":"provider_managed","encryption_key":{"crn":"crn:v1:bluemix:public:kms:us-south:a/123456:e4a29d1a-2ef0-42a6-8fd2-350deb1c647e:key:5437653b-c4b1-447f-9646-b2a2a4cd6179"},"href":"https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263","id":"r134-f6bfa329-0e36-433f-a3bb-0df632e79263","lifecycle_state":"stable","minimum_capacity":1,"name":"my-snapshot","operating_system":{"architecture":"amd64","dedicated_host_only":false,"display_name":"Ubuntu Server 16.04 LTS amd64","family":"Ubuntu Server","href":"https://us-south.iaas.cloud.ibm.com/v1/operating_systems/ubuntu-16-amd64","name":"ubuntu-16-amd64","vendor":"Canonical","version":"16.04 LTS"},"resource_group":{"href":"https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345","id":"fee82deba12e4c0fb69c3b09d1f12345","name":"my-resource-group"},"resource_type":"snapshot","service_tags":["ServiceTags"],"size":1,"source_image":{"crn":"crn:v1:bluemix:public:is:us-south:a/123456::image:72b27b5c-f4b0-48bb-b954-5becc7c1dcb8","deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/images/72b27b5c-f4b0-48bb-b954-5becc7c1dcb8","id":"72b27b5c-f4b0-48bb-b954-5becc7c1dcb8","name":"my-image","remote":{"account":{"id":"aa2432b1fa4d4ace891e9b80fc104e34","resource_type":"account"},"region":{"href":"https://us-south.iaas.cloud.ibm.com/v1/regions/us-south","name":"us-south"}},"resource_type":"image"},"source_snapshot":{"crn":"crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263","deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263","id":"r134-f6bfa329-0e36-433f-a3bb-0df632e79263","name":"my-snapshot","remote":{"region":{"href":"https://us-south.iaas.cloud.ibm.com/v1/regions/us-south","name":"us-south"}},"resource_type":"snapshot"},"source_volume":{"crn":"crn:v1:bluemix:public:is:us-south-1:a/123456::volume:1a6b7274-678d-4dfb-8981-c71dd9d4daa5","deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/volumes/1a6b7274-678d-4dfb-8981-c71dd9d4daa5","id":"1a6b7274-678d-4dfb-8981-c71dd9d4daa5","name":"my-volume","remote":{"region":{"href":"https://us-south.iaas.cloud.ibm.com/v1/regions/us-south","name":"us-south"}},"resource_type":"volume"},"user_tags":["UserTags"]}],"total_count":2,"limit":1}`) + fmt.Fprintf(res, "%s", `{"snapshot_consistency_groups":[{"backup_policy_plan":{"deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6/plans/r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178","id":"r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178","name":"my-policy-plan","remote":{"region":{"href":"https://us-south.iaas.cloud.ibm.com/v1/regions/us-south","name":"us-south"}},"resource_type":"backup_policy_plan"},"created_at":"2019-01-01T12:00:00.000Z","crn":"crn:v1:bluemix:public:is:us-south:a/123456::snapshot-consistency-group:r134-fa329f6b-0e36-433f-a3bb-0df632e79263","delete_snapshots_on_delete":false,"href":"https://us-south.iaas.cloud.ibm.com/v1/snapshot_consistency_groups/r134-fa329f6b-0e36-433f-a3bb-0df632e79263","id":"r134-fa329f6b-0e36-433f-a3bb-0df632e79263","lifecycle_state":"stable","name":"my-snapshot-consistency-group","resource_group":{"href":"https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345","id":"fee82deba12e4c0fb69c3b09d1f12345","name":"my-resource-group"},"resource_type":"snapshot_consistency_group","service_tags":["ServiceTags"],"snapshots":[{"crn":"crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263","deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263","id":"r134-f6bfa329-0e36-433f-a3bb-0df632e79263","name":"my-snapshot","remote":{"region":{"href":"https://us-south.iaas.cloud.ibm.com/v1/regions/us-south","name":"us-south"}},"resource_type":"snapshot"}]}],"total_count":2,"limit":1}`) } else { res.WriteHeader(400) } })) }) - It(`Use SnapshotsPager.GetNext successfully`, func() { + It(`Use SnapshotConsistencyGroupsPager.GetNext successfully`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -51337,33 +51176,19 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - listSnapshotsOptionsModel := &vpcv1.ListSnapshotsOptions{ - Limit: core.Int64Ptr(int64(10)), - Tag: core.StringPtr("testString"), - ResourceGroupID: core.StringPtr("testString"), - Name: core.StringPtr("testString"), - SourceVolumeID: core.StringPtr("testString"), - SourceVolumeCRN: core.StringPtr("crn:v1:bluemix:public:is:us-south-1:a/123456::volume:1a6b7274-678d-4dfb-8981-c71dd9d4daa5"), - SourceImageID: core.StringPtr("testString"), - SourceImageCRN: core.StringPtr("crn:v1:bluemix:public:is:us-south:a/123456::image:72b27b5c-f4b0-48bb-b954-5becc7c1dcb8"), - Sort: core.StringPtr("name"), - BackupPolicyPlanID: core.StringPtr("testString"), - CopiesID: core.StringPtr("testString"), - CopiesName: core.StringPtr("my-snapshot-copy"), - CopiesCRN: core.StringPtr("testString"), - CopiesRemoteRegionName: core.StringPtr("us-south"), - SourceSnapshotID: core.StringPtr("testString"), - SourceSnapshotRemoteRegionName: core.StringPtr("us-south"), - SourceVolumeRemoteRegionName: core.StringPtr("us-south"), - SourceImageRemoteRegionName: core.StringPtr("us-south"), - ClonesZoneName: core.StringPtr("us-south-1"), + listSnapshotConsistencyGroupsOptionsModel := &vpcv1.ListSnapshotConsistencyGroupsOptions{ + Limit: core.Int64Ptr(int64(10)), + ResourceGroupID: core.StringPtr("testString"), + Name: core.StringPtr("testString"), + Sort: core.StringPtr("name"), + BackupPolicyPlanID: core.StringPtr("testString"), } - pager, err := vpcService.NewSnapshotsPager(listSnapshotsOptionsModel) + pager, err := vpcService.NewSnapshotConsistencyGroupsPager(listSnapshotConsistencyGroupsOptionsModel) Expect(err).To(BeNil()) Expect(pager).ToNot(BeNil()) - var allResults []vpcv1.Snapshot + var allResults []vpcv1.SnapshotConsistencyGroup for pager.HasNext() { nextPage, err := pager.GetNext() Expect(err).To(BeNil()) @@ -51372,7 +51197,7 @@ var _ = Describe(`VpcV1`, func() { } Expect(len(allResults)).To(Equal(2)) }) - It(`Use SnapshotsPager.GetAll successfully`, func() { + It(`Use SnapshotConsistencyGroupsPager.GetAll successfully`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -51381,29 +51206,15 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - listSnapshotsOptionsModel := &vpcv1.ListSnapshotsOptions{ - Limit: core.Int64Ptr(int64(10)), - Tag: core.StringPtr("testString"), - ResourceGroupID: core.StringPtr("testString"), - Name: core.StringPtr("testString"), - SourceVolumeID: core.StringPtr("testString"), - SourceVolumeCRN: core.StringPtr("crn:v1:bluemix:public:is:us-south-1:a/123456::volume:1a6b7274-678d-4dfb-8981-c71dd9d4daa5"), - SourceImageID: core.StringPtr("testString"), - SourceImageCRN: core.StringPtr("crn:v1:bluemix:public:is:us-south:a/123456::image:72b27b5c-f4b0-48bb-b954-5becc7c1dcb8"), - Sort: core.StringPtr("name"), - BackupPolicyPlanID: core.StringPtr("testString"), - CopiesID: core.StringPtr("testString"), - CopiesName: core.StringPtr("my-snapshot-copy"), - CopiesCRN: core.StringPtr("testString"), - CopiesRemoteRegionName: core.StringPtr("us-south"), - SourceSnapshotID: core.StringPtr("testString"), - SourceSnapshotRemoteRegionName: core.StringPtr("us-south"), - SourceVolumeRemoteRegionName: core.StringPtr("us-south"), - SourceImageRemoteRegionName: core.StringPtr("us-south"), - ClonesZoneName: core.StringPtr("us-south-1"), + listSnapshotConsistencyGroupsOptionsModel := &vpcv1.ListSnapshotConsistencyGroupsOptions{ + Limit: core.Int64Ptr(int64(10)), + ResourceGroupID: core.StringPtr("testString"), + Name: core.StringPtr("testString"), + Sort: core.StringPtr("name"), + BackupPolicyPlanID: core.StringPtr("testString"), } - pager, err := vpcService.NewSnapshotsPager(listSnapshotsOptionsModel) + pager, err := vpcService.NewSnapshotConsistencyGroupsPager(listSnapshotConsistencyGroupsOptionsModel) Expect(err).To(BeNil()) Expect(pager).ToNot(BeNil()) @@ -51414,16 +51225,16 @@ var _ = Describe(`VpcV1`, func() { }) }) }) - Describe(`CreateSnapshot(createSnapshotOptions *CreateSnapshotOptions) - Operation response error`, func() { + Describe(`CreateSnapshotConsistencyGroup(createSnapshotConsistencyGroupOptions *CreateSnapshotConsistencyGroupOptions) - Operation response error`, func() { version := "testString" - createSnapshotPath := "/snapshots" + createSnapshotConsistencyGroupPath := "/snapshot_consistency_groups" Context(`Using mock server endpoint with invalid JSON response`, func() { BeforeEach(func() { testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(createSnapshotPath)) + Expect(req.URL.EscapedPath()).To(Equal(createSnapshotConsistencyGroupPath)) Expect(req.Method).To(Equal("POST")) Expect(req.URL.Query()["version"]).To(Equal([]string{"testString"})) Expect(req.URL.Query()["generation"]).To(Equal([]string{fmt.Sprint(int64(2))})) @@ -51432,7 +51243,7 @@ var _ = Describe(`VpcV1`, func() { fmt.Fprint(res, `} this is not valid json {`) })) }) - It(`Invoke CreateSnapshot with error: Operation response processing error`, func() { + It(`Invoke CreateSnapshotConsistencyGroup with error: Operation response processing error`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -51441,14 +51252,6 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the ZoneIdentityByName model - zoneIdentityModel := new(vpcv1.ZoneIdentityByName) - zoneIdentityModel.Name = core.StringPtr("us-south-1") - - // Construct an instance of the SnapshotClonePrototype model - snapshotClonePrototypeModel := new(vpcv1.SnapshotClonePrototype) - snapshotClonePrototypeModel.Zone = zoneIdentityModel - // Construct an instance of the ResourceGroupIdentityByID model resourceGroupIdentityModel := new(vpcv1.ResourceGroupIdentityByID) resourceGroupIdentityModel.ID = core.StringPtr("fee82deba12e4c0fb69c3b09d1f12345") @@ -51457,27 +51260,32 @@ var _ = Describe(`VpcV1`, func() { volumeIdentityModel := new(vpcv1.VolumeIdentityByID) volumeIdentityModel.ID = core.StringPtr("1a6b7274-678d-4dfb-8981-c71dd9d4daa5") - // Construct an instance of the SnapshotPrototypeSnapshotBySourceVolume model - snapshotPrototypeModel := new(vpcv1.SnapshotPrototypeSnapshotBySourceVolume) - snapshotPrototypeModel.Clones = []vpcv1.SnapshotClonePrototype{*snapshotClonePrototypeModel} - snapshotPrototypeModel.Name = core.StringPtr("my-snapshot") - snapshotPrototypeModel.ResourceGroup = resourceGroupIdentityModel - snapshotPrototypeModel.UserTags = []string{} - snapshotPrototypeModel.SourceVolume = volumeIdentityModel - - // Construct an instance of the CreateSnapshotOptions model - createSnapshotOptionsModel := new(vpcv1.CreateSnapshotOptions) - createSnapshotOptionsModel.SnapshotPrototype = snapshotPrototypeModel - createSnapshotOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the SnapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshotsSnapshotsItem model + snapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshotsSnapshotsItemModel := new(vpcv1.SnapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshotsSnapshotsItem) + snapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshotsSnapshotsItemModel.Name = core.StringPtr("my-snapshot") + snapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshotsSnapshotsItemModel.SourceVolume = volumeIdentityModel + snapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshotsSnapshotsItemModel.UserTags = []string{"testString"} + + // Construct an instance of the SnapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshots model + snapshotConsistencyGroupPrototypeModel := new(vpcv1.SnapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshots) + snapshotConsistencyGroupPrototypeModel.DeleteSnapshotsOnDelete = core.BoolPtr(true) + snapshotConsistencyGroupPrototypeModel.Name = core.StringPtr("my-snapshot-consistency-group") + snapshotConsistencyGroupPrototypeModel.ResourceGroup = resourceGroupIdentityModel + snapshotConsistencyGroupPrototypeModel.Snapshots = []vpcv1.SnapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshotsSnapshotsItem{*snapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshotsSnapshotsItemModel} + + // Construct an instance of the CreateSnapshotConsistencyGroupOptions model + createSnapshotConsistencyGroupOptionsModel := new(vpcv1.CreateSnapshotConsistencyGroupOptions) + createSnapshotConsistencyGroupOptionsModel.SnapshotConsistencyGroupPrototype = snapshotConsistencyGroupPrototypeModel + createSnapshotConsistencyGroupOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Expect response parsing to fail since we are receiving a text/plain response - result, response, operationErr := vpcService.CreateSnapshot(createSnapshotOptionsModel) + result, response, operationErr := vpcService.CreateSnapshotConsistencyGroup(createSnapshotConsistencyGroupOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).To(BeNil()) // Enable retries and test again vpcService.EnableRetries(0, 0) - result, response, operationErr = vpcService.CreateSnapshot(createSnapshotOptionsModel) + result, response, operationErr = vpcService.CreateSnapshotConsistencyGroup(createSnapshotConsistencyGroupOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).To(BeNil()) @@ -51487,16 +51295,16 @@ var _ = Describe(`VpcV1`, func() { }) }) }) - Describe(`CreateSnapshot(createSnapshotOptions *CreateSnapshotOptions)`, func() { + Describe(`CreateSnapshotConsistencyGroup(createSnapshotConsistencyGroupOptions *CreateSnapshotConsistencyGroupOptions)`, func() { version := "testString" - createSnapshotPath := "/snapshots" + createSnapshotConsistencyGroupPath := "/snapshot_consistency_groups" Context(`Using mock server endpoint with timeout`, func() { BeforeEach(func() { testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(createSnapshotPath)) + Expect(req.URL.EscapedPath()).To(Equal(createSnapshotConsistencyGroupPath)) Expect(req.Method).To(Equal("POST")) // For gzip-disabled operation, verify Content-Encoding is not set. @@ -51523,10 +51331,10 @@ var _ = Describe(`VpcV1`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(201) - fmt.Fprintf(res, "%s", `{"backup_policy_plan": {"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6/plans/r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "id": "r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "name": "my-policy-plan", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "backup_policy_plan"}, "bootable": true, "captured_at": "2019-01-01T12:00:00.000Z", "clones": [{"available": false, "created_at": "2019-01-01T12:00:00.000Z", "zone": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south/zones/us-south-1", "name": "us-south-1"}}], "copies": [{"crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "id": "r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "name": "my-snapshot", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "snapshot"}], "created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "deletable": false, "encryption": "provider_managed", "encryption_key": {"crn": "crn:v1:bluemix:public:kms:us-south:a/123456:e4a29d1a-2ef0-42a6-8fd2-350deb1c647e:key:5437653b-c4b1-447f-9646-b2a2a4cd6179"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "id": "r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "lifecycle_state": "stable", "minimum_capacity": 1, "name": "my-snapshot", "operating_system": {"architecture": "amd64", "dedicated_host_only": false, "display_name": "Ubuntu Server 16.04 LTS amd64", "family": "Ubuntu Server", "href": "https://us-south.iaas.cloud.ibm.com/v1/operating_systems/ubuntu-16-amd64", "name": "ubuntu-16-amd64", "vendor": "Canonical", "version": "16.04 LTS"}, "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "resource_type": "snapshot", "service_tags": ["ServiceTags"], "size": 1, "source_image": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::image:72b27b5c-f4b0-48bb-b954-5becc7c1dcb8", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/images/72b27b5c-f4b0-48bb-b954-5becc7c1dcb8", "id": "72b27b5c-f4b0-48bb-b954-5becc7c1dcb8", "name": "my-image", "remote": {"account": {"id": "aa2432b1fa4d4ace891e9b80fc104e34", "resource_type": "account"}, "region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "image"}, "source_snapshot": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "id": "r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "name": "my-snapshot", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "snapshot"}, "source_volume": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::volume:1a6b7274-678d-4dfb-8981-c71dd9d4daa5", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/volumes/1a6b7274-678d-4dfb-8981-c71dd9d4daa5", "id": "1a6b7274-678d-4dfb-8981-c71dd9d4daa5", "name": "my-volume", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "volume"}, "user_tags": ["UserTags"]}`) + fmt.Fprintf(res, "%s", `{"backup_policy_plan": {"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6/plans/r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "id": "r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "name": "my-policy-plan", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "backup_policy_plan"}, "created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot-consistency-group:r134-fa329f6b-0e36-433f-a3bb-0df632e79263", "delete_snapshots_on_delete": false, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshot_consistency_groups/r134-fa329f6b-0e36-433f-a3bb-0df632e79263", "id": "r134-fa329f6b-0e36-433f-a3bb-0df632e79263", "lifecycle_state": "stable", "name": "my-snapshot-consistency-group", "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "resource_type": "snapshot_consistency_group", "service_tags": ["ServiceTags"], "snapshots": [{"crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "id": "r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "name": "my-snapshot", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "snapshot"}]}`) })) }) - It(`Invoke CreateSnapshot successfully with retries`, func() { + It(`Invoke CreateSnapshotConsistencyGroup successfully with retries`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -51536,14 +51344,6 @@ var _ = Describe(`VpcV1`, func() { Expect(vpcService).ToNot(BeNil()) vpcService.EnableRetries(0, 0) - // Construct an instance of the ZoneIdentityByName model - zoneIdentityModel := new(vpcv1.ZoneIdentityByName) - zoneIdentityModel.Name = core.StringPtr("us-south-1") - - // Construct an instance of the SnapshotClonePrototype model - snapshotClonePrototypeModel := new(vpcv1.SnapshotClonePrototype) - snapshotClonePrototypeModel.Zone = zoneIdentityModel - // Construct an instance of the ResourceGroupIdentityByID model resourceGroupIdentityModel := new(vpcv1.ResourceGroupIdentityByID) resourceGroupIdentityModel.ID = core.StringPtr("fee82deba12e4c0fb69c3b09d1f12345") @@ -51552,29 +51352,34 @@ var _ = Describe(`VpcV1`, func() { volumeIdentityModel := new(vpcv1.VolumeIdentityByID) volumeIdentityModel.ID = core.StringPtr("1a6b7274-678d-4dfb-8981-c71dd9d4daa5") - // Construct an instance of the SnapshotPrototypeSnapshotBySourceVolume model - snapshotPrototypeModel := new(vpcv1.SnapshotPrototypeSnapshotBySourceVolume) - snapshotPrototypeModel.Clones = []vpcv1.SnapshotClonePrototype{*snapshotClonePrototypeModel} - snapshotPrototypeModel.Name = core.StringPtr("my-snapshot") - snapshotPrototypeModel.ResourceGroup = resourceGroupIdentityModel - snapshotPrototypeModel.UserTags = []string{} - snapshotPrototypeModel.SourceVolume = volumeIdentityModel + // Construct an instance of the SnapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshotsSnapshotsItem model + snapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshotsSnapshotsItemModel := new(vpcv1.SnapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshotsSnapshotsItem) + snapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshotsSnapshotsItemModel.Name = core.StringPtr("my-snapshot") + snapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshotsSnapshotsItemModel.SourceVolume = volumeIdentityModel + snapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshotsSnapshotsItemModel.UserTags = []string{"testString"} - // Construct an instance of the CreateSnapshotOptions model - createSnapshotOptionsModel := new(vpcv1.CreateSnapshotOptions) - createSnapshotOptionsModel.SnapshotPrototype = snapshotPrototypeModel - createSnapshotOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the SnapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshots model + snapshotConsistencyGroupPrototypeModel := new(vpcv1.SnapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshots) + snapshotConsistencyGroupPrototypeModel.DeleteSnapshotsOnDelete = core.BoolPtr(true) + snapshotConsistencyGroupPrototypeModel.Name = core.StringPtr("my-snapshot-consistency-group") + snapshotConsistencyGroupPrototypeModel.ResourceGroup = resourceGroupIdentityModel + snapshotConsistencyGroupPrototypeModel.Snapshots = []vpcv1.SnapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshotsSnapshotsItem{*snapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshotsSnapshotsItemModel} + + // Construct an instance of the CreateSnapshotConsistencyGroupOptions model + createSnapshotConsistencyGroupOptionsModel := new(vpcv1.CreateSnapshotConsistencyGroupOptions) + createSnapshotConsistencyGroupOptionsModel.SnapshotConsistencyGroupPrototype = snapshotConsistencyGroupPrototypeModel + createSnapshotConsistencyGroupOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with a Context to test a timeout error ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond) defer cancelFunc() - _, _, operationErr := vpcService.CreateSnapshotWithContext(ctx, createSnapshotOptionsModel) + _, _, operationErr := vpcService.CreateSnapshotConsistencyGroupWithContext(ctx, createSnapshotConsistencyGroupOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) // Disable retries and test again vpcService.DisableRetries() - result, response, operationErr := vpcService.CreateSnapshot(createSnapshotOptionsModel) + result, response, operationErr := vpcService.CreateSnapshotConsistencyGroup(createSnapshotConsistencyGroupOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) @@ -51582,7 +51387,7 @@ var _ = Describe(`VpcV1`, func() { // Re-test the timeout error with retries disabled ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond) defer cancelFunc2() - _, _, operationErr = vpcService.CreateSnapshotWithContext(ctx, createSnapshotOptionsModel) + _, _, operationErr = vpcService.CreateSnapshotConsistencyGroupWithContext(ctx, createSnapshotConsistencyGroupOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) }) @@ -51596,7 +51401,7 @@ var _ = Describe(`VpcV1`, func() { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(createSnapshotPath)) + Expect(req.URL.EscapedPath()).To(Equal(createSnapshotConsistencyGroupPath)) Expect(req.Method).To(Equal("POST")) // For gzip-disabled operation, verify Content-Encoding is not set. @@ -51620,10 +51425,10 @@ var _ = Describe(`VpcV1`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(201) - fmt.Fprintf(res, "%s", `{"backup_policy_plan": {"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6/plans/r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "id": "r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "name": "my-policy-plan", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "backup_policy_plan"}, "bootable": true, "captured_at": "2019-01-01T12:00:00.000Z", "clones": [{"available": false, "created_at": "2019-01-01T12:00:00.000Z", "zone": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south/zones/us-south-1", "name": "us-south-1"}}], "copies": [{"crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "id": "r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "name": "my-snapshot", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "snapshot"}], "created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "deletable": false, "encryption": "provider_managed", "encryption_key": {"crn": "crn:v1:bluemix:public:kms:us-south:a/123456:e4a29d1a-2ef0-42a6-8fd2-350deb1c647e:key:5437653b-c4b1-447f-9646-b2a2a4cd6179"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "id": "r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "lifecycle_state": "stable", "minimum_capacity": 1, "name": "my-snapshot", "operating_system": {"architecture": "amd64", "dedicated_host_only": false, "display_name": "Ubuntu Server 16.04 LTS amd64", "family": "Ubuntu Server", "href": "https://us-south.iaas.cloud.ibm.com/v1/operating_systems/ubuntu-16-amd64", "name": "ubuntu-16-amd64", "vendor": "Canonical", "version": "16.04 LTS"}, "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "resource_type": "snapshot", "service_tags": ["ServiceTags"], "size": 1, "source_image": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::image:72b27b5c-f4b0-48bb-b954-5becc7c1dcb8", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/images/72b27b5c-f4b0-48bb-b954-5becc7c1dcb8", "id": "72b27b5c-f4b0-48bb-b954-5becc7c1dcb8", "name": "my-image", "remote": {"account": {"id": "aa2432b1fa4d4ace891e9b80fc104e34", "resource_type": "account"}, "region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "image"}, "source_snapshot": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "id": "r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "name": "my-snapshot", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "snapshot"}, "source_volume": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::volume:1a6b7274-678d-4dfb-8981-c71dd9d4daa5", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/volumes/1a6b7274-678d-4dfb-8981-c71dd9d4daa5", "id": "1a6b7274-678d-4dfb-8981-c71dd9d4daa5", "name": "my-volume", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "volume"}, "user_tags": ["UserTags"]}`) + fmt.Fprintf(res, "%s", `{"backup_policy_plan": {"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6/plans/r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "id": "r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "name": "my-policy-plan", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "backup_policy_plan"}, "created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot-consistency-group:r134-fa329f6b-0e36-433f-a3bb-0df632e79263", "delete_snapshots_on_delete": false, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshot_consistency_groups/r134-fa329f6b-0e36-433f-a3bb-0df632e79263", "id": "r134-fa329f6b-0e36-433f-a3bb-0df632e79263", "lifecycle_state": "stable", "name": "my-snapshot-consistency-group", "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "resource_type": "snapshot_consistency_group", "service_tags": ["ServiceTags"], "snapshots": [{"crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "id": "r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "name": "my-snapshot", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "snapshot"}]}`) })) }) - It(`Invoke CreateSnapshot successfully`, func() { + It(`Invoke CreateSnapshotConsistencyGroup successfully`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -51633,19 +51438,11 @@ var _ = Describe(`VpcV1`, func() { Expect(vpcService).ToNot(BeNil()) // Invoke operation with nil options model (negative test) - result, response, operationErr := vpcService.CreateSnapshot(nil) + result, response, operationErr := vpcService.CreateSnapshotConsistencyGroup(nil) Expect(operationErr).NotTo(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) - // Construct an instance of the ZoneIdentityByName model - zoneIdentityModel := new(vpcv1.ZoneIdentityByName) - zoneIdentityModel.Name = core.StringPtr("us-south-1") - - // Construct an instance of the SnapshotClonePrototype model - snapshotClonePrototypeModel := new(vpcv1.SnapshotClonePrototype) - snapshotClonePrototypeModel.Zone = zoneIdentityModel - // Construct an instance of the ResourceGroupIdentityByID model resourceGroupIdentityModel := new(vpcv1.ResourceGroupIdentityByID) resourceGroupIdentityModel.ID = core.StringPtr("fee82deba12e4c0fb69c3b09d1f12345") @@ -51654,27 +51451,32 @@ var _ = Describe(`VpcV1`, func() { volumeIdentityModel := new(vpcv1.VolumeIdentityByID) volumeIdentityModel.ID = core.StringPtr("1a6b7274-678d-4dfb-8981-c71dd9d4daa5") - // Construct an instance of the SnapshotPrototypeSnapshotBySourceVolume model - snapshotPrototypeModel := new(vpcv1.SnapshotPrototypeSnapshotBySourceVolume) - snapshotPrototypeModel.Clones = []vpcv1.SnapshotClonePrototype{*snapshotClonePrototypeModel} - snapshotPrototypeModel.Name = core.StringPtr("my-snapshot") - snapshotPrototypeModel.ResourceGroup = resourceGroupIdentityModel - snapshotPrototypeModel.UserTags = []string{} - snapshotPrototypeModel.SourceVolume = volumeIdentityModel + // Construct an instance of the SnapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshotsSnapshotsItem model + snapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshotsSnapshotsItemModel := new(vpcv1.SnapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshotsSnapshotsItem) + snapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshotsSnapshotsItemModel.Name = core.StringPtr("my-snapshot") + snapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshotsSnapshotsItemModel.SourceVolume = volumeIdentityModel + snapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshotsSnapshotsItemModel.UserTags = []string{"testString"} - // Construct an instance of the CreateSnapshotOptions model - createSnapshotOptionsModel := new(vpcv1.CreateSnapshotOptions) - createSnapshotOptionsModel.SnapshotPrototype = snapshotPrototypeModel - createSnapshotOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the SnapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshots model + snapshotConsistencyGroupPrototypeModel := new(vpcv1.SnapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshots) + snapshotConsistencyGroupPrototypeModel.DeleteSnapshotsOnDelete = core.BoolPtr(true) + snapshotConsistencyGroupPrototypeModel.Name = core.StringPtr("my-snapshot-consistency-group") + snapshotConsistencyGroupPrototypeModel.ResourceGroup = resourceGroupIdentityModel + snapshotConsistencyGroupPrototypeModel.Snapshots = []vpcv1.SnapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshotsSnapshotsItem{*snapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshotsSnapshotsItemModel} + + // Construct an instance of the CreateSnapshotConsistencyGroupOptions model + createSnapshotConsistencyGroupOptionsModel := new(vpcv1.CreateSnapshotConsistencyGroupOptions) + createSnapshotConsistencyGroupOptionsModel.SnapshotConsistencyGroupPrototype = snapshotConsistencyGroupPrototypeModel + createSnapshotConsistencyGroupOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with valid options model (positive test) - result, response, operationErr = vpcService.CreateSnapshot(createSnapshotOptionsModel) + result, response, operationErr = vpcService.CreateSnapshotConsistencyGroup(createSnapshotConsistencyGroupOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) }) - It(`Invoke CreateSnapshot with error: Operation validation and request error`, func() { + It(`Invoke CreateSnapshotConsistencyGroup with error: Operation validation and request error`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -51683,14 +51485,6 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the ZoneIdentityByName model - zoneIdentityModel := new(vpcv1.ZoneIdentityByName) - zoneIdentityModel.Name = core.StringPtr("us-south-1") - - // Construct an instance of the SnapshotClonePrototype model - snapshotClonePrototypeModel := new(vpcv1.SnapshotClonePrototype) - snapshotClonePrototypeModel.Zone = zoneIdentityModel - // Construct an instance of the ResourceGroupIdentityByID model resourceGroupIdentityModel := new(vpcv1.ResourceGroupIdentityByID) resourceGroupIdentityModel.ID = core.StringPtr("fee82deba12e4c0fb69c3b09d1f12345") @@ -51699,30 +51493,35 @@ var _ = Describe(`VpcV1`, func() { volumeIdentityModel := new(vpcv1.VolumeIdentityByID) volumeIdentityModel.ID = core.StringPtr("1a6b7274-678d-4dfb-8981-c71dd9d4daa5") - // Construct an instance of the SnapshotPrototypeSnapshotBySourceVolume model - snapshotPrototypeModel := new(vpcv1.SnapshotPrototypeSnapshotBySourceVolume) - snapshotPrototypeModel.Clones = []vpcv1.SnapshotClonePrototype{*snapshotClonePrototypeModel} - snapshotPrototypeModel.Name = core.StringPtr("my-snapshot") - snapshotPrototypeModel.ResourceGroup = resourceGroupIdentityModel - snapshotPrototypeModel.UserTags = []string{} - snapshotPrototypeModel.SourceVolume = volumeIdentityModel - - // Construct an instance of the CreateSnapshotOptions model - createSnapshotOptionsModel := new(vpcv1.CreateSnapshotOptions) - createSnapshotOptionsModel.SnapshotPrototype = snapshotPrototypeModel - createSnapshotOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the SnapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshotsSnapshotsItem model + snapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshotsSnapshotsItemModel := new(vpcv1.SnapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshotsSnapshotsItem) + snapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshotsSnapshotsItemModel.Name = core.StringPtr("my-snapshot") + snapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshotsSnapshotsItemModel.SourceVolume = volumeIdentityModel + snapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshotsSnapshotsItemModel.UserTags = []string{"testString"} + + // Construct an instance of the SnapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshots model + snapshotConsistencyGroupPrototypeModel := new(vpcv1.SnapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshots) + snapshotConsistencyGroupPrototypeModel.DeleteSnapshotsOnDelete = core.BoolPtr(true) + snapshotConsistencyGroupPrototypeModel.Name = core.StringPtr("my-snapshot-consistency-group") + snapshotConsistencyGroupPrototypeModel.ResourceGroup = resourceGroupIdentityModel + snapshotConsistencyGroupPrototypeModel.Snapshots = []vpcv1.SnapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshotsSnapshotsItem{*snapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshotsSnapshotsItemModel} + + // Construct an instance of the CreateSnapshotConsistencyGroupOptions model + createSnapshotConsistencyGroupOptionsModel := new(vpcv1.CreateSnapshotConsistencyGroupOptions) + createSnapshotConsistencyGroupOptionsModel.SnapshotConsistencyGroupPrototype = snapshotConsistencyGroupPrototypeModel + createSnapshotConsistencyGroupOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with empty URL (negative test) err := vpcService.SetServiceURL("") Expect(err).To(BeNil()) - result, response, operationErr := vpcService.CreateSnapshot(createSnapshotOptionsModel) + result, response, operationErr := vpcService.CreateSnapshotConsistencyGroup(createSnapshotConsistencyGroupOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING)) Expect(response).To(BeNil()) Expect(result).To(BeNil()) - // Construct a second instance of the CreateSnapshotOptions model with no property values - createSnapshotOptionsModelNew := new(vpcv1.CreateSnapshotOptions) + // Construct a second instance of the CreateSnapshotConsistencyGroupOptions model with no property values + createSnapshotConsistencyGroupOptionsModelNew := new(vpcv1.CreateSnapshotConsistencyGroupOptions) // Invoke operation with invalid model (negative test) - result, response, operationErr = vpcService.CreateSnapshot(createSnapshotOptionsModelNew) + result, response, operationErr = vpcService.CreateSnapshotConsistencyGroup(createSnapshotConsistencyGroupOptionsModelNew) Expect(operationErr).ToNot(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) @@ -51740,7 +51539,7 @@ var _ = Describe(`VpcV1`, func() { res.WriteHeader(201) })) }) - It(`Invoke CreateSnapshot successfully`, func() { + It(`Invoke CreateSnapshotConsistencyGroup successfully`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -51749,14 +51548,6 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the ZoneIdentityByName model - zoneIdentityModel := new(vpcv1.ZoneIdentityByName) - zoneIdentityModel.Name = core.StringPtr("us-south-1") - - // Construct an instance of the SnapshotClonePrototype model - snapshotClonePrototypeModel := new(vpcv1.SnapshotClonePrototype) - snapshotClonePrototypeModel.Zone = zoneIdentityModel - // Construct an instance of the ResourceGroupIdentityByID model resourceGroupIdentityModel := new(vpcv1.ResourceGroupIdentityByID) resourceGroupIdentityModel.ID = core.StringPtr("fee82deba12e4c0fb69c3b09d1f12345") @@ -51765,21 +51556,26 @@ var _ = Describe(`VpcV1`, func() { volumeIdentityModel := new(vpcv1.VolumeIdentityByID) volumeIdentityModel.ID = core.StringPtr("1a6b7274-678d-4dfb-8981-c71dd9d4daa5") - // Construct an instance of the SnapshotPrototypeSnapshotBySourceVolume model - snapshotPrototypeModel := new(vpcv1.SnapshotPrototypeSnapshotBySourceVolume) - snapshotPrototypeModel.Clones = []vpcv1.SnapshotClonePrototype{*snapshotClonePrototypeModel} - snapshotPrototypeModel.Name = core.StringPtr("my-snapshot") - snapshotPrototypeModel.ResourceGroup = resourceGroupIdentityModel - snapshotPrototypeModel.UserTags = []string{} - snapshotPrototypeModel.SourceVolume = volumeIdentityModel + // Construct an instance of the SnapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshotsSnapshotsItem model + snapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshotsSnapshotsItemModel := new(vpcv1.SnapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshotsSnapshotsItem) + snapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshotsSnapshotsItemModel.Name = core.StringPtr("my-snapshot") + snapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshotsSnapshotsItemModel.SourceVolume = volumeIdentityModel + snapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshotsSnapshotsItemModel.UserTags = []string{"testString"} - // Construct an instance of the CreateSnapshotOptions model - createSnapshotOptionsModel := new(vpcv1.CreateSnapshotOptions) - createSnapshotOptionsModel.SnapshotPrototype = snapshotPrototypeModel - createSnapshotOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the SnapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshots model + snapshotConsistencyGroupPrototypeModel := new(vpcv1.SnapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshots) + snapshotConsistencyGroupPrototypeModel.DeleteSnapshotsOnDelete = core.BoolPtr(true) + snapshotConsistencyGroupPrototypeModel.Name = core.StringPtr("my-snapshot-consistency-group") + snapshotConsistencyGroupPrototypeModel.ResourceGroup = resourceGroupIdentityModel + snapshotConsistencyGroupPrototypeModel.Snapshots = []vpcv1.SnapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshotsSnapshotsItem{*snapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshotsSnapshotsItemModel} + + // Construct an instance of the CreateSnapshotConsistencyGroupOptions model + createSnapshotConsistencyGroupOptionsModel := new(vpcv1.CreateSnapshotConsistencyGroupOptions) + createSnapshotConsistencyGroupOptionsModel.SnapshotConsistencyGroupPrototype = snapshotConsistencyGroupPrototypeModel + createSnapshotConsistencyGroupOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation - result, response, operationErr := vpcService.CreateSnapshot(createSnapshotOptionsModel) + result, response, operationErr := vpcService.CreateSnapshotConsistencyGroup(createSnapshotConsistencyGroupOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) @@ -51791,26 +51587,136 @@ var _ = Describe(`VpcV1`, func() { }) }) }) - Describe(`DeleteSnapshot(deleteSnapshotOptions *DeleteSnapshotOptions)`, func() { + Describe(`DeleteSnapshotConsistencyGroup(deleteSnapshotConsistencyGroupOptions *DeleteSnapshotConsistencyGroupOptions) - Operation response error`, func() { version := "testString" - deleteSnapshotPath := "/snapshots/testString" + deleteSnapshotConsistencyGroupPath := "/snapshot_consistency_groups/testString" + Context(`Using mock server endpoint with invalid JSON response`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Verify the contents of the request + Expect(req.URL.EscapedPath()).To(Equal(deleteSnapshotConsistencyGroupPath)) + Expect(req.Method).To(Equal("DELETE")) + Expect(req.URL.Query()["version"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["generation"]).To(Equal([]string{fmt.Sprint(int64(2))})) + res.Header().Set("Content-type", "application/json") + res.WriteHeader(202) + fmt.Fprint(res, `} this is not valid json {`) + })) + }) + It(`Invoke DeleteSnapshotConsistencyGroup with error: Operation response processing error`, func() { + vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + Version: core.StringPtr(version), + }) + Expect(serviceErr).To(BeNil()) + Expect(vpcService).ToNot(BeNil()) + + // Construct an instance of the DeleteSnapshotConsistencyGroupOptions model + deleteSnapshotConsistencyGroupOptionsModel := new(vpcv1.DeleteSnapshotConsistencyGroupOptions) + deleteSnapshotConsistencyGroupOptionsModel.ID = core.StringPtr("testString") + deleteSnapshotConsistencyGroupOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Expect response parsing to fail since we are receiving a text/plain response + result, response, operationErr := vpcService.DeleteSnapshotConsistencyGroup(deleteSnapshotConsistencyGroupOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).To(BeNil()) + + // Enable retries and test again + vpcService.EnableRetries(0, 0) + result, response, operationErr = vpcService.DeleteSnapshotConsistencyGroup(deleteSnapshotConsistencyGroupOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + }) + Describe(`DeleteSnapshotConsistencyGroup(deleteSnapshotConsistencyGroupOptions *DeleteSnapshotConsistencyGroupOptions)`, func() { + version := "testString" + deleteSnapshotConsistencyGroupPath := "/snapshot_consistency_groups/testString" + Context(`Using mock server endpoint with timeout`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Verify the contents of the request + Expect(req.URL.EscapedPath()).To(Equal(deleteSnapshotConsistencyGroupPath)) + Expect(req.Method).To(Equal("DELETE")) + + Expect(req.URL.Query()["version"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["generation"]).To(Equal([]string{fmt.Sprint(int64(2))})) + // Sleep a short time to support a timeout test + time.Sleep(100 * time.Millisecond) + + // Set mock response + res.Header().Set("Content-type", "application/json") + res.WriteHeader(202) + fmt.Fprintf(res, "%s", `{"backup_policy_plan": {"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6/plans/r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "id": "r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "name": "my-policy-plan", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "backup_policy_plan"}, "created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot-consistency-group:r134-fa329f6b-0e36-433f-a3bb-0df632e79263", "delete_snapshots_on_delete": false, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshot_consistency_groups/r134-fa329f6b-0e36-433f-a3bb-0df632e79263", "id": "r134-fa329f6b-0e36-433f-a3bb-0df632e79263", "lifecycle_state": "stable", "name": "my-snapshot-consistency-group", "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "resource_type": "snapshot_consistency_group", "service_tags": ["ServiceTags"], "snapshots": [{"crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "id": "r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "name": "my-snapshot", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "snapshot"}]}`) + })) + }) + It(`Invoke DeleteSnapshotConsistencyGroup successfully with retries`, func() { + vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + Version: core.StringPtr(version), + }) + Expect(serviceErr).To(BeNil()) + Expect(vpcService).ToNot(BeNil()) + vpcService.EnableRetries(0, 0) + + // Construct an instance of the DeleteSnapshotConsistencyGroupOptions model + deleteSnapshotConsistencyGroupOptionsModel := new(vpcv1.DeleteSnapshotConsistencyGroupOptions) + deleteSnapshotConsistencyGroupOptionsModel.ID = core.StringPtr("testString") + deleteSnapshotConsistencyGroupOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation with a Context to test a timeout error + ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond) + defer cancelFunc() + _, _, operationErr := vpcService.DeleteSnapshotConsistencyGroupWithContext(ctx, deleteSnapshotConsistencyGroupOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) + + // Disable retries and test again + vpcService.DisableRetries() + result, response, operationErr := vpcService.DeleteSnapshotConsistencyGroup(deleteSnapshotConsistencyGroupOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).ToNot(BeNil()) + + // Re-test the timeout error with retries disabled + ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond) + defer cancelFunc2() + _, _, operationErr = vpcService.DeleteSnapshotConsistencyGroupWithContext(ctx, deleteSnapshotConsistencyGroupOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) + }) + AfterEach(func() { + testServer.Close() + }) + }) Context(`Using mock server endpoint`, func() { BeforeEach(func() { testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(deleteSnapshotPath)) + Expect(req.URL.EscapedPath()).To(Equal(deleteSnapshotConsistencyGroupPath)) Expect(req.Method).To(Equal("DELETE")) - Expect(req.Header["If-Match"]).ToNot(BeNil()) - Expect(req.Header["If-Match"][0]).To(Equal(fmt.Sprintf("%v", `W/"96d225c4-56bd-43d9-98fc-d7148e5c5028"`))) Expect(req.URL.Query()["version"]).To(Equal([]string{"testString"})) Expect(req.URL.Query()["generation"]).To(Equal([]string{fmt.Sprint(int64(2))})) - res.WriteHeader(204) + // Set mock response + res.Header().Set("Content-type", "application/json") + res.WriteHeader(202) + fmt.Fprintf(res, "%s", `{"backup_policy_plan": {"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6/plans/r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "id": "r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "name": "my-policy-plan", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "backup_policy_plan"}, "created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot-consistency-group:r134-fa329f6b-0e36-433f-a3bb-0df632e79263", "delete_snapshots_on_delete": false, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshot_consistency_groups/r134-fa329f6b-0e36-433f-a3bb-0df632e79263", "id": "r134-fa329f6b-0e36-433f-a3bb-0df632e79263", "lifecycle_state": "stable", "name": "my-snapshot-consistency-group", "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "resource_type": "snapshot_consistency_group", "service_tags": ["ServiceTags"], "snapshots": [{"crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "id": "r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "name": "my-snapshot", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "snapshot"}]}`) })) }) - It(`Invoke DeleteSnapshot successfully`, func() { + It(`Invoke DeleteSnapshotConsistencyGroup successfully`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -51820,22 +51726,24 @@ var _ = Describe(`VpcV1`, func() { Expect(vpcService).ToNot(BeNil()) // Invoke operation with nil options model (negative test) - response, operationErr := vpcService.DeleteSnapshot(nil) + result, response, operationErr := vpcService.DeleteSnapshotConsistencyGroup(nil) Expect(operationErr).NotTo(BeNil()) Expect(response).To(BeNil()) + Expect(result).To(BeNil()) - // Construct an instance of the DeleteSnapshotOptions model - deleteSnapshotOptionsModel := new(vpcv1.DeleteSnapshotOptions) - deleteSnapshotOptionsModel.ID = core.StringPtr("testString") - deleteSnapshotOptionsModel.IfMatch = core.StringPtr(`W/"96d225c4-56bd-43d9-98fc-d7148e5c5028"`) - deleteSnapshotOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the DeleteSnapshotConsistencyGroupOptions model + deleteSnapshotConsistencyGroupOptionsModel := new(vpcv1.DeleteSnapshotConsistencyGroupOptions) + deleteSnapshotConsistencyGroupOptionsModel.ID = core.StringPtr("testString") + deleteSnapshotConsistencyGroupOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with valid options model (positive test) - response, operationErr = vpcService.DeleteSnapshot(deleteSnapshotOptionsModel) + result, response, operationErr = vpcService.DeleteSnapshotConsistencyGroup(deleteSnapshotConsistencyGroupOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) + Expect(result).ToNot(BeNil()) + }) - It(`Invoke DeleteSnapshot with error: Operation validation and request error`, func() { + It(`Invoke DeleteSnapshotConsistencyGroup with error: Operation validation and request error`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -51844,40 +51752,76 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the DeleteSnapshotOptions model - deleteSnapshotOptionsModel := new(vpcv1.DeleteSnapshotOptions) - deleteSnapshotOptionsModel.ID = core.StringPtr("testString") - deleteSnapshotOptionsModel.IfMatch = core.StringPtr(`W/"96d225c4-56bd-43d9-98fc-d7148e5c5028"`) - deleteSnapshotOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the DeleteSnapshotConsistencyGroupOptions model + deleteSnapshotConsistencyGroupOptionsModel := new(vpcv1.DeleteSnapshotConsistencyGroupOptions) + deleteSnapshotConsistencyGroupOptionsModel.ID = core.StringPtr("testString") + deleteSnapshotConsistencyGroupOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with empty URL (negative test) err := vpcService.SetServiceURL("") Expect(err).To(BeNil()) - response, operationErr := vpcService.DeleteSnapshot(deleteSnapshotOptionsModel) + result, response, operationErr := vpcService.DeleteSnapshotConsistencyGroup(deleteSnapshotConsistencyGroupOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING)) Expect(response).To(BeNil()) - // Construct a second instance of the DeleteSnapshotOptions model with no property values - deleteSnapshotOptionsModelNew := new(vpcv1.DeleteSnapshotOptions) + Expect(result).To(BeNil()) + // Construct a second instance of the DeleteSnapshotConsistencyGroupOptions model with no property values + deleteSnapshotConsistencyGroupOptionsModelNew := new(vpcv1.DeleteSnapshotConsistencyGroupOptions) // Invoke operation with invalid model (negative test) - response, operationErr = vpcService.DeleteSnapshot(deleteSnapshotOptionsModelNew) + result, response, operationErr = vpcService.DeleteSnapshotConsistencyGroup(deleteSnapshotConsistencyGroupOptionsModelNew) Expect(operationErr).ToNot(BeNil()) Expect(response).To(BeNil()) + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + Context(`Using mock server endpoint with missing response body`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Set success status code with no respoonse body + res.WriteHeader(202) + })) + }) + It(`Invoke DeleteSnapshotConsistencyGroup successfully`, func() { + vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + Version: core.StringPtr(version), + }) + Expect(serviceErr).To(BeNil()) + Expect(vpcService).ToNot(BeNil()) + + // Construct an instance of the DeleteSnapshotConsistencyGroupOptions model + deleteSnapshotConsistencyGroupOptionsModel := new(vpcv1.DeleteSnapshotConsistencyGroupOptions) + deleteSnapshotConsistencyGroupOptionsModel.ID = core.StringPtr("testString") + deleteSnapshotConsistencyGroupOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation + result, response, operationErr := vpcService.DeleteSnapshotConsistencyGroup(deleteSnapshotConsistencyGroupOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + + // Verify a nil result + Expect(result).To(BeNil()) }) AfterEach(func() { testServer.Close() }) }) }) - Describe(`GetSnapshot(getSnapshotOptions *GetSnapshotOptions) - Operation response error`, func() { + Describe(`GetSnapshotConsistencyGroup(getSnapshotConsistencyGroupOptions *GetSnapshotConsistencyGroupOptions) - Operation response error`, func() { version := "testString" - getSnapshotPath := "/snapshots/testString" + getSnapshotConsistencyGroupPath := "/snapshot_consistency_groups/testString" Context(`Using mock server endpoint with invalid JSON response`, func() { BeforeEach(func() { testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(getSnapshotPath)) + Expect(req.URL.EscapedPath()).To(Equal(getSnapshotConsistencyGroupPath)) Expect(req.Method).To(Equal("GET")) Expect(req.URL.Query()["version"]).To(Equal([]string{"testString"})) Expect(req.URL.Query()["generation"]).To(Equal([]string{fmt.Sprint(int64(2))})) @@ -51886,7 +51830,7 @@ var _ = Describe(`VpcV1`, func() { fmt.Fprint(res, `} this is not valid json {`) })) }) - It(`Invoke GetSnapshot with error: Operation response processing error`, func() { + It(`Invoke GetSnapshotConsistencyGroup with error: Operation response processing error`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -51895,19 +51839,19 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the GetSnapshotOptions model - getSnapshotOptionsModel := new(vpcv1.GetSnapshotOptions) - getSnapshotOptionsModel.ID = core.StringPtr("testString") - getSnapshotOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the GetSnapshotConsistencyGroupOptions model + getSnapshotConsistencyGroupOptionsModel := new(vpcv1.GetSnapshotConsistencyGroupOptions) + getSnapshotConsistencyGroupOptionsModel.ID = core.StringPtr("testString") + getSnapshotConsistencyGroupOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Expect response parsing to fail since we are receiving a text/plain response - result, response, operationErr := vpcService.GetSnapshot(getSnapshotOptionsModel) + result, response, operationErr := vpcService.GetSnapshotConsistencyGroup(getSnapshotConsistencyGroupOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).To(BeNil()) // Enable retries and test again vpcService.EnableRetries(0, 0) - result, response, operationErr = vpcService.GetSnapshot(getSnapshotOptionsModel) + result, response, operationErr = vpcService.GetSnapshotConsistencyGroup(getSnapshotConsistencyGroupOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).To(BeNil()) @@ -51917,16 +51861,16 @@ var _ = Describe(`VpcV1`, func() { }) }) }) - Describe(`GetSnapshot(getSnapshotOptions *GetSnapshotOptions)`, func() { + Describe(`GetSnapshotConsistencyGroup(getSnapshotConsistencyGroupOptions *GetSnapshotConsistencyGroupOptions)`, func() { version := "testString" - getSnapshotPath := "/snapshots/testString" + getSnapshotConsistencyGroupPath := "/snapshot_consistency_groups/testString" Context(`Using mock server endpoint with timeout`, func() { BeforeEach(func() { testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(getSnapshotPath)) + Expect(req.URL.EscapedPath()).To(Equal(getSnapshotConsistencyGroupPath)) Expect(req.Method).To(Equal("GET")) Expect(req.URL.Query()["version"]).To(Equal([]string{"testString"})) @@ -51937,10 +51881,10 @@ var _ = Describe(`VpcV1`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"backup_policy_plan": {"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6/plans/r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "id": "r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "name": "my-policy-plan", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "backup_policy_plan"}, "bootable": true, "captured_at": "2019-01-01T12:00:00.000Z", "clones": [{"available": false, "created_at": "2019-01-01T12:00:00.000Z", "zone": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south/zones/us-south-1", "name": "us-south-1"}}], "copies": [{"crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "id": "r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "name": "my-snapshot", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "snapshot"}], "created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "deletable": false, "encryption": "provider_managed", "encryption_key": {"crn": "crn:v1:bluemix:public:kms:us-south:a/123456:e4a29d1a-2ef0-42a6-8fd2-350deb1c647e:key:5437653b-c4b1-447f-9646-b2a2a4cd6179"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "id": "r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "lifecycle_state": "stable", "minimum_capacity": 1, "name": "my-snapshot", "operating_system": {"architecture": "amd64", "dedicated_host_only": false, "display_name": "Ubuntu Server 16.04 LTS amd64", "family": "Ubuntu Server", "href": "https://us-south.iaas.cloud.ibm.com/v1/operating_systems/ubuntu-16-amd64", "name": "ubuntu-16-amd64", "vendor": "Canonical", "version": "16.04 LTS"}, "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "resource_type": "snapshot", "service_tags": ["ServiceTags"], "size": 1, "source_image": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::image:72b27b5c-f4b0-48bb-b954-5becc7c1dcb8", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/images/72b27b5c-f4b0-48bb-b954-5becc7c1dcb8", "id": "72b27b5c-f4b0-48bb-b954-5becc7c1dcb8", "name": "my-image", "remote": {"account": {"id": "aa2432b1fa4d4ace891e9b80fc104e34", "resource_type": "account"}, "region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "image"}, "source_snapshot": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "id": "r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "name": "my-snapshot", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "snapshot"}, "source_volume": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::volume:1a6b7274-678d-4dfb-8981-c71dd9d4daa5", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/volumes/1a6b7274-678d-4dfb-8981-c71dd9d4daa5", "id": "1a6b7274-678d-4dfb-8981-c71dd9d4daa5", "name": "my-volume", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "volume"}, "user_tags": ["UserTags"]}`) + fmt.Fprintf(res, "%s", `{"backup_policy_plan": {"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6/plans/r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "id": "r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "name": "my-policy-plan", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "backup_policy_plan"}, "created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot-consistency-group:r134-fa329f6b-0e36-433f-a3bb-0df632e79263", "delete_snapshots_on_delete": false, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshot_consistency_groups/r134-fa329f6b-0e36-433f-a3bb-0df632e79263", "id": "r134-fa329f6b-0e36-433f-a3bb-0df632e79263", "lifecycle_state": "stable", "name": "my-snapshot-consistency-group", "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "resource_type": "snapshot_consistency_group", "service_tags": ["ServiceTags"], "snapshots": [{"crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "id": "r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "name": "my-snapshot", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "snapshot"}]}`) })) }) - It(`Invoke GetSnapshot successfully with retries`, func() { + It(`Invoke GetSnapshotConsistencyGroup successfully with retries`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -51950,21 +51894,21 @@ var _ = Describe(`VpcV1`, func() { Expect(vpcService).ToNot(BeNil()) vpcService.EnableRetries(0, 0) - // Construct an instance of the GetSnapshotOptions model - getSnapshotOptionsModel := new(vpcv1.GetSnapshotOptions) - getSnapshotOptionsModel.ID = core.StringPtr("testString") - getSnapshotOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the GetSnapshotConsistencyGroupOptions model + getSnapshotConsistencyGroupOptionsModel := new(vpcv1.GetSnapshotConsistencyGroupOptions) + getSnapshotConsistencyGroupOptionsModel.ID = core.StringPtr("testString") + getSnapshotConsistencyGroupOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with a Context to test a timeout error ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond) defer cancelFunc() - _, _, operationErr := vpcService.GetSnapshotWithContext(ctx, getSnapshotOptionsModel) + _, _, operationErr := vpcService.GetSnapshotConsistencyGroupWithContext(ctx, getSnapshotConsistencyGroupOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) // Disable retries and test again vpcService.DisableRetries() - result, response, operationErr := vpcService.GetSnapshot(getSnapshotOptionsModel) + result, response, operationErr := vpcService.GetSnapshotConsistencyGroup(getSnapshotConsistencyGroupOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) @@ -51972,7 +51916,7 @@ var _ = Describe(`VpcV1`, func() { // Re-test the timeout error with retries disabled ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond) defer cancelFunc2() - _, _, operationErr = vpcService.GetSnapshotWithContext(ctx, getSnapshotOptionsModel) + _, _, operationErr = vpcService.GetSnapshotConsistencyGroupWithContext(ctx, getSnapshotConsistencyGroupOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) }) @@ -51986,7 +51930,7 @@ var _ = Describe(`VpcV1`, func() { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(getSnapshotPath)) + Expect(req.URL.EscapedPath()).To(Equal(getSnapshotConsistencyGroupPath)) Expect(req.Method).To(Equal("GET")) Expect(req.URL.Query()["version"]).To(Equal([]string{"testString"})) @@ -51994,10 +51938,10 @@ var _ = Describe(`VpcV1`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"backup_policy_plan": {"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6/plans/r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "id": "r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "name": "my-policy-plan", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "backup_policy_plan"}, "bootable": true, "captured_at": "2019-01-01T12:00:00.000Z", "clones": [{"available": false, "created_at": "2019-01-01T12:00:00.000Z", "zone": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south/zones/us-south-1", "name": "us-south-1"}}], "copies": [{"crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "id": "r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "name": "my-snapshot", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "snapshot"}], "created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "deletable": false, "encryption": "provider_managed", "encryption_key": {"crn": "crn:v1:bluemix:public:kms:us-south:a/123456:e4a29d1a-2ef0-42a6-8fd2-350deb1c647e:key:5437653b-c4b1-447f-9646-b2a2a4cd6179"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "id": "r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "lifecycle_state": "stable", "minimum_capacity": 1, "name": "my-snapshot", "operating_system": {"architecture": "amd64", "dedicated_host_only": false, "display_name": "Ubuntu Server 16.04 LTS amd64", "family": "Ubuntu Server", "href": "https://us-south.iaas.cloud.ibm.com/v1/operating_systems/ubuntu-16-amd64", "name": "ubuntu-16-amd64", "vendor": "Canonical", "version": "16.04 LTS"}, "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "resource_type": "snapshot", "service_tags": ["ServiceTags"], "size": 1, "source_image": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::image:72b27b5c-f4b0-48bb-b954-5becc7c1dcb8", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/images/72b27b5c-f4b0-48bb-b954-5becc7c1dcb8", "id": "72b27b5c-f4b0-48bb-b954-5becc7c1dcb8", "name": "my-image", "remote": {"account": {"id": "aa2432b1fa4d4ace891e9b80fc104e34", "resource_type": "account"}, "region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "image"}, "source_snapshot": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "id": "r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "name": "my-snapshot", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "snapshot"}, "source_volume": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::volume:1a6b7274-678d-4dfb-8981-c71dd9d4daa5", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/volumes/1a6b7274-678d-4dfb-8981-c71dd9d4daa5", "id": "1a6b7274-678d-4dfb-8981-c71dd9d4daa5", "name": "my-volume", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "volume"}, "user_tags": ["UserTags"]}`) + fmt.Fprintf(res, "%s", `{"backup_policy_plan": {"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6/plans/r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "id": "r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "name": "my-policy-plan", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "backup_policy_plan"}, "created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot-consistency-group:r134-fa329f6b-0e36-433f-a3bb-0df632e79263", "delete_snapshots_on_delete": false, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshot_consistency_groups/r134-fa329f6b-0e36-433f-a3bb-0df632e79263", "id": "r134-fa329f6b-0e36-433f-a3bb-0df632e79263", "lifecycle_state": "stable", "name": "my-snapshot-consistency-group", "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "resource_type": "snapshot_consistency_group", "service_tags": ["ServiceTags"], "snapshots": [{"crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "id": "r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "name": "my-snapshot", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "snapshot"}]}`) })) }) - It(`Invoke GetSnapshot successfully`, func() { + It(`Invoke GetSnapshotConsistencyGroup successfully`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -52007,24 +51951,24 @@ var _ = Describe(`VpcV1`, func() { Expect(vpcService).ToNot(BeNil()) // Invoke operation with nil options model (negative test) - result, response, operationErr := vpcService.GetSnapshot(nil) + result, response, operationErr := vpcService.GetSnapshotConsistencyGroup(nil) Expect(operationErr).NotTo(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) - // Construct an instance of the GetSnapshotOptions model - getSnapshotOptionsModel := new(vpcv1.GetSnapshotOptions) - getSnapshotOptionsModel.ID = core.StringPtr("testString") - getSnapshotOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the GetSnapshotConsistencyGroupOptions model + getSnapshotConsistencyGroupOptionsModel := new(vpcv1.GetSnapshotConsistencyGroupOptions) + getSnapshotConsistencyGroupOptionsModel.ID = core.StringPtr("testString") + getSnapshotConsistencyGroupOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with valid options model (positive test) - result, response, operationErr = vpcService.GetSnapshot(getSnapshotOptionsModel) + result, response, operationErr = vpcService.GetSnapshotConsistencyGroup(getSnapshotConsistencyGroupOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) }) - It(`Invoke GetSnapshot with error: Operation validation and request error`, func() { + It(`Invoke GetSnapshotConsistencyGroup with error: Operation validation and request error`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -52033,22 +51977,22 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the GetSnapshotOptions model - getSnapshotOptionsModel := new(vpcv1.GetSnapshotOptions) - getSnapshotOptionsModel.ID = core.StringPtr("testString") - getSnapshotOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the GetSnapshotConsistencyGroupOptions model + getSnapshotConsistencyGroupOptionsModel := new(vpcv1.GetSnapshotConsistencyGroupOptions) + getSnapshotConsistencyGroupOptionsModel.ID = core.StringPtr("testString") + getSnapshotConsistencyGroupOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with empty URL (negative test) err := vpcService.SetServiceURL("") Expect(err).To(BeNil()) - result, response, operationErr := vpcService.GetSnapshot(getSnapshotOptionsModel) + result, response, operationErr := vpcService.GetSnapshotConsistencyGroup(getSnapshotConsistencyGroupOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING)) Expect(response).To(BeNil()) Expect(result).To(BeNil()) - // Construct a second instance of the GetSnapshotOptions model with no property values - getSnapshotOptionsModelNew := new(vpcv1.GetSnapshotOptions) + // Construct a second instance of the GetSnapshotConsistencyGroupOptions model with no property values + getSnapshotConsistencyGroupOptionsModelNew := new(vpcv1.GetSnapshotConsistencyGroupOptions) // Invoke operation with invalid model (negative test) - result, response, operationErr = vpcService.GetSnapshot(getSnapshotOptionsModelNew) + result, response, operationErr = vpcService.GetSnapshotConsistencyGroup(getSnapshotConsistencyGroupOptionsModelNew) Expect(operationErr).ToNot(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) @@ -52066,7 +52010,7 @@ var _ = Describe(`VpcV1`, func() { res.WriteHeader(200) })) }) - It(`Invoke GetSnapshot successfully`, func() { + It(`Invoke GetSnapshotConsistencyGroup successfully`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -52075,13 +52019,13 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the GetSnapshotOptions model - getSnapshotOptionsModel := new(vpcv1.GetSnapshotOptions) - getSnapshotOptionsModel.ID = core.StringPtr("testString") - getSnapshotOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the GetSnapshotConsistencyGroupOptions model + getSnapshotConsistencyGroupOptionsModel := new(vpcv1.GetSnapshotConsistencyGroupOptions) + getSnapshotConsistencyGroupOptionsModel.ID = core.StringPtr("testString") + getSnapshotConsistencyGroupOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation - result, response, operationErr := vpcService.GetSnapshot(getSnapshotOptionsModel) + result, response, operationErr := vpcService.GetSnapshotConsistencyGroup(getSnapshotConsistencyGroupOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) @@ -52093,16 +52037,16 @@ var _ = Describe(`VpcV1`, func() { }) }) }) - Describe(`UpdateSnapshot(updateSnapshotOptions *UpdateSnapshotOptions) - Operation response error`, func() { + Describe(`UpdateSnapshotConsistencyGroup(updateSnapshotConsistencyGroupOptions *UpdateSnapshotConsistencyGroupOptions) - Operation response error`, func() { version := "testString" - updateSnapshotPath := "/snapshots/testString" + updateSnapshotConsistencyGroupPath := "/snapshot_consistency_groups/testString" Context(`Using mock server endpoint with invalid JSON response`, func() { BeforeEach(func() { testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(updateSnapshotPath)) + Expect(req.URL.EscapedPath()).To(Equal(updateSnapshotConsistencyGroupPath)) Expect(req.Method).To(Equal("PATCH")) Expect(req.Header["If-Match"]).ToNot(BeNil()) Expect(req.Header["If-Match"][0]).To(Equal(fmt.Sprintf("%v", `W/"96d225c4-56bd-43d9-98fc-d7148e5c5028"`))) @@ -52113,7 +52057,7 @@ var _ = Describe(`VpcV1`, func() { fmt.Fprint(res, `} this is not valid json {`) })) }) - It(`Invoke UpdateSnapshot with error: Operation response processing error`, func() { + It(`Invoke UpdateSnapshotConsistencyGroup with error: Operation response processing error`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -52122,28 +52066,28 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the SnapshotPatch model - snapshotPatchModel := new(vpcv1.SnapshotPatch) - snapshotPatchModel.Name = core.StringPtr("my-snapshot") - snapshotPatchModel.UserTags = []string{"testString"} - snapshotPatchModelAsPatch, asPatchErr := snapshotPatchModel.AsPatch() + // Construct an instance of the SnapshotConsistencyGroupPatch model + snapshotConsistencyGroupPatchModel := new(vpcv1.SnapshotConsistencyGroupPatch) + snapshotConsistencyGroupPatchModel.DeleteSnapshotsOnDelete = core.BoolPtr(true) + snapshotConsistencyGroupPatchModel.Name = core.StringPtr("my-snapshot-consistency-group") + snapshotConsistencyGroupPatchModelAsPatch, asPatchErr := snapshotConsistencyGroupPatchModel.AsPatch() Expect(asPatchErr).To(BeNil()) - // Construct an instance of the UpdateSnapshotOptions model - updateSnapshotOptionsModel := new(vpcv1.UpdateSnapshotOptions) - updateSnapshotOptionsModel.ID = core.StringPtr("testString") - updateSnapshotOptionsModel.SnapshotPatch = snapshotPatchModelAsPatch - updateSnapshotOptionsModel.IfMatch = core.StringPtr(`W/"96d225c4-56bd-43d9-98fc-d7148e5c5028"`) - updateSnapshotOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the UpdateSnapshotConsistencyGroupOptions model + updateSnapshotConsistencyGroupOptionsModel := new(vpcv1.UpdateSnapshotConsistencyGroupOptions) + updateSnapshotConsistencyGroupOptionsModel.ID = core.StringPtr("testString") + updateSnapshotConsistencyGroupOptionsModel.SnapshotConsistencyGroupPatch = snapshotConsistencyGroupPatchModelAsPatch + updateSnapshotConsistencyGroupOptionsModel.IfMatch = core.StringPtr(`W/"96d225c4-56bd-43d9-98fc-d7148e5c5028"`) + updateSnapshotConsistencyGroupOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Expect response parsing to fail since we are receiving a text/plain response - result, response, operationErr := vpcService.UpdateSnapshot(updateSnapshotOptionsModel) + result, response, operationErr := vpcService.UpdateSnapshotConsistencyGroup(updateSnapshotConsistencyGroupOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).To(BeNil()) // Enable retries and test again vpcService.EnableRetries(0, 0) - result, response, operationErr = vpcService.UpdateSnapshot(updateSnapshotOptionsModel) + result, response, operationErr = vpcService.UpdateSnapshotConsistencyGroup(updateSnapshotConsistencyGroupOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).To(BeNil()) @@ -52153,16 +52097,16 @@ var _ = Describe(`VpcV1`, func() { }) }) }) - Describe(`UpdateSnapshot(updateSnapshotOptions *UpdateSnapshotOptions)`, func() { + Describe(`UpdateSnapshotConsistencyGroup(updateSnapshotConsistencyGroupOptions *UpdateSnapshotConsistencyGroupOptions)`, func() { version := "testString" - updateSnapshotPath := "/snapshots/testString" + updateSnapshotConsistencyGroupPath := "/snapshot_consistency_groups/testString" Context(`Using mock server endpoint with timeout`, func() { BeforeEach(func() { testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(updateSnapshotPath)) + Expect(req.URL.EscapedPath()).To(Equal(updateSnapshotConsistencyGroupPath)) Expect(req.Method).To(Equal("PATCH")) // For gzip-disabled operation, verify Content-Encoding is not set. @@ -52191,10 +52135,10 @@ var _ = Describe(`VpcV1`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"backup_policy_plan": {"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6/plans/r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "id": "r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "name": "my-policy-plan", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "backup_policy_plan"}, "bootable": true, "captured_at": "2019-01-01T12:00:00.000Z", "clones": [{"available": false, "created_at": "2019-01-01T12:00:00.000Z", "zone": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south/zones/us-south-1", "name": "us-south-1"}}], "copies": [{"crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "id": "r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "name": "my-snapshot", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "snapshot"}], "created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "deletable": false, "encryption": "provider_managed", "encryption_key": {"crn": "crn:v1:bluemix:public:kms:us-south:a/123456:e4a29d1a-2ef0-42a6-8fd2-350deb1c647e:key:5437653b-c4b1-447f-9646-b2a2a4cd6179"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "id": "r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "lifecycle_state": "stable", "minimum_capacity": 1, "name": "my-snapshot", "operating_system": {"architecture": "amd64", "dedicated_host_only": false, "display_name": "Ubuntu Server 16.04 LTS amd64", "family": "Ubuntu Server", "href": "https://us-south.iaas.cloud.ibm.com/v1/operating_systems/ubuntu-16-amd64", "name": "ubuntu-16-amd64", "vendor": "Canonical", "version": "16.04 LTS"}, "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "resource_type": "snapshot", "service_tags": ["ServiceTags"], "size": 1, "source_image": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::image:72b27b5c-f4b0-48bb-b954-5becc7c1dcb8", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/images/72b27b5c-f4b0-48bb-b954-5becc7c1dcb8", "id": "72b27b5c-f4b0-48bb-b954-5becc7c1dcb8", "name": "my-image", "remote": {"account": {"id": "aa2432b1fa4d4ace891e9b80fc104e34", "resource_type": "account"}, "region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "image"}, "source_snapshot": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "id": "r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "name": "my-snapshot", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "snapshot"}, "source_volume": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::volume:1a6b7274-678d-4dfb-8981-c71dd9d4daa5", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/volumes/1a6b7274-678d-4dfb-8981-c71dd9d4daa5", "id": "1a6b7274-678d-4dfb-8981-c71dd9d4daa5", "name": "my-volume", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "volume"}, "user_tags": ["UserTags"]}`) + fmt.Fprintf(res, "%s", `{"backup_policy_plan": {"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6/plans/r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "id": "r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "name": "my-policy-plan", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "backup_policy_plan"}, "created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot-consistency-group:r134-fa329f6b-0e36-433f-a3bb-0df632e79263", "delete_snapshots_on_delete": false, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshot_consistency_groups/r134-fa329f6b-0e36-433f-a3bb-0df632e79263", "id": "r134-fa329f6b-0e36-433f-a3bb-0df632e79263", "lifecycle_state": "stable", "name": "my-snapshot-consistency-group", "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "resource_type": "snapshot_consistency_group", "service_tags": ["ServiceTags"], "snapshots": [{"crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "id": "r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "name": "my-snapshot", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "snapshot"}]}`) })) }) - It(`Invoke UpdateSnapshot successfully with retries`, func() { + It(`Invoke UpdateSnapshotConsistencyGroup successfully with retries`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -52204,30 +52148,30 @@ var _ = Describe(`VpcV1`, func() { Expect(vpcService).ToNot(BeNil()) vpcService.EnableRetries(0, 0) - // Construct an instance of the SnapshotPatch model - snapshotPatchModel := new(vpcv1.SnapshotPatch) - snapshotPatchModel.Name = core.StringPtr("my-snapshot") - snapshotPatchModel.UserTags = []string{"testString"} - snapshotPatchModelAsPatch, asPatchErr := snapshotPatchModel.AsPatch() + // Construct an instance of the SnapshotConsistencyGroupPatch model + snapshotConsistencyGroupPatchModel := new(vpcv1.SnapshotConsistencyGroupPatch) + snapshotConsistencyGroupPatchModel.DeleteSnapshotsOnDelete = core.BoolPtr(true) + snapshotConsistencyGroupPatchModel.Name = core.StringPtr("my-snapshot-consistency-group") + snapshotConsistencyGroupPatchModelAsPatch, asPatchErr := snapshotConsistencyGroupPatchModel.AsPatch() Expect(asPatchErr).To(BeNil()) - // Construct an instance of the UpdateSnapshotOptions model - updateSnapshotOptionsModel := new(vpcv1.UpdateSnapshotOptions) - updateSnapshotOptionsModel.ID = core.StringPtr("testString") - updateSnapshotOptionsModel.SnapshotPatch = snapshotPatchModelAsPatch - updateSnapshotOptionsModel.IfMatch = core.StringPtr(`W/"96d225c4-56bd-43d9-98fc-d7148e5c5028"`) - updateSnapshotOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the UpdateSnapshotConsistencyGroupOptions model + updateSnapshotConsistencyGroupOptionsModel := new(vpcv1.UpdateSnapshotConsistencyGroupOptions) + updateSnapshotConsistencyGroupOptionsModel.ID = core.StringPtr("testString") + updateSnapshotConsistencyGroupOptionsModel.SnapshotConsistencyGroupPatch = snapshotConsistencyGroupPatchModelAsPatch + updateSnapshotConsistencyGroupOptionsModel.IfMatch = core.StringPtr(`W/"96d225c4-56bd-43d9-98fc-d7148e5c5028"`) + updateSnapshotConsistencyGroupOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with a Context to test a timeout error ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond) defer cancelFunc() - _, _, operationErr := vpcService.UpdateSnapshotWithContext(ctx, updateSnapshotOptionsModel) + _, _, operationErr := vpcService.UpdateSnapshotConsistencyGroupWithContext(ctx, updateSnapshotConsistencyGroupOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) // Disable retries and test again vpcService.DisableRetries() - result, response, operationErr := vpcService.UpdateSnapshot(updateSnapshotOptionsModel) + result, response, operationErr := vpcService.UpdateSnapshotConsistencyGroup(updateSnapshotConsistencyGroupOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) @@ -52235,7 +52179,7 @@ var _ = Describe(`VpcV1`, func() { // Re-test the timeout error with retries disabled ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond) defer cancelFunc2() - _, _, operationErr = vpcService.UpdateSnapshotWithContext(ctx, updateSnapshotOptionsModel) + _, _, operationErr = vpcService.UpdateSnapshotConsistencyGroupWithContext(ctx, updateSnapshotConsistencyGroupOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) }) @@ -52249,7 +52193,7 @@ var _ = Describe(`VpcV1`, func() { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(updateSnapshotPath)) + Expect(req.URL.EscapedPath()).To(Equal(updateSnapshotConsistencyGroupPath)) Expect(req.Method).To(Equal("PATCH")) // For gzip-disabled operation, verify Content-Encoding is not set. @@ -52275,7 +52219,1598 @@ var _ = Describe(`VpcV1`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"backup_policy_plan": {"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6/plans/r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "id": "r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "name": "my-policy-plan", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "backup_policy_plan"}, "bootable": true, "captured_at": "2019-01-01T12:00:00.000Z", "clones": [{"available": false, "created_at": "2019-01-01T12:00:00.000Z", "zone": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south/zones/us-south-1", "name": "us-south-1"}}], "copies": [{"crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "id": "r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "name": "my-snapshot", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "snapshot"}], "created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "deletable": false, "encryption": "provider_managed", "encryption_key": {"crn": "crn:v1:bluemix:public:kms:us-south:a/123456:e4a29d1a-2ef0-42a6-8fd2-350deb1c647e:key:5437653b-c4b1-447f-9646-b2a2a4cd6179"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "id": "r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "lifecycle_state": "stable", "minimum_capacity": 1, "name": "my-snapshot", "operating_system": {"architecture": "amd64", "dedicated_host_only": false, "display_name": "Ubuntu Server 16.04 LTS amd64", "family": "Ubuntu Server", "href": "https://us-south.iaas.cloud.ibm.com/v1/operating_systems/ubuntu-16-amd64", "name": "ubuntu-16-amd64", "vendor": "Canonical", "version": "16.04 LTS"}, "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "resource_type": "snapshot", "service_tags": ["ServiceTags"], "size": 1, "source_image": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::image:72b27b5c-f4b0-48bb-b954-5becc7c1dcb8", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/images/72b27b5c-f4b0-48bb-b954-5becc7c1dcb8", "id": "72b27b5c-f4b0-48bb-b954-5becc7c1dcb8", "name": "my-image", "remote": {"account": {"id": "aa2432b1fa4d4ace891e9b80fc104e34", "resource_type": "account"}, "region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "image"}, "source_snapshot": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "id": "r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "name": "my-snapshot", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "snapshot"}, "source_volume": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::volume:1a6b7274-678d-4dfb-8981-c71dd9d4daa5", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/volumes/1a6b7274-678d-4dfb-8981-c71dd9d4daa5", "id": "1a6b7274-678d-4dfb-8981-c71dd9d4daa5", "name": "my-volume", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "volume"}, "user_tags": ["UserTags"]}`) + fmt.Fprintf(res, "%s", `{"backup_policy_plan": {"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6/plans/r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "id": "r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "name": "my-policy-plan", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "backup_policy_plan"}, "created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot-consistency-group:r134-fa329f6b-0e36-433f-a3bb-0df632e79263", "delete_snapshots_on_delete": false, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshot_consistency_groups/r134-fa329f6b-0e36-433f-a3bb-0df632e79263", "id": "r134-fa329f6b-0e36-433f-a3bb-0df632e79263", "lifecycle_state": "stable", "name": "my-snapshot-consistency-group", "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "resource_type": "snapshot_consistency_group", "service_tags": ["ServiceTags"], "snapshots": [{"crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "id": "r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "name": "my-snapshot", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "snapshot"}]}`) + })) + }) + It(`Invoke UpdateSnapshotConsistencyGroup successfully`, func() { + vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + Version: core.StringPtr(version), + }) + Expect(serviceErr).To(BeNil()) + Expect(vpcService).ToNot(BeNil()) + + // Invoke operation with nil options model (negative test) + result, response, operationErr := vpcService.UpdateSnapshotConsistencyGroup(nil) + Expect(operationErr).NotTo(BeNil()) + Expect(response).To(BeNil()) + Expect(result).To(BeNil()) + + // Construct an instance of the SnapshotConsistencyGroupPatch model + snapshotConsistencyGroupPatchModel := new(vpcv1.SnapshotConsistencyGroupPatch) + snapshotConsistencyGroupPatchModel.DeleteSnapshotsOnDelete = core.BoolPtr(true) + snapshotConsistencyGroupPatchModel.Name = core.StringPtr("my-snapshot-consistency-group") + snapshotConsistencyGroupPatchModelAsPatch, asPatchErr := snapshotConsistencyGroupPatchModel.AsPatch() + Expect(asPatchErr).To(BeNil()) + + // Construct an instance of the UpdateSnapshotConsistencyGroupOptions model + updateSnapshotConsistencyGroupOptionsModel := new(vpcv1.UpdateSnapshotConsistencyGroupOptions) + updateSnapshotConsistencyGroupOptionsModel.ID = core.StringPtr("testString") + updateSnapshotConsistencyGroupOptionsModel.SnapshotConsistencyGroupPatch = snapshotConsistencyGroupPatchModelAsPatch + updateSnapshotConsistencyGroupOptionsModel.IfMatch = core.StringPtr(`W/"96d225c4-56bd-43d9-98fc-d7148e5c5028"`) + updateSnapshotConsistencyGroupOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation with valid options model (positive test) + result, response, operationErr = vpcService.UpdateSnapshotConsistencyGroup(updateSnapshotConsistencyGroupOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).ToNot(BeNil()) + + }) + It(`Invoke UpdateSnapshotConsistencyGroup with error: Operation validation and request error`, func() { + vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + Version: core.StringPtr(version), + }) + Expect(serviceErr).To(BeNil()) + Expect(vpcService).ToNot(BeNil()) + + // Construct an instance of the SnapshotConsistencyGroupPatch model + snapshotConsistencyGroupPatchModel := new(vpcv1.SnapshotConsistencyGroupPatch) + snapshotConsistencyGroupPatchModel.DeleteSnapshotsOnDelete = core.BoolPtr(true) + snapshotConsistencyGroupPatchModel.Name = core.StringPtr("my-snapshot-consistency-group") + snapshotConsistencyGroupPatchModelAsPatch, asPatchErr := snapshotConsistencyGroupPatchModel.AsPatch() + Expect(asPatchErr).To(BeNil()) + + // Construct an instance of the UpdateSnapshotConsistencyGroupOptions model + updateSnapshotConsistencyGroupOptionsModel := new(vpcv1.UpdateSnapshotConsistencyGroupOptions) + updateSnapshotConsistencyGroupOptionsModel.ID = core.StringPtr("testString") + updateSnapshotConsistencyGroupOptionsModel.SnapshotConsistencyGroupPatch = snapshotConsistencyGroupPatchModelAsPatch + updateSnapshotConsistencyGroupOptionsModel.IfMatch = core.StringPtr(`W/"96d225c4-56bd-43d9-98fc-d7148e5c5028"`) + updateSnapshotConsistencyGroupOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Invoke operation with empty URL (negative test) + err := vpcService.SetServiceURL("") + Expect(err).To(BeNil()) + result, response, operationErr := vpcService.UpdateSnapshotConsistencyGroup(updateSnapshotConsistencyGroupOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING)) + Expect(response).To(BeNil()) + Expect(result).To(BeNil()) + // Construct a second instance of the UpdateSnapshotConsistencyGroupOptions model with no property values + updateSnapshotConsistencyGroupOptionsModelNew := new(vpcv1.UpdateSnapshotConsistencyGroupOptions) + // Invoke operation with invalid model (negative test) + result, response, operationErr = vpcService.UpdateSnapshotConsistencyGroup(updateSnapshotConsistencyGroupOptionsModelNew) + Expect(operationErr).ToNot(BeNil()) + Expect(response).To(BeNil()) + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + Context(`Using mock server endpoint with missing response body`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Set success status code with no respoonse body + res.WriteHeader(200) + })) + }) + It(`Invoke UpdateSnapshotConsistencyGroup successfully`, func() { + vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + Version: core.StringPtr(version), + }) + Expect(serviceErr).To(BeNil()) + Expect(vpcService).ToNot(BeNil()) + + // Construct an instance of the SnapshotConsistencyGroupPatch model + snapshotConsistencyGroupPatchModel := new(vpcv1.SnapshotConsistencyGroupPatch) + snapshotConsistencyGroupPatchModel.DeleteSnapshotsOnDelete = core.BoolPtr(true) + snapshotConsistencyGroupPatchModel.Name = core.StringPtr("my-snapshot-consistency-group") + snapshotConsistencyGroupPatchModelAsPatch, asPatchErr := snapshotConsistencyGroupPatchModel.AsPatch() + Expect(asPatchErr).To(BeNil()) + + // Construct an instance of the UpdateSnapshotConsistencyGroupOptions model + updateSnapshotConsistencyGroupOptionsModel := new(vpcv1.UpdateSnapshotConsistencyGroupOptions) + updateSnapshotConsistencyGroupOptionsModel.ID = core.StringPtr("testString") + updateSnapshotConsistencyGroupOptionsModel.SnapshotConsistencyGroupPatch = snapshotConsistencyGroupPatchModelAsPatch + updateSnapshotConsistencyGroupOptionsModel.IfMatch = core.StringPtr(`W/"96d225c4-56bd-43d9-98fc-d7148e5c5028"`) + updateSnapshotConsistencyGroupOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation + result, response, operationErr := vpcService.UpdateSnapshotConsistencyGroup(updateSnapshotConsistencyGroupOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + + // Verify a nil result + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + }) + Describe(`DeleteSnapshots(deleteSnapshotsOptions *DeleteSnapshotsOptions)`, func() { + version := "testString" + deleteSnapshotsPath := "/snapshots" + Context(`Using mock server endpoint`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Verify the contents of the request + Expect(req.URL.EscapedPath()).To(Equal(deleteSnapshotsPath)) + Expect(req.Method).To(Equal("DELETE")) + + Expect(req.URL.Query()["version"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["generation"]).To(Equal([]string{fmt.Sprint(int64(2))})) + Expect(req.URL.Query()["source_volume.id"]).To(Equal([]string{"testString"})) + res.WriteHeader(204) + })) + }) + It(`Invoke DeleteSnapshots successfully`, func() { + vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + Version: core.StringPtr(version), + }) + Expect(serviceErr).To(BeNil()) + Expect(vpcService).ToNot(BeNil()) + + // Invoke operation with nil options model (negative test) + response, operationErr := vpcService.DeleteSnapshots(nil) + Expect(operationErr).NotTo(BeNil()) + Expect(response).To(BeNil()) + + // Construct an instance of the DeleteSnapshotsOptions model + deleteSnapshotsOptionsModel := new(vpcv1.DeleteSnapshotsOptions) + deleteSnapshotsOptionsModel.SourceVolumeID = core.StringPtr("testString") + deleteSnapshotsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation with valid options model (positive test) + response, operationErr = vpcService.DeleteSnapshots(deleteSnapshotsOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + }) + It(`Invoke DeleteSnapshots with error: Operation validation and request error`, func() { + vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + Version: core.StringPtr(version), + }) + Expect(serviceErr).To(BeNil()) + Expect(vpcService).ToNot(BeNil()) + + // Construct an instance of the DeleteSnapshotsOptions model + deleteSnapshotsOptionsModel := new(vpcv1.DeleteSnapshotsOptions) + deleteSnapshotsOptionsModel.SourceVolumeID = core.StringPtr("testString") + deleteSnapshotsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Invoke operation with empty URL (negative test) + err := vpcService.SetServiceURL("") + Expect(err).To(BeNil()) + response, operationErr := vpcService.DeleteSnapshots(deleteSnapshotsOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING)) + Expect(response).To(BeNil()) + // Construct a second instance of the DeleteSnapshotsOptions model with no property values + deleteSnapshotsOptionsModelNew := new(vpcv1.DeleteSnapshotsOptions) + // Invoke operation with invalid model (negative test) + response, operationErr = vpcService.DeleteSnapshots(deleteSnapshotsOptionsModelNew) + Expect(operationErr).ToNot(BeNil()) + Expect(response).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + }) + Describe(`ListSnapshots(listSnapshotsOptions *ListSnapshotsOptions) - Operation response error`, func() { + version := "testString" + listSnapshotsPath := "/snapshots" + Context(`Using mock server endpoint with invalid JSON response`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Verify the contents of the request + Expect(req.URL.EscapedPath()).To(Equal(listSnapshotsPath)) + Expect(req.Method).To(Equal("GET")) + Expect(req.URL.Query()["version"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["generation"]).To(Equal([]string{fmt.Sprint(int64(2))})) + Expect(req.URL.Query()["start"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["limit"]).To(Equal([]string{fmt.Sprint(int64(10))})) + Expect(req.URL.Query()["tag"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["resource_group.id"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["name"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["source_volume.id"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["source_volume.crn"]).To(Equal([]string{"crn:v1:bluemix:public:is:us-south-1:a/123456::volume:1a6b7274-678d-4dfb-8981-c71dd9d4daa5"})) + Expect(req.URL.Query()["source_image.id"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["source_image.crn"]).To(Equal([]string{"crn:v1:bluemix:public:is:us-south:a/123456::image:72b27b5c-f4b0-48bb-b954-5becc7c1dcb8"})) + Expect(req.URL.Query()["sort"]).To(Equal([]string{"name"})) + Expect(req.URL.Query()["backup_policy_plan.id"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["copies[].id"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["copies[].name"]).To(Equal([]string{"my-snapshot-copy"})) + Expect(req.URL.Query()["copies[].crn"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["copies[].remote.region.name"]).To(Equal([]string{"us-south"})) + Expect(req.URL.Query()["source_snapshot.id"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["source_snapshot.remote.region.name"]).To(Equal([]string{"us-south"})) + Expect(req.URL.Query()["source_volume.remote.region.name"]).To(Equal([]string{"us-south"})) + Expect(req.URL.Query()["source_image.remote.region.name"]).To(Equal([]string{"us-south"})) + Expect(req.URL.Query()["clones[].zone.name"]).To(Equal([]string{"us-south-1"})) + Expect(req.URL.Query()["snapshot_consistency_group.id"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["snapshot_consistency_group.crn"]).To(Equal([]string{"crn:v1:bluemix:public:is:us-south:a/123456::snapshot-consistency-group:r134-fa329f6b-0e36-433f-a3bb-0df632e79263"})) + res.Header().Set("Content-type", "application/json") + res.WriteHeader(200) + fmt.Fprint(res, `} this is not valid json {`) + })) + }) + It(`Invoke ListSnapshots with error: Operation response processing error`, func() { + vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + Version: core.StringPtr(version), + }) + Expect(serviceErr).To(BeNil()) + Expect(vpcService).ToNot(BeNil()) + + // Construct an instance of the ListSnapshotsOptions model + listSnapshotsOptionsModel := new(vpcv1.ListSnapshotsOptions) + listSnapshotsOptionsModel.Start = core.StringPtr("testString") + listSnapshotsOptionsModel.Limit = core.Int64Ptr(int64(10)) + listSnapshotsOptionsModel.Tag = core.StringPtr("testString") + listSnapshotsOptionsModel.ResourceGroupID = core.StringPtr("testString") + listSnapshotsOptionsModel.Name = core.StringPtr("testString") + listSnapshotsOptionsModel.SourceVolumeID = core.StringPtr("testString") + listSnapshotsOptionsModel.SourceVolumeCRN = core.StringPtr("crn:v1:bluemix:public:is:us-south-1:a/123456::volume:1a6b7274-678d-4dfb-8981-c71dd9d4daa5") + listSnapshotsOptionsModel.SourceImageID = core.StringPtr("testString") + listSnapshotsOptionsModel.SourceImageCRN = core.StringPtr("crn:v1:bluemix:public:is:us-south:a/123456::image:72b27b5c-f4b0-48bb-b954-5becc7c1dcb8") + listSnapshotsOptionsModel.Sort = core.StringPtr("name") + listSnapshotsOptionsModel.BackupPolicyPlanID = core.StringPtr("testString") + listSnapshotsOptionsModel.CopiesID = core.StringPtr("testString") + listSnapshotsOptionsModel.CopiesName = core.StringPtr("my-snapshot-copy") + listSnapshotsOptionsModel.CopiesCRN = core.StringPtr("testString") + listSnapshotsOptionsModel.CopiesRemoteRegionName = core.StringPtr("us-south") + listSnapshotsOptionsModel.SourceSnapshotID = core.StringPtr("testString") + listSnapshotsOptionsModel.SourceSnapshotRemoteRegionName = core.StringPtr("us-south") + listSnapshotsOptionsModel.SourceVolumeRemoteRegionName = core.StringPtr("us-south") + listSnapshotsOptionsModel.SourceImageRemoteRegionName = core.StringPtr("us-south") + listSnapshotsOptionsModel.ClonesZoneName = core.StringPtr("us-south-1") + listSnapshotsOptionsModel.SnapshotConsistencyGroupID = core.StringPtr("testString") + listSnapshotsOptionsModel.SnapshotConsistencyGroupCRN = core.StringPtr("crn:v1:bluemix:public:is:us-south:a/123456::snapshot-consistency-group:r134-fa329f6b-0e36-433f-a3bb-0df632e79263") + listSnapshotsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Expect response parsing to fail since we are receiving a text/plain response + result, response, operationErr := vpcService.ListSnapshots(listSnapshotsOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).To(BeNil()) + + // Enable retries and test again + vpcService.EnableRetries(0, 0) + result, response, operationErr = vpcService.ListSnapshots(listSnapshotsOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + }) + Describe(`ListSnapshots(listSnapshotsOptions *ListSnapshotsOptions)`, func() { + version := "testString" + listSnapshotsPath := "/snapshots" + Context(`Using mock server endpoint with timeout`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Verify the contents of the request + Expect(req.URL.EscapedPath()).To(Equal(listSnapshotsPath)) + Expect(req.Method).To(Equal("GET")) + + Expect(req.URL.Query()["version"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["generation"]).To(Equal([]string{fmt.Sprint(int64(2))})) + Expect(req.URL.Query()["start"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["limit"]).To(Equal([]string{fmt.Sprint(int64(10))})) + Expect(req.URL.Query()["tag"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["resource_group.id"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["name"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["source_volume.id"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["source_volume.crn"]).To(Equal([]string{"crn:v1:bluemix:public:is:us-south-1:a/123456::volume:1a6b7274-678d-4dfb-8981-c71dd9d4daa5"})) + Expect(req.URL.Query()["source_image.id"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["source_image.crn"]).To(Equal([]string{"crn:v1:bluemix:public:is:us-south:a/123456::image:72b27b5c-f4b0-48bb-b954-5becc7c1dcb8"})) + Expect(req.URL.Query()["sort"]).To(Equal([]string{"name"})) + Expect(req.URL.Query()["backup_policy_plan.id"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["copies[].id"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["copies[].name"]).To(Equal([]string{"my-snapshot-copy"})) + Expect(req.URL.Query()["copies[].crn"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["copies[].remote.region.name"]).To(Equal([]string{"us-south"})) + Expect(req.URL.Query()["source_snapshot.id"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["source_snapshot.remote.region.name"]).To(Equal([]string{"us-south"})) + Expect(req.URL.Query()["source_volume.remote.region.name"]).To(Equal([]string{"us-south"})) + Expect(req.URL.Query()["source_image.remote.region.name"]).To(Equal([]string{"us-south"})) + Expect(req.URL.Query()["clones[].zone.name"]).To(Equal([]string{"us-south-1"})) + Expect(req.URL.Query()["snapshot_consistency_group.id"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["snapshot_consistency_group.crn"]).To(Equal([]string{"crn:v1:bluemix:public:is:us-south:a/123456::snapshot-consistency-group:r134-fa329f6b-0e36-433f-a3bb-0df632e79263"})) + // Sleep a short time to support a timeout test + time.Sleep(100 * time.Millisecond) + + // Set mock response + res.Header().Set("Content-type", "application/json") + res.WriteHeader(200) + fmt.Fprintf(res, "%s", `{"first": {"href": "https://us-south.iaas.cloud.ibm.com/v1/snapshots?limit=20"}, "limit": 20, "next": {"href": "https://us-south.iaas.cloud.ibm.com/v1/snapshots?start=9d5a91a3e2cbd233b5a5b33436855ed1&limit=20"}, "snapshots": [{"backup_policy_plan": {"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6/plans/r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "id": "r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "name": "my-policy-plan", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "backup_policy_plan"}, "bootable": true, "captured_at": "2019-01-01T12:00:00.000Z", "clones": [{"available": false, "created_at": "2019-01-01T12:00:00.000Z", "zone": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south/zones/us-south-1", "name": "us-south-1"}}], "copies": [{"crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "id": "r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "name": "my-snapshot", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "snapshot"}], "created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "deletable": false, "encryption": "provider_managed", "encryption_key": {"crn": "crn:v1:bluemix:public:kms:us-south:a/123456:e4a29d1a-2ef0-42a6-8fd2-350deb1c647e:key:5437653b-c4b1-447f-9646-b2a2a4cd6179"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "id": "r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "lifecycle_state": "stable", "minimum_capacity": 1, "name": "my-snapshot", "operating_system": {"architecture": "amd64", "dedicated_host_only": false, "display_name": "Ubuntu Server 16.04 LTS amd64", "family": "Ubuntu Server", "href": "https://us-south.iaas.cloud.ibm.com/v1/operating_systems/ubuntu-16-amd64", "name": "ubuntu-16-amd64", "vendor": "Canonical", "version": "16.04 LTS"}, "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "resource_type": "snapshot", "service_tags": ["ServiceTags"], "size": 1, "snapshot_consistency_group": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot-consistency-group:r134-fa329f6b-0e36-433f-a3bb-0df632e79263", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshot_consistency_groups/r134-fa329f6b-0e36-433f-a3bb-0df632e79263", "id": "r134-fa329f6b-0e36-433f-a3bb-0df632e79263", "name": "my-snapshot-consistency-group", "resource_type": "snapshot_consistency_group"}, "source_image": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::image:72b27b5c-f4b0-48bb-b954-5becc7c1dcb8", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/images/72b27b5c-f4b0-48bb-b954-5becc7c1dcb8", "id": "72b27b5c-f4b0-48bb-b954-5becc7c1dcb8", "name": "my-image", "remote": {"account": {"id": "aa2432b1fa4d4ace891e9b80fc104e34", "resource_type": "account"}, "region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "image"}, "source_snapshot": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "id": "r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "name": "my-snapshot", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "snapshot"}, "source_volume": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::volume:1a6b7274-678d-4dfb-8981-c71dd9d4daa5", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/volumes/1a6b7274-678d-4dfb-8981-c71dd9d4daa5", "id": "1a6b7274-678d-4dfb-8981-c71dd9d4daa5", "name": "my-volume", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "volume"}, "user_tags": ["UserTags"]}], "total_count": 132}`) + })) + }) + It(`Invoke ListSnapshots successfully with retries`, func() { + vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + Version: core.StringPtr(version), + }) + Expect(serviceErr).To(BeNil()) + Expect(vpcService).ToNot(BeNil()) + vpcService.EnableRetries(0, 0) + + // Construct an instance of the ListSnapshotsOptions model + listSnapshotsOptionsModel := new(vpcv1.ListSnapshotsOptions) + listSnapshotsOptionsModel.Start = core.StringPtr("testString") + listSnapshotsOptionsModel.Limit = core.Int64Ptr(int64(10)) + listSnapshotsOptionsModel.Tag = core.StringPtr("testString") + listSnapshotsOptionsModel.ResourceGroupID = core.StringPtr("testString") + listSnapshotsOptionsModel.Name = core.StringPtr("testString") + listSnapshotsOptionsModel.SourceVolumeID = core.StringPtr("testString") + listSnapshotsOptionsModel.SourceVolumeCRN = core.StringPtr("crn:v1:bluemix:public:is:us-south-1:a/123456::volume:1a6b7274-678d-4dfb-8981-c71dd9d4daa5") + listSnapshotsOptionsModel.SourceImageID = core.StringPtr("testString") + listSnapshotsOptionsModel.SourceImageCRN = core.StringPtr("crn:v1:bluemix:public:is:us-south:a/123456::image:72b27b5c-f4b0-48bb-b954-5becc7c1dcb8") + listSnapshotsOptionsModel.Sort = core.StringPtr("name") + listSnapshotsOptionsModel.BackupPolicyPlanID = core.StringPtr("testString") + listSnapshotsOptionsModel.CopiesID = core.StringPtr("testString") + listSnapshotsOptionsModel.CopiesName = core.StringPtr("my-snapshot-copy") + listSnapshotsOptionsModel.CopiesCRN = core.StringPtr("testString") + listSnapshotsOptionsModel.CopiesRemoteRegionName = core.StringPtr("us-south") + listSnapshotsOptionsModel.SourceSnapshotID = core.StringPtr("testString") + listSnapshotsOptionsModel.SourceSnapshotRemoteRegionName = core.StringPtr("us-south") + listSnapshotsOptionsModel.SourceVolumeRemoteRegionName = core.StringPtr("us-south") + listSnapshotsOptionsModel.SourceImageRemoteRegionName = core.StringPtr("us-south") + listSnapshotsOptionsModel.ClonesZoneName = core.StringPtr("us-south-1") + listSnapshotsOptionsModel.SnapshotConsistencyGroupID = core.StringPtr("testString") + listSnapshotsOptionsModel.SnapshotConsistencyGroupCRN = core.StringPtr("crn:v1:bluemix:public:is:us-south:a/123456::snapshot-consistency-group:r134-fa329f6b-0e36-433f-a3bb-0df632e79263") + listSnapshotsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation with a Context to test a timeout error + ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond) + defer cancelFunc() + _, _, operationErr := vpcService.ListSnapshotsWithContext(ctx, listSnapshotsOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) + + // Disable retries and test again + vpcService.DisableRetries() + result, response, operationErr := vpcService.ListSnapshots(listSnapshotsOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).ToNot(BeNil()) + + // Re-test the timeout error with retries disabled + ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond) + defer cancelFunc2() + _, _, operationErr = vpcService.ListSnapshotsWithContext(ctx, listSnapshotsOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) + }) + AfterEach(func() { + testServer.Close() + }) + }) + Context(`Using mock server endpoint`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Verify the contents of the request + Expect(req.URL.EscapedPath()).To(Equal(listSnapshotsPath)) + Expect(req.Method).To(Equal("GET")) + + Expect(req.URL.Query()["version"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["generation"]).To(Equal([]string{fmt.Sprint(int64(2))})) + Expect(req.URL.Query()["start"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["limit"]).To(Equal([]string{fmt.Sprint(int64(10))})) + Expect(req.URL.Query()["tag"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["resource_group.id"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["name"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["source_volume.id"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["source_volume.crn"]).To(Equal([]string{"crn:v1:bluemix:public:is:us-south-1:a/123456::volume:1a6b7274-678d-4dfb-8981-c71dd9d4daa5"})) + Expect(req.URL.Query()["source_image.id"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["source_image.crn"]).To(Equal([]string{"crn:v1:bluemix:public:is:us-south:a/123456::image:72b27b5c-f4b0-48bb-b954-5becc7c1dcb8"})) + Expect(req.URL.Query()["sort"]).To(Equal([]string{"name"})) + Expect(req.URL.Query()["backup_policy_plan.id"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["copies[].id"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["copies[].name"]).To(Equal([]string{"my-snapshot-copy"})) + Expect(req.URL.Query()["copies[].crn"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["copies[].remote.region.name"]).To(Equal([]string{"us-south"})) + Expect(req.URL.Query()["source_snapshot.id"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["source_snapshot.remote.region.name"]).To(Equal([]string{"us-south"})) + Expect(req.URL.Query()["source_volume.remote.region.name"]).To(Equal([]string{"us-south"})) + Expect(req.URL.Query()["source_image.remote.region.name"]).To(Equal([]string{"us-south"})) + Expect(req.URL.Query()["clones[].zone.name"]).To(Equal([]string{"us-south-1"})) + Expect(req.URL.Query()["snapshot_consistency_group.id"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["snapshot_consistency_group.crn"]).To(Equal([]string{"crn:v1:bluemix:public:is:us-south:a/123456::snapshot-consistency-group:r134-fa329f6b-0e36-433f-a3bb-0df632e79263"})) + // Set mock response + res.Header().Set("Content-type", "application/json") + res.WriteHeader(200) + fmt.Fprintf(res, "%s", `{"first": {"href": "https://us-south.iaas.cloud.ibm.com/v1/snapshots?limit=20"}, "limit": 20, "next": {"href": "https://us-south.iaas.cloud.ibm.com/v1/snapshots?start=9d5a91a3e2cbd233b5a5b33436855ed1&limit=20"}, "snapshots": [{"backup_policy_plan": {"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6/plans/r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "id": "r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "name": "my-policy-plan", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "backup_policy_plan"}, "bootable": true, "captured_at": "2019-01-01T12:00:00.000Z", "clones": [{"available": false, "created_at": "2019-01-01T12:00:00.000Z", "zone": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south/zones/us-south-1", "name": "us-south-1"}}], "copies": [{"crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "id": "r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "name": "my-snapshot", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "snapshot"}], "created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "deletable": false, "encryption": "provider_managed", "encryption_key": {"crn": "crn:v1:bluemix:public:kms:us-south:a/123456:e4a29d1a-2ef0-42a6-8fd2-350deb1c647e:key:5437653b-c4b1-447f-9646-b2a2a4cd6179"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "id": "r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "lifecycle_state": "stable", "minimum_capacity": 1, "name": "my-snapshot", "operating_system": {"architecture": "amd64", "dedicated_host_only": false, "display_name": "Ubuntu Server 16.04 LTS amd64", "family": "Ubuntu Server", "href": "https://us-south.iaas.cloud.ibm.com/v1/operating_systems/ubuntu-16-amd64", "name": "ubuntu-16-amd64", "vendor": "Canonical", "version": "16.04 LTS"}, "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "resource_type": "snapshot", "service_tags": ["ServiceTags"], "size": 1, "snapshot_consistency_group": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot-consistency-group:r134-fa329f6b-0e36-433f-a3bb-0df632e79263", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshot_consistency_groups/r134-fa329f6b-0e36-433f-a3bb-0df632e79263", "id": "r134-fa329f6b-0e36-433f-a3bb-0df632e79263", "name": "my-snapshot-consistency-group", "resource_type": "snapshot_consistency_group"}, "source_image": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::image:72b27b5c-f4b0-48bb-b954-5becc7c1dcb8", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/images/72b27b5c-f4b0-48bb-b954-5becc7c1dcb8", "id": "72b27b5c-f4b0-48bb-b954-5becc7c1dcb8", "name": "my-image", "remote": {"account": {"id": "aa2432b1fa4d4ace891e9b80fc104e34", "resource_type": "account"}, "region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "image"}, "source_snapshot": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "id": "r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "name": "my-snapshot", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "snapshot"}, "source_volume": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::volume:1a6b7274-678d-4dfb-8981-c71dd9d4daa5", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/volumes/1a6b7274-678d-4dfb-8981-c71dd9d4daa5", "id": "1a6b7274-678d-4dfb-8981-c71dd9d4daa5", "name": "my-volume", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "volume"}, "user_tags": ["UserTags"]}], "total_count": 132}`) + })) + }) + It(`Invoke ListSnapshots successfully`, func() { + vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + Version: core.StringPtr(version), + }) + Expect(serviceErr).To(BeNil()) + Expect(vpcService).ToNot(BeNil()) + + // Invoke operation with nil options model (negative test) + result, response, operationErr := vpcService.ListSnapshots(nil) + Expect(operationErr).NotTo(BeNil()) + Expect(response).To(BeNil()) + Expect(result).To(BeNil()) + + // Construct an instance of the ListSnapshotsOptions model + listSnapshotsOptionsModel := new(vpcv1.ListSnapshotsOptions) + listSnapshotsOptionsModel.Start = core.StringPtr("testString") + listSnapshotsOptionsModel.Limit = core.Int64Ptr(int64(10)) + listSnapshotsOptionsModel.Tag = core.StringPtr("testString") + listSnapshotsOptionsModel.ResourceGroupID = core.StringPtr("testString") + listSnapshotsOptionsModel.Name = core.StringPtr("testString") + listSnapshotsOptionsModel.SourceVolumeID = core.StringPtr("testString") + listSnapshotsOptionsModel.SourceVolumeCRN = core.StringPtr("crn:v1:bluemix:public:is:us-south-1:a/123456::volume:1a6b7274-678d-4dfb-8981-c71dd9d4daa5") + listSnapshotsOptionsModel.SourceImageID = core.StringPtr("testString") + listSnapshotsOptionsModel.SourceImageCRN = core.StringPtr("crn:v1:bluemix:public:is:us-south:a/123456::image:72b27b5c-f4b0-48bb-b954-5becc7c1dcb8") + listSnapshotsOptionsModel.Sort = core.StringPtr("name") + listSnapshotsOptionsModel.BackupPolicyPlanID = core.StringPtr("testString") + listSnapshotsOptionsModel.CopiesID = core.StringPtr("testString") + listSnapshotsOptionsModel.CopiesName = core.StringPtr("my-snapshot-copy") + listSnapshotsOptionsModel.CopiesCRN = core.StringPtr("testString") + listSnapshotsOptionsModel.CopiesRemoteRegionName = core.StringPtr("us-south") + listSnapshotsOptionsModel.SourceSnapshotID = core.StringPtr("testString") + listSnapshotsOptionsModel.SourceSnapshotRemoteRegionName = core.StringPtr("us-south") + listSnapshotsOptionsModel.SourceVolumeRemoteRegionName = core.StringPtr("us-south") + listSnapshotsOptionsModel.SourceImageRemoteRegionName = core.StringPtr("us-south") + listSnapshotsOptionsModel.ClonesZoneName = core.StringPtr("us-south-1") + listSnapshotsOptionsModel.SnapshotConsistencyGroupID = core.StringPtr("testString") + listSnapshotsOptionsModel.SnapshotConsistencyGroupCRN = core.StringPtr("crn:v1:bluemix:public:is:us-south:a/123456::snapshot-consistency-group:r134-fa329f6b-0e36-433f-a3bb-0df632e79263") + listSnapshotsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation with valid options model (positive test) + result, response, operationErr = vpcService.ListSnapshots(listSnapshotsOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).ToNot(BeNil()) + + }) + It(`Invoke ListSnapshots with error: Operation request error`, func() { + vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + Version: core.StringPtr(version), + }) + Expect(serviceErr).To(BeNil()) + Expect(vpcService).ToNot(BeNil()) + + // Construct an instance of the ListSnapshotsOptions model + listSnapshotsOptionsModel := new(vpcv1.ListSnapshotsOptions) + listSnapshotsOptionsModel.Start = core.StringPtr("testString") + listSnapshotsOptionsModel.Limit = core.Int64Ptr(int64(10)) + listSnapshotsOptionsModel.Tag = core.StringPtr("testString") + listSnapshotsOptionsModel.ResourceGroupID = core.StringPtr("testString") + listSnapshotsOptionsModel.Name = core.StringPtr("testString") + listSnapshotsOptionsModel.SourceVolumeID = core.StringPtr("testString") + listSnapshotsOptionsModel.SourceVolumeCRN = core.StringPtr("crn:v1:bluemix:public:is:us-south-1:a/123456::volume:1a6b7274-678d-4dfb-8981-c71dd9d4daa5") + listSnapshotsOptionsModel.SourceImageID = core.StringPtr("testString") + listSnapshotsOptionsModel.SourceImageCRN = core.StringPtr("crn:v1:bluemix:public:is:us-south:a/123456::image:72b27b5c-f4b0-48bb-b954-5becc7c1dcb8") + listSnapshotsOptionsModel.Sort = core.StringPtr("name") + listSnapshotsOptionsModel.BackupPolicyPlanID = core.StringPtr("testString") + listSnapshotsOptionsModel.CopiesID = core.StringPtr("testString") + listSnapshotsOptionsModel.CopiesName = core.StringPtr("my-snapshot-copy") + listSnapshotsOptionsModel.CopiesCRN = core.StringPtr("testString") + listSnapshotsOptionsModel.CopiesRemoteRegionName = core.StringPtr("us-south") + listSnapshotsOptionsModel.SourceSnapshotID = core.StringPtr("testString") + listSnapshotsOptionsModel.SourceSnapshotRemoteRegionName = core.StringPtr("us-south") + listSnapshotsOptionsModel.SourceVolumeRemoteRegionName = core.StringPtr("us-south") + listSnapshotsOptionsModel.SourceImageRemoteRegionName = core.StringPtr("us-south") + listSnapshotsOptionsModel.ClonesZoneName = core.StringPtr("us-south-1") + listSnapshotsOptionsModel.SnapshotConsistencyGroupID = core.StringPtr("testString") + listSnapshotsOptionsModel.SnapshotConsistencyGroupCRN = core.StringPtr("crn:v1:bluemix:public:is:us-south:a/123456::snapshot-consistency-group:r134-fa329f6b-0e36-433f-a3bb-0df632e79263") + listSnapshotsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Invoke operation with empty URL (negative test) + err := vpcService.SetServiceURL("") + Expect(err).To(BeNil()) + result, response, operationErr := vpcService.ListSnapshots(listSnapshotsOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING)) + Expect(response).To(BeNil()) + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + Context(`Using mock server endpoint with missing response body`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Set success status code with no respoonse body + res.WriteHeader(200) + })) + }) + It(`Invoke ListSnapshots successfully`, func() { + vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + Version: core.StringPtr(version), + }) + Expect(serviceErr).To(BeNil()) + Expect(vpcService).ToNot(BeNil()) + + // Construct an instance of the ListSnapshotsOptions model + listSnapshotsOptionsModel := new(vpcv1.ListSnapshotsOptions) + listSnapshotsOptionsModel.Start = core.StringPtr("testString") + listSnapshotsOptionsModel.Limit = core.Int64Ptr(int64(10)) + listSnapshotsOptionsModel.Tag = core.StringPtr("testString") + listSnapshotsOptionsModel.ResourceGroupID = core.StringPtr("testString") + listSnapshotsOptionsModel.Name = core.StringPtr("testString") + listSnapshotsOptionsModel.SourceVolumeID = core.StringPtr("testString") + listSnapshotsOptionsModel.SourceVolumeCRN = core.StringPtr("crn:v1:bluemix:public:is:us-south-1:a/123456::volume:1a6b7274-678d-4dfb-8981-c71dd9d4daa5") + listSnapshotsOptionsModel.SourceImageID = core.StringPtr("testString") + listSnapshotsOptionsModel.SourceImageCRN = core.StringPtr("crn:v1:bluemix:public:is:us-south:a/123456::image:72b27b5c-f4b0-48bb-b954-5becc7c1dcb8") + listSnapshotsOptionsModel.Sort = core.StringPtr("name") + listSnapshotsOptionsModel.BackupPolicyPlanID = core.StringPtr("testString") + listSnapshotsOptionsModel.CopiesID = core.StringPtr("testString") + listSnapshotsOptionsModel.CopiesName = core.StringPtr("my-snapshot-copy") + listSnapshotsOptionsModel.CopiesCRN = core.StringPtr("testString") + listSnapshotsOptionsModel.CopiesRemoteRegionName = core.StringPtr("us-south") + listSnapshotsOptionsModel.SourceSnapshotID = core.StringPtr("testString") + listSnapshotsOptionsModel.SourceSnapshotRemoteRegionName = core.StringPtr("us-south") + listSnapshotsOptionsModel.SourceVolumeRemoteRegionName = core.StringPtr("us-south") + listSnapshotsOptionsModel.SourceImageRemoteRegionName = core.StringPtr("us-south") + listSnapshotsOptionsModel.ClonesZoneName = core.StringPtr("us-south-1") + listSnapshotsOptionsModel.SnapshotConsistencyGroupID = core.StringPtr("testString") + listSnapshotsOptionsModel.SnapshotConsistencyGroupCRN = core.StringPtr("crn:v1:bluemix:public:is:us-south:a/123456::snapshot-consistency-group:r134-fa329f6b-0e36-433f-a3bb-0df632e79263") + listSnapshotsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation + result, response, operationErr := vpcService.ListSnapshots(listSnapshotsOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + + // Verify a nil result + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + Context(`Test pagination helper method on response`, func() { + It(`Invoke GetNextStart successfully`, func() { + responseObject := new(vpcv1.SnapshotCollection) + nextObject := new(vpcv1.SnapshotCollectionNext) + nextObject.Href = core.StringPtr("ibm.com?start=abc-123") + responseObject.Next = nextObject + + value, err := responseObject.GetNextStart() + Expect(err).To(BeNil()) + Expect(value).To(Equal(core.StringPtr("abc-123"))) + }) + It(`Invoke GetNextStart without a "Next" property in the response`, func() { + responseObject := new(vpcv1.SnapshotCollection) + + value, err := responseObject.GetNextStart() + Expect(err).To(BeNil()) + Expect(value).To(BeNil()) + }) + It(`Invoke GetNextStart without any query params in the "Next" URL`, func() { + responseObject := new(vpcv1.SnapshotCollection) + nextObject := new(vpcv1.SnapshotCollectionNext) + nextObject.Href = core.StringPtr("ibm.com") + responseObject.Next = nextObject + + value, err := responseObject.GetNextStart() + Expect(err).To(BeNil()) + Expect(value).To(BeNil()) + }) + }) + Context(`Using mock server endpoint - paginated response`, func() { + BeforeEach(func() { + var requestNumber int = 0 + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Verify the contents of the request + Expect(req.URL.EscapedPath()).To(Equal(listSnapshotsPath)) + Expect(req.Method).To(Equal("GET")) + + // Set mock response + res.Header().Set("Content-type", "application/json") + res.WriteHeader(200) + requestNumber++ + if requestNumber == 1 { + fmt.Fprintf(res, "%s", `{"snapshots":[{"backup_policy_plan":{"deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6/plans/r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178","id":"r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178","name":"my-policy-plan","remote":{"region":{"href":"https://us-south.iaas.cloud.ibm.com/v1/regions/us-south","name":"us-south"}},"resource_type":"backup_policy_plan"},"bootable":true,"captured_at":"2019-01-01T12:00:00.000Z","clones":[{"available":false,"created_at":"2019-01-01T12:00:00.000Z","zone":{"href":"https://us-south.iaas.cloud.ibm.com/v1/regions/us-south/zones/us-south-1","name":"us-south-1"}}],"copies":[{"crn":"crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263","deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263","id":"r134-f6bfa329-0e36-433f-a3bb-0df632e79263","name":"my-snapshot","remote":{"region":{"href":"https://us-south.iaas.cloud.ibm.com/v1/regions/us-south","name":"us-south"}},"resource_type":"snapshot"}],"created_at":"2019-01-01T12:00:00.000Z","crn":"crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263","deletable":false,"encryption":"provider_managed","encryption_key":{"crn":"crn:v1:bluemix:public:kms:us-south:a/123456:e4a29d1a-2ef0-42a6-8fd2-350deb1c647e:key:5437653b-c4b1-447f-9646-b2a2a4cd6179"},"href":"https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263","id":"r134-f6bfa329-0e36-433f-a3bb-0df632e79263","lifecycle_state":"stable","minimum_capacity":1,"name":"my-snapshot","operating_system":{"architecture":"amd64","dedicated_host_only":false,"display_name":"Ubuntu Server 16.04 LTS amd64","family":"Ubuntu Server","href":"https://us-south.iaas.cloud.ibm.com/v1/operating_systems/ubuntu-16-amd64","name":"ubuntu-16-amd64","vendor":"Canonical","version":"16.04 LTS"},"resource_group":{"href":"https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345","id":"fee82deba12e4c0fb69c3b09d1f12345","name":"my-resource-group"},"resource_type":"snapshot","service_tags":["ServiceTags"],"size":1,"snapshot_consistency_group":{"crn":"crn:v1:bluemix:public:is:us-south:a/123456::snapshot-consistency-group:r134-fa329f6b-0e36-433f-a3bb-0df632e79263","deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/snapshot_consistency_groups/r134-fa329f6b-0e36-433f-a3bb-0df632e79263","id":"r134-fa329f6b-0e36-433f-a3bb-0df632e79263","name":"my-snapshot-consistency-group","resource_type":"snapshot_consistency_group"},"source_image":{"crn":"crn:v1:bluemix:public:is:us-south:a/123456::image:72b27b5c-f4b0-48bb-b954-5becc7c1dcb8","deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/images/72b27b5c-f4b0-48bb-b954-5becc7c1dcb8","id":"72b27b5c-f4b0-48bb-b954-5becc7c1dcb8","name":"my-image","remote":{"account":{"id":"aa2432b1fa4d4ace891e9b80fc104e34","resource_type":"account"},"region":{"href":"https://us-south.iaas.cloud.ibm.com/v1/regions/us-south","name":"us-south"}},"resource_type":"image"},"source_snapshot":{"crn":"crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263","deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263","id":"r134-f6bfa329-0e36-433f-a3bb-0df632e79263","name":"my-snapshot","remote":{"region":{"href":"https://us-south.iaas.cloud.ibm.com/v1/regions/us-south","name":"us-south"}},"resource_type":"snapshot"},"source_volume":{"crn":"crn:v1:bluemix:public:is:us-south-1:a/123456::volume:1a6b7274-678d-4dfb-8981-c71dd9d4daa5","deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/volumes/1a6b7274-678d-4dfb-8981-c71dd9d4daa5","id":"1a6b7274-678d-4dfb-8981-c71dd9d4daa5","name":"my-volume","remote":{"region":{"href":"https://us-south.iaas.cloud.ibm.com/v1/regions/us-south","name":"us-south"}},"resource_type":"volume"},"user_tags":["UserTags"]}],"next":{"href":"https://myhost.com/somePath?start=1"},"total_count":2,"limit":1}`) + } else if requestNumber == 2 { + fmt.Fprintf(res, "%s", `{"snapshots":[{"backup_policy_plan":{"deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6/plans/r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178","id":"r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178","name":"my-policy-plan","remote":{"region":{"href":"https://us-south.iaas.cloud.ibm.com/v1/regions/us-south","name":"us-south"}},"resource_type":"backup_policy_plan"},"bootable":true,"captured_at":"2019-01-01T12:00:00.000Z","clones":[{"available":false,"created_at":"2019-01-01T12:00:00.000Z","zone":{"href":"https://us-south.iaas.cloud.ibm.com/v1/regions/us-south/zones/us-south-1","name":"us-south-1"}}],"copies":[{"crn":"crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263","deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263","id":"r134-f6bfa329-0e36-433f-a3bb-0df632e79263","name":"my-snapshot","remote":{"region":{"href":"https://us-south.iaas.cloud.ibm.com/v1/regions/us-south","name":"us-south"}},"resource_type":"snapshot"}],"created_at":"2019-01-01T12:00:00.000Z","crn":"crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263","deletable":false,"encryption":"provider_managed","encryption_key":{"crn":"crn:v1:bluemix:public:kms:us-south:a/123456:e4a29d1a-2ef0-42a6-8fd2-350deb1c647e:key:5437653b-c4b1-447f-9646-b2a2a4cd6179"},"href":"https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263","id":"r134-f6bfa329-0e36-433f-a3bb-0df632e79263","lifecycle_state":"stable","minimum_capacity":1,"name":"my-snapshot","operating_system":{"architecture":"amd64","dedicated_host_only":false,"display_name":"Ubuntu Server 16.04 LTS amd64","family":"Ubuntu Server","href":"https://us-south.iaas.cloud.ibm.com/v1/operating_systems/ubuntu-16-amd64","name":"ubuntu-16-amd64","vendor":"Canonical","version":"16.04 LTS"},"resource_group":{"href":"https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345","id":"fee82deba12e4c0fb69c3b09d1f12345","name":"my-resource-group"},"resource_type":"snapshot","service_tags":["ServiceTags"],"size":1,"snapshot_consistency_group":{"crn":"crn:v1:bluemix:public:is:us-south:a/123456::snapshot-consistency-group:r134-fa329f6b-0e36-433f-a3bb-0df632e79263","deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/snapshot_consistency_groups/r134-fa329f6b-0e36-433f-a3bb-0df632e79263","id":"r134-fa329f6b-0e36-433f-a3bb-0df632e79263","name":"my-snapshot-consistency-group","resource_type":"snapshot_consistency_group"},"source_image":{"crn":"crn:v1:bluemix:public:is:us-south:a/123456::image:72b27b5c-f4b0-48bb-b954-5becc7c1dcb8","deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/images/72b27b5c-f4b0-48bb-b954-5becc7c1dcb8","id":"72b27b5c-f4b0-48bb-b954-5becc7c1dcb8","name":"my-image","remote":{"account":{"id":"aa2432b1fa4d4ace891e9b80fc104e34","resource_type":"account"},"region":{"href":"https://us-south.iaas.cloud.ibm.com/v1/regions/us-south","name":"us-south"}},"resource_type":"image"},"source_snapshot":{"crn":"crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263","deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263","id":"r134-f6bfa329-0e36-433f-a3bb-0df632e79263","name":"my-snapshot","remote":{"region":{"href":"https://us-south.iaas.cloud.ibm.com/v1/regions/us-south","name":"us-south"}},"resource_type":"snapshot"},"source_volume":{"crn":"crn:v1:bluemix:public:is:us-south-1:a/123456::volume:1a6b7274-678d-4dfb-8981-c71dd9d4daa5","deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/volumes/1a6b7274-678d-4dfb-8981-c71dd9d4daa5","id":"1a6b7274-678d-4dfb-8981-c71dd9d4daa5","name":"my-volume","remote":{"region":{"href":"https://us-south.iaas.cloud.ibm.com/v1/regions/us-south","name":"us-south"}},"resource_type":"volume"},"user_tags":["UserTags"]}],"total_count":2,"limit":1}`) + } else { + res.WriteHeader(400) + } + })) + }) + It(`Use SnapshotsPager.GetNext successfully`, func() { + vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + Version: core.StringPtr(version), + }) + Expect(serviceErr).To(BeNil()) + Expect(vpcService).ToNot(BeNil()) + + listSnapshotsOptionsModel := &vpcv1.ListSnapshotsOptions{ + Limit: core.Int64Ptr(int64(10)), + Tag: core.StringPtr("testString"), + ResourceGroupID: core.StringPtr("testString"), + Name: core.StringPtr("testString"), + SourceVolumeID: core.StringPtr("testString"), + SourceVolumeCRN: core.StringPtr("crn:v1:bluemix:public:is:us-south-1:a/123456::volume:1a6b7274-678d-4dfb-8981-c71dd9d4daa5"), + SourceImageID: core.StringPtr("testString"), + SourceImageCRN: core.StringPtr("crn:v1:bluemix:public:is:us-south:a/123456::image:72b27b5c-f4b0-48bb-b954-5becc7c1dcb8"), + Sort: core.StringPtr("name"), + BackupPolicyPlanID: core.StringPtr("testString"), + CopiesID: core.StringPtr("testString"), + CopiesName: core.StringPtr("my-snapshot-copy"), + CopiesCRN: core.StringPtr("testString"), + CopiesRemoteRegionName: core.StringPtr("us-south"), + SourceSnapshotID: core.StringPtr("testString"), + SourceSnapshotRemoteRegionName: core.StringPtr("us-south"), + SourceVolumeRemoteRegionName: core.StringPtr("us-south"), + SourceImageRemoteRegionName: core.StringPtr("us-south"), + ClonesZoneName: core.StringPtr("us-south-1"), + SnapshotConsistencyGroupID: core.StringPtr("testString"), + SnapshotConsistencyGroupCRN: core.StringPtr("crn:v1:bluemix:public:is:us-south:a/123456::snapshot-consistency-group:r134-fa329f6b-0e36-433f-a3bb-0df632e79263"), + } + + pager, err := vpcService.NewSnapshotsPager(listSnapshotsOptionsModel) + Expect(err).To(BeNil()) + Expect(pager).ToNot(BeNil()) + + var allResults []vpcv1.Snapshot + for pager.HasNext() { + nextPage, err := pager.GetNext() + Expect(err).To(BeNil()) + Expect(nextPage).ToNot(BeNil()) + allResults = append(allResults, nextPage...) + } + Expect(len(allResults)).To(Equal(2)) + }) + It(`Use SnapshotsPager.GetAll successfully`, func() { + vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + Version: core.StringPtr(version), + }) + Expect(serviceErr).To(BeNil()) + Expect(vpcService).ToNot(BeNil()) + + listSnapshotsOptionsModel := &vpcv1.ListSnapshotsOptions{ + Limit: core.Int64Ptr(int64(10)), + Tag: core.StringPtr("testString"), + ResourceGroupID: core.StringPtr("testString"), + Name: core.StringPtr("testString"), + SourceVolumeID: core.StringPtr("testString"), + SourceVolumeCRN: core.StringPtr("crn:v1:bluemix:public:is:us-south-1:a/123456::volume:1a6b7274-678d-4dfb-8981-c71dd9d4daa5"), + SourceImageID: core.StringPtr("testString"), + SourceImageCRN: core.StringPtr("crn:v1:bluemix:public:is:us-south:a/123456::image:72b27b5c-f4b0-48bb-b954-5becc7c1dcb8"), + Sort: core.StringPtr("name"), + BackupPolicyPlanID: core.StringPtr("testString"), + CopiesID: core.StringPtr("testString"), + CopiesName: core.StringPtr("my-snapshot-copy"), + CopiesCRN: core.StringPtr("testString"), + CopiesRemoteRegionName: core.StringPtr("us-south"), + SourceSnapshotID: core.StringPtr("testString"), + SourceSnapshotRemoteRegionName: core.StringPtr("us-south"), + SourceVolumeRemoteRegionName: core.StringPtr("us-south"), + SourceImageRemoteRegionName: core.StringPtr("us-south"), + ClonesZoneName: core.StringPtr("us-south-1"), + SnapshotConsistencyGroupID: core.StringPtr("testString"), + SnapshotConsistencyGroupCRN: core.StringPtr("crn:v1:bluemix:public:is:us-south:a/123456::snapshot-consistency-group:r134-fa329f6b-0e36-433f-a3bb-0df632e79263"), + } + + pager, err := vpcService.NewSnapshotsPager(listSnapshotsOptionsModel) + Expect(err).To(BeNil()) + Expect(pager).ToNot(BeNil()) + + allResults, err := pager.GetAll() + Expect(err).To(BeNil()) + Expect(allResults).ToNot(BeNil()) + Expect(len(allResults)).To(Equal(2)) + }) + }) + }) + Describe(`CreateSnapshot(createSnapshotOptions *CreateSnapshotOptions) - Operation response error`, func() { + version := "testString" + createSnapshotPath := "/snapshots" + Context(`Using mock server endpoint with invalid JSON response`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Verify the contents of the request + Expect(req.URL.EscapedPath()).To(Equal(createSnapshotPath)) + Expect(req.Method).To(Equal("POST")) + Expect(req.URL.Query()["version"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["generation"]).To(Equal([]string{fmt.Sprint(int64(2))})) + res.Header().Set("Content-type", "application/json") + res.WriteHeader(201) + fmt.Fprint(res, `} this is not valid json {`) + })) + }) + It(`Invoke CreateSnapshot with error: Operation response processing error`, func() { + vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + Version: core.StringPtr(version), + }) + Expect(serviceErr).To(BeNil()) + Expect(vpcService).ToNot(BeNil()) + + // Construct an instance of the ZoneIdentityByName model + zoneIdentityModel := new(vpcv1.ZoneIdentityByName) + zoneIdentityModel.Name = core.StringPtr("us-south-1") + + // Construct an instance of the SnapshotClonePrototype model + snapshotClonePrototypeModel := new(vpcv1.SnapshotClonePrototype) + snapshotClonePrototypeModel.Zone = zoneIdentityModel + + // Construct an instance of the ResourceGroupIdentityByID model + resourceGroupIdentityModel := new(vpcv1.ResourceGroupIdentityByID) + resourceGroupIdentityModel.ID = core.StringPtr("fee82deba12e4c0fb69c3b09d1f12345") + + // Construct an instance of the VolumeIdentityByID model + volumeIdentityModel := new(vpcv1.VolumeIdentityByID) + volumeIdentityModel.ID = core.StringPtr("1a6b7274-678d-4dfb-8981-c71dd9d4daa5") + + // Construct an instance of the SnapshotPrototypeSnapshotBySourceVolume model + snapshotPrototypeModel := new(vpcv1.SnapshotPrototypeSnapshotBySourceVolume) + snapshotPrototypeModel.Clones = []vpcv1.SnapshotClonePrototype{*snapshotClonePrototypeModel} + snapshotPrototypeModel.Name = core.StringPtr("my-snapshot") + snapshotPrototypeModel.ResourceGroup = resourceGroupIdentityModel + snapshotPrototypeModel.UserTags = []string{} + snapshotPrototypeModel.SourceVolume = volumeIdentityModel + + // Construct an instance of the CreateSnapshotOptions model + createSnapshotOptionsModel := new(vpcv1.CreateSnapshotOptions) + createSnapshotOptionsModel.SnapshotPrototype = snapshotPrototypeModel + createSnapshotOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Expect response parsing to fail since we are receiving a text/plain response + result, response, operationErr := vpcService.CreateSnapshot(createSnapshotOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).To(BeNil()) + + // Enable retries and test again + vpcService.EnableRetries(0, 0) + result, response, operationErr = vpcService.CreateSnapshot(createSnapshotOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + }) + Describe(`CreateSnapshot(createSnapshotOptions *CreateSnapshotOptions)`, func() { + version := "testString" + createSnapshotPath := "/snapshots" + Context(`Using mock server endpoint with timeout`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Verify the contents of the request + Expect(req.URL.EscapedPath()).To(Equal(createSnapshotPath)) + Expect(req.Method).To(Equal("POST")) + + // For gzip-disabled operation, verify Content-Encoding is not set. + Expect(req.Header.Get("Content-Encoding")).To(BeEmpty()) + + // If there is a body, then make sure we can read it + bodyBuf := new(bytes.Buffer) + if req.Header.Get("Content-Encoding") == "gzip" { + body, err := core.NewGzipDecompressionReader(req.Body) + Expect(err).To(BeNil()) + _, err = bodyBuf.ReadFrom(body) + Expect(err).To(BeNil()) + } else { + _, err := bodyBuf.ReadFrom(req.Body) + Expect(err).To(BeNil()) + } + fmt.Fprintf(GinkgoWriter, " Request body: %s", bodyBuf.String()) + + Expect(req.URL.Query()["version"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["generation"]).To(Equal([]string{fmt.Sprint(int64(2))})) + // Sleep a short time to support a timeout test + time.Sleep(100 * time.Millisecond) + + // Set mock response + res.Header().Set("Content-type", "application/json") + res.WriteHeader(201) + fmt.Fprintf(res, "%s", `{"backup_policy_plan": {"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6/plans/r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "id": "r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "name": "my-policy-plan", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "backup_policy_plan"}, "bootable": true, "captured_at": "2019-01-01T12:00:00.000Z", "clones": [{"available": false, "created_at": "2019-01-01T12:00:00.000Z", "zone": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south/zones/us-south-1", "name": "us-south-1"}}], "copies": [{"crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "id": "r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "name": "my-snapshot", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "snapshot"}], "created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "deletable": false, "encryption": "provider_managed", "encryption_key": {"crn": "crn:v1:bluemix:public:kms:us-south:a/123456:e4a29d1a-2ef0-42a6-8fd2-350deb1c647e:key:5437653b-c4b1-447f-9646-b2a2a4cd6179"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "id": "r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "lifecycle_state": "stable", "minimum_capacity": 1, "name": "my-snapshot", "operating_system": {"architecture": "amd64", "dedicated_host_only": false, "display_name": "Ubuntu Server 16.04 LTS amd64", "family": "Ubuntu Server", "href": "https://us-south.iaas.cloud.ibm.com/v1/operating_systems/ubuntu-16-amd64", "name": "ubuntu-16-amd64", "vendor": "Canonical", "version": "16.04 LTS"}, "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "resource_type": "snapshot", "service_tags": ["ServiceTags"], "size": 1, "snapshot_consistency_group": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot-consistency-group:r134-fa329f6b-0e36-433f-a3bb-0df632e79263", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshot_consistency_groups/r134-fa329f6b-0e36-433f-a3bb-0df632e79263", "id": "r134-fa329f6b-0e36-433f-a3bb-0df632e79263", "name": "my-snapshot-consistency-group", "resource_type": "snapshot_consistency_group"}, "source_image": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::image:72b27b5c-f4b0-48bb-b954-5becc7c1dcb8", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/images/72b27b5c-f4b0-48bb-b954-5becc7c1dcb8", "id": "72b27b5c-f4b0-48bb-b954-5becc7c1dcb8", "name": "my-image", "remote": {"account": {"id": "aa2432b1fa4d4ace891e9b80fc104e34", "resource_type": "account"}, "region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "image"}, "source_snapshot": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "id": "r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "name": "my-snapshot", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "snapshot"}, "source_volume": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::volume:1a6b7274-678d-4dfb-8981-c71dd9d4daa5", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/volumes/1a6b7274-678d-4dfb-8981-c71dd9d4daa5", "id": "1a6b7274-678d-4dfb-8981-c71dd9d4daa5", "name": "my-volume", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "volume"}, "user_tags": ["UserTags"]}`) + })) + }) + It(`Invoke CreateSnapshot successfully with retries`, func() { + vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + Version: core.StringPtr(version), + }) + Expect(serviceErr).To(BeNil()) + Expect(vpcService).ToNot(BeNil()) + vpcService.EnableRetries(0, 0) + + // Construct an instance of the ZoneIdentityByName model + zoneIdentityModel := new(vpcv1.ZoneIdentityByName) + zoneIdentityModel.Name = core.StringPtr("us-south-1") + + // Construct an instance of the SnapshotClonePrototype model + snapshotClonePrototypeModel := new(vpcv1.SnapshotClonePrototype) + snapshotClonePrototypeModel.Zone = zoneIdentityModel + + // Construct an instance of the ResourceGroupIdentityByID model + resourceGroupIdentityModel := new(vpcv1.ResourceGroupIdentityByID) + resourceGroupIdentityModel.ID = core.StringPtr("fee82deba12e4c0fb69c3b09d1f12345") + + // Construct an instance of the VolumeIdentityByID model + volumeIdentityModel := new(vpcv1.VolumeIdentityByID) + volumeIdentityModel.ID = core.StringPtr("1a6b7274-678d-4dfb-8981-c71dd9d4daa5") + + // Construct an instance of the SnapshotPrototypeSnapshotBySourceVolume model + snapshotPrototypeModel := new(vpcv1.SnapshotPrototypeSnapshotBySourceVolume) + snapshotPrototypeModel.Clones = []vpcv1.SnapshotClonePrototype{*snapshotClonePrototypeModel} + snapshotPrototypeModel.Name = core.StringPtr("my-snapshot") + snapshotPrototypeModel.ResourceGroup = resourceGroupIdentityModel + snapshotPrototypeModel.UserTags = []string{} + snapshotPrototypeModel.SourceVolume = volumeIdentityModel + + // Construct an instance of the CreateSnapshotOptions model + createSnapshotOptionsModel := new(vpcv1.CreateSnapshotOptions) + createSnapshotOptionsModel.SnapshotPrototype = snapshotPrototypeModel + createSnapshotOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation with a Context to test a timeout error + ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond) + defer cancelFunc() + _, _, operationErr := vpcService.CreateSnapshotWithContext(ctx, createSnapshotOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) + + // Disable retries and test again + vpcService.DisableRetries() + result, response, operationErr := vpcService.CreateSnapshot(createSnapshotOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).ToNot(BeNil()) + + // Re-test the timeout error with retries disabled + ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond) + defer cancelFunc2() + _, _, operationErr = vpcService.CreateSnapshotWithContext(ctx, createSnapshotOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) + }) + AfterEach(func() { + testServer.Close() + }) + }) + Context(`Using mock server endpoint`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Verify the contents of the request + Expect(req.URL.EscapedPath()).To(Equal(createSnapshotPath)) + Expect(req.Method).To(Equal("POST")) + + // For gzip-disabled operation, verify Content-Encoding is not set. + Expect(req.Header.Get("Content-Encoding")).To(BeEmpty()) + + // If there is a body, then make sure we can read it + bodyBuf := new(bytes.Buffer) + if req.Header.Get("Content-Encoding") == "gzip" { + body, err := core.NewGzipDecompressionReader(req.Body) + Expect(err).To(BeNil()) + _, err = bodyBuf.ReadFrom(body) + Expect(err).To(BeNil()) + } else { + _, err := bodyBuf.ReadFrom(req.Body) + Expect(err).To(BeNil()) + } + fmt.Fprintf(GinkgoWriter, " Request body: %s", bodyBuf.String()) + + Expect(req.URL.Query()["version"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["generation"]).To(Equal([]string{fmt.Sprint(int64(2))})) + // Set mock response + res.Header().Set("Content-type", "application/json") + res.WriteHeader(201) + fmt.Fprintf(res, "%s", `{"backup_policy_plan": {"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6/plans/r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "id": "r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "name": "my-policy-plan", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "backup_policy_plan"}, "bootable": true, "captured_at": "2019-01-01T12:00:00.000Z", "clones": [{"available": false, "created_at": "2019-01-01T12:00:00.000Z", "zone": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south/zones/us-south-1", "name": "us-south-1"}}], "copies": [{"crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "id": "r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "name": "my-snapshot", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "snapshot"}], "created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "deletable": false, "encryption": "provider_managed", "encryption_key": {"crn": "crn:v1:bluemix:public:kms:us-south:a/123456:e4a29d1a-2ef0-42a6-8fd2-350deb1c647e:key:5437653b-c4b1-447f-9646-b2a2a4cd6179"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "id": "r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "lifecycle_state": "stable", "minimum_capacity": 1, "name": "my-snapshot", "operating_system": {"architecture": "amd64", "dedicated_host_only": false, "display_name": "Ubuntu Server 16.04 LTS amd64", "family": "Ubuntu Server", "href": "https://us-south.iaas.cloud.ibm.com/v1/operating_systems/ubuntu-16-amd64", "name": "ubuntu-16-amd64", "vendor": "Canonical", "version": "16.04 LTS"}, "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "resource_type": "snapshot", "service_tags": ["ServiceTags"], "size": 1, "snapshot_consistency_group": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot-consistency-group:r134-fa329f6b-0e36-433f-a3bb-0df632e79263", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshot_consistency_groups/r134-fa329f6b-0e36-433f-a3bb-0df632e79263", "id": "r134-fa329f6b-0e36-433f-a3bb-0df632e79263", "name": "my-snapshot-consistency-group", "resource_type": "snapshot_consistency_group"}, "source_image": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::image:72b27b5c-f4b0-48bb-b954-5becc7c1dcb8", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/images/72b27b5c-f4b0-48bb-b954-5becc7c1dcb8", "id": "72b27b5c-f4b0-48bb-b954-5becc7c1dcb8", "name": "my-image", "remote": {"account": {"id": "aa2432b1fa4d4ace891e9b80fc104e34", "resource_type": "account"}, "region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "image"}, "source_snapshot": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "id": "r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "name": "my-snapshot", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "snapshot"}, "source_volume": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::volume:1a6b7274-678d-4dfb-8981-c71dd9d4daa5", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/volumes/1a6b7274-678d-4dfb-8981-c71dd9d4daa5", "id": "1a6b7274-678d-4dfb-8981-c71dd9d4daa5", "name": "my-volume", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "volume"}, "user_tags": ["UserTags"]}`) + })) + }) + It(`Invoke CreateSnapshot successfully`, func() { + vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + Version: core.StringPtr(version), + }) + Expect(serviceErr).To(BeNil()) + Expect(vpcService).ToNot(BeNil()) + + // Invoke operation with nil options model (negative test) + result, response, operationErr := vpcService.CreateSnapshot(nil) + Expect(operationErr).NotTo(BeNil()) + Expect(response).To(BeNil()) + Expect(result).To(BeNil()) + + // Construct an instance of the ZoneIdentityByName model + zoneIdentityModel := new(vpcv1.ZoneIdentityByName) + zoneIdentityModel.Name = core.StringPtr("us-south-1") + + // Construct an instance of the SnapshotClonePrototype model + snapshotClonePrototypeModel := new(vpcv1.SnapshotClonePrototype) + snapshotClonePrototypeModel.Zone = zoneIdentityModel + + // Construct an instance of the ResourceGroupIdentityByID model + resourceGroupIdentityModel := new(vpcv1.ResourceGroupIdentityByID) + resourceGroupIdentityModel.ID = core.StringPtr("fee82deba12e4c0fb69c3b09d1f12345") + + // Construct an instance of the VolumeIdentityByID model + volumeIdentityModel := new(vpcv1.VolumeIdentityByID) + volumeIdentityModel.ID = core.StringPtr("1a6b7274-678d-4dfb-8981-c71dd9d4daa5") + + // Construct an instance of the SnapshotPrototypeSnapshotBySourceVolume model + snapshotPrototypeModel := new(vpcv1.SnapshotPrototypeSnapshotBySourceVolume) + snapshotPrototypeModel.Clones = []vpcv1.SnapshotClonePrototype{*snapshotClonePrototypeModel} + snapshotPrototypeModel.Name = core.StringPtr("my-snapshot") + snapshotPrototypeModel.ResourceGroup = resourceGroupIdentityModel + snapshotPrototypeModel.UserTags = []string{} + snapshotPrototypeModel.SourceVolume = volumeIdentityModel + + // Construct an instance of the CreateSnapshotOptions model + createSnapshotOptionsModel := new(vpcv1.CreateSnapshotOptions) + createSnapshotOptionsModel.SnapshotPrototype = snapshotPrototypeModel + createSnapshotOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation with valid options model (positive test) + result, response, operationErr = vpcService.CreateSnapshot(createSnapshotOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).ToNot(BeNil()) + + }) + It(`Invoke CreateSnapshot with error: Operation validation and request error`, func() { + vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + Version: core.StringPtr(version), + }) + Expect(serviceErr).To(BeNil()) + Expect(vpcService).ToNot(BeNil()) + + // Construct an instance of the ZoneIdentityByName model + zoneIdentityModel := new(vpcv1.ZoneIdentityByName) + zoneIdentityModel.Name = core.StringPtr("us-south-1") + + // Construct an instance of the SnapshotClonePrototype model + snapshotClonePrototypeModel := new(vpcv1.SnapshotClonePrototype) + snapshotClonePrototypeModel.Zone = zoneIdentityModel + + // Construct an instance of the ResourceGroupIdentityByID model + resourceGroupIdentityModel := new(vpcv1.ResourceGroupIdentityByID) + resourceGroupIdentityModel.ID = core.StringPtr("fee82deba12e4c0fb69c3b09d1f12345") + + // Construct an instance of the VolumeIdentityByID model + volumeIdentityModel := new(vpcv1.VolumeIdentityByID) + volumeIdentityModel.ID = core.StringPtr("1a6b7274-678d-4dfb-8981-c71dd9d4daa5") + + // Construct an instance of the SnapshotPrototypeSnapshotBySourceVolume model + snapshotPrototypeModel := new(vpcv1.SnapshotPrototypeSnapshotBySourceVolume) + snapshotPrototypeModel.Clones = []vpcv1.SnapshotClonePrototype{*snapshotClonePrototypeModel} + snapshotPrototypeModel.Name = core.StringPtr("my-snapshot") + snapshotPrototypeModel.ResourceGroup = resourceGroupIdentityModel + snapshotPrototypeModel.UserTags = []string{} + snapshotPrototypeModel.SourceVolume = volumeIdentityModel + + // Construct an instance of the CreateSnapshotOptions model + createSnapshotOptionsModel := new(vpcv1.CreateSnapshotOptions) + createSnapshotOptionsModel.SnapshotPrototype = snapshotPrototypeModel + createSnapshotOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Invoke operation with empty URL (negative test) + err := vpcService.SetServiceURL("") + Expect(err).To(BeNil()) + result, response, operationErr := vpcService.CreateSnapshot(createSnapshotOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING)) + Expect(response).To(BeNil()) + Expect(result).To(BeNil()) + // Construct a second instance of the CreateSnapshotOptions model with no property values + createSnapshotOptionsModelNew := new(vpcv1.CreateSnapshotOptions) + // Invoke operation with invalid model (negative test) + result, response, operationErr = vpcService.CreateSnapshot(createSnapshotOptionsModelNew) + Expect(operationErr).ToNot(BeNil()) + Expect(response).To(BeNil()) + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + Context(`Using mock server endpoint with missing response body`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Set success status code with no respoonse body + res.WriteHeader(201) + })) + }) + It(`Invoke CreateSnapshot successfully`, func() { + vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + Version: core.StringPtr(version), + }) + Expect(serviceErr).To(BeNil()) + Expect(vpcService).ToNot(BeNil()) + + // Construct an instance of the ZoneIdentityByName model + zoneIdentityModel := new(vpcv1.ZoneIdentityByName) + zoneIdentityModel.Name = core.StringPtr("us-south-1") + + // Construct an instance of the SnapshotClonePrototype model + snapshotClonePrototypeModel := new(vpcv1.SnapshotClonePrototype) + snapshotClonePrototypeModel.Zone = zoneIdentityModel + + // Construct an instance of the ResourceGroupIdentityByID model + resourceGroupIdentityModel := new(vpcv1.ResourceGroupIdentityByID) + resourceGroupIdentityModel.ID = core.StringPtr("fee82deba12e4c0fb69c3b09d1f12345") + + // Construct an instance of the VolumeIdentityByID model + volumeIdentityModel := new(vpcv1.VolumeIdentityByID) + volumeIdentityModel.ID = core.StringPtr("1a6b7274-678d-4dfb-8981-c71dd9d4daa5") + + // Construct an instance of the SnapshotPrototypeSnapshotBySourceVolume model + snapshotPrototypeModel := new(vpcv1.SnapshotPrototypeSnapshotBySourceVolume) + snapshotPrototypeModel.Clones = []vpcv1.SnapshotClonePrototype{*snapshotClonePrototypeModel} + snapshotPrototypeModel.Name = core.StringPtr("my-snapshot") + snapshotPrototypeModel.ResourceGroup = resourceGroupIdentityModel + snapshotPrototypeModel.UserTags = []string{} + snapshotPrototypeModel.SourceVolume = volumeIdentityModel + + // Construct an instance of the CreateSnapshotOptions model + createSnapshotOptionsModel := new(vpcv1.CreateSnapshotOptions) + createSnapshotOptionsModel.SnapshotPrototype = snapshotPrototypeModel + createSnapshotOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation + result, response, operationErr := vpcService.CreateSnapshot(createSnapshotOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + + // Verify a nil result + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + }) + Describe(`DeleteSnapshot(deleteSnapshotOptions *DeleteSnapshotOptions)`, func() { + version := "testString" + deleteSnapshotPath := "/snapshots/testString" + Context(`Using mock server endpoint`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Verify the contents of the request + Expect(req.URL.EscapedPath()).To(Equal(deleteSnapshotPath)) + Expect(req.Method).To(Equal("DELETE")) + + Expect(req.Header["If-Match"]).ToNot(BeNil()) + Expect(req.Header["If-Match"][0]).To(Equal(fmt.Sprintf("%v", `W/"96d225c4-56bd-43d9-98fc-d7148e5c5028"`))) + Expect(req.URL.Query()["version"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["generation"]).To(Equal([]string{fmt.Sprint(int64(2))})) + res.WriteHeader(204) + })) + }) + It(`Invoke DeleteSnapshot successfully`, func() { + vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + Version: core.StringPtr(version), + }) + Expect(serviceErr).To(BeNil()) + Expect(vpcService).ToNot(BeNil()) + + // Invoke operation with nil options model (negative test) + response, operationErr := vpcService.DeleteSnapshot(nil) + Expect(operationErr).NotTo(BeNil()) + Expect(response).To(BeNil()) + + // Construct an instance of the DeleteSnapshotOptions model + deleteSnapshotOptionsModel := new(vpcv1.DeleteSnapshotOptions) + deleteSnapshotOptionsModel.ID = core.StringPtr("testString") + deleteSnapshotOptionsModel.IfMatch = core.StringPtr(`W/"96d225c4-56bd-43d9-98fc-d7148e5c5028"`) + deleteSnapshotOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation with valid options model (positive test) + response, operationErr = vpcService.DeleteSnapshot(deleteSnapshotOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + }) + It(`Invoke DeleteSnapshot with error: Operation validation and request error`, func() { + vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + Version: core.StringPtr(version), + }) + Expect(serviceErr).To(BeNil()) + Expect(vpcService).ToNot(BeNil()) + + // Construct an instance of the DeleteSnapshotOptions model + deleteSnapshotOptionsModel := new(vpcv1.DeleteSnapshotOptions) + deleteSnapshotOptionsModel.ID = core.StringPtr("testString") + deleteSnapshotOptionsModel.IfMatch = core.StringPtr(`W/"96d225c4-56bd-43d9-98fc-d7148e5c5028"`) + deleteSnapshotOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Invoke operation with empty URL (negative test) + err := vpcService.SetServiceURL("") + Expect(err).To(BeNil()) + response, operationErr := vpcService.DeleteSnapshot(deleteSnapshotOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING)) + Expect(response).To(BeNil()) + // Construct a second instance of the DeleteSnapshotOptions model with no property values + deleteSnapshotOptionsModelNew := new(vpcv1.DeleteSnapshotOptions) + // Invoke operation with invalid model (negative test) + response, operationErr = vpcService.DeleteSnapshot(deleteSnapshotOptionsModelNew) + Expect(operationErr).ToNot(BeNil()) + Expect(response).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + }) + Describe(`GetSnapshot(getSnapshotOptions *GetSnapshotOptions) - Operation response error`, func() { + version := "testString" + getSnapshotPath := "/snapshots/testString" + Context(`Using mock server endpoint with invalid JSON response`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Verify the contents of the request + Expect(req.URL.EscapedPath()).To(Equal(getSnapshotPath)) + Expect(req.Method).To(Equal("GET")) + Expect(req.URL.Query()["version"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["generation"]).To(Equal([]string{fmt.Sprint(int64(2))})) + res.Header().Set("Content-type", "application/json") + res.WriteHeader(200) + fmt.Fprint(res, `} this is not valid json {`) + })) + }) + It(`Invoke GetSnapshot with error: Operation response processing error`, func() { + vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + Version: core.StringPtr(version), + }) + Expect(serviceErr).To(BeNil()) + Expect(vpcService).ToNot(BeNil()) + + // Construct an instance of the GetSnapshotOptions model + getSnapshotOptionsModel := new(vpcv1.GetSnapshotOptions) + getSnapshotOptionsModel.ID = core.StringPtr("testString") + getSnapshotOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Expect response parsing to fail since we are receiving a text/plain response + result, response, operationErr := vpcService.GetSnapshot(getSnapshotOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).To(BeNil()) + + // Enable retries and test again + vpcService.EnableRetries(0, 0) + result, response, operationErr = vpcService.GetSnapshot(getSnapshotOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + }) + Describe(`GetSnapshot(getSnapshotOptions *GetSnapshotOptions)`, func() { + version := "testString" + getSnapshotPath := "/snapshots/testString" + Context(`Using mock server endpoint with timeout`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Verify the contents of the request + Expect(req.URL.EscapedPath()).To(Equal(getSnapshotPath)) + Expect(req.Method).To(Equal("GET")) + + Expect(req.URL.Query()["version"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["generation"]).To(Equal([]string{fmt.Sprint(int64(2))})) + // Sleep a short time to support a timeout test + time.Sleep(100 * time.Millisecond) + + // Set mock response + res.Header().Set("Content-type", "application/json") + res.WriteHeader(200) + fmt.Fprintf(res, "%s", `{"backup_policy_plan": {"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6/plans/r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "id": "r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "name": "my-policy-plan", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "backup_policy_plan"}, "bootable": true, "captured_at": "2019-01-01T12:00:00.000Z", "clones": [{"available": false, "created_at": "2019-01-01T12:00:00.000Z", "zone": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south/zones/us-south-1", "name": "us-south-1"}}], "copies": [{"crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "id": "r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "name": "my-snapshot", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "snapshot"}], "created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "deletable": false, "encryption": "provider_managed", "encryption_key": {"crn": "crn:v1:bluemix:public:kms:us-south:a/123456:e4a29d1a-2ef0-42a6-8fd2-350deb1c647e:key:5437653b-c4b1-447f-9646-b2a2a4cd6179"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "id": "r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "lifecycle_state": "stable", "minimum_capacity": 1, "name": "my-snapshot", "operating_system": {"architecture": "amd64", "dedicated_host_only": false, "display_name": "Ubuntu Server 16.04 LTS amd64", "family": "Ubuntu Server", "href": "https://us-south.iaas.cloud.ibm.com/v1/operating_systems/ubuntu-16-amd64", "name": "ubuntu-16-amd64", "vendor": "Canonical", "version": "16.04 LTS"}, "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "resource_type": "snapshot", "service_tags": ["ServiceTags"], "size": 1, "snapshot_consistency_group": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot-consistency-group:r134-fa329f6b-0e36-433f-a3bb-0df632e79263", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshot_consistency_groups/r134-fa329f6b-0e36-433f-a3bb-0df632e79263", "id": "r134-fa329f6b-0e36-433f-a3bb-0df632e79263", "name": "my-snapshot-consistency-group", "resource_type": "snapshot_consistency_group"}, "source_image": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::image:72b27b5c-f4b0-48bb-b954-5becc7c1dcb8", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/images/72b27b5c-f4b0-48bb-b954-5becc7c1dcb8", "id": "72b27b5c-f4b0-48bb-b954-5becc7c1dcb8", "name": "my-image", "remote": {"account": {"id": "aa2432b1fa4d4ace891e9b80fc104e34", "resource_type": "account"}, "region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "image"}, "source_snapshot": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "id": "r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "name": "my-snapshot", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "snapshot"}, "source_volume": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::volume:1a6b7274-678d-4dfb-8981-c71dd9d4daa5", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/volumes/1a6b7274-678d-4dfb-8981-c71dd9d4daa5", "id": "1a6b7274-678d-4dfb-8981-c71dd9d4daa5", "name": "my-volume", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "volume"}, "user_tags": ["UserTags"]}`) + })) + }) + It(`Invoke GetSnapshot successfully with retries`, func() { + vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + Version: core.StringPtr(version), + }) + Expect(serviceErr).To(BeNil()) + Expect(vpcService).ToNot(BeNil()) + vpcService.EnableRetries(0, 0) + + // Construct an instance of the GetSnapshotOptions model + getSnapshotOptionsModel := new(vpcv1.GetSnapshotOptions) + getSnapshotOptionsModel.ID = core.StringPtr("testString") + getSnapshotOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation with a Context to test a timeout error + ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond) + defer cancelFunc() + _, _, operationErr := vpcService.GetSnapshotWithContext(ctx, getSnapshotOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) + + // Disable retries and test again + vpcService.DisableRetries() + result, response, operationErr := vpcService.GetSnapshot(getSnapshotOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).ToNot(BeNil()) + + // Re-test the timeout error with retries disabled + ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond) + defer cancelFunc2() + _, _, operationErr = vpcService.GetSnapshotWithContext(ctx, getSnapshotOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) + }) + AfterEach(func() { + testServer.Close() + }) + }) + Context(`Using mock server endpoint`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Verify the contents of the request + Expect(req.URL.EscapedPath()).To(Equal(getSnapshotPath)) + Expect(req.Method).To(Equal("GET")) + + Expect(req.URL.Query()["version"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["generation"]).To(Equal([]string{fmt.Sprint(int64(2))})) + // Set mock response + res.Header().Set("Content-type", "application/json") + res.WriteHeader(200) + fmt.Fprintf(res, "%s", `{"backup_policy_plan": {"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6/plans/r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "id": "r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "name": "my-policy-plan", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "backup_policy_plan"}, "bootable": true, "captured_at": "2019-01-01T12:00:00.000Z", "clones": [{"available": false, "created_at": "2019-01-01T12:00:00.000Z", "zone": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south/zones/us-south-1", "name": "us-south-1"}}], "copies": [{"crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "id": "r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "name": "my-snapshot", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "snapshot"}], "created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "deletable": false, "encryption": "provider_managed", "encryption_key": {"crn": "crn:v1:bluemix:public:kms:us-south:a/123456:e4a29d1a-2ef0-42a6-8fd2-350deb1c647e:key:5437653b-c4b1-447f-9646-b2a2a4cd6179"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "id": "r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "lifecycle_state": "stable", "minimum_capacity": 1, "name": "my-snapshot", "operating_system": {"architecture": "amd64", "dedicated_host_only": false, "display_name": "Ubuntu Server 16.04 LTS amd64", "family": "Ubuntu Server", "href": "https://us-south.iaas.cloud.ibm.com/v1/operating_systems/ubuntu-16-amd64", "name": "ubuntu-16-amd64", "vendor": "Canonical", "version": "16.04 LTS"}, "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "resource_type": "snapshot", "service_tags": ["ServiceTags"], "size": 1, "snapshot_consistency_group": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot-consistency-group:r134-fa329f6b-0e36-433f-a3bb-0df632e79263", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshot_consistency_groups/r134-fa329f6b-0e36-433f-a3bb-0df632e79263", "id": "r134-fa329f6b-0e36-433f-a3bb-0df632e79263", "name": "my-snapshot-consistency-group", "resource_type": "snapshot_consistency_group"}, "source_image": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::image:72b27b5c-f4b0-48bb-b954-5becc7c1dcb8", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/images/72b27b5c-f4b0-48bb-b954-5becc7c1dcb8", "id": "72b27b5c-f4b0-48bb-b954-5becc7c1dcb8", "name": "my-image", "remote": {"account": {"id": "aa2432b1fa4d4ace891e9b80fc104e34", "resource_type": "account"}, "region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "image"}, "source_snapshot": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "id": "r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "name": "my-snapshot", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "snapshot"}, "source_volume": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::volume:1a6b7274-678d-4dfb-8981-c71dd9d4daa5", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/volumes/1a6b7274-678d-4dfb-8981-c71dd9d4daa5", "id": "1a6b7274-678d-4dfb-8981-c71dd9d4daa5", "name": "my-volume", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "volume"}, "user_tags": ["UserTags"]}`) + })) + }) + It(`Invoke GetSnapshot successfully`, func() { + vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + Version: core.StringPtr(version), + }) + Expect(serviceErr).To(BeNil()) + Expect(vpcService).ToNot(BeNil()) + + // Invoke operation with nil options model (negative test) + result, response, operationErr := vpcService.GetSnapshot(nil) + Expect(operationErr).NotTo(BeNil()) + Expect(response).To(BeNil()) + Expect(result).To(BeNil()) + + // Construct an instance of the GetSnapshotOptions model + getSnapshotOptionsModel := new(vpcv1.GetSnapshotOptions) + getSnapshotOptionsModel.ID = core.StringPtr("testString") + getSnapshotOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation with valid options model (positive test) + result, response, operationErr = vpcService.GetSnapshot(getSnapshotOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).ToNot(BeNil()) + + }) + It(`Invoke GetSnapshot with error: Operation validation and request error`, func() { + vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + Version: core.StringPtr(version), + }) + Expect(serviceErr).To(BeNil()) + Expect(vpcService).ToNot(BeNil()) + + // Construct an instance of the GetSnapshotOptions model + getSnapshotOptionsModel := new(vpcv1.GetSnapshotOptions) + getSnapshotOptionsModel.ID = core.StringPtr("testString") + getSnapshotOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Invoke operation with empty URL (negative test) + err := vpcService.SetServiceURL("") + Expect(err).To(BeNil()) + result, response, operationErr := vpcService.GetSnapshot(getSnapshotOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING)) + Expect(response).To(BeNil()) + Expect(result).To(BeNil()) + // Construct a second instance of the GetSnapshotOptions model with no property values + getSnapshotOptionsModelNew := new(vpcv1.GetSnapshotOptions) + // Invoke operation with invalid model (negative test) + result, response, operationErr = vpcService.GetSnapshot(getSnapshotOptionsModelNew) + Expect(operationErr).ToNot(BeNil()) + Expect(response).To(BeNil()) + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + Context(`Using mock server endpoint with missing response body`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Set success status code with no respoonse body + res.WriteHeader(200) + })) + }) + It(`Invoke GetSnapshot successfully`, func() { + vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + Version: core.StringPtr(version), + }) + Expect(serviceErr).To(BeNil()) + Expect(vpcService).ToNot(BeNil()) + + // Construct an instance of the GetSnapshotOptions model + getSnapshotOptionsModel := new(vpcv1.GetSnapshotOptions) + getSnapshotOptionsModel.ID = core.StringPtr("testString") + getSnapshotOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation + result, response, operationErr := vpcService.GetSnapshot(getSnapshotOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + + // Verify a nil result + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + }) + Describe(`UpdateSnapshot(updateSnapshotOptions *UpdateSnapshotOptions) - Operation response error`, func() { + version := "testString" + updateSnapshotPath := "/snapshots/testString" + Context(`Using mock server endpoint with invalid JSON response`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Verify the contents of the request + Expect(req.URL.EscapedPath()).To(Equal(updateSnapshotPath)) + Expect(req.Method).To(Equal("PATCH")) + Expect(req.Header["If-Match"]).ToNot(BeNil()) + Expect(req.Header["If-Match"][0]).To(Equal(fmt.Sprintf("%v", `W/"96d225c4-56bd-43d9-98fc-d7148e5c5028"`))) + Expect(req.URL.Query()["version"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["generation"]).To(Equal([]string{fmt.Sprint(int64(2))})) + res.Header().Set("Content-type", "application/json") + res.WriteHeader(200) + fmt.Fprint(res, `} this is not valid json {`) + })) + }) + It(`Invoke UpdateSnapshot with error: Operation response processing error`, func() { + vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + Version: core.StringPtr(version), + }) + Expect(serviceErr).To(BeNil()) + Expect(vpcService).ToNot(BeNil()) + + // Construct an instance of the SnapshotPatch model + snapshotPatchModel := new(vpcv1.SnapshotPatch) + snapshotPatchModel.Name = core.StringPtr("my-snapshot") + snapshotPatchModel.UserTags = []string{"testString"} + snapshotPatchModelAsPatch, asPatchErr := snapshotPatchModel.AsPatch() + Expect(asPatchErr).To(BeNil()) + + // Construct an instance of the UpdateSnapshotOptions model + updateSnapshotOptionsModel := new(vpcv1.UpdateSnapshotOptions) + updateSnapshotOptionsModel.ID = core.StringPtr("testString") + updateSnapshotOptionsModel.SnapshotPatch = snapshotPatchModelAsPatch + updateSnapshotOptionsModel.IfMatch = core.StringPtr(`W/"96d225c4-56bd-43d9-98fc-d7148e5c5028"`) + updateSnapshotOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Expect response parsing to fail since we are receiving a text/plain response + result, response, operationErr := vpcService.UpdateSnapshot(updateSnapshotOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).To(BeNil()) + + // Enable retries and test again + vpcService.EnableRetries(0, 0) + result, response, operationErr = vpcService.UpdateSnapshot(updateSnapshotOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + }) + Describe(`UpdateSnapshot(updateSnapshotOptions *UpdateSnapshotOptions)`, func() { + version := "testString" + updateSnapshotPath := "/snapshots/testString" + Context(`Using mock server endpoint with timeout`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Verify the contents of the request + Expect(req.URL.EscapedPath()).To(Equal(updateSnapshotPath)) + Expect(req.Method).To(Equal("PATCH")) + + // For gzip-disabled operation, verify Content-Encoding is not set. + Expect(req.Header.Get("Content-Encoding")).To(BeEmpty()) + + // If there is a body, then make sure we can read it + bodyBuf := new(bytes.Buffer) + if req.Header.Get("Content-Encoding") == "gzip" { + body, err := core.NewGzipDecompressionReader(req.Body) + Expect(err).To(BeNil()) + _, err = bodyBuf.ReadFrom(body) + Expect(err).To(BeNil()) + } else { + _, err := bodyBuf.ReadFrom(req.Body) + Expect(err).To(BeNil()) + } + fmt.Fprintf(GinkgoWriter, " Request body: %s", bodyBuf.String()) + + Expect(req.Header["If-Match"]).ToNot(BeNil()) + Expect(req.Header["If-Match"][0]).To(Equal(fmt.Sprintf("%v", `W/"96d225c4-56bd-43d9-98fc-d7148e5c5028"`))) + Expect(req.URL.Query()["version"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["generation"]).To(Equal([]string{fmt.Sprint(int64(2))})) + // Sleep a short time to support a timeout test + time.Sleep(100 * time.Millisecond) + + // Set mock response + res.Header().Set("Content-type", "application/json") + res.WriteHeader(200) + fmt.Fprintf(res, "%s", `{"backup_policy_plan": {"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6/plans/r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "id": "r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "name": "my-policy-plan", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "backup_policy_plan"}, "bootable": true, "captured_at": "2019-01-01T12:00:00.000Z", "clones": [{"available": false, "created_at": "2019-01-01T12:00:00.000Z", "zone": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south/zones/us-south-1", "name": "us-south-1"}}], "copies": [{"crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "id": "r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "name": "my-snapshot", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "snapshot"}], "created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "deletable": false, "encryption": "provider_managed", "encryption_key": {"crn": "crn:v1:bluemix:public:kms:us-south:a/123456:e4a29d1a-2ef0-42a6-8fd2-350deb1c647e:key:5437653b-c4b1-447f-9646-b2a2a4cd6179"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "id": "r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "lifecycle_state": "stable", "minimum_capacity": 1, "name": "my-snapshot", "operating_system": {"architecture": "amd64", "dedicated_host_only": false, "display_name": "Ubuntu Server 16.04 LTS amd64", "family": "Ubuntu Server", "href": "https://us-south.iaas.cloud.ibm.com/v1/operating_systems/ubuntu-16-amd64", "name": "ubuntu-16-amd64", "vendor": "Canonical", "version": "16.04 LTS"}, "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "resource_type": "snapshot", "service_tags": ["ServiceTags"], "size": 1, "snapshot_consistency_group": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot-consistency-group:r134-fa329f6b-0e36-433f-a3bb-0df632e79263", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshot_consistency_groups/r134-fa329f6b-0e36-433f-a3bb-0df632e79263", "id": "r134-fa329f6b-0e36-433f-a3bb-0df632e79263", "name": "my-snapshot-consistency-group", "resource_type": "snapshot_consistency_group"}, "source_image": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::image:72b27b5c-f4b0-48bb-b954-5becc7c1dcb8", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/images/72b27b5c-f4b0-48bb-b954-5becc7c1dcb8", "id": "72b27b5c-f4b0-48bb-b954-5becc7c1dcb8", "name": "my-image", "remote": {"account": {"id": "aa2432b1fa4d4ace891e9b80fc104e34", "resource_type": "account"}, "region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "image"}, "source_snapshot": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "id": "r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "name": "my-snapshot", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "snapshot"}, "source_volume": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::volume:1a6b7274-678d-4dfb-8981-c71dd9d4daa5", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/volumes/1a6b7274-678d-4dfb-8981-c71dd9d4daa5", "id": "1a6b7274-678d-4dfb-8981-c71dd9d4daa5", "name": "my-volume", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "volume"}, "user_tags": ["UserTags"]}`) + })) + }) + It(`Invoke UpdateSnapshot successfully with retries`, func() { + vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + Version: core.StringPtr(version), + }) + Expect(serviceErr).To(BeNil()) + Expect(vpcService).ToNot(BeNil()) + vpcService.EnableRetries(0, 0) + + // Construct an instance of the SnapshotPatch model + snapshotPatchModel := new(vpcv1.SnapshotPatch) + snapshotPatchModel.Name = core.StringPtr("my-snapshot") + snapshotPatchModel.UserTags = []string{"testString"} + snapshotPatchModelAsPatch, asPatchErr := snapshotPatchModel.AsPatch() + Expect(asPatchErr).To(BeNil()) + + // Construct an instance of the UpdateSnapshotOptions model + updateSnapshotOptionsModel := new(vpcv1.UpdateSnapshotOptions) + updateSnapshotOptionsModel.ID = core.StringPtr("testString") + updateSnapshotOptionsModel.SnapshotPatch = snapshotPatchModelAsPatch + updateSnapshotOptionsModel.IfMatch = core.StringPtr(`W/"96d225c4-56bd-43d9-98fc-d7148e5c5028"`) + updateSnapshotOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation with a Context to test a timeout error + ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond) + defer cancelFunc() + _, _, operationErr := vpcService.UpdateSnapshotWithContext(ctx, updateSnapshotOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) + + // Disable retries and test again + vpcService.DisableRetries() + result, response, operationErr := vpcService.UpdateSnapshot(updateSnapshotOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).ToNot(BeNil()) + + // Re-test the timeout error with retries disabled + ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond) + defer cancelFunc2() + _, _, operationErr = vpcService.UpdateSnapshotWithContext(ctx, updateSnapshotOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) + }) + AfterEach(func() { + testServer.Close() + }) + }) + Context(`Using mock server endpoint`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Verify the contents of the request + Expect(req.URL.EscapedPath()).To(Equal(updateSnapshotPath)) + Expect(req.Method).To(Equal("PATCH")) + + // For gzip-disabled operation, verify Content-Encoding is not set. + Expect(req.Header.Get("Content-Encoding")).To(BeEmpty()) + + // If there is a body, then make sure we can read it + bodyBuf := new(bytes.Buffer) + if req.Header.Get("Content-Encoding") == "gzip" { + body, err := core.NewGzipDecompressionReader(req.Body) + Expect(err).To(BeNil()) + _, err = bodyBuf.ReadFrom(body) + Expect(err).To(BeNil()) + } else { + _, err := bodyBuf.ReadFrom(req.Body) + Expect(err).To(BeNil()) + } + fmt.Fprintf(GinkgoWriter, " Request body: %s", bodyBuf.String()) + + Expect(req.Header["If-Match"]).ToNot(BeNil()) + Expect(req.Header["If-Match"][0]).To(Equal(fmt.Sprintf("%v", `W/"96d225c4-56bd-43d9-98fc-d7148e5c5028"`))) + Expect(req.URL.Query()["version"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["generation"]).To(Equal([]string{fmt.Sprint(int64(2))})) + // Set mock response + res.Header().Set("Content-type", "application/json") + res.WriteHeader(200) + fmt.Fprintf(res, "%s", `{"backup_policy_plan": {"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6/plans/r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "id": "r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "name": "my-policy-plan", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "backup_policy_plan"}, "bootable": true, "captured_at": "2019-01-01T12:00:00.000Z", "clones": [{"available": false, "created_at": "2019-01-01T12:00:00.000Z", "zone": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south/zones/us-south-1", "name": "us-south-1"}}], "copies": [{"crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "id": "r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "name": "my-snapshot", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "snapshot"}], "created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "deletable": false, "encryption": "provider_managed", "encryption_key": {"crn": "crn:v1:bluemix:public:kms:us-south:a/123456:e4a29d1a-2ef0-42a6-8fd2-350deb1c647e:key:5437653b-c4b1-447f-9646-b2a2a4cd6179"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "id": "r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "lifecycle_state": "stable", "minimum_capacity": 1, "name": "my-snapshot", "operating_system": {"architecture": "amd64", "dedicated_host_only": false, "display_name": "Ubuntu Server 16.04 LTS amd64", "family": "Ubuntu Server", "href": "https://us-south.iaas.cloud.ibm.com/v1/operating_systems/ubuntu-16-amd64", "name": "ubuntu-16-amd64", "vendor": "Canonical", "version": "16.04 LTS"}, "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "resource_type": "snapshot", "service_tags": ["ServiceTags"], "size": 1, "snapshot_consistency_group": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot-consistency-group:r134-fa329f6b-0e36-433f-a3bb-0df632e79263", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshot_consistency_groups/r134-fa329f6b-0e36-433f-a3bb-0df632e79263", "id": "r134-fa329f6b-0e36-433f-a3bb-0df632e79263", "name": "my-snapshot-consistency-group", "resource_type": "snapshot_consistency_group"}, "source_image": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::image:72b27b5c-f4b0-48bb-b954-5becc7c1dcb8", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/images/72b27b5c-f4b0-48bb-b954-5becc7c1dcb8", "id": "72b27b5c-f4b0-48bb-b954-5becc7c1dcb8", "name": "my-image", "remote": {"account": {"id": "aa2432b1fa4d4ace891e9b80fc104e34", "resource_type": "account"}, "region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "image"}, "source_snapshot": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "id": "r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "name": "my-snapshot", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "snapshot"}, "source_volume": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::volume:1a6b7274-678d-4dfb-8981-c71dd9d4daa5", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/volumes/1a6b7274-678d-4dfb-8981-c71dd9d4daa5", "id": "1a6b7274-678d-4dfb-8981-c71dd9d4daa5", "name": "my-volume", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "volume"}, "user_tags": ["UserTags"]}`) })) }) It(`Invoke UpdateSnapshot successfully`, func() { @@ -91286,23 +92821,29 @@ var _ = Describe(`VpcV1`, func() { backupPolicyScopePrototypeModel.CRN = core.StringPtr("crn:v1:bluemix:public:enterprise::a/123456::enterprise:ebc2b430240943458b9e91e1432cfcce") Expect(backupPolicyScopePrototypeModel.CRN).To(Equal(core.StringPtr("crn:v1:bluemix:public:enterprise::a/123456::enterprise:ebc2b430240943458b9e91e1432cfcce"))) + // Construct an instance of the BackupPolicyPrototypeBackupPolicyMatchResourceTypeVolumePrototype model + backupPolicyPrototypeModel := new(vpcv1.BackupPolicyPrototypeBackupPolicyMatchResourceTypeVolumePrototype) + Expect(backupPolicyPrototypeModel).ToNot(BeNil()) + backupPolicyPrototypeModel.MatchUserTags = []string{"my-daily-backup-policy"} + backupPolicyPrototypeModel.Name = core.StringPtr("my-backup-policy") + backupPolicyPrototypeModel.Plans = []vpcv1.BackupPolicyPlanPrototype{*backupPolicyPlanPrototypeModel} + backupPolicyPrototypeModel.ResourceGroup = resourceGroupIdentityModel + backupPolicyPrototypeModel.Scope = backupPolicyScopePrototypeModel + backupPolicyPrototypeModel.MatchResourceType = core.StringPtr("volume") + Expect(backupPolicyPrototypeModel.MatchUserTags).To(Equal([]string{"my-daily-backup-policy"})) + Expect(backupPolicyPrototypeModel.Name).To(Equal(core.StringPtr("my-backup-policy"))) + Expect(backupPolicyPrototypeModel.Plans).To(Equal([]vpcv1.BackupPolicyPlanPrototype{*backupPolicyPlanPrototypeModel})) + Expect(backupPolicyPrototypeModel.ResourceGroup).To(Equal(resourceGroupIdentityModel)) + Expect(backupPolicyPrototypeModel.Scope).To(Equal(backupPolicyScopePrototypeModel)) + Expect(backupPolicyPrototypeModel.MatchResourceType).To(Equal(core.StringPtr("volume"))) + // Construct an instance of the CreateBackupPolicyOptions model - createBackupPolicyOptionsMatchUserTags := []string{"my-daily-backup-policy"} - createBackupPolicyOptionsModel := vpcService.NewCreateBackupPolicyOptions(createBackupPolicyOptionsMatchUserTags) - createBackupPolicyOptionsModel.SetMatchUserTags([]string{"my-daily-backup-policy"}) - createBackupPolicyOptionsModel.SetMatchResourceTypes([]string{"volume"}) - createBackupPolicyOptionsModel.SetName("my-backup-policy") - createBackupPolicyOptionsModel.SetPlans([]vpcv1.BackupPolicyPlanPrototype{*backupPolicyPlanPrototypeModel}) - createBackupPolicyOptionsModel.SetResourceGroup(resourceGroupIdentityModel) - createBackupPolicyOptionsModel.SetScope(backupPolicyScopePrototypeModel) + var backupPolicyPrototype vpcv1.BackupPolicyPrototypeIntf = nil + createBackupPolicyOptionsModel := vpcService.NewCreateBackupPolicyOptions(backupPolicyPrototype) + createBackupPolicyOptionsModel.SetBackupPolicyPrototype(backupPolicyPrototypeModel) createBackupPolicyOptionsModel.SetHeaders(map[string]string{"foo": "bar"}) Expect(createBackupPolicyOptionsModel).ToNot(BeNil()) - Expect(createBackupPolicyOptionsModel.MatchUserTags).To(Equal([]string{"my-daily-backup-policy"})) - Expect(createBackupPolicyOptionsModel.MatchResourceTypes).To(Equal([]string{"volume"})) - Expect(createBackupPolicyOptionsModel.Name).To(Equal(core.StringPtr("my-backup-policy"))) - Expect(createBackupPolicyOptionsModel.Plans).To(Equal([]vpcv1.BackupPolicyPlanPrototype{*backupPolicyPlanPrototypeModel})) - Expect(createBackupPolicyOptionsModel.ResourceGroup).To(Equal(resourceGroupIdentityModel)) - Expect(createBackupPolicyOptionsModel.Scope).To(Equal(backupPolicyScopePrototypeModel)) + Expect(createBackupPolicyOptionsModel.BackupPolicyPrototype).To(Equal(backupPolicyPrototypeModel)) Expect(createBackupPolicyOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) }) It(`Invoke NewCreateBackupPolicyPlanOptions successfully`, func() { @@ -93539,6 +95080,50 @@ var _ = Describe(`VpcV1`, func() { Expect(createSnapshotCloneOptionsModel.ZoneName).To(Equal(core.StringPtr("testString"))) Expect(createSnapshotCloneOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) }) + It(`Invoke NewCreateSnapshotConsistencyGroupOptions successfully`, func() { + // Construct an instance of the ResourceGroupIdentityByID model + resourceGroupIdentityModel := new(vpcv1.ResourceGroupIdentityByID) + Expect(resourceGroupIdentityModel).ToNot(BeNil()) + resourceGroupIdentityModel.ID = core.StringPtr("fee82deba12e4c0fb69c3b09d1f12345") + Expect(resourceGroupIdentityModel.ID).To(Equal(core.StringPtr("fee82deba12e4c0fb69c3b09d1f12345"))) + + // Construct an instance of the VolumeIdentityByID model + volumeIdentityModel := new(vpcv1.VolumeIdentityByID) + Expect(volumeIdentityModel).ToNot(BeNil()) + volumeIdentityModel.ID = core.StringPtr("1a6b7274-678d-4dfb-8981-c71dd9d4daa5") + Expect(volumeIdentityModel.ID).To(Equal(core.StringPtr("1a6b7274-678d-4dfb-8981-c71dd9d4daa5"))) + + // Construct an instance of the SnapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshotsSnapshotsItem model + snapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshotsSnapshotsItemModel := new(vpcv1.SnapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshotsSnapshotsItem) + Expect(snapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshotsSnapshotsItemModel).ToNot(BeNil()) + snapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshotsSnapshotsItemModel.Name = core.StringPtr("my-snapshot") + snapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshotsSnapshotsItemModel.SourceVolume = volumeIdentityModel + snapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshotsSnapshotsItemModel.UserTags = []string{"testString"} + Expect(snapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshotsSnapshotsItemModel.Name).To(Equal(core.StringPtr("my-snapshot"))) + Expect(snapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshotsSnapshotsItemModel.SourceVolume).To(Equal(volumeIdentityModel)) + Expect(snapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshotsSnapshotsItemModel.UserTags).To(Equal([]string{"testString"})) + + // Construct an instance of the SnapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshots model + snapshotConsistencyGroupPrototypeModel := new(vpcv1.SnapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshots) + Expect(snapshotConsistencyGroupPrototypeModel).ToNot(BeNil()) + snapshotConsistencyGroupPrototypeModel.DeleteSnapshotsOnDelete = core.BoolPtr(true) + snapshotConsistencyGroupPrototypeModel.Name = core.StringPtr("my-snapshot-consistency-group") + snapshotConsistencyGroupPrototypeModel.ResourceGroup = resourceGroupIdentityModel + snapshotConsistencyGroupPrototypeModel.Snapshots = []vpcv1.SnapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshotsSnapshotsItem{*snapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshotsSnapshotsItemModel} + Expect(snapshotConsistencyGroupPrototypeModel.DeleteSnapshotsOnDelete).To(Equal(core.BoolPtr(true))) + Expect(snapshotConsistencyGroupPrototypeModel.Name).To(Equal(core.StringPtr("my-snapshot-consistency-group"))) + Expect(snapshotConsistencyGroupPrototypeModel.ResourceGroup).To(Equal(resourceGroupIdentityModel)) + Expect(snapshotConsistencyGroupPrototypeModel.Snapshots).To(Equal([]vpcv1.SnapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshotsSnapshotsItem{*snapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshotsSnapshotsItemModel})) + + // Construct an instance of the CreateSnapshotConsistencyGroupOptions model + var snapshotConsistencyGroupPrototype vpcv1.SnapshotConsistencyGroupPrototypeIntf = nil + createSnapshotConsistencyGroupOptionsModel := vpcService.NewCreateSnapshotConsistencyGroupOptions(snapshotConsistencyGroupPrototype) + createSnapshotConsistencyGroupOptionsModel.SetSnapshotConsistencyGroupPrototype(snapshotConsistencyGroupPrototypeModel) + createSnapshotConsistencyGroupOptionsModel.SetHeaders(map[string]string{"foo": "bar"}) + Expect(createSnapshotConsistencyGroupOptionsModel).ToNot(BeNil()) + Expect(createSnapshotConsistencyGroupOptionsModel.SnapshotConsistencyGroupPrototype).To(Equal(snapshotConsistencyGroupPrototypeModel)) + Expect(createSnapshotConsistencyGroupOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) + }) It(`Invoke NewCreateSnapshotOptions successfully`, func() { // Construct an instance of the ZoneIdentityByName model zoneIdentityModel := new(vpcv1.ZoneIdentityByName) @@ -94660,6 +96245,16 @@ var _ = Describe(`VpcV1`, func() { Expect(deleteSnapshotCloneOptionsModel.ZoneName).To(Equal(core.StringPtr("testString"))) Expect(deleteSnapshotCloneOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) }) + It(`Invoke NewDeleteSnapshotConsistencyGroupOptions successfully`, func() { + // Construct an instance of the DeleteSnapshotConsistencyGroupOptions model + id := "testString" + deleteSnapshotConsistencyGroupOptionsModel := vpcService.NewDeleteSnapshotConsistencyGroupOptions(id) + deleteSnapshotConsistencyGroupOptionsModel.SetID("testString") + deleteSnapshotConsistencyGroupOptionsModel.SetHeaders(map[string]string{"foo": "bar"}) + Expect(deleteSnapshotConsistencyGroupOptionsModel).ToNot(BeNil()) + Expect(deleteSnapshotConsistencyGroupOptionsModel.ID).To(Equal(core.StringPtr("testString"))) + Expect(deleteSnapshotConsistencyGroupOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) + }) It(`Invoke NewDeleteSnapshotOptions successfully`, func() { // Construct an instance of the DeleteSnapshotOptions model id := "testString" @@ -95614,6 +97209,16 @@ var _ = Describe(`VpcV1`, func() { Expect(getSnapshotCloneOptionsModel.ZoneName).To(Equal(core.StringPtr("testString"))) Expect(getSnapshotCloneOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) }) + It(`Invoke NewGetSnapshotConsistencyGroupOptions successfully`, func() { + // Construct an instance of the GetSnapshotConsistencyGroupOptions model + id := "testString" + getSnapshotConsistencyGroupOptionsModel := vpcService.NewGetSnapshotConsistencyGroupOptions(id) + getSnapshotConsistencyGroupOptionsModel.SetID("testString") + getSnapshotConsistencyGroupOptionsModel.SetHeaders(map[string]string{"foo": "bar"}) + Expect(getSnapshotConsistencyGroupOptionsModel).ToNot(BeNil()) + Expect(getSnapshotConsistencyGroupOptionsModel.ID).To(Equal(core.StringPtr("testString"))) + Expect(getSnapshotConsistencyGroupOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) + }) It(`Invoke NewGetSnapshotOptions successfully`, func() { // Construct an instance of the GetSnapshotOptions model id := "testString" @@ -96710,6 +98315,25 @@ var _ = Describe(`VpcV1`, func() { Expect(listSnapshotClonesOptionsModel.ID).To(Equal(core.StringPtr("testString"))) Expect(listSnapshotClonesOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) }) + It(`Invoke NewListSnapshotConsistencyGroupsOptions successfully`, func() { + // Construct an instance of the ListSnapshotConsistencyGroupsOptions model + listSnapshotConsistencyGroupsOptionsModel := vpcService.NewListSnapshotConsistencyGroupsOptions() + listSnapshotConsistencyGroupsOptionsModel.SetStart("testString") + listSnapshotConsistencyGroupsOptionsModel.SetLimit(int64(10)) + listSnapshotConsistencyGroupsOptionsModel.SetResourceGroupID("testString") + listSnapshotConsistencyGroupsOptionsModel.SetName("testString") + listSnapshotConsistencyGroupsOptionsModel.SetSort("name") + listSnapshotConsistencyGroupsOptionsModel.SetBackupPolicyPlanID("testString") + listSnapshotConsistencyGroupsOptionsModel.SetHeaders(map[string]string{"foo": "bar"}) + Expect(listSnapshotConsistencyGroupsOptionsModel).ToNot(BeNil()) + Expect(listSnapshotConsistencyGroupsOptionsModel.Start).To(Equal(core.StringPtr("testString"))) + Expect(listSnapshotConsistencyGroupsOptionsModel.Limit).To(Equal(core.Int64Ptr(int64(10)))) + Expect(listSnapshotConsistencyGroupsOptionsModel.ResourceGroupID).To(Equal(core.StringPtr("testString"))) + Expect(listSnapshotConsistencyGroupsOptionsModel.Name).To(Equal(core.StringPtr("testString"))) + Expect(listSnapshotConsistencyGroupsOptionsModel.Sort).To(Equal(core.StringPtr("name"))) + Expect(listSnapshotConsistencyGroupsOptionsModel.BackupPolicyPlanID).To(Equal(core.StringPtr("testString"))) + Expect(listSnapshotConsistencyGroupsOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) + }) It(`Invoke NewListSnapshotsOptions successfully`, func() { // Construct an instance of the ListSnapshotsOptions model listSnapshotsOptionsModel := vpcService.NewListSnapshotsOptions() @@ -96733,6 +98357,8 @@ var _ = Describe(`VpcV1`, func() { listSnapshotsOptionsModel.SetSourceVolumeRemoteRegionName("us-south") listSnapshotsOptionsModel.SetSourceImageRemoteRegionName("us-south") listSnapshotsOptionsModel.SetClonesZoneName("us-south-1") + listSnapshotsOptionsModel.SetSnapshotConsistencyGroupID("testString") + listSnapshotsOptionsModel.SetSnapshotConsistencyGroupCRN("crn:v1:bluemix:public:is:us-south:a/123456::snapshot-consistency-group:r134-fa329f6b-0e36-433f-a3bb-0df632e79263") listSnapshotsOptionsModel.SetHeaders(map[string]string{"foo": "bar"}) Expect(listSnapshotsOptionsModel).ToNot(BeNil()) Expect(listSnapshotsOptionsModel.Start).To(Equal(core.StringPtr("testString"))) @@ -96755,6 +98381,8 @@ var _ = Describe(`VpcV1`, func() { Expect(listSnapshotsOptionsModel.SourceVolumeRemoteRegionName).To(Equal(core.StringPtr("us-south"))) Expect(listSnapshotsOptionsModel.SourceImageRemoteRegionName).To(Equal(core.StringPtr("us-south"))) Expect(listSnapshotsOptionsModel.ClonesZoneName).To(Equal(core.StringPtr("us-south-1"))) + Expect(listSnapshotsOptionsModel.SnapshotConsistencyGroupID).To(Equal(core.StringPtr("testString"))) + Expect(listSnapshotsOptionsModel.SnapshotConsistencyGroupCRN).To(Equal(core.StringPtr("crn:v1:bluemix:public:is:us-south:a/123456::snapshot-consistency-group:r134-fa329f6b-0e36-433f-a3bb-0df632e79263"))) Expect(listSnapshotsOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) }) It(`Invoke NewListSubnetReservedIpsOptions successfully`, func() { @@ -97342,6 +98970,16 @@ var _ = Describe(`VpcV1`, func() { _, err := vpcService.NewSnapshotClonePrototype(zone) Expect(err).ToNot(BeNil()) }) + It(`Invoke NewSnapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshotsSnapshotsItem successfully`, func() { + var sourceVolume vpcv1.VolumeIdentityIntf = nil + _, err := vpcService.NewSnapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshotsSnapshotsItem(sourceVolume) + Expect(err).ToNot(BeNil()) + }) + It(`Invoke NewSnapshotConsistencyGroupPrototypeSnapshotsItem successfully`, func() { + var sourceVolume vpcv1.VolumeIdentityIntf = nil + _, err := vpcService.NewSnapshotConsistencyGroupPrototypeSnapshotsItem(sourceVolume) + Expect(err).ToNot(BeNil()) + }) It(`Invoke NewStartBareMetalServerOptions successfully`, func() { // Construct an instance of the StartBareMetalServerOptions model id := "testString" @@ -97981,6 +99619,21 @@ var _ = Describe(`VpcV1`, func() { Expect(updateShareOptionsModel.IfMatch).To(Equal(core.StringPtr(`W/"96d225c4-56bd-43d9-98fc-d7148e5c5028"`))) Expect(updateShareOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) }) + It(`Invoke NewUpdateSnapshotConsistencyGroupOptions successfully`, func() { + // Construct an instance of the UpdateSnapshotConsistencyGroupOptions model + id := "testString" + snapshotConsistencyGroupPatch := map[string]interface{}{"anyKey": "anyValue"} + updateSnapshotConsistencyGroupOptionsModel := vpcService.NewUpdateSnapshotConsistencyGroupOptions(id, snapshotConsistencyGroupPatch) + updateSnapshotConsistencyGroupOptionsModel.SetID("testString") + updateSnapshotConsistencyGroupOptionsModel.SetSnapshotConsistencyGroupPatch(map[string]interface{}{"anyKey": "anyValue"}) + updateSnapshotConsistencyGroupOptionsModel.SetIfMatch(`W/"96d225c4-56bd-43d9-98fc-d7148e5c5028"`) + updateSnapshotConsistencyGroupOptionsModel.SetHeaders(map[string]string{"foo": "bar"}) + Expect(updateSnapshotConsistencyGroupOptionsModel).ToNot(BeNil()) + Expect(updateSnapshotConsistencyGroupOptionsModel.ID).To(Equal(core.StringPtr("testString"))) + Expect(updateSnapshotConsistencyGroupOptionsModel.SnapshotConsistencyGroupPatch).To(Equal(map[string]interface{}{"anyKey": "anyValue"})) + Expect(updateSnapshotConsistencyGroupOptionsModel.IfMatch).To(Equal(core.StringPtr(`W/"96d225c4-56bd-43d9-98fc-d7148e5c5028"`))) + Expect(updateSnapshotConsistencyGroupOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) + }) It(`Invoke NewUpdateSnapshotOptions successfully`, func() { // Construct an instance of the UpdateSnapshotOptions model id := "testString" @@ -98244,6 +99897,20 @@ var _ = Describe(`VpcV1`, func() { _, err := vpcService.NewVolumePrototypeInstanceBySourceSnapshotContext(profile, sourceSnapshot) Expect(err).ToNot(BeNil()) }) + It(`Invoke NewBackupPolicyPrototypeBackupPolicyMatchResourceTypeInstancePrototype successfully`, func() { + matchUserTags := []string{"my-daily-backup-policy"} + matchResourceType := "instance" + _model, err := vpcService.NewBackupPolicyPrototypeBackupPolicyMatchResourceTypeInstancePrototype(matchUserTags, matchResourceType) + Expect(_model).ToNot(BeNil()) + Expect(err).To(BeNil()) + }) + It(`Invoke NewBackupPolicyPrototypeBackupPolicyMatchResourceTypeVolumePrototype successfully`, func() { + matchUserTags := []string{"my-daily-backup-policy"} + matchResourceType := "volume" + _model, err := vpcService.NewBackupPolicyPrototypeBackupPolicyMatchResourceTypeVolumePrototype(matchUserTags, matchResourceType) + Expect(_model).ToNot(BeNil()) + Expect(err).To(BeNil()) + }) It(`Invoke NewBareMetalServerNetworkInterfacePrototypeBareMetalServerNetworkInterfaceByHiperSocketPrototype successfully`, func() { var subnet vpcv1.SubnetIdentityIntf = nil interfaceType := "hipersocket" @@ -98935,6 +100602,12 @@ var _ = Describe(`VpcV1`, func() { _, err := vpcService.NewSharePrototypeShareBySourceShare(profile, zone, replicationCronSpec, sourceShare) Expect(err).ToNot(BeNil()) }) + It(`Invoke NewSnapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshots successfully`, func() { + snapshots := []vpcv1.SnapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshotsSnapshotsItem{} + _model, err := vpcService.NewSnapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshots(snapshots) + Expect(_model).ToNot(BeNil()) + Expect(err).To(BeNil()) + }) It(`Invoke NewSnapshotIdentityByCRN successfully`, func() { crn := "crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263" _model, err := vpcService.NewSnapshotIdentityByCRN(crn)