From 9b7664dc3cffc5442be94182141f9a595e664b26 Mon Sep 17 00:00:00 2001 From: Ujjwal Kumar <78945437+ujjwal-ibm@users.noreply.github.com> Date: Wed, 29 Jun 2022 10:25:46 +0530 Subject: [PATCH] feat(2022-06-22): updated the sdk as per the 2022-06-22 api version for baas (#54) Signed-off-by: Ujjwal Kumar --- README.md | 8 +- common/version.go | 2 +- vpcv1/vpc_v1.go | 2148 ++++++++++++++- vpcv1/vpc_v1_examples_test.go | 229 ++ vpcv1/vpc_v1_integration_test.go | 69 + vpcv1/vpc_v1_integration_utils_test.go | 98 + vpcv1/vpc_v1_test.go | 3515 ++++++++++++++++++++++-- 7 files changed, 5688 insertions(+), 381 deletions(-) diff --git a/README.md b/README.md index 37a2250..069603a 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.20.0 +# IBM Cloud VPC Go SDK Version 0.21.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.20.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.21.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.20.0 +go get github.com/IBM/vpc-go-sdk@v0.21.0 ``` @@ -90,7 +90,7 @@ to your `Gopkg.toml` file. Here is an example: ``` [[constraint]] name = "github.com/IBM/vpc-go-sdk/" - version = "0.20.0" + version = "0.21.0" ``` Then run `dep ensure`. diff --git a/common/version.go b/common/version.go index 67f6a4d..beecdcc 100644 --- a/common/version.go +++ b/common/version.go @@ -1,4 +1,4 @@ package common // Version of the SDK -const Version = "0.20.0" +const Version = "0.21.0" diff --git a/vpcv1/vpc_v1.go b/vpcv1/vpc_v1.go index 468fb69..b4d1366 100644 --- a/vpcv1/vpc_v1.go +++ b/vpcv1/vpc_v1.go @@ -37,7 +37,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: 2022-05-31 +// API Version: 2022-03-29 type VpcV1 struct { Service *core.BaseService @@ -121,7 +121,7 @@ func NewVpcV1(options *VpcV1Options) (service *VpcV1, err error) { } if options.Version == nil { - options.Version = core.StringPtr("2022-05-31") + options.Version = core.StringPtr("2022-03-29") } service = &VpcV1{ @@ -8913,6 +8913,731 @@ func (vpc *VpcV1) UpdateDedicatedHostWithContext(ctx context.Context, updateDedi return } +// ListBackupPolicies : List all backup policies +// This request lists all backup policies in the region. Backup policies control which sources are selected for backup +// and include a set of backup policy plans that provide the backup schedules and deletion triggers. +func (vpc *VpcV1) ListBackupPolicies(listBackupPoliciesOptions *ListBackupPoliciesOptions) (result *BackupPolicyCollection, response *core.DetailedResponse, err error) { + return vpc.ListBackupPoliciesWithContext(context.Background(), listBackupPoliciesOptions) +} + +// ListBackupPoliciesWithContext is an alternate form of the ListBackupPolicies method which supports a Context parameter +func (vpc *VpcV1) ListBackupPoliciesWithContext(ctx context.Context, listBackupPoliciesOptions *ListBackupPoliciesOptions) (result *BackupPolicyCollection, response *core.DetailedResponse, err error) { + err = core.ValidateStruct(listBackupPoliciesOptions, "listBackupPoliciesOptions") + if err != nil { + return + } + + builder := core.NewRequestBuilder(core.GET) + builder = builder.WithContext(ctx) + builder.EnableGzipCompression = vpc.GetEnableGzipCompression() + _, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/backup_policies`, nil) + if err != nil { + return + } + + for headerName, headerValue := range listBackupPoliciesOptions.Headers { + builder.AddHeader(headerName, headerValue) + } + + sdkHeaders := common.GetSdkHeaders("vpc", "V1", "ListBackupPolicies") + 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 listBackupPoliciesOptions.Start != nil { + builder.AddQuery("start", fmt.Sprint(*listBackupPoliciesOptions.Start)) + } + if listBackupPoliciesOptions.Limit != nil { + builder.AddQuery("limit", fmt.Sprint(*listBackupPoliciesOptions.Limit)) + } + if listBackupPoliciesOptions.ResourceGroupID != nil { + builder.AddQuery("resource_group.id", fmt.Sprint(*listBackupPoliciesOptions.ResourceGroupID)) + } + if listBackupPoliciesOptions.Name != nil { + builder.AddQuery("name", fmt.Sprint(*listBackupPoliciesOptions.Name)) + } + if listBackupPoliciesOptions.Tag != nil { + builder.AddQuery("tag", fmt.Sprint(*listBackupPoliciesOptions.Tag)) + } + + 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, UnmarshalBackupPolicyCollection) + if err != nil { + return + } + response.Result = result + } + + return +} + +// 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) { + 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) { + err = core.ValidateStruct(createBackupPolicyOptions, "createBackupPolicyOptions") + if err != nil { + return + } + + builder := core.NewRequestBuilder(core.POST) + builder = builder.WithContext(ctx) + builder.EnableGzipCompression = vpc.GetEnableGzipCompression() + _, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/backup_policies`, nil) + if err != nil { + return + } + + for headerName, headerValue := range createBackupPolicyOptions.Headers { + builder.AddHeader(headerName, headerValue) + } + + sdkHeaders := common.GetSdkHeaders("vpc", "V1", "CreateBackupPolicy") + 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)) + + body := make(map[string]interface{}) + if createBackupPolicyOptions.MatchResourceTypes != nil { + body["match_resource_types"] = createBackupPolicyOptions.MatchResourceTypes + } + if createBackupPolicyOptions.MatchUserTags != nil { + body["match_user_tags"] = createBackupPolicyOptions.MatchUserTags + } + 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 + } + _, err = builder.SetBodyContentJSON(body) + 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, UnmarshalBackupPolicy) + if err != nil { + return + } + response.Result = result + } + + return +} + +// ListBackupPolicyPlans : List all plans for a backup policy +// This request retrieves all plans for a backup policy. Backup plans provide the backup schedule and deletion triggers. +func (vpc *VpcV1) ListBackupPolicyPlans(listBackupPolicyPlansOptions *ListBackupPolicyPlansOptions) (result *BackupPolicyPlanCollection, response *core.DetailedResponse, err error) { + return vpc.ListBackupPolicyPlansWithContext(context.Background(), listBackupPolicyPlansOptions) +} + +// ListBackupPolicyPlansWithContext is an alternate form of the ListBackupPolicyPlans method which supports a Context parameter +func (vpc *VpcV1) ListBackupPolicyPlansWithContext(ctx context.Context, listBackupPolicyPlansOptions *ListBackupPolicyPlansOptions) (result *BackupPolicyPlanCollection, response *core.DetailedResponse, err error) { + err = core.ValidateNotNil(listBackupPolicyPlansOptions, "listBackupPolicyPlansOptions cannot be nil") + if err != nil { + return + } + err = core.ValidateStruct(listBackupPolicyPlansOptions, "listBackupPolicyPlansOptions") + if err != nil { + return + } + + pathParamsMap := map[string]string{ + "backup_policy_id": *listBackupPolicyPlansOptions.BackupPolicyID, + } + + builder := core.NewRequestBuilder(core.GET) + builder = builder.WithContext(ctx) + builder.EnableGzipCompression = vpc.GetEnableGzipCompression() + _, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/backup_policies/{backup_policy_id}/plans`, pathParamsMap) + if err != nil { + return + } + + for headerName, headerValue := range listBackupPolicyPlansOptions.Headers { + builder.AddHeader(headerName, headerValue) + } + + sdkHeaders := common.GetSdkHeaders("vpc", "V1", "ListBackupPolicyPlans") + 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 listBackupPolicyPlansOptions.Name != nil { + builder.AddQuery("name", fmt.Sprint(*listBackupPolicyPlansOptions.Name)) + } + + 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, UnmarshalBackupPolicyPlanCollection) + if err != nil { + return + } + response.Result = result + } + + return +} + +// CreateBackupPolicyPlan : Create a plan for a backup policy +// This request creates a new backup policy plan from a backup policy plan prototype object. The prototype object is +// structured in the same way as a retrieved backup policy plan, and contains the information necessary to create the +// new backup policy plan. +// +// Backups created by this plan will use the resource group of the source being backed up. +// +// Backups created by this plan will use the plan's name truncated to 46 characters, followed by a unique 16-character +// suffix. +func (vpc *VpcV1) CreateBackupPolicyPlan(createBackupPolicyPlanOptions *CreateBackupPolicyPlanOptions) (result *BackupPolicyPlan, response *core.DetailedResponse, err error) { + return vpc.CreateBackupPolicyPlanWithContext(context.Background(), createBackupPolicyPlanOptions) +} + +// CreateBackupPolicyPlanWithContext is an alternate form of the CreateBackupPolicyPlan method which supports a Context parameter +func (vpc *VpcV1) CreateBackupPolicyPlanWithContext(ctx context.Context, createBackupPolicyPlanOptions *CreateBackupPolicyPlanOptions) (result *BackupPolicyPlan, response *core.DetailedResponse, err error) { + err = core.ValidateNotNil(createBackupPolicyPlanOptions, "createBackupPolicyPlanOptions cannot be nil") + if err != nil { + return + } + err = core.ValidateStruct(createBackupPolicyPlanOptions, "createBackupPolicyPlanOptions") + if err != nil { + return + } + + pathParamsMap := map[string]string{ + "backup_policy_id": *createBackupPolicyPlanOptions.BackupPolicyID, + } + + builder := core.NewRequestBuilder(core.POST) + builder = builder.WithContext(ctx) + builder.EnableGzipCompression = vpc.GetEnableGzipCompression() + _, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/backup_policies/{backup_policy_id}/plans`, pathParamsMap) + if err != nil { + return + } + + for headerName, headerValue := range createBackupPolicyPlanOptions.Headers { + builder.AddHeader(headerName, headerValue) + } + + sdkHeaders := common.GetSdkHeaders("vpc", "V1", "CreateBackupPolicyPlan") + 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)) + + body := make(map[string]interface{}) + if createBackupPolicyPlanOptions.CronSpec != nil { + body["cron_spec"] = createBackupPolicyPlanOptions.CronSpec + } + if createBackupPolicyPlanOptions.Active != nil { + body["active"] = createBackupPolicyPlanOptions.Active + } + if createBackupPolicyPlanOptions.AttachUserTags != nil { + body["attach_user_tags"] = createBackupPolicyPlanOptions.AttachUserTags + } + if createBackupPolicyPlanOptions.CopyUserTags != nil { + body["copy_user_tags"] = createBackupPolicyPlanOptions.CopyUserTags + } + if createBackupPolicyPlanOptions.DeletionTrigger != nil { + body["deletion_trigger"] = createBackupPolicyPlanOptions.DeletionTrigger + } + if createBackupPolicyPlanOptions.Name != nil { + body["name"] = createBackupPolicyPlanOptions.Name + } + _, err = builder.SetBodyContentJSON(body) + 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, UnmarshalBackupPolicyPlan) + if err != nil { + return + } + response.Result = result + } + + return +} + +// DeleteBackupPolicyPlan : Delete a backup policy plan +// This request deletes a backup policy plan. This operation cannot be reversed. Any backups that have been created by +// the plan will remain but will no longer be subject to the plan's deletion trigger. Any running jobs associated with +// the plan will run to completion before the plan is deleted. +// +// If the request is accepted, the backup policy plan `status` will be set to `deleting`. Once deletion processing +// completes, the backup policy plan will no longer be retrievable. +func (vpc *VpcV1) DeleteBackupPolicyPlan(deleteBackupPolicyPlanOptions *DeleteBackupPolicyPlanOptions) (result *BackupPolicyPlan, response *core.DetailedResponse, err error) { + return vpc.DeleteBackupPolicyPlanWithContext(context.Background(), deleteBackupPolicyPlanOptions) +} + +// DeleteBackupPolicyPlanWithContext is an alternate form of the DeleteBackupPolicyPlan method which supports a Context parameter +func (vpc *VpcV1) DeleteBackupPolicyPlanWithContext(ctx context.Context, deleteBackupPolicyPlanOptions *DeleteBackupPolicyPlanOptions) (result *BackupPolicyPlan, response *core.DetailedResponse, err error) { + err = core.ValidateNotNil(deleteBackupPolicyPlanOptions, "deleteBackupPolicyPlanOptions cannot be nil") + if err != nil { + return + } + err = core.ValidateStruct(deleteBackupPolicyPlanOptions, "deleteBackupPolicyPlanOptions") + if err != nil { + return + } + + pathParamsMap := map[string]string{ + "backup_policy_id": *deleteBackupPolicyPlanOptions.BackupPolicyID, + "id": *deleteBackupPolicyPlanOptions.ID, + } + + builder := core.NewRequestBuilder(core.DELETE) + builder = builder.WithContext(ctx) + builder.EnableGzipCompression = vpc.GetEnableGzipCompression() + _, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/backup_policies/{backup_policy_id}/plans/{id}`, pathParamsMap) + if err != nil { + return + } + + for headerName, headerValue := range deleteBackupPolicyPlanOptions.Headers { + builder.AddHeader(headerName, headerValue) + } + + sdkHeaders := common.GetSdkHeaders("vpc", "V1", "DeleteBackupPolicyPlan") + for headerName, headerValue := range sdkHeaders { + builder.AddHeader(headerName, headerValue) + } + builder.AddHeader("Accept", "application/json") + if deleteBackupPolicyPlanOptions.IfMatch != nil { + builder.AddHeader("If-Match", fmt.Sprint(*deleteBackupPolicyPlanOptions.IfMatch)) + } + + 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, UnmarshalBackupPolicyPlan) + if err != nil { + return + } + response.Result = result + } + + return +} + +// GetBackupPolicyPlan : Retrieve a backup policy plan +// This request retrieves a single backup policy plan specified by the identifier in the URL. +func (vpc *VpcV1) GetBackupPolicyPlan(getBackupPolicyPlanOptions *GetBackupPolicyPlanOptions) (result *BackupPolicyPlan, response *core.DetailedResponse, err error) { + return vpc.GetBackupPolicyPlanWithContext(context.Background(), getBackupPolicyPlanOptions) +} + +// GetBackupPolicyPlanWithContext is an alternate form of the GetBackupPolicyPlan method which supports a Context parameter +func (vpc *VpcV1) GetBackupPolicyPlanWithContext(ctx context.Context, getBackupPolicyPlanOptions *GetBackupPolicyPlanOptions) (result *BackupPolicyPlan, response *core.DetailedResponse, err error) { + err = core.ValidateNotNil(getBackupPolicyPlanOptions, "getBackupPolicyPlanOptions cannot be nil") + if err != nil { + return + } + err = core.ValidateStruct(getBackupPolicyPlanOptions, "getBackupPolicyPlanOptions") + if err != nil { + return + } + + pathParamsMap := map[string]string{ + "backup_policy_id": *getBackupPolicyPlanOptions.BackupPolicyID, + "id": *getBackupPolicyPlanOptions.ID, + } + + builder := core.NewRequestBuilder(core.GET) + builder = builder.WithContext(ctx) + builder.EnableGzipCompression = vpc.GetEnableGzipCompression() + _, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/backup_policies/{backup_policy_id}/plans/{id}`, pathParamsMap) + if err != nil { + return + } + + for headerName, headerValue := range getBackupPolicyPlanOptions.Headers { + builder.AddHeader(headerName, headerValue) + } + + sdkHeaders := common.GetSdkHeaders("vpc", "V1", "GetBackupPolicyPlan") + 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, UnmarshalBackupPolicyPlan) + if err != nil { + return + } + response.Result = result + } + + return +} + +// UpdateBackupPolicyPlan : Update a backup policy plan +// This request updates a backup policy plan with the information in a provided plan patch. The plan patch object is +// structured in the same way as a retrieved backup policy plan and can contains only the information to be updated. +func (vpc *VpcV1) UpdateBackupPolicyPlan(updateBackupPolicyPlanOptions *UpdateBackupPolicyPlanOptions) (result *BackupPolicyPlan, response *core.DetailedResponse, err error) { + return vpc.UpdateBackupPolicyPlanWithContext(context.Background(), updateBackupPolicyPlanOptions) +} + +// UpdateBackupPolicyPlanWithContext is an alternate form of the UpdateBackupPolicyPlan method which supports a Context parameter +func (vpc *VpcV1) UpdateBackupPolicyPlanWithContext(ctx context.Context, updateBackupPolicyPlanOptions *UpdateBackupPolicyPlanOptions) (result *BackupPolicyPlan, response *core.DetailedResponse, err error) { + err = core.ValidateNotNil(updateBackupPolicyPlanOptions, "updateBackupPolicyPlanOptions cannot be nil") + if err != nil { + return + } + err = core.ValidateStruct(updateBackupPolicyPlanOptions, "updateBackupPolicyPlanOptions") + if err != nil { + return + } + + pathParamsMap := map[string]string{ + "backup_policy_id": *updateBackupPolicyPlanOptions.BackupPolicyID, + "id": *updateBackupPolicyPlanOptions.ID, + } + + builder := core.NewRequestBuilder(core.PATCH) + builder = builder.WithContext(ctx) + builder.EnableGzipCompression = vpc.GetEnableGzipCompression() + _, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/backup_policies/{backup_policy_id}/plans/{id}`, pathParamsMap) + if err != nil { + return + } + + for headerName, headerValue := range updateBackupPolicyPlanOptions.Headers { + builder.AddHeader(headerName, headerValue) + } + + sdkHeaders := common.GetSdkHeaders("vpc", "V1", "UpdateBackupPolicyPlan") + for headerName, headerValue := range sdkHeaders { + builder.AddHeader(headerName, headerValue) + } + builder.AddHeader("Accept", "application/json") + builder.AddHeader("Content-Type", "application/merge-patch+json") + if updateBackupPolicyPlanOptions.IfMatch != nil { + builder.AddHeader("If-Match", fmt.Sprint(*updateBackupPolicyPlanOptions.IfMatch)) + } + + builder.AddQuery("version", fmt.Sprint(*vpc.Version)) + builder.AddQuery("generation", fmt.Sprint(*vpc.generation)) + + _, err = builder.SetBodyContentJSON(updateBackupPolicyPlanOptions.BackupPolicyPlanPatch) + 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, UnmarshalBackupPolicyPlan) + if err != nil { + return + } + response.Result = result + } + + return +} + +// DeleteBackupPolicy : Delete a backup policy +// This request deletes a backup policy. This operation cannot be reversed. +// +// 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) { + 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) { + err = core.ValidateNotNil(deleteBackupPolicyOptions, "deleteBackupPolicyOptions cannot be nil") + if err != nil { + return + } + err = core.ValidateStruct(deleteBackupPolicyOptions, "deleteBackupPolicyOptions") + if err != nil { + return + } + + pathParamsMap := map[string]string{ + "id": *deleteBackupPolicyOptions.ID, + } + + builder := core.NewRequestBuilder(core.DELETE) + builder = builder.WithContext(ctx) + builder.EnableGzipCompression = vpc.GetEnableGzipCompression() + _, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/backup_policies/{id}`, pathParamsMap) + if err != nil { + return + } + + for headerName, headerValue := range deleteBackupPolicyOptions.Headers { + builder.AddHeader(headerName, headerValue) + } + + sdkHeaders := common.GetSdkHeaders("vpc", "V1", "DeleteBackupPolicy") + for headerName, headerValue := range sdkHeaders { + builder.AddHeader(headerName, headerValue) + } + builder.AddHeader("Accept", "application/json") + if deleteBackupPolicyOptions.IfMatch != nil { + builder.AddHeader("If-Match", fmt.Sprint(*deleteBackupPolicyOptions.IfMatch)) + } + + 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, UnmarshalBackupPolicy) + if err != nil { + return + } + response.Result = result + } + + return +} + +// 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) { + 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) { + err = core.ValidateNotNil(getBackupPolicyOptions, "getBackupPolicyOptions cannot be nil") + if err != nil { + return + } + err = core.ValidateStruct(getBackupPolicyOptions, "getBackupPolicyOptions") + if err != nil { + return + } + + pathParamsMap := map[string]string{ + "id": *getBackupPolicyOptions.ID, + } + + builder := core.NewRequestBuilder(core.GET) + builder = builder.WithContext(ctx) + builder.EnableGzipCompression = vpc.GetEnableGzipCompression() + _, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/backup_policies/{id}`, pathParamsMap) + if err != nil { + return + } + + for headerName, headerValue := range getBackupPolicyOptions.Headers { + builder.AddHeader(headerName, headerValue) + } + + sdkHeaders := common.GetSdkHeaders("vpc", "V1", "GetBackupPolicy") + 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, UnmarshalBackupPolicy) + if err != nil { + return + } + response.Result = result + } + + return +} + +// 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) { + 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) { + err = core.ValidateNotNil(updateBackupPolicyOptions, "updateBackupPolicyOptions cannot be nil") + if err != nil { + return + } + err = core.ValidateStruct(updateBackupPolicyOptions, "updateBackupPolicyOptions") + if err != nil { + return + } + + pathParamsMap := map[string]string{ + "id": *updateBackupPolicyOptions.ID, + } + + builder := core.NewRequestBuilder(core.PATCH) + builder = builder.WithContext(ctx) + builder.EnableGzipCompression = vpc.GetEnableGzipCompression() + _, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/backup_policies/{id}`, pathParamsMap) + if err != nil { + return + } + + for headerName, headerValue := range updateBackupPolicyOptions.Headers { + builder.AddHeader(headerName, headerValue) + } + + sdkHeaders := common.GetSdkHeaders("vpc", "V1", "UpdateBackupPolicy") + for headerName, headerValue := range sdkHeaders { + builder.AddHeader(headerName, headerValue) + } + builder.AddHeader("Accept", "application/json") + builder.AddHeader("Content-Type", "application/merge-patch+json") + if updateBackupPolicyOptions.IfMatch != nil { + builder.AddHeader("If-Match", fmt.Sprint(*updateBackupPolicyOptions.IfMatch)) + } + + builder.AddQuery("version", fmt.Sprint(*vpc.Version)) + builder.AddQuery("generation", fmt.Sprint(*vpc.generation)) + + _, err = builder.SetBodyContentJSON(updateBackupPolicyOptions.BackupPolicyPatch) + 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, UnmarshalBackupPolicy) + if err != nil { + return + } + response.Result = result + } + + return +} + // ListPlacementGroups : List all placement groups // This request lists all placement groups in the region. func (vpc *VpcV1) ListPlacementGroups(listPlacementGroupsOptions *ListPlacementGroupsOptions) (result *PlacementGroupCollection, response *core.DetailedResponse, err error) { @@ -11504,6 +12229,9 @@ func (vpc *VpcV1) ListSnapshotsWithContext(ctx context.Context, listSnapshotsOpt if listSnapshotsOptions.Sort != nil { builder.AddQuery("sort", fmt.Sprint(*listSnapshotsOptions.Sort)) } + if listSnapshotsOptions.BackupPolicyPlanID != nil { + builder.AddQuery("backup_policy_plan.id", fmt.Sprint(*listSnapshotsOptions.BackupPolicyPlanID)) + } request, err := builder.Build() if err != nil { @@ -19624,77 +20352,311 @@ func (*VpcV1) NewAddVPNGatewayConnectionPeerCIDROptions(vpnGatewayID string, id } } -// SetVPNGatewayID : Allow user to set VPNGatewayID -func (_options *AddVPNGatewayConnectionPeerCIDROptions) SetVPNGatewayID(vpnGatewayID string) *AddVPNGatewayConnectionPeerCIDROptions { - _options.VPNGatewayID = core.StringPtr(vpnGatewayID) - return _options -} - -// SetID : Allow user to set ID -func (_options *AddVPNGatewayConnectionPeerCIDROptions) SetID(id string) *AddVPNGatewayConnectionPeerCIDROptions { - _options.ID = core.StringPtr(id) - return _options -} +// SetVPNGatewayID : Allow user to set VPNGatewayID +func (_options *AddVPNGatewayConnectionPeerCIDROptions) SetVPNGatewayID(vpnGatewayID string) *AddVPNGatewayConnectionPeerCIDROptions { + _options.VPNGatewayID = core.StringPtr(vpnGatewayID) + return _options +} + +// SetID : Allow user to set ID +func (_options *AddVPNGatewayConnectionPeerCIDROptions) SetID(id string) *AddVPNGatewayConnectionPeerCIDROptions { + _options.ID = core.StringPtr(id) + return _options +} + +// SetCIDRPrefix : Allow user to set CIDRPrefix +func (_options *AddVPNGatewayConnectionPeerCIDROptions) SetCIDRPrefix(cidrPrefix string) *AddVPNGatewayConnectionPeerCIDROptions { + _options.CIDRPrefix = core.StringPtr(cidrPrefix) + return _options +} + +// SetPrefixLength : Allow user to set PrefixLength +func (_options *AddVPNGatewayConnectionPeerCIDROptions) SetPrefixLength(prefixLength string) *AddVPNGatewayConnectionPeerCIDROptions { + _options.PrefixLength = core.StringPtr(prefixLength) + return _options +} + +// SetHeaders : Allow user to set Headers +func (options *AddVPNGatewayConnectionPeerCIDROptions) SetHeaders(param map[string]string) *AddVPNGatewayConnectionPeerCIDROptions { + options.Headers = param + return options +} + +// AddressPrefix : AddressPrefix struct +type AddressPrefix struct { + // The CIDR block for this prefix. + CIDR *string `json:"cidr" validate:"required"` + + // The date and time that the prefix was created. + CreatedAt *strfmt.DateTime `json:"created_at" validate:"required"` + + // Indicates whether subnets exist with addresses from this prefix. + HasSubnets *bool `json:"has_subnets" validate:"required"` + + // The URL for this address prefix. + Href *string `json:"href" validate:"required"` + + // The unique identifier for this address prefix. + ID *string `json:"id" validate:"required"` + + // Indicates whether this is the default prefix for this zone in this VPC. If a default prefix was automatically + // created when the VPC was created, the prefix is automatically named using a hyphenated list of randomly-selected + // words, but may be updated with a user-specified name. + IsDefault *bool `json:"is_default" validate:"required"` + + // The user-defined name for this address prefix. Names must be unique within the VPC the address prefix resides in. + Name *string `json:"name" validate:"required"` + + // The zone this address prefix resides in. + Zone *ZoneReference `json:"zone" validate:"required"` +} + +// UnmarshalAddressPrefix unmarshals an instance of AddressPrefix from the specified map of raw messages. +func UnmarshalAddressPrefix(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(AddressPrefix) + err = core.UnmarshalPrimitive(m, "cidr", &obj.CIDR) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "created_at", &obj.CreatedAt) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "has_subnets", &obj.HasSubnets) + 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, "is_default", &obj.IsDefault) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "name", &obj.Name) + if err != nil { + return + } + err = core.UnmarshalModel(m, "zone", &obj.Zone, UnmarshalZoneReference) + if err != nil { + return + } + reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) + return +} + +// AddressPrefixCollection : AddressPrefixCollection struct +type AddressPrefixCollection struct { + // Collection of address prefixes. + AddressPrefixes []AddressPrefix `json:"address_prefixes" validate:"required"` + + // A link to the first page of resources. + First *AddressPrefixCollectionFirst `json:"first" validate:"required"` + + // The maximum number of resources that can be returned by the request. + Limit *int64 `json:"limit" validate:"required"` + + // A link to the next page of resources. This property is present for all pages + // except the last page. + Next *AddressPrefixCollectionNext `json:"next,omitempty"` + + // The total number of resources across all pages. + TotalCount *int64 `json:"total_count" validate:"required"` +} + +// UnmarshalAddressPrefixCollection unmarshals an instance of AddressPrefixCollection from the specified map of raw messages. +func UnmarshalAddressPrefixCollection(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(AddressPrefixCollection) + err = core.UnmarshalModel(m, "address_prefixes", &obj.AddressPrefixes, UnmarshalAddressPrefix) + if err != nil { + return + } + err = core.UnmarshalModel(m, "first", &obj.First, UnmarshalAddressPrefixCollectionFirst) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "limit", &obj.Limit) + if err != nil { + return + } + err = core.UnmarshalModel(m, "next", &obj.Next, UnmarshalAddressPrefixCollectionNext) + 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 *AddressPrefixCollection) 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 +} + +// AddressPrefixCollectionFirst : A link to the first page of resources. +type AddressPrefixCollectionFirst struct { + // The URL for a page of resources. + Href *string `json:"href" validate:"required"` +} + +// UnmarshalAddressPrefixCollectionFirst unmarshals an instance of AddressPrefixCollectionFirst from the specified map of raw messages. +func UnmarshalAddressPrefixCollectionFirst(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(AddressPrefixCollectionFirst) + err = core.UnmarshalPrimitive(m, "href", &obj.Href) + if err != nil { + return + } + reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) + return +} + +// AddressPrefixCollectionNext : A link to the next page of resources. This property is present for all pages except the last page. +type AddressPrefixCollectionNext struct { + // The URL for a page of resources. + Href *string `json:"href" validate:"required"` +} + +// UnmarshalAddressPrefixCollectionNext unmarshals an instance of AddressPrefixCollectionNext from the specified map of raw messages. +func UnmarshalAddressPrefixCollectionNext(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(AddressPrefixCollectionNext) + err = core.UnmarshalPrimitive(m, "href", &obj.Href) + if err != nil { + return + } + reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) + return +} + +// AddressPrefixPatch : AddressPrefixPatch struct +type AddressPrefixPatch struct { + // Indicates whether this is the default prefix for this zone in this VPC. Updating to true makes this prefix the + // default prefix for this zone in this VPC, provided the VPC currently has no default address prefix for this zone. + // Updating to false removes the default prefix for this zone in this VPC. + IsDefault *bool `json:"is_default,omitempty"` -// SetCIDRPrefix : Allow user to set CIDRPrefix -func (_options *AddVPNGatewayConnectionPeerCIDROptions) SetCIDRPrefix(cidrPrefix string) *AddVPNGatewayConnectionPeerCIDROptions { - _options.CIDRPrefix = core.StringPtr(cidrPrefix) - return _options + // The user-defined name for this address prefix. Names must be unique within the VPC the address prefix resides in. + Name *string `json:"name,omitempty"` } -// SetPrefixLength : Allow user to set PrefixLength -func (_options *AddVPNGatewayConnectionPeerCIDROptions) SetPrefixLength(prefixLength string) *AddVPNGatewayConnectionPeerCIDROptions { - _options.PrefixLength = core.StringPtr(prefixLength) - return _options +// UnmarshalAddressPrefixPatch unmarshals an instance of AddressPrefixPatch from the specified map of raw messages. +func UnmarshalAddressPrefixPatch(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(AddressPrefixPatch) + err = core.UnmarshalPrimitive(m, "is_default", &obj.IsDefault) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "name", &obj.Name) + if err != nil { + return + } + reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) + return } -// SetHeaders : Allow user to set Headers -func (options *AddVPNGatewayConnectionPeerCIDROptions) SetHeaders(param map[string]string) *AddVPNGatewayConnectionPeerCIDROptions { - options.Headers = param - return options +// AsPatch returns a generic map representation of the AddressPrefixPatch +func (addressPrefixPatch *AddressPrefixPatch) AsPatch() (_patch map[string]interface{}, err error) { + var jsonData []byte + jsonData, err = json.Marshal(addressPrefixPatch) + if err == nil { + err = json.Unmarshal(jsonData, &_patch) + } + return } -// AddressPrefix : AddressPrefix struct -type AddressPrefix struct { - // The CIDR block for this prefix. - CIDR *string `json:"cidr" validate:"required"` - - // The date and time that the prefix was created. +// BackupPolicy : BackupPolicy struct +type BackupPolicy struct { + // The date and time that the backup policy was created. CreatedAt *strfmt.DateTime `json:"created_at" validate:"required"` - // Indicates whether subnets exist with addresses from this prefix. - HasSubnets *bool `json:"has_subnets" validate:"required"` + // The CRN for this backup policy. + CRN *string `json:"crn" validate:"required"` - // The URL for this address prefix. + // The URL for this backup policy. Href *string `json:"href" validate:"required"` - // The unique identifier for this address prefix. + // The unique identifier for this backup policy. ID *string `json:"id" validate:"required"` - // Indicates whether this is the default prefix for this zone in this VPC. If a default prefix was automatically - // created when the VPC was created, the prefix is automatically named using a hyphenated list of randomly-selected - // words, but may be updated with a user-specified name. - IsDefault *bool `json:"is_default" 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 user-defined name for this address prefix. Names must be unique within the VPC the address prefix resides in. + // The lifecycle state of the backup policy. + LifecycleState *string `json:"lifecycle_state" validate:"required"` + + // A 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 + // 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"` + + // 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 unique user-defined name for this backup policy. Name *string `json:"name" validate:"required"` - // The zone this address prefix resides in. - Zone *ZoneReference `json:"zone" 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"` } -// UnmarshalAddressPrefix unmarshals an instance of AddressPrefix from the specified map of raw messages. -func UnmarshalAddressPrefix(m map[string]json.RawMessage, result interface{}) (err error) { - obj := new(AddressPrefix) - err = core.UnmarshalPrimitive(m, "cidr", &obj.CIDR) - if err != nil { - return - } +// Constants associated with the BackupPolicy.LifecycleState property. +// The lifecycle state of the backup policy. +const ( + BackupPolicyLifecycleStateDeletingConst = "deleting" + BackupPolicyLifecycleStateFailedConst = "failed" + BackupPolicyLifecycleStatePendingConst = "pending" + BackupPolicyLifecycleStateStableConst = "stable" + BackupPolicyLifecycleStateSuspendedConst = "suspended" + BackupPolicyLifecycleStateUpdatingConst = "updating" + BackupPolicyLifecycleStateWaitingConst = "waiting" +) + +// Constants associated with the BackupPolicy.MatchResourceTypes property. +// The resource type. +const ( + BackupPolicyMatchResourceTypesVolumeConst = "volume" +) + +// Constants associated with the BackupPolicy.ResourceType property. +// The resource type. +const ( + BackupPolicyResourceTypeBackupPolicyConst = "backup_policy" +) + +// 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) err = core.UnmarshalPrimitive(m, "created_at", &obj.CreatedAt) if err != nil { return } - err = core.UnmarshalPrimitive(m, "has_subnets", &obj.HasSubnets) + err = core.UnmarshalPrimitive(m, "crn", &obj.CRN) if err != nil { return } @@ -19706,7 +20668,19 @@ func UnmarshalAddressPrefix(m map[string]json.RawMessage, result interface{}) (e if err != nil { return } - err = core.UnmarshalPrimitive(m, "is_default", &obj.IsDefault) + 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_resource_types", &obj.MatchResourceTypes) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "match_user_tags", &obj.MatchUserTags) if err != nil { return } @@ -19714,7 +20688,15 @@ func UnmarshalAddressPrefix(m map[string]json.RawMessage, result interface{}) (e if err != nil { return } - err = core.UnmarshalModel(m, "zone", &obj.Zone, UnmarshalZoneReference) + 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 } @@ -19722,33 +20704,33 @@ func UnmarshalAddressPrefix(m map[string]json.RawMessage, result interface{}) (e return } -// AddressPrefixCollection : AddressPrefixCollection struct -type AddressPrefixCollection struct { - // Collection of address prefixes. - AddressPrefixes []AddressPrefix `json:"address_prefixes" validate:"required"` +// BackupPolicyCollection : BackupPolicyCollection struct +type BackupPolicyCollection struct { + // Collection of backup policies. + BackupPolicies []BackupPolicy `json:"backup_policies" validate:"required"` // A link to the first page of resources. - First *AddressPrefixCollectionFirst `json:"first" validate:"required"` + First *BackupPolicyCollectionFirst `json:"first" validate:"required"` // The maximum number of resources that can be returned by the request. Limit *int64 `json:"limit" validate:"required"` // A link to the next page of resources. This property is present for all pages // except the last page. - Next *AddressPrefixCollectionNext `json:"next,omitempty"` + Next *BackupPolicyCollectionNext `json:"next,omitempty"` // The total number of resources across all pages. TotalCount *int64 `json:"total_count" validate:"required"` } -// UnmarshalAddressPrefixCollection unmarshals an instance of AddressPrefixCollection from the specified map of raw messages. -func UnmarshalAddressPrefixCollection(m map[string]json.RawMessage, result interface{}) (err error) { - obj := new(AddressPrefixCollection) - err = core.UnmarshalModel(m, "address_prefixes", &obj.AddressPrefixes, UnmarshalAddressPrefix) +// UnmarshalBackupPolicyCollection unmarshals an instance of BackupPolicyCollection from the specified map of raw messages. +func UnmarshalBackupPolicyCollection(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(BackupPolicyCollection) + err = core.UnmarshalModel(m, "backup_policies", &obj.BackupPolicies, UnmarshalBackupPolicy) if err != nil { return } - err = core.UnmarshalModel(m, "first", &obj.First, UnmarshalAddressPrefixCollectionFirst) + err = core.UnmarshalModel(m, "first", &obj.First, UnmarshalBackupPolicyCollectionFirst) if err != nil { return } @@ -19756,7 +20738,7 @@ func UnmarshalAddressPrefixCollection(m map[string]json.RawMessage, result inter if err != nil { return } - err = core.UnmarshalModel(m, "next", &obj.Next, UnmarshalAddressPrefixCollectionNext) + err = core.UnmarshalModel(m, "next", &obj.Next, UnmarshalBackupPolicyCollectionNext) if err != nil { return } @@ -19769,7 +20751,7 @@ func UnmarshalAddressPrefixCollection(m map[string]json.RawMessage, result inter } // Retrieve the value to be passed to a request to access the next page of results -func (resp *AddressPrefixCollection) GetNextStart() (*string, error) { +func (resp *BackupPolicyCollection) GetNextStart() (*string, error) { if core.IsNil(resp.Next) { return nil, nil } @@ -19780,15 +20762,15 @@ func (resp *AddressPrefixCollection) GetNextStart() (*string, error) { return start, nil } -// AddressPrefixCollectionFirst : A link to the first page of resources. -type AddressPrefixCollectionFirst struct { +// BackupPolicyCollectionFirst : A link to the first page of resources. +type BackupPolicyCollectionFirst struct { // The URL for a page of resources. Href *string `json:"href" validate:"required"` } -// UnmarshalAddressPrefixCollectionFirst unmarshals an instance of AddressPrefixCollectionFirst from the specified map of raw messages. -func UnmarshalAddressPrefixCollectionFirst(m map[string]json.RawMessage, result interface{}) (err error) { - obj := new(AddressPrefixCollectionFirst) +// UnmarshalBackupPolicyCollectionFirst unmarshals an instance of BackupPolicyCollectionFirst from the specified map of raw messages. +func UnmarshalBackupPolicyCollectionFirst(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(BackupPolicyCollectionFirst) err = core.UnmarshalPrimitive(m, "href", &obj.Href) if err != nil { return @@ -19797,15 +20779,15 @@ func UnmarshalAddressPrefixCollectionFirst(m map[string]json.RawMessage, result return } -// AddressPrefixCollectionNext : A link to the next page of resources. This property is present for all pages except the last page. -type AddressPrefixCollectionNext struct { +// BackupPolicyCollectionNext : A link to the next page of resources. This property is present for all pages except the last page. +type BackupPolicyCollectionNext struct { // The URL for a page of resources. Href *string `json:"href" validate:"required"` } -// UnmarshalAddressPrefixCollectionNext unmarshals an instance of AddressPrefixCollectionNext from the specified map of raw messages. -func UnmarshalAddressPrefixCollectionNext(m map[string]json.RawMessage, result interface{}) (err error) { - obj := new(AddressPrefixCollectionNext) +// UnmarshalBackupPolicyCollectionNext unmarshals an instance of BackupPolicyCollectionNext from the specified map of raw messages. +func UnmarshalBackupPolicyCollectionNext(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(BackupPolicyCollectionNext) err = core.UnmarshalPrimitive(m, "href", &obj.Href) if err != nil { return @@ -19814,21 +20796,20 @@ func UnmarshalAddressPrefixCollectionNext(m map[string]json.RawMessage, result i return } -// AddressPrefixPatch : AddressPrefixPatch struct -type AddressPrefixPatch struct { - // Indicates whether this is the default prefix for this zone in this VPC. Updating to true makes this prefix the - // default prefix for this zone in this VPC, provided the VPC currently has no default address prefix for this zone. - // Updating to false removes the default prefix for this zone in this VPC. - IsDefault *bool `json:"is_default,omitempty"` +// BackupPolicyPatch : BackupPolicyPatch struct +type BackupPolicyPatch struct { + // The user tags this backup policy applies 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"` - // The user-defined name for this address prefix. Names must be unique within the VPC the address prefix resides in. + // The user-defined name for this backup policy. Names must be unique within the region this backup policy resides in. Name *string `json:"name,omitempty"` } -// UnmarshalAddressPrefixPatch unmarshals an instance of AddressPrefixPatch from the specified map of raw messages. -func UnmarshalAddressPrefixPatch(m map[string]json.RawMessage, result interface{}) (err error) { - obj := new(AddressPrefixPatch) - err = core.UnmarshalPrimitive(m, "is_default", &obj.IsDefault) +// 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, "match_user_tags", &obj.MatchUserTags) if err != nil { return } @@ -19840,16 +20821,415 @@ func UnmarshalAddressPrefixPatch(m map[string]json.RawMessage, result interface{ return } -// AsPatch returns a generic map representation of the AddressPrefixPatch -func (addressPrefixPatch *AddressPrefixPatch) AsPatch() (_patch map[string]interface{}, err error) { +// AsPatch returns a generic map representation of the BackupPolicyPatch +func (backupPolicyPatch *BackupPolicyPatch) AsPatch() (_patch map[string]interface{}, err error) { var jsonData []byte - jsonData, err = json.Marshal(addressPrefixPatch) + jsonData, err = json.Marshal(backupPolicyPatch) + if err == nil { + err = json.Unmarshal(jsonData, &_patch) + } + return +} + +// BackupPolicyPlan : BackupPolicyPlan struct +type BackupPolicyPlan struct { + // Indicates whether the plan is active. + Active *bool `json:"active" validate:"required"` + + // The user tags to attach to backups (snapshots) created by this plan. + AttachUserTags []string `json:"attach_user_tags" validate:"required"` + + // Indicates whether to copy the source's user tags to the created backups (snapshots). + CopyUserTags *bool `json:"copy_user_tags" validate:"required"` + + // The date and time that the backup policy plan was created. + CreatedAt *strfmt.DateTime `json:"created_at" validate:"required"` + + // The cron specification for the backup schedule. The backup policy jobs + // (which create and delete backups for this plan) will not start until this time, and may start for up to 90 minutes + // after this time. + // + // All backup schedules for plans in the same policy must be at least an hour apart. + CronSpec *string `json:"cron_spec" validate:"required"` + + DeletionTrigger *BackupPolicyPlanDeletionTrigger `json:"deletion_trigger" validate:"required"` + + // The URL for this backup policy plan. + Href *string `json:"href" validate:"required"` + + // The unique identifier for this backup policy plan. + ID *string `json:"id" validate:"required"` + + // The lifecycle state of this backup policy plan. + LifecycleState *string `json:"lifecycle_state" validate:"required"` + + // The unique user-defined name for this backup policy plan. + Name *string `json:"name" validate:"required"` + + // The resource type. + ResourceType *string `json:"resource_type" validate:"required"` +} + +// Constants associated with the BackupPolicyPlan.LifecycleState property. +// The lifecycle state of this backup policy plan. +const ( + BackupPolicyPlanLifecycleStateDeletingConst = "deleting" + BackupPolicyPlanLifecycleStateFailedConst = "failed" + BackupPolicyPlanLifecycleStatePendingConst = "pending" + BackupPolicyPlanLifecycleStateStableConst = "stable" + BackupPolicyPlanLifecycleStateSuspendedConst = "suspended" + BackupPolicyPlanLifecycleStateUpdatingConst = "updating" + BackupPolicyPlanLifecycleStateWaitingConst = "waiting" +) + +// Constants associated with the BackupPolicyPlan.ResourceType property. +// The resource type. +const ( + BackupPolicyPlanResourceTypeBackupPolicyPlanConst = "backup_policy_plan" +) + +// UnmarshalBackupPolicyPlan unmarshals an instance of BackupPolicyPlan from the specified map of raw messages. +func UnmarshalBackupPolicyPlan(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(BackupPolicyPlan) + err = core.UnmarshalPrimitive(m, "active", &obj.Active) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "attach_user_tags", &obj.AttachUserTags) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "copy_user_tags", &obj.CopyUserTags) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "created_at", &obj.CreatedAt) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "cron_spec", &obj.CronSpec) + if err != nil { + return + } + err = core.UnmarshalModel(m, "deletion_trigger", &obj.DeletionTrigger, UnmarshalBackupPolicyPlanDeletionTrigger) + 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, "lifecycle_state", &obj.LifecycleState) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "name", &obj.Name) + 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 +} + +// BackupPolicyPlanCollection : BackupPolicyPlanCollection struct +type BackupPolicyPlanCollection struct { + // Collection of backup policy plans. + Plans []BackupPolicyPlan `json:"plans" validate:"required"` +} + +// UnmarshalBackupPolicyPlanCollection unmarshals an instance of BackupPolicyPlanCollection from the specified map of raw messages. +func UnmarshalBackupPolicyPlanCollection(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(BackupPolicyPlanCollection) + err = core.UnmarshalModel(m, "plans", &obj.Plans, UnmarshalBackupPolicyPlan) + if err != nil { + return + } + reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) + return +} + +// BackupPolicyPlanDeletionTrigger : BackupPolicyPlanDeletionTrigger struct +type BackupPolicyPlanDeletionTrigger struct { + // The maximum number of days to keep each backup after creation. + DeleteAfter *int64 `json:"delete_after" validate:"required"` + + // The maximum number of recent backups to keep. If absent, there is no maximum. + DeleteOverCount *int64 `json:"delete_over_count,omitempty"` +} + +// UnmarshalBackupPolicyPlanDeletionTrigger unmarshals an instance of BackupPolicyPlanDeletionTrigger from the specified map of raw messages. +func UnmarshalBackupPolicyPlanDeletionTrigger(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(BackupPolicyPlanDeletionTrigger) + err = core.UnmarshalPrimitive(m, "delete_after", &obj.DeleteAfter) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "delete_over_count", &obj.DeleteOverCount) + if err != nil { + return + } + reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) + return +} + +// BackupPolicyPlanDeletionTriggerPatch : BackupPolicyPlanDeletionTriggerPatch struct +type BackupPolicyPlanDeletionTriggerPatch struct { + // The maximum number of days to keep each backup after creation. + DeleteAfter *int64 `json:"delete_after,omitempty"` + + // The maximum number of recent backups to keep. Specify `null` to remove any existing maximum. + DeleteOverCount *int64 `json:"delete_over_count,omitempty"` +} + +// UnmarshalBackupPolicyPlanDeletionTriggerPatch unmarshals an instance of BackupPolicyPlanDeletionTriggerPatch from the specified map of raw messages. +func UnmarshalBackupPolicyPlanDeletionTriggerPatch(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(BackupPolicyPlanDeletionTriggerPatch) + err = core.UnmarshalPrimitive(m, "delete_after", &obj.DeleteAfter) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "delete_over_count", &obj.DeleteOverCount) + if err != nil { + return + } + reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) + return +} + +// BackupPolicyPlanDeletionTriggerPrototype : BackupPolicyPlanDeletionTriggerPrototype struct +type BackupPolicyPlanDeletionTriggerPrototype struct { + // The maximum number of days to keep each backup after creation. + DeleteAfter *int64 `json:"delete_after,omitempty"` + + // The maximum number of recent backups to keep. If unspecified, there will be no maximum. + DeleteOverCount *int64 `json:"delete_over_count,omitempty"` +} + +// UnmarshalBackupPolicyPlanDeletionTriggerPrototype unmarshals an instance of BackupPolicyPlanDeletionTriggerPrototype from the specified map of raw messages. +func UnmarshalBackupPolicyPlanDeletionTriggerPrototype(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(BackupPolicyPlanDeletionTriggerPrototype) + err = core.UnmarshalPrimitive(m, "delete_after", &obj.DeleteAfter) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "delete_over_count", &obj.DeleteOverCount) + if err != nil { + return + } + reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) + return +} + +// BackupPolicyPlanPatch : BackupPolicyPlanPatch struct +type BackupPolicyPlanPatch struct { + // Indicates whether the plan is active. + Active *bool `json:"active,omitempty"` + + // The user tags to attach to backups (snapshots) created by this plan. Updating this value does not change the user + // tags for backups that have already been created by this plan. + AttachUserTags []string `json:"attach_user_tags,omitempty"` + + // Indicates whether to copy the source's user tags to the created backups (snapshots). + CopyUserTags *bool `json:"copy_user_tags,omitempty"` + + // The cron specification for the backup schedule. The backup policy jobs + // (which create and delete backups for this plan) will not start until this time, and may start for up to 90 minutes + // after this time. + // + // All backup schedules for plans in the same policy must be at least an hour apart. + CronSpec *string `json:"cron_spec,omitempty"` + + DeletionTrigger *BackupPolicyPlanDeletionTriggerPatch `json:"deletion_trigger,omitempty"` + + // The user-defined name for this backup policy plan. Names must be unique within the backup policy this plan resides + // in. + Name *string `json:"name,omitempty"` +} + +// UnmarshalBackupPolicyPlanPatch unmarshals an instance of BackupPolicyPlanPatch from the specified map of raw messages. +func UnmarshalBackupPolicyPlanPatch(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(BackupPolicyPlanPatch) + err = core.UnmarshalPrimitive(m, "active", &obj.Active) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "attach_user_tags", &obj.AttachUserTags) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "copy_user_tags", &obj.CopyUserTags) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "cron_spec", &obj.CronSpec) + if err != nil { + return + } + err = core.UnmarshalModel(m, "deletion_trigger", &obj.DeletionTrigger, UnmarshalBackupPolicyPlanDeletionTriggerPatch) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "name", &obj.Name) + if err != nil { + return + } + reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) + return +} + +// AsPatch returns a generic map representation of the BackupPolicyPlanPatch +func (backupPolicyPlanPatch *BackupPolicyPlanPatch) AsPatch() (_patch map[string]interface{}, err error) { + var jsonData []byte + jsonData, err = json.Marshal(backupPolicyPlanPatch) if err == nil { err = json.Unmarshal(jsonData, &_patch) } return } +// BackupPolicyPlanPrototype : BackupPolicyPlanPrototype struct +type BackupPolicyPlanPrototype struct { + // Indicates whether the plan is active. + Active *bool `json:"active,omitempty"` + + // User tags to attach to each backup (snapshot) created by this plan. If unspecified, no user tags will be attached. + AttachUserTags []string `json:"attach_user_tags,omitempty"` + + // Indicates whether to copy the source's user tags to the created backups (snapshots). + CopyUserTags *bool `json:"copy_user_tags,omitempty"` + + // The cron specification for the backup schedule. The backup policy jobs + // (which create and delete backups for this plan) will not start until this time, and may start for up to 90 minutes + // after this time. + // + // All backup schedules for plans in the same policy must be at least an hour apart. + CronSpec *string `json:"cron_spec" validate:"required"` + + DeletionTrigger *BackupPolicyPlanDeletionTriggerPrototype `json:"deletion_trigger,omitempty"` + + // The user-defined name for this backup policy plan. Names must be unique within the backup policy this plan resides + // in. If unspecified, the name will be a hyphenated list of randomly-selected words. + Name *string `json:"name,omitempty"` +} + +// NewBackupPolicyPlanPrototype : Instantiate BackupPolicyPlanPrototype (Generic Model Constructor) +func (*VpcV1) NewBackupPolicyPlanPrototype(cronSpec string) (_model *BackupPolicyPlanPrototype, err error) { + _model = &BackupPolicyPlanPrototype{ + CronSpec: core.StringPtr(cronSpec), + } + err = core.ValidateStruct(_model, "required parameters") + return +} + +// UnmarshalBackupPolicyPlanPrototype unmarshals an instance of BackupPolicyPlanPrototype from the specified map of raw messages. +func UnmarshalBackupPolicyPlanPrototype(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(BackupPolicyPlanPrototype) + err = core.UnmarshalPrimitive(m, "active", &obj.Active) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "attach_user_tags", &obj.AttachUserTags) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "copy_user_tags", &obj.CopyUserTags) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "cron_spec", &obj.CronSpec) + if err != nil { + return + } + err = core.UnmarshalModel(m, "deletion_trigger", &obj.DeletionTrigger, UnmarshalBackupPolicyPlanDeletionTriggerPrototype) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "name", &obj.Name) + if err != nil { + return + } + reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) + return +} + +// BackupPolicyPlanReference : BackupPolicyPlanReference struct +type BackupPolicyPlanReference struct { + // If present, this property indicates the referenced resource has been deleted and provides + // some supplementary information. + Deleted *BackupPolicyPlanReferenceDeleted `json:"deleted,omitempty"` + + // The URL for this backup policy plan. + Href *string `json:"href" validate:"required"` + + // The unique identifier for this backup policy plan. + ID *string `json:"id" validate:"required"` + + // The unique user-defined name for this backup policy plan. + Name *string `json:"name" validate:"required"` + + // The resource type. + ResourceType *string `json:"resource_type" validate:"required"` +} + +// Constants associated with the BackupPolicyPlanReference.ResourceType property. +// The resource type. +const ( + BackupPolicyPlanReferenceResourceTypeBackupPolicyPlanConst = "backup_policy_plan" +) + +// UnmarshalBackupPolicyPlanReference unmarshals an instance of BackupPolicyPlanReference from the specified map of raw messages. +func UnmarshalBackupPolicyPlanReference(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(BackupPolicyPlanReference) + err = core.UnmarshalModel(m, "deleted", &obj.Deleted, UnmarshalBackupPolicyPlanReferenceDeleted) + 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.UnmarshalPrimitive(m, "resource_type", &obj.ResourceType) + if err != nil { + return + } + reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) + return +} + +// BackupPolicyPlanReferenceDeleted : If present, this property indicates the referenced resource has been deleted and provides some supplementary +// information. +type BackupPolicyPlanReferenceDeleted struct { + // Link to documentation about deleted resources. + MoreInfo *string `json:"more_info" validate:"required"` +} + +// UnmarshalBackupPolicyPlanReferenceDeleted unmarshals an instance of BackupPolicyPlanReferenceDeleted from the specified map of raw messages. +func UnmarshalBackupPolicyPlanReferenceDeleted(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(BackupPolicyPlanReferenceDeleted) + err = core.UnmarshalPrimitive(m, "more_info", &obj.MoreInfo) + if err != nil { + return + } + reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) + return +} + // BareMetalServer : BareMetalServer struct type BareMetalServer struct { // The total bandwidth (in megabits per second) shared across the bare metal server's network interfaces. @@ -22297,6 +23677,165 @@ func (options *CheckVPNGatewayConnectionPeerCIDROptions) SetHeaders(param map[st return options } +// CreateBackupPolicyOptions : The CreateBackupPolicy options. +type CreateBackupPolicyOptions struct { + // A 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. + MatchResourceTypes []string `json:"match_resource_types,omitempty"` + + // 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,omitempty"` + + // The user-defined name for this backup policy. Names must be unique within the region this backup policy resides in. + // 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) is used. + ResourceGroup ResourceGroupIdentityIntf `json:"resource_group,omitempty"` + + // 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() *CreateBackupPolicyOptions { + return &CreateBackupPolicyOptions{} +} + +// SetMatchResourceTypes : Allow user to set MatchResourceTypes +func (_options *CreateBackupPolicyOptions) SetMatchResourceTypes(matchResourceTypes []string) *CreateBackupPolicyOptions { + _options.MatchResourceTypes = matchResourceTypes + return _options +} + +// SetMatchUserTags : Allow user to set MatchUserTags +func (_options *CreateBackupPolicyOptions) SetMatchUserTags(matchUserTags []string) *CreateBackupPolicyOptions { + _options.MatchUserTags = matchUserTags + 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 +} + +// SetHeaders : Allow user to set Headers +func (options *CreateBackupPolicyOptions) SetHeaders(param map[string]string) *CreateBackupPolicyOptions { + options.Headers = param + return options +} + +// CreateBackupPolicyPlanOptions : The CreateBackupPolicyPlan options. +type CreateBackupPolicyPlanOptions struct { + // The backup policy identifier. + BackupPolicyID *string `json:"backup_policy_id" validate:"required,ne="` + + // The cron specification for the backup schedule. The backup policy jobs + // (which create and delete backups for this plan) will not start until this time, and may start for up to 90 minutes + // after this time. + // + // All backup schedules for plans in the same policy must be at least an hour apart. + CronSpec *string `json:"cron_spec" validate:"required"` + + // Indicates whether the plan is active. + Active *bool `json:"active,omitempty"` + + // User tags to attach to each backup (snapshot) created by this plan. If unspecified, no user tags will be attached. + AttachUserTags []string `json:"attach_user_tags,omitempty"` + + // Indicates whether to copy the source's user tags to the created backups (snapshots). + CopyUserTags *bool `json:"copy_user_tags,omitempty"` + + DeletionTrigger *BackupPolicyPlanDeletionTriggerPrototype `json:"deletion_trigger,omitempty"` + + // The user-defined name for this backup policy plan. Names must be unique within the backup policy this plan resides + // in. If unspecified, the name will be a hyphenated list of randomly-selected words. + Name *string `json:"name,omitempty"` + + // Allows users to set headers on API requests + Headers map[string]string +} + +// NewCreateBackupPolicyPlanOptions : Instantiate CreateBackupPolicyPlanOptions +func (*VpcV1) NewCreateBackupPolicyPlanOptions(backupPolicyID string, cronSpec string) *CreateBackupPolicyPlanOptions { + return &CreateBackupPolicyPlanOptions{ + BackupPolicyID: core.StringPtr(backupPolicyID), + CronSpec: core.StringPtr(cronSpec), + } +} + +// SetBackupPolicyID : Allow user to set BackupPolicyID +func (_options *CreateBackupPolicyPlanOptions) SetBackupPolicyID(backupPolicyID string) *CreateBackupPolicyPlanOptions { + _options.BackupPolicyID = core.StringPtr(backupPolicyID) + return _options +} + +// SetCronSpec : Allow user to set CronSpec +func (_options *CreateBackupPolicyPlanOptions) SetCronSpec(cronSpec string) *CreateBackupPolicyPlanOptions { + _options.CronSpec = core.StringPtr(cronSpec) + return _options +} + +// SetActive : Allow user to set Active +func (_options *CreateBackupPolicyPlanOptions) SetActive(active bool) *CreateBackupPolicyPlanOptions { + _options.Active = core.BoolPtr(active) + return _options +} + +// SetAttachUserTags : Allow user to set AttachUserTags +func (_options *CreateBackupPolicyPlanOptions) SetAttachUserTags(attachUserTags []string) *CreateBackupPolicyPlanOptions { + _options.AttachUserTags = attachUserTags + return _options +} + +// SetCopyUserTags : Allow user to set CopyUserTags +func (_options *CreateBackupPolicyPlanOptions) SetCopyUserTags(copyUserTags bool) *CreateBackupPolicyPlanOptions { + _options.CopyUserTags = core.BoolPtr(copyUserTags) + return _options +} + +// SetDeletionTrigger : Allow user to set DeletionTrigger +func (_options *CreateBackupPolicyPlanOptions) SetDeletionTrigger(deletionTrigger *BackupPolicyPlanDeletionTriggerPrototype) *CreateBackupPolicyPlanOptions { + _options.DeletionTrigger = deletionTrigger + return _options +} + +// SetName : Allow user to set Name +func (_options *CreateBackupPolicyPlanOptions) SetName(name string) *CreateBackupPolicyPlanOptions { + _options.Name = core.StringPtr(name) + return _options +} + +// SetHeaders : Allow user to set Headers +func (options *CreateBackupPolicyPlanOptions) SetHeaders(param map[string]string) *CreateBackupPolicyPlanOptions { + options.Headers = param + return options +} + // CreateBareMetalServerConsoleAccessTokenOptions : The CreateBareMetalServerConsoleAccessToken options. type CreateBareMetalServerConsoleAccessTokenOptions struct { // The bare metal server identifier. @@ -27329,6 +28868,90 @@ func UnmarshalDefaultSecurityGroup(m map[string]json.RawMessage, result interfac return } +// DeleteBackupPolicyOptions : The DeleteBackupPolicy options. +type DeleteBackupPolicyOptions struct { + // The backup policy identifier. + ID *string `json:"id" validate:"required,ne="` + + // If present, the request will fail if the specified ETag value does not match the resource's current ETag value. + IfMatch *string `json:"If-Match,omitempty"` + + // Allows users to set headers on API requests + Headers map[string]string +} + +// NewDeleteBackupPolicyOptions : Instantiate DeleteBackupPolicyOptions +func (*VpcV1) NewDeleteBackupPolicyOptions(id string) *DeleteBackupPolicyOptions { + return &DeleteBackupPolicyOptions{ + ID: core.StringPtr(id), + } +} + +// SetID : Allow user to set ID +func (_options *DeleteBackupPolicyOptions) SetID(id string) *DeleteBackupPolicyOptions { + _options.ID = core.StringPtr(id) + return _options +} + +// SetIfMatch : Allow user to set IfMatch +func (_options *DeleteBackupPolicyOptions) SetIfMatch(ifMatch string) *DeleteBackupPolicyOptions { + _options.IfMatch = core.StringPtr(ifMatch) + return _options +} + +// SetHeaders : Allow user to set Headers +func (options *DeleteBackupPolicyOptions) SetHeaders(param map[string]string) *DeleteBackupPolicyOptions { + options.Headers = param + return options +} + +// DeleteBackupPolicyPlanOptions : The DeleteBackupPolicyPlan options. +type DeleteBackupPolicyPlanOptions struct { + // The backup policy identifier. + BackupPolicyID *string `json:"backup_policy_id" validate:"required,ne="` + + // The backup policy plan identifier. + ID *string `json:"id" validate:"required,ne="` + + // If present, the request will fail if the specified ETag value does not match the resource's current ETag value. + IfMatch *string `json:"If-Match,omitempty"` + + // Allows users to set headers on API requests + Headers map[string]string +} + +// NewDeleteBackupPolicyPlanOptions : Instantiate DeleteBackupPolicyPlanOptions +func (*VpcV1) NewDeleteBackupPolicyPlanOptions(backupPolicyID string, id string) *DeleteBackupPolicyPlanOptions { + return &DeleteBackupPolicyPlanOptions{ + BackupPolicyID: core.StringPtr(backupPolicyID), + ID: core.StringPtr(id), + } +} + +// SetBackupPolicyID : Allow user to set BackupPolicyID +func (_options *DeleteBackupPolicyPlanOptions) SetBackupPolicyID(backupPolicyID string) *DeleteBackupPolicyPlanOptions { + _options.BackupPolicyID = core.StringPtr(backupPolicyID) + return _options +} + +// SetID : Allow user to set ID +func (_options *DeleteBackupPolicyPlanOptions) SetID(id string) *DeleteBackupPolicyPlanOptions { + _options.ID = core.StringPtr(id) + return _options +} + +// SetIfMatch : Allow user to set IfMatch +func (_options *DeleteBackupPolicyPlanOptions) SetIfMatch(ifMatch string) *DeleteBackupPolicyPlanOptions { + _options.IfMatch = core.StringPtr(ifMatch) + return _options +} + +// SetHeaders : Allow user to set Headers +func (options *DeleteBackupPolicyPlanOptions) SetHeaders(param map[string]string) *DeleteBackupPolicyPlanOptions { + options.Headers = param + return options +} + // DeleteBareMetalServerNetworkInterfaceOptions : The DeleteBareMetalServerNetworkInterface options. type DeleteBareMetalServerNetworkInterfaceOptions struct { // The bare metal server identifier. @@ -28949,7 +30572,7 @@ func (options *DeleteVPNGatewayOptions) SetHeaders(param map[string]string) *Del type EncryptionKeyIdentity struct { // The CRN of the [Key Protect Root // Key](https://cloud.ibm.com/docs/key-protect?topic=key-protect-getting-started-tutorial) or [Hyper Protect Crypto - // Service Root Key](https://cloud.ibm.com/docs/hs-crypto?topic=hs-crypto-get-started) for this resource. + // Services Root Key](https://cloud.ibm.com/docs/hs-crypto?topic=hs-crypto-get-started) for this resource. CRN *string `json:"crn,omitempty"` } @@ -28976,7 +30599,7 @@ func UnmarshalEncryptionKeyIdentity(m map[string]json.RawMessage, result interfa type EncryptionKeyReference struct { // The CRN of the [Key Protect Root // Key](https://cloud.ibm.com/docs/key-protect?topic=key-protect-getting-started-tutorial) or [Hyper Protect Crypto - // Service Root Key](https://cloud.ibm.com/docs/hs-crypto?topic=hs-crypto-get-started) for this resource. + // Services Root Key](https://cloud.ibm.com/docs/hs-crypto?topic=hs-crypto-get-started) for this resource. CRN *string `json:"crn" validate:"required"` } @@ -30333,6 +31956,72 @@ func UnmarshalGenericResourceReferenceDeleted(m map[string]json.RawMessage, resu return } +// GetBackupPolicyOptions : The GetBackupPolicy options. +type GetBackupPolicyOptions struct { + // The backup policy identifier. + ID *string `json:"id" validate:"required,ne="` + + // Allows users to set headers on API requests + Headers map[string]string +} + +// NewGetBackupPolicyOptions : Instantiate GetBackupPolicyOptions +func (*VpcV1) NewGetBackupPolicyOptions(id string) *GetBackupPolicyOptions { + return &GetBackupPolicyOptions{ + ID: core.StringPtr(id), + } +} + +// SetID : Allow user to set ID +func (_options *GetBackupPolicyOptions) SetID(id string) *GetBackupPolicyOptions { + _options.ID = core.StringPtr(id) + return _options +} + +// SetHeaders : Allow user to set Headers +func (options *GetBackupPolicyOptions) SetHeaders(param map[string]string) *GetBackupPolicyOptions { + options.Headers = param + return options +} + +// GetBackupPolicyPlanOptions : The GetBackupPolicyPlan options. +type GetBackupPolicyPlanOptions struct { + // The backup policy identifier. + BackupPolicyID *string `json:"backup_policy_id" validate:"required,ne="` + + // The backup policy plan identifier. + ID *string `json:"id" validate:"required,ne="` + + // Allows users to set headers on API requests + Headers map[string]string +} + +// NewGetBackupPolicyPlanOptions : Instantiate GetBackupPolicyPlanOptions +func (*VpcV1) NewGetBackupPolicyPlanOptions(backupPolicyID string, id string) *GetBackupPolicyPlanOptions { + return &GetBackupPolicyPlanOptions{ + BackupPolicyID: core.StringPtr(backupPolicyID), + ID: core.StringPtr(id), + } +} + +// SetBackupPolicyID : Allow user to set BackupPolicyID +func (_options *GetBackupPolicyPlanOptions) SetBackupPolicyID(backupPolicyID string) *GetBackupPolicyPlanOptions { + _options.BackupPolicyID = core.StringPtr(backupPolicyID) + return _options +} + +// SetID : Allow user to set ID +func (_options *GetBackupPolicyPlanOptions) SetID(id string) *GetBackupPolicyPlanOptions { + _options.ID = core.StringPtr(id) + return _options +} + +// SetHeaders : Allow user to set Headers +func (options *GetBackupPolicyPlanOptions) SetHeaders(param map[string]string) *GetBackupPolicyPlanOptions { + options.Headers = param + return options +} + // GetBareMetalServerDiskOptions : The GetBareMetalServerDisk options. type GetBareMetalServerDiskOptions struct { // The bare metal server identifier. @@ -33881,7 +35570,7 @@ type ImagePrototype struct { // // That representation is created by wrapping the key's value with the `encryption_key` root key (which must also be // specified), using either [Key Protect](https://cloud.ibm.com/docs/key-protect?topic=key-protect-wrap-keys) or the - // [Hyper Protect Crypto Service](https://cloud.ibm.com/docs/services/hs-crypto?topic=hs-crypto-wrap-keys). + // [Hyper Protect Crypto Services](https://cloud.ibm.com/docs/services/hs-crypto?topic=hs-crypto-wrap-keys). // // If unspecified, the imported image is treated as unencrypted. EncryptedDataKey *string `json:"encrypted_data_key,omitempty"` @@ -38412,10 +40101,11 @@ type InstancePrototype struct { // `total_network_bandwidth`. TotalVolumeBandwidth *int64 `json:"total_volume_bandwidth,omitempty"` - // User data to be made available when setting up the virtual server instance. + // [User data](https://cloud.ibm.com/docs/vpc?topic=vpc-user-data) to make available when setting up the virtual server + // instance. UserData *string `json:"user_data,omitempty"` - // The volume attachments for this virtual server instance. + // The additional volume attachments to create for the virtual server instance. VolumeAttachments []VolumeAttachmentPrototypeInstanceContext `json:"volume_attachments,omitempty"` // The VPC the virtual server instance is to be a part of. If specified, it must match @@ -38701,10 +40391,11 @@ type InstanceTemplate struct { // `total_network_bandwidth`. TotalVolumeBandwidth *int64 `json:"total_volume_bandwidth,omitempty"` - // User data to be made available when setting up the virtual server instance. + // [User data](https://cloud.ibm.com/docs/vpc?topic=vpc-user-data) to make available when setting up the virtual server + // instance. UserData *string `json:"user_data,omitempty"` - // The volume attachments for this virtual server instance. + // The additional volume attachments to create for the virtual server instance. VolumeAttachments []VolumeAttachmentPrototypeInstanceContext `json:"volume_attachments,omitempty"` // The VPC the virtual server instance is to be a part of. If specified, it must match @@ -39029,10 +40720,11 @@ type InstanceTemplatePrototype struct { // `total_network_bandwidth`. TotalVolumeBandwidth *int64 `json:"total_volume_bandwidth,omitempty"` - // User data to be made available when setting up the virtual server instance. + // [User data](https://cloud.ibm.com/docs/vpc?topic=vpc-user-data) to make available when setting up the virtual server + // instance. UserData *string `json:"user_data,omitempty"` - // The volume attachments for this virtual server instance. + // The additional volume attachments to create for the virtual server instance. VolumeAttachments []VolumeAttachmentPrototypeInstanceContext `json:"volume_attachments,omitempty"` // The VPC the virtual server instance is to be a part of. If specified, it must match @@ -39605,6 +41297,105 @@ func UnmarshalLegacyCloudObjectStorageBucketReference(m map[string]json.RawMessa return } +// ListBackupPoliciesOptions : The ListBackupPolicies options. +type ListBackupPoliciesOptions 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 in the resource group with the specified identifier. + ResourceGroupID *string `json:"resource_group.id,omitempty"` + + // Filters the collection to resources with the exact specified name. + Name *string `json:"name,omitempty"` + + // Filters the collection to resources with the exact tag value. + Tag *string `json:"tag,omitempty"` + + // Allows users to set headers on API requests + Headers map[string]string +} + +// NewListBackupPoliciesOptions : Instantiate ListBackupPoliciesOptions +func (*VpcV1) NewListBackupPoliciesOptions() *ListBackupPoliciesOptions { + return &ListBackupPoliciesOptions{} +} + +// SetStart : Allow user to set Start +func (_options *ListBackupPoliciesOptions) SetStart(start string) *ListBackupPoliciesOptions { + _options.Start = core.StringPtr(start) + return _options +} + +// SetLimit : Allow user to set Limit +func (_options *ListBackupPoliciesOptions) SetLimit(limit int64) *ListBackupPoliciesOptions { + _options.Limit = core.Int64Ptr(limit) + return _options +} + +// SetResourceGroupID : Allow user to set ResourceGroupID +func (_options *ListBackupPoliciesOptions) SetResourceGroupID(resourceGroupID string) *ListBackupPoliciesOptions { + _options.ResourceGroupID = core.StringPtr(resourceGroupID) + return _options +} + +// SetName : Allow user to set Name +func (_options *ListBackupPoliciesOptions) SetName(name string) *ListBackupPoliciesOptions { + _options.Name = core.StringPtr(name) + return _options +} + +// SetTag : Allow user to set Tag +func (_options *ListBackupPoliciesOptions) SetTag(tag string) *ListBackupPoliciesOptions { + _options.Tag = core.StringPtr(tag) + return _options +} + +// SetHeaders : Allow user to set Headers +func (options *ListBackupPoliciesOptions) SetHeaders(param map[string]string) *ListBackupPoliciesOptions { + options.Headers = param + return options +} + +// ListBackupPolicyPlansOptions : The ListBackupPolicyPlans options. +type ListBackupPolicyPlansOptions struct { + // The backup policy identifier. + BackupPolicyID *string `json:"backup_policy_id" validate:"required,ne="` + + // Filters the collection to resources with the exact specified name. + Name *string `json:"name,omitempty"` + + // Allows users to set headers on API requests + Headers map[string]string +} + +// NewListBackupPolicyPlansOptions : Instantiate ListBackupPolicyPlansOptions +func (*VpcV1) NewListBackupPolicyPlansOptions(backupPolicyID string) *ListBackupPolicyPlansOptions { + return &ListBackupPolicyPlansOptions{ + BackupPolicyID: core.StringPtr(backupPolicyID), + } +} + +// SetBackupPolicyID : Allow user to set BackupPolicyID +func (_options *ListBackupPolicyPlansOptions) SetBackupPolicyID(backupPolicyID string) *ListBackupPolicyPlansOptions { + _options.BackupPolicyID = core.StringPtr(backupPolicyID) + return _options +} + +// SetName : Allow user to set Name +func (_options *ListBackupPolicyPlansOptions) SetName(name string) *ListBackupPolicyPlansOptions { + _options.Name = core.StringPtr(name) + return _options +} + +// SetHeaders : Allow user to set Headers +func (options *ListBackupPolicyPlansOptions) SetHeaders(param map[string]string) *ListBackupPolicyPlansOptions { + options.Headers = param + return options +} + // ListBareMetalServerDisksOptions : The ListBareMetalServerDisks options. type ListBareMetalServerDisksOptions struct { // The bare metal server identifier. @@ -41902,6 +43693,9 @@ type ListSnapshotsOptions struct { // 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 the backup plan with the specified identifier. + BackupPolicyPlanID *string `json:"backup_policy_plan.id,omitempty"` + // Allows users to set headers on API requests Headers map[string]string } @@ -41980,6 +43774,12 @@ func (_options *ListSnapshotsOptions) SetSort(sort string) *ListSnapshotsOptions return _options } +// SetBackupPolicyPlanID : Allow user to set BackupPolicyPlanID +func (_options *ListSnapshotsOptions) SetBackupPolicyPlanID(backupPolicyPlanID string) *ListSnapshotsOptions { + _options.BackupPolicyPlanID = core.StringPtr(backupPolicyPlanID) + return _options +} + // SetHeaders : Allow user to set Headers func (options *ListSnapshotsOptions) SetHeaders(param map[string]string) *ListSnapshotsOptions { options.Headers = param @@ -51806,6 +53606,9 @@ func (options *SetSubnetPublicGatewayOptions) SetHeaders(param map[string]string // Snapshot : Snapshot struct type Snapshot struct { + // If present, the backup policy plan which created this snapshot. + BackupPolicyPlan *BackupPolicyPlanReference `json:"backup_policy_plan,omitempty"` + // Indicates if a boot volume attachment can be created with a volume created from this snapshot. Bootable *bool `json:"bootable" validate:"required"` @@ -51905,6 +53708,10 @@ const ( // UnmarshalSnapshot unmarshals an instance of Snapshot from the specified map of raw messages. func UnmarshalSnapshot(m map[string]json.RawMessage, result interface{}) (err error) { obj := new(Snapshot) + err = core.UnmarshalModel(m, "backup_policy_plan", &obj.BackupPolicyPlan, UnmarshalBackupPolicyPlanReference) + if err != nil { + return + } err = core.UnmarshalPrimitive(m, "bootable", &obj.Bootable) if err != nil { return @@ -53028,6 +54835,112 @@ func (options *UnsetSubnetPublicGatewayOptions) SetHeaders(param map[string]stri return options } +// UpdateBackupPolicyOptions : The UpdateBackupPolicy options. +type UpdateBackupPolicyOptions struct { + // The backup policy identifier. + ID *string `json:"id" validate:"required,ne="` + + // The backup policy patch. + BackupPolicyPatch map[string]interface{} `json:"BackupPolicy_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 +} + +// NewUpdateBackupPolicyOptions : Instantiate UpdateBackupPolicyOptions +func (*VpcV1) NewUpdateBackupPolicyOptions(id string, backupPolicyPatch map[string]interface{}) *UpdateBackupPolicyOptions { + return &UpdateBackupPolicyOptions{ + ID: core.StringPtr(id), + BackupPolicyPatch: backupPolicyPatch, + } +} + +// SetID : Allow user to set ID +func (_options *UpdateBackupPolicyOptions) SetID(id string) *UpdateBackupPolicyOptions { + _options.ID = core.StringPtr(id) + return _options +} + +// SetBackupPolicyPatch : Allow user to set BackupPolicyPatch +func (_options *UpdateBackupPolicyOptions) SetBackupPolicyPatch(backupPolicyPatch map[string]interface{}) *UpdateBackupPolicyOptions { + _options.BackupPolicyPatch = backupPolicyPatch + return _options +} + +// SetIfMatch : Allow user to set IfMatch +func (_options *UpdateBackupPolicyOptions) SetIfMatch(ifMatch string) *UpdateBackupPolicyOptions { + _options.IfMatch = core.StringPtr(ifMatch) + return _options +} + +// SetHeaders : Allow user to set Headers +func (options *UpdateBackupPolicyOptions) SetHeaders(param map[string]string) *UpdateBackupPolicyOptions { + options.Headers = param + return options +} + +// UpdateBackupPolicyPlanOptions : The UpdateBackupPolicyPlan options. +type UpdateBackupPolicyPlanOptions struct { + // The backup policy identifier. + BackupPolicyID *string `json:"backup_policy_id" validate:"required,ne="` + + // The backup policy plan identifier. + ID *string `json:"id" validate:"required,ne="` + + // The backup policy plan patch. + BackupPolicyPlanPatch map[string]interface{} `json:"BackupPolicyPlan_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 +} + +// NewUpdateBackupPolicyPlanOptions : Instantiate UpdateBackupPolicyPlanOptions +func (*VpcV1) NewUpdateBackupPolicyPlanOptions(backupPolicyID string, id string, backupPolicyPlanPatch map[string]interface{}) *UpdateBackupPolicyPlanOptions { + return &UpdateBackupPolicyPlanOptions{ + BackupPolicyID: core.StringPtr(backupPolicyID), + ID: core.StringPtr(id), + BackupPolicyPlanPatch: backupPolicyPlanPatch, + } +} + +// SetBackupPolicyID : Allow user to set BackupPolicyID +func (_options *UpdateBackupPolicyPlanOptions) SetBackupPolicyID(backupPolicyID string) *UpdateBackupPolicyPlanOptions { + _options.BackupPolicyID = core.StringPtr(backupPolicyID) + return _options +} + +// SetID : Allow user to set ID +func (_options *UpdateBackupPolicyPlanOptions) SetID(id string) *UpdateBackupPolicyPlanOptions { + _options.ID = core.StringPtr(id) + return _options +} + +// SetBackupPolicyPlanPatch : Allow user to set BackupPolicyPlanPatch +func (_options *UpdateBackupPolicyPlanOptions) SetBackupPolicyPlanPatch(backupPolicyPlanPatch map[string]interface{}) *UpdateBackupPolicyPlanOptions { + _options.BackupPolicyPlanPatch = backupPolicyPlanPatch + return _options +} + +// SetIfMatch : Allow user to set IfMatch +func (_options *UpdateBackupPolicyPlanOptions) SetIfMatch(ifMatch string) *UpdateBackupPolicyPlanOptions { + _options.IfMatch = core.StringPtr(ifMatch) + return _options +} + +// SetHeaders : Allow user to set Headers +func (options *UpdateBackupPolicyPlanOptions) SetHeaders(param map[string]string) *UpdateBackupPolicyPlanOptions { + options.Headers = param + return options +} + // UpdateBareMetalServerDiskOptions : The UpdateBareMetalServerDisk options. type UpdateBareMetalServerDiskOptions struct { // The bare metal server identifier. @@ -60860,7 +62773,7 @@ func UnmarshalDedicatedHostPrototypeDedicatedHostByZone(m map[string]json.RawMes type EncryptionKeyIdentityByCRN struct { // The CRN of the [Key Protect Root // Key](https://cloud.ibm.com/docs/key-protect?topic=key-protect-getting-started-tutorial) or [Hyper Protect Crypto - // Service Root Key](https://cloud.ibm.com/docs/hs-crypto?topic=hs-crypto-get-started) for this resource. + // Services Root Key](https://cloud.ibm.com/docs/hs-crypto?topic=hs-crypto-get-started) for this resource. CRN *string `json:"crn" validate:"required"` } @@ -62023,7 +63936,7 @@ type ImagePrototypeImageByFile struct { // // That representation is created by wrapping the key's value with the `encryption_key` root key (which must also be // specified), using either [Key Protect](https://cloud.ibm.com/docs/key-protect?topic=key-protect-wrap-keys) or the - // [Hyper Protect Crypto Service](https://cloud.ibm.com/docs/services/hs-crypto?topic=hs-crypto-wrap-keys). + // [Hyper Protect Crypto Services](https://cloud.ibm.com/docs/services/hs-crypto?topic=hs-crypto-wrap-keys). // // If unspecified, the imported image is treated as unencrypted. EncryptedDataKey *string `json:"encrypted_data_key,omitempty"` @@ -64933,10 +66846,11 @@ type InstancePrototypeInstanceByImage struct { // `total_network_bandwidth`. TotalVolumeBandwidth *int64 `json:"total_volume_bandwidth,omitempty"` - // User data to be made available when setting up the virtual server instance. + // [User data](https://cloud.ibm.com/docs/vpc?topic=vpc-user-data) to make available when setting up the virtual server + // instance. UserData *string `json:"user_data,omitempty"` - // The volume attachments for this virtual server instance. + // The additional volume attachments to create for the virtual server instance. VolumeAttachments []VolumeAttachmentPrototypeInstanceContext `json:"volume_attachments,omitempty"` // The VPC the virtual server instance is to be a part of. If specified, it must match the VPC referenced by the @@ -65094,10 +67008,11 @@ type InstancePrototypeInstanceBySourceSnapshot struct { // `total_network_bandwidth`. TotalVolumeBandwidth *int64 `json:"total_volume_bandwidth,omitempty"` - // User data to be made available when setting up the virtual server instance. + // [User data](https://cloud.ibm.com/docs/vpc?topic=vpc-user-data) to make available when setting up the virtual server + // instance. UserData *string `json:"user_data,omitempty"` - // The volume attachments for this virtual server instance. + // The additional volume attachments to create for the virtual server instance. VolumeAttachments []VolumeAttachmentPrototypeInstanceContext `json:"volume_attachments,omitempty"` // The VPC the virtual server instance is to be a part of. If specified, it must match the VPC referenced by the @@ -65248,10 +67163,11 @@ type InstancePrototypeInstanceBySourceTemplate struct { // `total_network_bandwidth`. TotalVolumeBandwidth *int64 `json:"total_volume_bandwidth,omitempty"` - // User data to be made available when setting up the virtual server instance. + // [User data](https://cloud.ibm.com/docs/vpc?topic=vpc-user-data) to make available when setting up the virtual server + // instance. UserData *string `json:"user_data,omitempty"` - // The volume attachments for this virtual server instance. + // The additional volume attachments to create for the virtual server instance. VolumeAttachments []VolumeAttachmentPrototypeInstanceContext `json:"volume_attachments,omitempty"` // The VPC the virtual server instance is to be a part of. If specified, it must match the VPC referenced by the @@ -65507,10 +67423,11 @@ type InstanceTemplatePrototypeInstanceByImage struct { // `total_network_bandwidth`. TotalVolumeBandwidth *int64 `json:"total_volume_bandwidth,omitempty"` - // User data to be made available when setting up the virtual server instance. + // [User data](https://cloud.ibm.com/docs/vpc?topic=vpc-user-data) to make available when setting up the virtual server + // instance. UserData *string `json:"user_data,omitempty"` - // The volume attachments for this virtual server instance. + // The additional volume attachments to create for the virtual server instance. VolumeAttachments []VolumeAttachmentPrototypeInstanceContext `json:"volume_attachments,omitempty"` // The VPC the virtual server instance is to be a part of. If specified, it must match the VPC referenced by the @@ -65668,10 +67585,11 @@ type InstanceTemplatePrototypeInstanceBySourceTemplate struct { // `total_network_bandwidth`. TotalVolumeBandwidth *int64 `json:"total_volume_bandwidth,omitempty"` - // User data to be made available when setting up the virtual server instance. + // [User data](https://cloud.ibm.com/docs/vpc?topic=vpc-user-data) to make available when setting up the virtual server + // instance. UserData *string `json:"user_data,omitempty"` - // The volume attachments for this virtual server instance. + // The additional volume attachments to create for the virtual server instance. VolumeAttachments []VolumeAttachmentPrototypeInstanceContext `json:"volume_attachments,omitempty"` // The VPC the virtual server instance is to be a part of. If specified, it must match the VPC referenced by the @@ -65846,10 +67764,11 @@ type InstanceTemplateInstanceByImage struct { // `total_network_bandwidth`. TotalVolumeBandwidth *int64 `json:"total_volume_bandwidth,omitempty"` - // User data to be made available when setting up the virtual server instance. + // [User data](https://cloud.ibm.com/docs/vpc?topic=vpc-user-data) to make available when setting up the virtual server + // instance. UserData *string `json:"user_data,omitempty"` - // The volume attachments for this virtual server instance. + // The additional volume attachments to create for the virtual server instance. VolumeAttachments []VolumeAttachmentPrototypeInstanceContext `json:"volume_attachments,omitempty"` // The VPC the virtual server instance is to be a part of. If specified, it must match the VPC referenced by the @@ -66024,10 +67943,11 @@ type InstanceTemplateInstanceBySourceSnapshot struct { // `total_network_bandwidth`. TotalVolumeBandwidth *int64 `json:"total_volume_bandwidth,omitempty"` - // User data to be made available when setting up the virtual server instance. + // [User data](https://cloud.ibm.com/docs/vpc?topic=vpc-user-data) to make available when setting up the virtual server + // instance. UserData *string `json:"user_data,omitempty"` - // The volume attachments for this virtual server instance. + // The additional volume attachments to create for the virtual server instance. VolumeAttachments []VolumeAttachmentPrototypeInstanceContext `json:"volume_attachments,omitempty"` // The VPC the virtual server instance is to be a part of. If specified, it must match the VPC referenced by the diff --git a/vpcv1/vpc_v1_examples_test.go b/vpcv1/vpc_v1_examples_test.go index 6419ee9..73bc709 100644 --- a/vpcv1/vpc_v1_examples_test.go +++ b/vpcv1/vpc_v1_examples_test.go @@ -34,6 +34,9 @@ var ( serviceErr error configLoaded bool = false externalConfigFile = "../vpc.env" + backupPolicyID string + backupPolicyPlanID string + backupPolicyJobID string vpcID string subnetID string keyID string @@ -4280,6 +4283,188 @@ var _ = Describe(`VpcV1 Examples Tests`, func() { }) + It(`ListBackupPolicies request example`, func() { + fmt.Println("\nListBackupPolicies() result:") + // begin-list_backup_policies + + listBackupPoliciesOptions := vpcService.NewListBackupPoliciesOptions() + + backupPolicyCollection, response, err := vpcService.ListBackupPolicies(listBackupPoliciesOptions) + if err != nil { + panic(err) + } + + // end-list_backup_policies + + Expect(err).To(BeNil()) + Expect(response.StatusCode).To(Equal(200)) + Expect(backupPolicyCollection).ToNot(BeNil()) + + }) + It(`CreateBackupPolicy request example`, func() { + fmt.Println("\nCreateBackupPolicy() result:") + // begin-create_backup_policy + + createBackupPolicyOptions := vpcService.NewCreateBackupPolicyOptions() + userTags := []string{"tag1", "tag2"} + createBackupPolicyOptions.SetName("my-backup-policy") + createBackupPolicyOptions.SetMatchUserTags(userTags) + + backupPolicy, response, err := vpcService.CreateBackupPolicy(createBackupPolicyOptions) + if err != nil { + panic(err) + } + + // end-create_backup_policy + backupPolicyID = *backupPolicy.ID + + Expect(err).To(BeNil()) + Expect(response.StatusCode).To(Equal(201)) + Expect(backupPolicy).ToNot(BeNil()) + + }) + It(`CreateBackupPolicyPlan request example`, func() { + fmt.Println("\nCreateBackupPolicyPlan() result:") + // begin-create_backup_policy_plan + + createBackupPolicyPlanOptions := vpcService.NewCreateBackupPolicyPlanOptions( + backupPolicyID, + "*/5 1,2,3 * * *", + ) + createBackupPolicyPlanOptions.SetName("my-backup-policy-plan") + + backupPolicyPlan, response, err := vpcService.CreateBackupPolicyPlan(createBackupPolicyPlanOptions) + if err != nil { + panic(err) + } + + // end-create_backup_policy_plan + backupPolicyPlanID = *backupPolicyPlan.ID + Expect(err).To(BeNil()) + Expect(response.StatusCode).To(Equal(201)) + Expect(backupPolicyPlan).ToNot(BeNil()) + + }) + It(`ListBackupPolicyPlans request example`, func() { + fmt.Println("\nListBackupPolicyPlans() result:") + // begin-list_backup_policy_plans + + listBackupPolicyPlansOptions := vpcService.NewListBackupPolicyPlansOptions( + backupPolicyID, + ) + + backupPolicyPlanCollection, response, err := vpcService.ListBackupPolicyPlans(listBackupPolicyPlansOptions) + if err != nil { + panic(err) + } + + // end-list_backup_policy_plans + + Expect(err).To(BeNil()) + Expect(response.StatusCode).To(Equal(200)) + Expect(backupPolicyPlanCollection).ToNot(BeNil()) + + }) + + It(`GetBackupPolicyPlan request example`, func() { + fmt.Println("\nGetBackupPolicyPlan() result:") + // begin-get_backup_policy_plan + + getBackupPolicyPlanOptions := vpcService.NewGetBackupPolicyPlanOptions( + backupPolicyID, + backupPolicyPlanID, + ) + + backupPolicyPlan, response, err := vpcService.GetBackupPolicyPlan(getBackupPolicyPlanOptions) + if err != nil { + panic(err) + } + + // end-get_backup_policy_plan + + Expect(err).To(BeNil()) + Expect(response.StatusCode).To(Equal(200)) + Expect(backupPolicyPlan).ToNot(BeNil()) + + }) + It(`UpdateBackupPolicyPlan request example`, func() { + fmt.Println("\nUpdateBackupPolicyPlan() result:") + // begin-update_backup_policy_plan + + backupPolicyPlanPatchModel := &vpcv1.BackupPolicyPlanPatch{ + Name: core.StringPtr("my-backup-plan-updated"), + } + backupPolicyPlanPatchModelAsPatch, asPatchErr := backupPolicyPlanPatchModel.AsPatch() + Expect(asPatchErr).To(BeNil()) + + updateBackupPolicyPlanOptions := vpcService.NewUpdateBackupPolicyPlanOptions( + backupPolicyID, + backupPolicyPlanID, + backupPolicyPlanPatchModelAsPatch, + ) + updateBackupPolicyPlanOptions.SetIfMatch(`W/"96d225c4-56bd-43d9-98fc-d7148e5c5028"`) + + backupPolicyPlan, response, err := vpcService.UpdateBackupPolicyPlan(updateBackupPolicyPlanOptions) + if err != nil { + panic(err) + } + + // end-update_backup_policy_plan + + Expect(err).To(BeNil()) + Expect(response.StatusCode).To(Equal(200)) + Expect(backupPolicyPlan).ToNot(BeNil()) + + }) + It(`GetBackupPolicy request example`, func() { + fmt.Println("\nGetBackupPolicy() result:") + // begin-get_backup_policy + + getBackupPolicyOptions := vpcService.NewGetBackupPolicyOptions( + backupPolicyID, + ) + + backupPolicy, response, err := vpcService.GetBackupPolicy(getBackupPolicyOptions) + if err != nil { + panic(err) + } + + // end-get_backup_policy + + Expect(err).To(BeNil()) + Expect(response.StatusCode).To(Equal(200)) + Expect(backupPolicy).ToNot(BeNil()) + + }) + It(`UpdateBackupPolicy request example`, func() { + fmt.Println("\nUpdateBackupPolicy() result:") + // begin-update_backup_policy + + backupPolicyPatchModel := &vpcv1.BackupPolicyPatch{ + Name: core.StringPtr("my-backup-policy-update"), + } + backupPolicyPatchModelAsPatch, asPatchErr := backupPolicyPatchModel.AsPatch() + Expect(asPatchErr).To(BeNil()) + + updateBackupPolicyOptions := vpcService.NewUpdateBackupPolicyOptions( + backupPolicyID, + backupPolicyPatchModelAsPatch, + ) + updateBackupPolicyOptions.SetIfMatch(`W/"96d225c4-56bd-43d9-98fc-d7148e5c5028"`) + + backupPolicy, response, err := vpcService.UpdateBackupPolicy(updateBackupPolicyOptions) + if err != nil { + panic(err) + } + + // end-update_backup_policy + + Expect(err).To(BeNil()) + Expect(response.StatusCode).To(Equal(200)) + Expect(backupPolicy).ToNot(BeNil()) + + }) + It(`ListPlacementGroups request example`, func() { fmt.Println("\nListPlacementGroups() result:") // begin-list_placement_groups @@ -6093,6 +6278,50 @@ var _ = Describe(`VpcV1 Examples Tests`, func() { Expect(response.StatusCode).To(Equal(202)) }) + + It(`DeleteBackupPolicyPlan request example`, func() { + fmt.Println("\nDeleteBackupPolicyPlan() result:") + // begin-delete_backup_policy_plan + + deleteBackupPolicyPlanOptions := vpcService.NewDeleteBackupPolicyPlanOptions( + backupPolicyID, + backupPolicyPlanID, + ) + deleteBackupPolicyPlanOptions.SetIfMatch(`W/"96d225c4-56bd-43d9-98fc-d7148e5c5028"`) + + backupPolicyPlan, response, err := vpcService.DeleteBackupPolicyPlan(deleteBackupPolicyPlanOptions) + if err != nil { + panic(err) + } + + // end-delete_backup_policy_plan + + Expect(err).To(BeNil()) + Expect(response.StatusCode).To(Equal(202)) + Expect(backupPolicyPlan).ToNot(BeNil()) + + }) + It(`DeleteBackupPolicy request example`, func() { + fmt.Println("\nDeleteBackupPolicy() result:") + // begin-delete_backup_policy + + deleteBackupPolicyOptions := vpcService.NewDeleteBackupPolicyOptions( + backupPolicyID, + ) + deleteBackupPolicyOptions.SetIfMatch(`W/"96d225c4-56bd-43d9-98fc-d7148e5c5028"`) + + backupPolicy, response, err := vpcService.DeleteBackupPolicy(deleteBackupPolicyOptions) + if err != nil { + panic(err) + } + + // end-delete_backup_policy + + Expect(err).To(BeNil()) + Expect(response.StatusCode).To(Equal(202)) + Expect(backupPolicy).ToNot(BeNil()) + + }) }) }) diff --git a/vpcv1/vpc_v1_integration_test.go b/vpcv1/vpc_v1_integration_test.go index 00622ab..e92980f 100644 --- a/vpcv1/vpc_v1_integration_test.go +++ b/vpcv1/vpc_v1_integration_test.go @@ -91,6 +91,8 @@ var ( createdIgManagerSchedulerID *string memberID *string lbProfile *string + backupPolicyID *string + backupPolicyPlanID *string detailed = flag.Bool("detailed", false, "boolean") Running = "running" skipForMockTesting = flag.Bool("skipForMockTesting", false, "boolean") @@ -1923,6 +1925,73 @@ func TestPlacementGroups(t *testing.T) { }) } +func TestBackupPolicies(t *testing.T) { + vpcService := createVpcService(t) + var ifMatchPolicy, ifMatchPlan string + t.Run("Backup Policies", func(t *testing.T) { + t.Run("Create backup policy", func(t *testing.T) { + userTags := []string{"tag1", "tag2"} + name := "my-backup-policy" + + res, _, err := CreateBackupPolicy(vpcService, name, userTags) + ValidateResponse(t, res, err, POST, detailed, increment) + backupPolicyID = res.ID + }) + + t.Run("List all backup policies", func(t *testing.T) { + res, _, err := ListBackupPolicies(vpcService) + ValidateListResponse(t, res, err, GET, detailed, increment) + }) + t.Run("Create backup policy plan", func(t *testing.T) { + name := "my-backup-policy-plan" + cronSpec := "*/5 1,2,3 * * *" + res, _, err := CreateBackupPolicyPlan(vpcService, *backupPolicyID, cronSpec, name) + ValidateResponse(t, res, err, POST, detailed, increment) + backupPolicyPlanID = res.ID + }) + t.Run("List all backup policy plans", func(t *testing.T) { + res, _, err := ListBackupPolicyPlans(vpcService, *backupPolicyID) + ValidateListResponse(t, res, err, GET, detailed, increment) + }) + + t.Run("Get backup policy", func(t *testing.T) { + res, httpres, err := GetBackupPolicy(vpcService, *backupPolicyID) + ifMatchPolicy = httpres.GetHeaders()["Etag"][0] + ValidateResponse(t, res, err, GET, detailed, increment) + }) + + t.Run("Get backup policy plan", func(t *testing.T) { + res, httpres, err := GetBackupPolicyPlan(vpcService, *backupPolicyID, *backupPolicyPlanID) + ifMatchPlan = httpres.GetHeaders()["Etag"][0] + ValidateResponse(t, res, err, GET, detailed, increment) + }) + + t.Run("Update backup policy plan", func(t *testing.T) { + name := "my-backup-policy-plan-updated" + res, _, err := UpdateBackupPolicyPlan(vpcService, *backupPolicyID, *backupPolicyPlanID, name, ifMatchPlan) + ValidateResponse(t, res, err, PATCH, detailed, increment) + + }) + + t.Run("Update backup policy", func(t *testing.T) { + name := "my-backup-policy-updated" + res, _, err := UpdateBackupPolicy(vpcService, *backupPolicyID, name, ifMatchPolicy) + ValidateResponse(t, res, err, PATCH, detailed, increment) + + }) + + t.Run("Delete backup policy plan", func(t *testing.T) { + res, err := DeleteBackupPolicyPlan(vpcService, *backupPolicyID, *backupPolicyPlanID, ifMatchPlan) + ValidateDeleteResponse(t, res, err, DELETE, res.StatusCode, detailed, increment) + }) + + t.Run("Delete backup policy", func(t *testing.T) { + res, err := DeleteBackupPolicy(vpcService, *backupPolicyID, ifMatchPolicy) + ValidateDeleteResponse(t, res, err, DELETE, res.StatusCode, detailed, increment) + }) + + }) +} func TestVPCTeardown(t *testing.T) { vpcService := createVpcService(t) shouldSkipTest(t) diff --git a/vpcv1/vpc_v1_integration_utils_test.go b/vpcv1/vpc_v1_integration_utils_test.go index ac82238..18aeb57 100644 --- a/vpcv1/vpc_v1_integration_utils_test.go +++ b/vpcv1/vpc_v1_integration_utils_test.go @@ -3323,9 +3323,11 @@ func CreateSnapshot(vpcService *vpcv1.VpcV1, volumeID, name string) (snapshot *v Name: core.StringPtr("my-snapshot-1"), SourceVolume: volumeIdentityModel, } + options := &vpcv1.CreateSnapshotOptions{ SnapshotPrototype: snapshotPrototypeModel, } + snapshot, response, err = vpcService.CreateSnapshot(options) return } @@ -3563,3 +3565,99 @@ func PollVPNGateway(vpcService *vpcv1.VpcV1, gatewayID, status string, pollFrequ } } } + +// Backup Policies + +func ListBackupPolicies(vpcService *vpcv1.VpcV1) (backupPoliciesCollection *vpcv1.BackupPolicyCollection, response *core.DetailedResponse, err error) { + options := vpcService.NewListBackupPoliciesOptions() + backupPoliciesCollection, response, err = vpcService.ListBackupPolicies(options) + return +} +func ListBackupPolicyPlans(vpcService *vpcv1.VpcV1, backupPolicyID string) (backupPolicyPlanCollection *vpcv1.BackupPolicyPlanCollection, response *core.DetailedResponse, err error) { + options := vpcService.NewListBackupPolicyPlansOptions( + backupPolicyID, + ) + backupPolicyPlanCollection, response, err = vpcService.ListBackupPolicyPlans(options) + return +} + +func CreateBackupPolicy(vpcService *vpcv1.VpcV1, name string, userTags []string) (backupPolicy *vpcv1.BackupPolicy, response *core.DetailedResponse, err error) { + options := vpcService.NewCreateBackupPolicyOptions() + options.SetName(name) + options.SetMatchUserTags(userTags) + + backupPolicy, response, err = vpcService.CreateBackupPolicy(options) + return +} + +func CreateBackupPolicyPlan(vpcService *vpcv1.VpcV1, backupPolicyID, cronSpec, name string) (backupPolicyPlan *vpcv1.BackupPolicyPlan, response *core.DetailedResponse, err error) { + options := vpcService.NewCreateBackupPolicyPlanOptions( + backupPolicyID, + cronSpec, + ) + options.SetName(name) + + backupPolicyPlan, response, err = vpcService.CreateBackupPolicyPlan(options) + return +} + +func DeleteBackupPolicyPlan(vpcService *vpcv1.VpcV1, backupPolicyID, backupPolicyPlanID, ifMatch string) (response *core.DetailedResponse, err error) { + deleteBackupPolicyPlanOptions := vpcService.NewDeleteBackupPolicyPlanOptions( + backupPolicyID, + backupPolicyPlanID, + ) + _, response, err = vpcService.DeleteBackupPolicyPlan(deleteBackupPolicyPlanOptions) + return response, err +} + +func DeleteBackupPolicy(vpcService *vpcv1.VpcV1, backupPolicyID, ifMatch string) (response *core.DetailedResponse, err error) { + deleteBackupPolicyOptions := vpcService.NewDeleteBackupPolicyOptions( + backupPolicyID, + ) + _, response, err = vpcService.DeleteBackupPolicy(deleteBackupPolicyOptions) + return response, err +} + +func GetBackupPolicyPlan(vpcService *vpcv1.VpcV1, backupPolicyID, backupPolicyPlanID string) (backupPolicyPlan *vpcv1.BackupPolicyPlan, response *core.DetailedResponse, err error) { + options := vpcService.NewGetBackupPolicyPlanOptions( + backupPolicyID, + backupPolicyPlanID, + ) + backupPolicyPlan, response, err = vpcService.GetBackupPolicyPlan(options) + return +} +func GetBackupPolicy(vpcService *vpcv1.VpcV1, backupPolicyID string) (backupPolicy *vpcv1.BackupPolicy, response *core.DetailedResponse, err error) { + options := vpcService.NewGetBackupPolicyOptions( + backupPolicyID, + ) + backupPolicy, response, err = vpcService.GetBackupPolicy(options) + return +} + +func UpdateBackupPolicyPlan(vpcService *vpcv1.VpcV1, backupPolicyID, backupPolicyPlanID, name, ifMatch string) (backupPolicyPlan *vpcv1.BackupPolicyPlan, response *core.DetailedResponse, err error) { + backupPolicyPlanPatchModel := &vpcv1.BackupPolicyPlanPatch{ + Name: &name, + } + backupPolicyPlanPatchModelAsPatch, _ := backupPolicyPlanPatchModel.AsPatch() + updateBackupPolicyPlanOptions := vpcService.NewUpdateBackupPolicyPlanOptions( + backupPolicyID, + backupPolicyPlanID, + backupPolicyPlanPatchModelAsPatch, + ) + updateBackupPolicyPlanOptions.SetIfMatch(ifMatch) + backupPolicyPlan, response, err = vpcService.UpdateBackupPolicyPlan(updateBackupPolicyPlanOptions) + return +} +func UpdateBackupPolicy(vpcService *vpcv1.VpcV1, backupPolicyID, name, ifMatch string) (backupPolicy *vpcv1.BackupPolicy, response *core.DetailedResponse, err error) { + backupPolicyPatchModel := &vpcv1.BackupPolicyPatch{ + Name: &name, + } + backupPolicyPatchModelAsPatch, _ := backupPolicyPatchModel.AsPatch() + updateBackupPolicyOptions := vpcService.NewUpdateBackupPolicyOptions( + backupPolicyID, + backupPolicyPatchModelAsPatch, + ) + updateBackupPolicyOptions.SetIfMatch(ifMatch) + backupPolicy, response, err = vpcService.UpdateBackupPolicy(updateBackupPolicyOptions) + return +} diff --git a/vpcv1/vpc_v1_test.go b/vpcv1/vpc_v1_test.go index 14d863b..9363e82 100644 --- a/vpcv1/vpc_v1_test.go +++ b/vpcv1/vpc_v1_test.go @@ -32709,27 +32709,30 @@ var _ = Describe(`VpcV1`, func() { }) }) }) - Describe(`ListPlacementGroups(listPlacementGroupsOptions *ListPlacementGroupsOptions) - Operation response error`, func() { + Describe(`ListBackupPolicies(listBackupPoliciesOptions *ListBackupPoliciesOptions) - Operation response error`, func() { version := "testString" - listPlacementGroupsPath := "/placement_groups" + listBackupPoliciesPath := "/backup_policies" 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(listPlacementGroupsPath)) + Expect(req.URL.EscapedPath()).To(Equal(listBackupPoliciesPath)) 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(1))})) + Expect(req.URL.Query()["resource_group.id"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["name"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["tag"]).To(Equal([]string{"testString"})) res.Header().Set("Content-type", "application/json") res.WriteHeader(200) fmt.Fprint(res, `} this is not valid json {`) })) }) - It(`Invoke ListPlacementGroups with error: Operation response processing error`, func() { + It(`Invoke ListBackupPolicies with error: Operation response processing error`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -32738,20 +32741,23 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the ListPlacementGroupsOptions model - listPlacementGroupsOptionsModel := new(vpcv1.ListPlacementGroupsOptions) - listPlacementGroupsOptionsModel.Start = core.StringPtr("testString") - listPlacementGroupsOptionsModel.Limit = core.Int64Ptr(int64(1)) - listPlacementGroupsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the ListBackupPoliciesOptions model + listBackupPoliciesOptionsModel := new(vpcv1.ListBackupPoliciesOptions) + listBackupPoliciesOptionsModel.Start = core.StringPtr("testString") + listBackupPoliciesOptionsModel.Limit = core.Int64Ptr(int64(1)) + listBackupPoliciesOptionsModel.ResourceGroupID = core.StringPtr("testString") + listBackupPoliciesOptionsModel.Name = core.StringPtr("testString") + listBackupPoliciesOptionsModel.Tag = core.StringPtr("testString") + listBackupPoliciesOptionsModel.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.ListPlacementGroups(listPlacementGroupsOptionsModel) + result, response, operationErr := vpcService.ListBackupPolicies(listBackupPoliciesOptionsModel) 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.ListPlacementGroups(listPlacementGroupsOptionsModel) + result, response, operationErr = vpcService.ListBackupPolicies(listBackupPoliciesOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).To(BeNil()) @@ -32761,32 +32767,35 @@ var _ = Describe(`VpcV1`, func() { }) }) }) - Describe(`ListPlacementGroups(listPlacementGroupsOptions *ListPlacementGroupsOptions)`, func() { + Describe(`ListBackupPolicies(listBackupPoliciesOptions *ListBackupPoliciesOptions)`, func() { version := "testString" - listPlacementGroupsPath := "/placement_groups" + listBackupPoliciesPath := "/backup_policies" 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(listPlacementGroupsPath)) + Expect(req.URL.EscapedPath()).To(Equal(listBackupPoliciesPath)) 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(1))})) + Expect(req.URL.Query()["resource_group.id"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["name"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["tag"]).To(Equal([]string{"testString"})) // 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/placement_groups?limit=20"}, "limit": 20, "next": {"href": "https://us-south.iaas.cloud.ibm.com/v1/placement_groups?start=9d5a91a3e2cbd233b5a5b33436855ed1&limit=20"}, "placement_groups": [{"created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south:a/123456::placement-group:r018-418fe842-a3e9-47b9-a938-1aa5bd632871", "href": "https://us-south.iaas.cloud.ibm.com/v1/placement_groups/r018-418fe842-a3e9-47b9-a938-1aa5bd632871", "id": "r018-418fe842-a3e9-47b9-a938-1aa5bd632871", "lifecycle_state": "stable", "name": "my-placement-group", "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "resource_type": "placement_group", "strategy": "host_spread"}], "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", "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", "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"}], "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 ListPlacementGroups successfully with retries`, func() { + It(`Invoke ListBackupPolicies successfully with retries`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -32796,22 +32805,25 @@ var _ = Describe(`VpcV1`, func() { Expect(vpcService).ToNot(BeNil()) vpcService.EnableRetries(0, 0) - // Construct an instance of the ListPlacementGroupsOptions model - listPlacementGroupsOptionsModel := new(vpcv1.ListPlacementGroupsOptions) - listPlacementGroupsOptionsModel.Start = core.StringPtr("testString") - listPlacementGroupsOptionsModel.Limit = core.Int64Ptr(int64(1)) - listPlacementGroupsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the ListBackupPoliciesOptions model + listBackupPoliciesOptionsModel := new(vpcv1.ListBackupPoliciesOptions) + listBackupPoliciesOptionsModel.Start = core.StringPtr("testString") + listBackupPoliciesOptionsModel.Limit = core.Int64Ptr(int64(1)) + listBackupPoliciesOptionsModel.ResourceGroupID = core.StringPtr("testString") + listBackupPoliciesOptionsModel.Name = core.StringPtr("testString") + listBackupPoliciesOptionsModel.Tag = core.StringPtr("testString") + listBackupPoliciesOptionsModel.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.ListPlacementGroupsWithContext(ctx, listPlacementGroupsOptionsModel) + _, _, operationErr := vpcService.ListBackupPoliciesWithContext(ctx, listBackupPoliciesOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) // Disable retries and test again vpcService.DisableRetries() - result, response, operationErr := vpcService.ListPlacementGroups(listPlacementGroupsOptionsModel) + result, response, operationErr := vpcService.ListBackupPolicies(listBackupPoliciesOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) @@ -32819,7 +32831,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.ListPlacementGroupsWithContext(ctx, listPlacementGroupsOptionsModel) + _, _, operationErr = vpcService.ListBackupPoliciesWithContext(ctx, listBackupPoliciesOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) }) @@ -32833,20 +32845,23 @@ var _ = Describe(`VpcV1`, func() { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(listPlacementGroupsPath)) + Expect(req.URL.EscapedPath()).To(Equal(listBackupPoliciesPath)) 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(1))})) + Expect(req.URL.Query()["resource_group.id"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["name"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["tag"]).To(Equal([]string{"testString"})) // 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/placement_groups?limit=20"}, "limit": 20, "next": {"href": "https://us-south.iaas.cloud.ibm.com/v1/placement_groups?start=9d5a91a3e2cbd233b5a5b33436855ed1&limit=20"}, "placement_groups": [{"created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south:a/123456::placement-group:r018-418fe842-a3e9-47b9-a938-1aa5bd632871", "href": "https://us-south.iaas.cloud.ibm.com/v1/placement_groups/r018-418fe842-a3e9-47b9-a938-1aa5bd632871", "id": "r018-418fe842-a3e9-47b9-a938-1aa5bd632871", "lifecycle_state": "stable", "name": "my-placement-group", "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "resource_type": "placement_group", "strategy": "host_spread"}], "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", "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", "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"}], "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 ListPlacementGroups successfully`, func() { + It(`Invoke ListBackupPolicies successfully`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -32856,25 +32871,28 @@ var _ = Describe(`VpcV1`, func() { Expect(vpcService).ToNot(BeNil()) // Invoke operation with nil options model (negative test) - result, response, operationErr := vpcService.ListPlacementGroups(nil) + result, response, operationErr := vpcService.ListBackupPolicies(nil) Expect(operationErr).NotTo(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) - // Construct an instance of the ListPlacementGroupsOptions model - listPlacementGroupsOptionsModel := new(vpcv1.ListPlacementGroupsOptions) - listPlacementGroupsOptionsModel.Start = core.StringPtr("testString") - listPlacementGroupsOptionsModel.Limit = core.Int64Ptr(int64(1)) - listPlacementGroupsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the ListBackupPoliciesOptions model + listBackupPoliciesOptionsModel := new(vpcv1.ListBackupPoliciesOptions) + listBackupPoliciesOptionsModel.Start = core.StringPtr("testString") + listBackupPoliciesOptionsModel.Limit = core.Int64Ptr(int64(1)) + listBackupPoliciesOptionsModel.ResourceGroupID = core.StringPtr("testString") + listBackupPoliciesOptionsModel.Name = core.StringPtr("testString") + listBackupPoliciesOptionsModel.Tag = core.StringPtr("testString") + listBackupPoliciesOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with valid options model (positive test) - result, response, operationErr = vpcService.ListPlacementGroups(listPlacementGroupsOptionsModel) + result, response, operationErr = vpcService.ListBackupPolicies(listBackupPoliciesOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) }) - It(`Invoke ListPlacementGroups with error: Operation request error`, func() { + It(`Invoke ListBackupPolicies with error: Operation request error`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -32883,15 +32901,18 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the ListPlacementGroupsOptions model - listPlacementGroupsOptionsModel := new(vpcv1.ListPlacementGroupsOptions) - listPlacementGroupsOptionsModel.Start = core.StringPtr("testString") - listPlacementGroupsOptionsModel.Limit = core.Int64Ptr(int64(1)) - listPlacementGroupsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the ListBackupPoliciesOptions model + listBackupPoliciesOptionsModel := new(vpcv1.ListBackupPoliciesOptions) + listBackupPoliciesOptionsModel.Start = core.StringPtr("testString") + listBackupPoliciesOptionsModel.Limit = core.Int64Ptr(int64(1)) + listBackupPoliciesOptionsModel.ResourceGroupID = core.StringPtr("testString") + listBackupPoliciesOptionsModel.Name = core.StringPtr("testString") + listBackupPoliciesOptionsModel.Tag = core.StringPtr("testString") + listBackupPoliciesOptionsModel.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.ListPlacementGroups(listPlacementGroupsOptionsModel) + result, response, operationErr := vpcService.ListBackupPolicies(listBackupPoliciesOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING)) Expect(response).To(BeNil()) @@ -32910,7 +32931,7 @@ var _ = Describe(`VpcV1`, func() { res.WriteHeader(200) })) }) - It(`Invoke ListPlacementGroups successfully`, func() { + It(`Invoke ListBackupPolicies successfully`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -32919,14 +32940,17 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the ListPlacementGroupsOptions model - listPlacementGroupsOptionsModel := new(vpcv1.ListPlacementGroupsOptions) - listPlacementGroupsOptionsModel.Start = core.StringPtr("testString") - listPlacementGroupsOptionsModel.Limit = core.Int64Ptr(int64(1)) - listPlacementGroupsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the ListBackupPoliciesOptions model + listBackupPoliciesOptionsModel := new(vpcv1.ListBackupPoliciesOptions) + listBackupPoliciesOptionsModel.Start = core.StringPtr("testString") + listBackupPoliciesOptionsModel.Limit = core.Int64Ptr(int64(1)) + listBackupPoliciesOptionsModel.ResourceGroupID = core.StringPtr("testString") + listBackupPoliciesOptionsModel.Name = core.StringPtr("testString") + listBackupPoliciesOptionsModel.Tag = core.StringPtr("testString") + listBackupPoliciesOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation - result, response, operationErr := vpcService.ListPlacementGroups(listPlacementGroupsOptionsModel) + result, response, operationErr := vpcService.ListBackupPolicies(listBackupPoliciesOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) @@ -32939,8 +32963,8 @@ var _ = Describe(`VpcV1`, func() { }) Context(`Test pagination helper method on response`, func() { It(`Invoke GetNextStart successfully`, func() { - responseObject := new(vpcv1.PlacementGroupCollection) - nextObject := new(vpcv1.PlacementGroupCollectionNext) + responseObject := new(vpcv1.BackupPolicyCollection) + nextObject := new(vpcv1.BackupPolicyCollectionNext) nextObject.Href = core.StringPtr("ibm.com?start=abc-123") responseObject.Next = nextObject @@ -32949,15 +32973,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.PlacementGroupCollection) + responseObject := new(vpcv1.BackupPolicyCollection) 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.PlacementGroupCollection) - nextObject := new(vpcv1.PlacementGroupCollectionNext) + responseObject := new(vpcv1.BackupPolicyCollection) + nextObject := new(vpcv1.BackupPolicyCollectionNext) nextObject.Href = core.StringPtr("ibm.com") responseObject.Next = nextObject @@ -32967,16 +32991,16 @@ var _ = Describe(`VpcV1`, func() { }) }) }) - Describe(`CreatePlacementGroup(createPlacementGroupOptions *CreatePlacementGroupOptions) - Operation response error`, func() { + Describe(`CreateBackupPolicy(createBackupPolicyOptions *CreateBackupPolicyOptions) - Operation response error`, func() { version := "testString" - createPlacementGroupPath := "/placement_groups" + createBackupPolicyPath := "/backup_policies" 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(createPlacementGroupPath)) + Expect(req.URL.EscapedPath()).To(Equal(createBackupPolicyPath)) 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))})) @@ -32985,7 +33009,7 @@ var _ = Describe(`VpcV1`, func() { fmt.Fprint(res, `} this is not valid json {`) })) }) - It(`Invoke CreatePlacementGroup with error: Operation response processing error`, func() { + It(`Invoke CreateBackupPolicy with error: Operation response processing error`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -32994,25 +33018,41 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) + // Construct an instance of the BackupPolicyPlanDeletionTriggerPrototype model + backupPolicyPlanDeletionTriggerPrototypeModel := new(vpcv1.BackupPolicyPlanDeletionTriggerPrototype) + backupPolicyPlanDeletionTriggerPrototypeModel.DeleteAfter = core.Int64Ptr(int64(20)) + backupPolicyPlanDeletionTriggerPrototypeModel.DeleteOverCount = core.Int64Ptr(int64(20)) + + // Construct an instance of the BackupPolicyPlanPrototype model + backupPolicyPlanPrototypeModel := new(vpcv1.BackupPolicyPlanPrototype) + backupPolicyPlanPrototypeModel.Active = core.BoolPtr(true) + backupPolicyPlanPrototypeModel.AttachUserTags = []string{"my-daily-backup-plan"} + backupPolicyPlanPrototypeModel.CopyUserTags = core.BoolPtr(true) + backupPolicyPlanPrototypeModel.CronSpec = core.StringPtr("*/5 1,2,3 * * *") + backupPolicyPlanPrototypeModel.DeletionTrigger = backupPolicyPlanDeletionTriggerPrototypeModel + backupPolicyPlanPrototypeModel.Name = core.StringPtr("my-policy-plan") + // Construct an instance of the ResourceGroupIdentityByID model resourceGroupIdentityModel := new(vpcv1.ResourceGroupIdentityByID) resourceGroupIdentityModel.ID = core.StringPtr("fee82deba12e4c0fb69c3b09d1f12345") - // Construct an instance of the CreatePlacementGroupOptions model - createPlacementGroupOptionsModel := new(vpcv1.CreatePlacementGroupOptions) - createPlacementGroupOptionsModel.Strategy = core.StringPtr("host_spread") - createPlacementGroupOptionsModel.Name = core.StringPtr("my-placement-group") - createPlacementGroupOptionsModel.ResourceGroup = resourceGroupIdentityModel - createPlacementGroupOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the CreateBackupPolicyOptions model + createBackupPolicyOptionsModel := new(vpcv1.CreateBackupPolicyOptions) + createBackupPolicyOptionsModel.MatchResourceTypes = []string{"volume"} + createBackupPolicyOptionsModel.MatchUserTags = []string{"my-daily-backup-policy"} + createBackupPolicyOptionsModel.Name = core.StringPtr("my-backup-policy") + createBackupPolicyOptionsModel.Plans = []vpcv1.BackupPolicyPlanPrototype{*backupPolicyPlanPrototypeModel} + createBackupPolicyOptionsModel.ResourceGroup = resourceGroupIdentityModel + 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.CreatePlacementGroup(createPlacementGroupOptionsModel) + result, response, operationErr := vpcService.CreateBackupPolicy(createBackupPolicyOptionsModel) 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.CreatePlacementGroup(createPlacementGroupOptionsModel) + result, response, operationErr = vpcService.CreateBackupPolicy(createBackupPolicyOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).To(BeNil()) @@ -33022,16 +33062,16 @@ var _ = Describe(`VpcV1`, func() { }) }) }) - Describe(`CreatePlacementGroup(createPlacementGroupOptions *CreatePlacementGroupOptions)`, func() { + Describe(`CreateBackupPolicy(createBackupPolicyOptions *CreateBackupPolicyOptions)`, func() { version := "testString" - createPlacementGroupPath := "/placement_groups" + createBackupPolicyPath := "/backup_policies" 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(createPlacementGroupPath)) + Expect(req.URL.EscapedPath()).To(Equal(createBackupPolicyPath)) Expect(req.Method).To(Equal("POST")) // For gzip-disabled operation, verify Content-Encoding is not set. @@ -33058,10 +33098,10 @@ 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::placement-group:r018-418fe842-a3e9-47b9-a938-1aa5bd632871", "href": "https://us-south.iaas.cloud.ibm.com/v1/placement_groups/r018-418fe842-a3e9-47b9-a938-1aa5bd632871", "id": "r018-418fe842-a3e9-47b9-a938-1aa5bd632871", "lifecycle_state": "stable", "name": "my-placement-group", "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "resource_type": "placement_group", "strategy": "host_spread"}`) + 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", "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", "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"}`) })) }) - It(`Invoke CreatePlacementGroup successfully with retries`, func() { + It(`Invoke CreateBackupPolicy successfully with retries`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -33071,27 +33111,43 @@ var _ = Describe(`VpcV1`, func() { Expect(vpcService).ToNot(BeNil()) vpcService.EnableRetries(0, 0) + // Construct an instance of the BackupPolicyPlanDeletionTriggerPrototype model + backupPolicyPlanDeletionTriggerPrototypeModel := new(vpcv1.BackupPolicyPlanDeletionTriggerPrototype) + backupPolicyPlanDeletionTriggerPrototypeModel.DeleteAfter = core.Int64Ptr(int64(20)) + backupPolicyPlanDeletionTriggerPrototypeModel.DeleteOverCount = core.Int64Ptr(int64(20)) + + // Construct an instance of the BackupPolicyPlanPrototype model + backupPolicyPlanPrototypeModel := new(vpcv1.BackupPolicyPlanPrototype) + backupPolicyPlanPrototypeModel.Active = core.BoolPtr(true) + backupPolicyPlanPrototypeModel.AttachUserTags = []string{"my-daily-backup-plan"} + backupPolicyPlanPrototypeModel.CopyUserTags = core.BoolPtr(true) + backupPolicyPlanPrototypeModel.CronSpec = core.StringPtr("*/5 1,2,3 * * *") + backupPolicyPlanPrototypeModel.DeletionTrigger = backupPolicyPlanDeletionTriggerPrototypeModel + backupPolicyPlanPrototypeModel.Name = core.StringPtr("my-policy-plan") + // Construct an instance of the ResourceGroupIdentityByID model resourceGroupIdentityModel := new(vpcv1.ResourceGroupIdentityByID) resourceGroupIdentityModel.ID = core.StringPtr("fee82deba12e4c0fb69c3b09d1f12345") - // Construct an instance of the CreatePlacementGroupOptions model - createPlacementGroupOptionsModel := new(vpcv1.CreatePlacementGroupOptions) - createPlacementGroupOptionsModel.Strategy = core.StringPtr("host_spread") - createPlacementGroupOptionsModel.Name = core.StringPtr("my-placement-group") - createPlacementGroupOptionsModel.ResourceGroup = resourceGroupIdentityModel - createPlacementGroupOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the CreateBackupPolicyOptions model + createBackupPolicyOptionsModel := new(vpcv1.CreateBackupPolicyOptions) + createBackupPolicyOptionsModel.MatchResourceTypes = []string{"volume"} + createBackupPolicyOptionsModel.MatchUserTags = []string{"my-daily-backup-policy"} + createBackupPolicyOptionsModel.Name = core.StringPtr("my-backup-policy") + createBackupPolicyOptionsModel.Plans = []vpcv1.BackupPolicyPlanPrototype{*backupPolicyPlanPrototypeModel} + createBackupPolicyOptionsModel.ResourceGroup = resourceGroupIdentityModel + createBackupPolicyOptionsModel.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.CreatePlacementGroupWithContext(ctx, createPlacementGroupOptionsModel) + _, _, operationErr := vpcService.CreateBackupPolicyWithContext(ctx, createBackupPolicyOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) // Disable retries and test again vpcService.DisableRetries() - result, response, operationErr := vpcService.CreatePlacementGroup(createPlacementGroupOptionsModel) + result, response, operationErr := vpcService.CreateBackupPolicy(createBackupPolicyOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) @@ -33099,7 +33155,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.CreatePlacementGroupWithContext(ctx, createPlacementGroupOptionsModel) + _, _, operationErr = vpcService.CreateBackupPolicyWithContext(ctx, createBackupPolicyOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) }) @@ -33113,7 +33169,7 @@ var _ = Describe(`VpcV1`, func() { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(createPlacementGroupPath)) + Expect(req.URL.EscapedPath()).To(Equal(createBackupPolicyPath)) Expect(req.Method).To(Equal("POST")) // For gzip-disabled operation, verify Content-Encoding is not set. @@ -33137,10 +33193,10 @@ 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::placement-group:r018-418fe842-a3e9-47b9-a938-1aa5bd632871", "href": "https://us-south.iaas.cloud.ibm.com/v1/placement_groups/r018-418fe842-a3e9-47b9-a938-1aa5bd632871", "id": "r018-418fe842-a3e9-47b9-a938-1aa5bd632871", "lifecycle_state": "stable", "name": "my-placement-group", "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "resource_type": "placement_group", "strategy": "host_spread"}`) + 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", "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", "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"}`) })) }) - It(`Invoke CreatePlacementGroup successfully`, func() { + It(`Invoke CreateBackupPolicy successfully`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -33150,30 +33206,46 @@ var _ = Describe(`VpcV1`, func() { Expect(vpcService).ToNot(BeNil()) // Invoke operation with nil options model (negative test) - result, response, operationErr := vpcService.CreatePlacementGroup(nil) + result, response, operationErr := vpcService.CreateBackupPolicy(nil) Expect(operationErr).NotTo(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) + // Construct an instance of the BackupPolicyPlanDeletionTriggerPrototype model + backupPolicyPlanDeletionTriggerPrototypeModel := new(vpcv1.BackupPolicyPlanDeletionTriggerPrototype) + backupPolicyPlanDeletionTriggerPrototypeModel.DeleteAfter = core.Int64Ptr(int64(20)) + backupPolicyPlanDeletionTriggerPrototypeModel.DeleteOverCount = core.Int64Ptr(int64(20)) + + // Construct an instance of the BackupPolicyPlanPrototype model + backupPolicyPlanPrototypeModel := new(vpcv1.BackupPolicyPlanPrototype) + backupPolicyPlanPrototypeModel.Active = core.BoolPtr(true) + backupPolicyPlanPrototypeModel.AttachUserTags = []string{"my-daily-backup-plan"} + backupPolicyPlanPrototypeModel.CopyUserTags = core.BoolPtr(true) + backupPolicyPlanPrototypeModel.CronSpec = core.StringPtr("*/5 1,2,3 * * *") + backupPolicyPlanPrototypeModel.DeletionTrigger = backupPolicyPlanDeletionTriggerPrototypeModel + backupPolicyPlanPrototypeModel.Name = core.StringPtr("my-policy-plan") + // Construct an instance of the ResourceGroupIdentityByID model resourceGroupIdentityModel := new(vpcv1.ResourceGroupIdentityByID) resourceGroupIdentityModel.ID = core.StringPtr("fee82deba12e4c0fb69c3b09d1f12345") - // Construct an instance of the CreatePlacementGroupOptions model - createPlacementGroupOptionsModel := new(vpcv1.CreatePlacementGroupOptions) - createPlacementGroupOptionsModel.Strategy = core.StringPtr("host_spread") - createPlacementGroupOptionsModel.Name = core.StringPtr("my-placement-group") - createPlacementGroupOptionsModel.ResourceGroup = resourceGroupIdentityModel - createPlacementGroupOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the CreateBackupPolicyOptions model + createBackupPolicyOptionsModel := new(vpcv1.CreateBackupPolicyOptions) + createBackupPolicyOptionsModel.MatchResourceTypes = []string{"volume"} + createBackupPolicyOptionsModel.MatchUserTags = []string{"my-daily-backup-policy"} + createBackupPolicyOptionsModel.Name = core.StringPtr("my-backup-policy") + createBackupPolicyOptionsModel.Plans = []vpcv1.BackupPolicyPlanPrototype{*backupPolicyPlanPrototypeModel} + createBackupPolicyOptionsModel.ResourceGroup = resourceGroupIdentityModel + createBackupPolicyOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with valid options model (positive test) - result, response, operationErr = vpcService.CreatePlacementGroup(createPlacementGroupOptionsModel) + result, response, operationErr = vpcService.CreateBackupPolicy(createBackupPolicyOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) }) - It(`Invoke CreatePlacementGroup with error: Operation validation and request error`, func() { + It(`Invoke CreateBackupPolicy with error: Operation request error`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -33182,31 +33254,40 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) + // Construct an instance of the BackupPolicyPlanDeletionTriggerPrototype model + backupPolicyPlanDeletionTriggerPrototypeModel := new(vpcv1.BackupPolicyPlanDeletionTriggerPrototype) + backupPolicyPlanDeletionTriggerPrototypeModel.DeleteAfter = core.Int64Ptr(int64(20)) + backupPolicyPlanDeletionTriggerPrototypeModel.DeleteOverCount = core.Int64Ptr(int64(20)) + + // Construct an instance of the BackupPolicyPlanPrototype model + backupPolicyPlanPrototypeModel := new(vpcv1.BackupPolicyPlanPrototype) + backupPolicyPlanPrototypeModel.Active = core.BoolPtr(true) + backupPolicyPlanPrototypeModel.AttachUserTags = []string{"my-daily-backup-plan"} + backupPolicyPlanPrototypeModel.CopyUserTags = core.BoolPtr(true) + backupPolicyPlanPrototypeModel.CronSpec = core.StringPtr("*/5 1,2,3 * * *") + backupPolicyPlanPrototypeModel.DeletionTrigger = backupPolicyPlanDeletionTriggerPrototypeModel + backupPolicyPlanPrototypeModel.Name = core.StringPtr("my-policy-plan") + // Construct an instance of the ResourceGroupIdentityByID model resourceGroupIdentityModel := new(vpcv1.ResourceGroupIdentityByID) resourceGroupIdentityModel.ID = core.StringPtr("fee82deba12e4c0fb69c3b09d1f12345") - // Construct an instance of the CreatePlacementGroupOptions model - createPlacementGroupOptionsModel := new(vpcv1.CreatePlacementGroupOptions) - createPlacementGroupOptionsModel.Strategy = core.StringPtr("host_spread") - createPlacementGroupOptionsModel.Name = core.StringPtr("my-placement-group") - createPlacementGroupOptionsModel.ResourceGroup = resourceGroupIdentityModel - createPlacementGroupOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the CreateBackupPolicyOptions model + createBackupPolicyOptionsModel := new(vpcv1.CreateBackupPolicyOptions) + createBackupPolicyOptionsModel.MatchResourceTypes = []string{"volume"} + createBackupPolicyOptionsModel.MatchUserTags = []string{"my-daily-backup-policy"} + createBackupPolicyOptionsModel.Name = core.StringPtr("my-backup-policy") + createBackupPolicyOptionsModel.Plans = []vpcv1.BackupPolicyPlanPrototype{*backupPolicyPlanPrototypeModel} + createBackupPolicyOptionsModel.ResourceGroup = resourceGroupIdentityModel + createBackupPolicyOptionsModel.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.CreatePlacementGroup(createPlacementGroupOptionsModel) + result, response, operationErr := vpcService.CreateBackupPolicy(createBackupPolicyOptionsModel) 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 CreatePlacementGroupOptions model with no property values - createPlacementGroupOptionsModelNew := new(vpcv1.CreatePlacementGroupOptions) - // Invoke operation with invalid model (negative test) - result, response, operationErr = vpcService.CreatePlacementGroup(createPlacementGroupOptionsModelNew) - Expect(operationErr).ToNot(BeNil()) - Expect(response).To(BeNil()) - Expect(result).To(BeNil()) }) AfterEach(func() { testServer.Close() @@ -33221,7 +33302,7 @@ var _ = Describe(`VpcV1`, func() { res.WriteHeader(201) })) }) - It(`Invoke CreatePlacementGroup successfully`, func() { + It(`Invoke CreateBackupPolicy successfully`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -33230,19 +33311,35 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) + // Construct an instance of the BackupPolicyPlanDeletionTriggerPrototype model + backupPolicyPlanDeletionTriggerPrototypeModel := new(vpcv1.BackupPolicyPlanDeletionTriggerPrototype) + backupPolicyPlanDeletionTriggerPrototypeModel.DeleteAfter = core.Int64Ptr(int64(20)) + backupPolicyPlanDeletionTriggerPrototypeModel.DeleteOverCount = core.Int64Ptr(int64(20)) + + // Construct an instance of the BackupPolicyPlanPrototype model + backupPolicyPlanPrototypeModel := new(vpcv1.BackupPolicyPlanPrototype) + backupPolicyPlanPrototypeModel.Active = core.BoolPtr(true) + backupPolicyPlanPrototypeModel.AttachUserTags = []string{"my-daily-backup-plan"} + backupPolicyPlanPrototypeModel.CopyUserTags = core.BoolPtr(true) + backupPolicyPlanPrototypeModel.CronSpec = core.StringPtr("*/5 1,2,3 * * *") + backupPolicyPlanPrototypeModel.DeletionTrigger = backupPolicyPlanDeletionTriggerPrototypeModel + backupPolicyPlanPrototypeModel.Name = core.StringPtr("my-policy-plan") + // Construct an instance of the ResourceGroupIdentityByID model resourceGroupIdentityModel := new(vpcv1.ResourceGroupIdentityByID) resourceGroupIdentityModel.ID = core.StringPtr("fee82deba12e4c0fb69c3b09d1f12345") - // Construct an instance of the CreatePlacementGroupOptions model - createPlacementGroupOptionsModel := new(vpcv1.CreatePlacementGroupOptions) - createPlacementGroupOptionsModel.Strategy = core.StringPtr("host_spread") - createPlacementGroupOptionsModel.Name = core.StringPtr("my-placement-group") - createPlacementGroupOptionsModel.ResourceGroup = resourceGroupIdentityModel - createPlacementGroupOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the CreateBackupPolicyOptions model + createBackupPolicyOptionsModel := new(vpcv1.CreateBackupPolicyOptions) + createBackupPolicyOptionsModel.MatchResourceTypes = []string{"volume"} + createBackupPolicyOptionsModel.MatchUserTags = []string{"my-daily-backup-policy"} + createBackupPolicyOptionsModel.Name = core.StringPtr("my-backup-policy") + createBackupPolicyOptionsModel.Plans = []vpcv1.BackupPolicyPlanPrototype{*backupPolicyPlanPrototypeModel} + createBackupPolicyOptionsModel.ResourceGroup = resourceGroupIdentityModel + createBackupPolicyOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation - result, response, operationErr := vpcService.CreatePlacementGroup(createPlacementGroupOptionsModel) + result, response, operationErr := vpcService.CreateBackupPolicy(createBackupPolicyOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) @@ -33254,98 +33351,26 @@ var _ = Describe(`VpcV1`, func() { }) }) }) - Describe(`DeletePlacementGroup(deletePlacementGroupOptions *DeletePlacementGroupOptions)`, func() { + Describe(`ListBackupPolicyPlans(listBackupPolicyPlansOptions *ListBackupPolicyPlansOptions) - Operation response error`, func() { version := "testString" - deletePlacementGroupPath := "/placement_groups/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(deletePlacementGroupPath)) - 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.WriteHeader(202) - })) - }) - It(`Invoke DeletePlacementGroup 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.DeletePlacementGroup(nil) - Expect(operationErr).NotTo(BeNil()) - Expect(response).To(BeNil()) - - // Construct an instance of the DeletePlacementGroupOptions model - deletePlacementGroupOptionsModel := new(vpcv1.DeletePlacementGroupOptions) - deletePlacementGroupOptionsModel.ID = core.StringPtr("testString") - deletePlacementGroupOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} - - // Invoke operation with valid options model (positive test) - response, operationErr = vpcService.DeletePlacementGroup(deletePlacementGroupOptionsModel) - Expect(operationErr).To(BeNil()) - Expect(response).ToNot(BeNil()) - }) - It(`Invoke DeletePlacementGroup 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 DeletePlacementGroupOptions model - deletePlacementGroupOptionsModel := new(vpcv1.DeletePlacementGroupOptions) - deletePlacementGroupOptionsModel.ID = core.StringPtr("testString") - deletePlacementGroupOptionsModel.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.DeletePlacementGroup(deletePlacementGroupOptionsModel) - Expect(operationErr).ToNot(BeNil()) - Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING)) - Expect(response).To(BeNil()) - // Construct a second instance of the DeletePlacementGroupOptions model with no property values - deletePlacementGroupOptionsModelNew := new(vpcv1.DeletePlacementGroupOptions) - // Invoke operation with invalid model (negative test) - response, operationErr = vpcService.DeletePlacementGroup(deletePlacementGroupOptionsModelNew) - Expect(operationErr).ToNot(BeNil()) - Expect(response).To(BeNil()) - }) - AfterEach(func() { - testServer.Close() - }) - }) - }) - Describe(`GetPlacementGroup(getPlacementGroupOptions *GetPlacementGroupOptions) - Operation response error`, func() { - version := "testString" - getPlacementGroupPath := "/placement_groups/testString" + listBackupPolicyPlansPath := "/backup_policies/testString/plans" 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(getPlacementGroupPath)) + Expect(req.URL.EscapedPath()).To(Equal(listBackupPolicyPlansPath)) 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()["name"]).To(Equal([]string{"testString"})) res.Header().Set("Content-type", "application/json") res.WriteHeader(200) fmt.Fprint(res, `} this is not valid json {`) })) }) - It(`Invoke GetPlacementGroup with error: Operation response processing error`, func() { + It(`Invoke ListBackupPolicyPlans with error: Operation response processing error`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -33354,19 +33379,20 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the GetPlacementGroupOptions model - getPlacementGroupOptionsModel := new(vpcv1.GetPlacementGroupOptions) - getPlacementGroupOptionsModel.ID = core.StringPtr("testString") - getPlacementGroupOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the ListBackupPolicyPlansOptions model + listBackupPolicyPlansOptionsModel := new(vpcv1.ListBackupPolicyPlansOptions) + listBackupPolicyPlansOptionsModel.BackupPolicyID = core.StringPtr("testString") + listBackupPolicyPlansOptionsModel.Name = core.StringPtr("testString") + listBackupPolicyPlansOptionsModel.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.GetPlacementGroup(getPlacementGroupOptionsModel) + result, response, operationErr := vpcService.ListBackupPolicyPlans(listBackupPolicyPlansOptionsModel) 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.GetPlacementGroup(getPlacementGroupOptionsModel) + result, response, operationErr = vpcService.ListBackupPolicyPlans(listBackupPolicyPlansOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).To(BeNil()) @@ -33376,30 +33402,31 @@ var _ = Describe(`VpcV1`, func() { }) }) }) - Describe(`GetPlacementGroup(getPlacementGroupOptions *GetPlacementGroupOptions)`, func() { + Describe(`ListBackupPolicyPlans(listBackupPolicyPlansOptions *ListBackupPolicyPlansOptions)`, func() { version := "testString" - getPlacementGroupPath := "/placement_groups/testString" + listBackupPolicyPlansPath := "/backup_policies/testString/plans" 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(getPlacementGroupPath)) + Expect(req.URL.EscapedPath()).To(Equal(listBackupPolicyPlansPath)) 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()["name"]).To(Equal([]string{"testString"})) // 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", `{"created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south:a/123456::placement-group:r018-418fe842-a3e9-47b9-a938-1aa5bd632871", "href": "https://us-south.iaas.cloud.ibm.com/v1/placement_groups/r018-418fe842-a3e9-47b9-a938-1aa5bd632871", "id": "r018-418fe842-a3e9-47b9-a938-1aa5bd632871", "lifecycle_state": "stable", "name": "my-placement-group", "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "resource_type": "placement_group", "strategy": "host_spread"}`) + fmt.Fprintf(res, "%s", `{"plans": [{"active": true, "attach_user_tags": ["AttachUserTags"], "copy_user_tags": true, "created_at": "2019-01-01T12:00:00.000Z", "cron_spec": "*/5 1,2,3 * * *", "deletion_trigger": {"delete_after": 20, "delete_over_count": 20}, "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", "lifecycle_state": "stable", "name": "my-policy-plan", "resource_type": "backup_policy_plan"}]}`) })) }) - It(`Invoke GetPlacementGroup successfully with retries`, func() { + It(`Invoke ListBackupPolicyPlans successfully with retries`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -33409,21 +33436,22 @@ var _ = Describe(`VpcV1`, func() { Expect(vpcService).ToNot(BeNil()) vpcService.EnableRetries(0, 0) - // Construct an instance of the GetPlacementGroupOptions model - getPlacementGroupOptionsModel := new(vpcv1.GetPlacementGroupOptions) - getPlacementGroupOptionsModel.ID = core.StringPtr("testString") - getPlacementGroupOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the ListBackupPolicyPlansOptions model + listBackupPolicyPlansOptionsModel := new(vpcv1.ListBackupPolicyPlansOptions) + listBackupPolicyPlansOptionsModel.BackupPolicyID = core.StringPtr("testString") + listBackupPolicyPlansOptionsModel.Name = core.StringPtr("testString") + listBackupPolicyPlansOptionsModel.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.GetPlacementGroupWithContext(ctx, getPlacementGroupOptionsModel) + _, _, operationErr := vpcService.ListBackupPolicyPlansWithContext(ctx, listBackupPolicyPlansOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) // Disable retries and test again vpcService.DisableRetries() - result, response, operationErr := vpcService.GetPlacementGroup(getPlacementGroupOptionsModel) + result, response, operationErr := vpcService.ListBackupPolicyPlans(listBackupPolicyPlansOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) @@ -33431,7 +33459,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.GetPlacementGroupWithContext(ctx, getPlacementGroupOptionsModel) + _, _, operationErr = vpcService.ListBackupPolicyPlansWithContext(ctx, listBackupPolicyPlansOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) }) @@ -33445,18 +33473,19 @@ var _ = Describe(`VpcV1`, func() { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(getPlacementGroupPath)) + Expect(req.URL.EscapedPath()).To(Equal(listBackupPolicyPlansPath)) 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()["name"]).To(Equal([]string{"testString"})) // 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::placement-group:r018-418fe842-a3e9-47b9-a938-1aa5bd632871", "href": "https://us-south.iaas.cloud.ibm.com/v1/placement_groups/r018-418fe842-a3e9-47b9-a938-1aa5bd632871", "id": "r018-418fe842-a3e9-47b9-a938-1aa5bd632871", "lifecycle_state": "stable", "name": "my-placement-group", "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "resource_type": "placement_group", "strategy": "host_spread"}`) + fmt.Fprintf(res, "%s", `{"plans": [{"active": true, "attach_user_tags": ["AttachUserTags"], "copy_user_tags": true, "created_at": "2019-01-01T12:00:00.000Z", "cron_spec": "*/5 1,2,3 * * *", "deletion_trigger": {"delete_after": 20, "delete_over_count": 20}, "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", "lifecycle_state": "stable", "name": "my-policy-plan", "resource_type": "backup_policy_plan"}]}`) })) }) - It(`Invoke GetPlacementGroup successfully`, func() { + It(`Invoke ListBackupPolicyPlans successfully`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -33466,24 +33495,25 @@ var _ = Describe(`VpcV1`, func() { Expect(vpcService).ToNot(BeNil()) // Invoke operation with nil options model (negative test) - result, response, operationErr := vpcService.GetPlacementGroup(nil) + result, response, operationErr := vpcService.ListBackupPolicyPlans(nil) Expect(operationErr).NotTo(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) - // Construct an instance of the GetPlacementGroupOptions model - getPlacementGroupOptionsModel := new(vpcv1.GetPlacementGroupOptions) - getPlacementGroupOptionsModel.ID = core.StringPtr("testString") - getPlacementGroupOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the ListBackupPolicyPlansOptions model + listBackupPolicyPlansOptionsModel := new(vpcv1.ListBackupPolicyPlansOptions) + listBackupPolicyPlansOptionsModel.BackupPolicyID = core.StringPtr("testString") + listBackupPolicyPlansOptionsModel.Name = core.StringPtr("testString") + listBackupPolicyPlansOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with valid options model (positive test) - result, response, operationErr = vpcService.GetPlacementGroup(getPlacementGroupOptionsModel) + result, response, operationErr = vpcService.ListBackupPolicyPlans(listBackupPolicyPlansOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) }) - It(`Invoke GetPlacementGroup with error: Operation validation and request error`, func() { + It(`Invoke ListBackupPolicyPlans with error: Operation validation and request error`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -33492,22 +33522,23 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the GetPlacementGroupOptions model - getPlacementGroupOptionsModel := new(vpcv1.GetPlacementGroupOptions) - getPlacementGroupOptionsModel.ID = core.StringPtr("testString") - getPlacementGroupOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the ListBackupPolicyPlansOptions model + listBackupPolicyPlansOptionsModel := new(vpcv1.ListBackupPolicyPlansOptions) + listBackupPolicyPlansOptionsModel.BackupPolicyID = core.StringPtr("testString") + listBackupPolicyPlansOptionsModel.Name = core.StringPtr("testString") + listBackupPolicyPlansOptionsModel.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.GetPlacementGroup(getPlacementGroupOptionsModel) + result, response, operationErr := vpcService.ListBackupPolicyPlans(listBackupPolicyPlansOptionsModel) 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 GetPlacementGroupOptions model with no property values - getPlacementGroupOptionsModelNew := new(vpcv1.GetPlacementGroupOptions) + // Construct a second instance of the ListBackupPolicyPlansOptions model with no property values + listBackupPolicyPlansOptionsModelNew := new(vpcv1.ListBackupPolicyPlansOptions) // Invoke operation with invalid model (negative test) - result, response, operationErr = vpcService.GetPlacementGroup(getPlacementGroupOptionsModelNew) + result, response, operationErr = vpcService.ListBackupPolicyPlans(listBackupPolicyPlansOptionsModelNew) Expect(operationErr).ToNot(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) @@ -33525,7 +33556,7 @@ var _ = Describe(`VpcV1`, func() { res.WriteHeader(200) })) }) - It(`Invoke GetPlacementGroup successfully`, func() { + It(`Invoke ListBackupPolicyPlans successfully`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -33534,13 +33565,14 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the GetPlacementGroupOptions model - getPlacementGroupOptionsModel := new(vpcv1.GetPlacementGroupOptions) - getPlacementGroupOptionsModel.ID = core.StringPtr("testString") - getPlacementGroupOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the ListBackupPolicyPlansOptions model + listBackupPolicyPlansOptionsModel := new(vpcv1.ListBackupPolicyPlansOptions) + listBackupPolicyPlansOptionsModel.BackupPolicyID = core.StringPtr("testString") + listBackupPolicyPlansOptionsModel.Name = core.StringPtr("testString") + listBackupPolicyPlansOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation - result, response, operationErr := vpcService.GetPlacementGroup(getPlacementGroupOptionsModel) + result, response, operationErr := vpcService.ListBackupPolicyPlans(listBackupPolicyPlansOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) @@ -33552,25 +33584,25 @@ var _ = Describe(`VpcV1`, func() { }) }) }) - Describe(`UpdatePlacementGroup(updatePlacementGroupOptions *UpdatePlacementGroupOptions) - Operation response error`, func() { + Describe(`CreateBackupPolicyPlan(createBackupPolicyPlanOptions *CreateBackupPolicyPlanOptions) - Operation response error`, func() { version := "testString" - updatePlacementGroupPath := "/placement_groups/testString" + createBackupPolicyPlanPath := "/backup_policies/testString/plans" 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(updatePlacementGroupPath)) - Expect(req.Method).To(Equal("PATCH")) + Expect(req.URL.EscapedPath()).To(Equal(createBackupPolicyPlanPath)) + 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(200) + res.WriteHeader(201) fmt.Fprint(res, `} this is not valid json {`) })) }) - It(`Invoke UpdatePlacementGroup with error: Operation response processing error`, func() { + It(`Invoke CreateBackupPolicyPlan with error: Operation response processing error`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -33579,26 +33611,30 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the PlacementGroupPatch model - placementGroupPatchModel := new(vpcv1.PlacementGroupPatch) - placementGroupPatchModel.Name = core.StringPtr("my-placement-group") - placementGroupPatchModelAsPatch, asPatchErr := placementGroupPatchModel.AsPatch() - Expect(asPatchErr).To(BeNil()) + // Construct an instance of the BackupPolicyPlanDeletionTriggerPrototype model + backupPolicyPlanDeletionTriggerPrototypeModel := new(vpcv1.BackupPolicyPlanDeletionTriggerPrototype) + backupPolicyPlanDeletionTriggerPrototypeModel.DeleteAfter = core.Int64Ptr(int64(20)) + backupPolicyPlanDeletionTriggerPrototypeModel.DeleteOverCount = core.Int64Ptr(int64(20)) - // Construct an instance of the UpdatePlacementGroupOptions model - updatePlacementGroupOptionsModel := new(vpcv1.UpdatePlacementGroupOptions) - updatePlacementGroupOptionsModel.ID = core.StringPtr("testString") - updatePlacementGroupOptionsModel.PlacementGroupPatch = placementGroupPatchModelAsPatch - updatePlacementGroupOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the CreateBackupPolicyPlanOptions model + createBackupPolicyPlanOptionsModel := new(vpcv1.CreateBackupPolicyPlanOptions) + createBackupPolicyPlanOptionsModel.BackupPolicyID = core.StringPtr("testString") + createBackupPolicyPlanOptionsModel.CronSpec = core.StringPtr("*/5 1,2,3 * * *") + createBackupPolicyPlanOptionsModel.Active = core.BoolPtr(true) + createBackupPolicyPlanOptionsModel.AttachUserTags = []string{"my-daily-backup-plan"} + createBackupPolicyPlanOptionsModel.CopyUserTags = core.BoolPtr(true) + createBackupPolicyPlanOptionsModel.DeletionTrigger = backupPolicyPlanDeletionTriggerPrototypeModel + createBackupPolicyPlanOptionsModel.Name = core.StringPtr("my-policy-plan") + createBackupPolicyPlanOptionsModel.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.UpdatePlacementGroup(updatePlacementGroupOptionsModel) + result, response, operationErr := vpcService.CreateBackupPolicyPlan(createBackupPolicyPlanOptionsModel) 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.UpdatePlacementGroup(updatePlacementGroupOptionsModel) + result, response, operationErr = vpcService.CreateBackupPolicyPlan(createBackupPolicyPlanOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).To(BeNil()) @@ -33608,17 +33644,2766 @@ var _ = Describe(`VpcV1`, func() { }) }) }) - Describe(`UpdatePlacementGroup(updatePlacementGroupOptions *UpdatePlacementGroupOptions)`, func() { + Describe(`CreateBackupPolicyPlan(createBackupPolicyPlanOptions *CreateBackupPolicyPlanOptions)`, func() { version := "testString" - updatePlacementGroupPath := "/placement_groups/testString" + createBackupPolicyPlanPath := "/backup_policies/testString/plans" 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(updatePlacementGroupPath)) - Expect(req.Method).To(Equal("PATCH")) + Expect(req.URL.EscapedPath()).To(Equal(createBackupPolicyPlanPath)) + 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", `{"active": true, "attach_user_tags": ["AttachUserTags"], "copy_user_tags": true, "created_at": "2019-01-01T12:00:00.000Z", "cron_spec": "*/5 1,2,3 * * *", "deletion_trigger": {"delete_after": 20, "delete_over_count": 20}, "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", "lifecycle_state": "stable", "name": "my-policy-plan", "resource_type": "backup_policy_plan"}`) + })) + }) + It(`Invoke CreateBackupPolicyPlan 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 BackupPolicyPlanDeletionTriggerPrototype model + backupPolicyPlanDeletionTriggerPrototypeModel := new(vpcv1.BackupPolicyPlanDeletionTriggerPrototype) + backupPolicyPlanDeletionTriggerPrototypeModel.DeleteAfter = core.Int64Ptr(int64(20)) + backupPolicyPlanDeletionTriggerPrototypeModel.DeleteOverCount = core.Int64Ptr(int64(20)) + + // Construct an instance of the CreateBackupPolicyPlanOptions model + createBackupPolicyPlanOptionsModel := new(vpcv1.CreateBackupPolicyPlanOptions) + createBackupPolicyPlanOptionsModel.BackupPolicyID = core.StringPtr("testString") + createBackupPolicyPlanOptionsModel.CronSpec = core.StringPtr("*/5 1,2,3 * * *") + createBackupPolicyPlanOptionsModel.Active = core.BoolPtr(true) + createBackupPolicyPlanOptionsModel.AttachUserTags = []string{"my-daily-backup-plan"} + createBackupPolicyPlanOptionsModel.CopyUserTags = core.BoolPtr(true) + createBackupPolicyPlanOptionsModel.DeletionTrigger = backupPolicyPlanDeletionTriggerPrototypeModel + createBackupPolicyPlanOptionsModel.Name = core.StringPtr("my-policy-plan") + createBackupPolicyPlanOptionsModel.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.CreateBackupPolicyPlanWithContext(ctx, createBackupPolicyPlanOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) + + // Disable retries and test again + vpcService.DisableRetries() + result, response, operationErr := vpcService.CreateBackupPolicyPlan(createBackupPolicyPlanOptionsModel) + 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.CreateBackupPolicyPlanWithContext(ctx, createBackupPolicyPlanOptionsModel) + 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(createBackupPolicyPlanPath)) + 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", `{"active": true, "attach_user_tags": ["AttachUserTags"], "copy_user_tags": true, "created_at": "2019-01-01T12:00:00.000Z", "cron_spec": "*/5 1,2,3 * * *", "deletion_trigger": {"delete_after": 20, "delete_over_count": 20}, "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", "lifecycle_state": "stable", "name": "my-policy-plan", "resource_type": "backup_policy_plan"}`) + })) + }) + It(`Invoke CreateBackupPolicyPlan 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.CreateBackupPolicyPlan(nil) + Expect(operationErr).NotTo(BeNil()) + Expect(response).To(BeNil()) + Expect(result).To(BeNil()) + + // Construct an instance of the BackupPolicyPlanDeletionTriggerPrototype model + backupPolicyPlanDeletionTriggerPrototypeModel := new(vpcv1.BackupPolicyPlanDeletionTriggerPrototype) + backupPolicyPlanDeletionTriggerPrototypeModel.DeleteAfter = core.Int64Ptr(int64(20)) + backupPolicyPlanDeletionTriggerPrototypeModel.DeleteOverCount = core.Int64Ptr(int64(20)) + + // Construct an instance of the CreateBackupPolicyPlanOptions model + createBackupPolicyPlanOptionsModel := new(vpcv1.CreateBackupPolicyPlanOptions) + createBackupPolicyPlanOptionsModel.BackupPolicyID = core.StringPtr("testString") + createBackupPolicyPlanOptionsModel.CronSpec = core.StringPtr("*/5 1,2,3 * * *") + createBackupPolicyPlanOptionsModel.Active = core.BoolPtr(true) + createBackupPolicyPlanOptionsModel.AttachUserTags = []string{"my-daily-backup-plan"} + createBackupPolicyPlanOptionsModel.CopyUserTags = core.BoolPtr(true) + createBackupPolicyPlanOptionsModel.DeletionTrigger = backupPolicyPlanDeletionTriggerPrototypeModel + createBackupPolicyPlanOptionsModel.Name = core.StringPtr("my-policy-plan") + createBackupPolicyPlanOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation with valid options model (positive test) + result, response, operationErr = vpcService.CreateBackupPolicyPlan(createBackupPolicyPlanOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).ToNot(BeNil()) + + }) + It(`Invoke CreateBackupPolicyPlan 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 BackupPolicyPlanDeletionTriggerPrototype model + backupPolicyPlanDeletionTriggerPrototypeModel := new(vpcv1.BackupPolicyPlanDeletionTriggerPrototype) + backupPolicyPlanDeletionTriggerPrototypeModel.DeleteAfter = core.Int64Ptr(int64(20)) + backupPolicyPlanDeletionTriggerPrototypeModel.DeleteOverCount = core.Int64Ptr(int64(20)) + + // Construct an instance of the CreateBackupPolicyPlanOptions model + createBackupPolicyPlanOptionsModel := new(vpcv1.CreateBackupPolicyPlanOptions) + createBackupPolicyPlanOptionsModel.BackupPolicyID = core.StringPtr("testString") + createBackupPolicyPlanOptionsModel.CronSpec = core.StringPtr("*/5 1,2,3 * * *") + createBackupPolicyPlanOptionsModel.Active = core.BoolPtr(true) + createBackupPolicyPlanOptionsModel.AttachUserTags = []string{"my-daily-backup-plan"} + createBackupPolicyPlanOptionsModel.CopyUserTags = core.BoolPtr(true) + createBackupPolicyPlanOptionsModel.DeletionTrigger = backupPolicyPlanDeletionTriggerPrototypeModel + createBackupPolicyPlanOptionsModel.Name = core.StringPtr("my-policy-plan") + createBackupPolicyPlanOptionsModel.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.CreateBackupPolicyPlan(createBackupPolicyPlanOptionsModel) + 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 CreateBackupPolicyPlanOptions model with no property values + createBackupPolicyPlanOptionsModelNew := new(vpcv1.CreateBackupPolicyPlanOptions) + // Invoke operation with invalid model (negative test) + result, response, operationErr = vpcService.CreateBackupPolicyPlan(createBackupPolicyPlanOptionsModelNew) + 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 CreateBackupPolicyPlan 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 BackupPolicyPlanDeletionTriggerPrototype model + backupPolicyPlanDeletionTriggerPrototypeModel := new(vpcv1.BackupPolicyPlanDeletionTriggerPrototype) + backupPolicyPlanDeletionTriggerPrototypeModel.DeleteAfter = core.Int64Ptr(int64(20)) + backupPolicyPlanDeletionTriggerPrototypeModel.DeleteOverCount = core.Int64Ptr(int64(20)) + + // Construct an instance of the CreateBackupPolicyPlanOptions model + createBackupPolicyPlanOptionsModel := new(vpcv1.CreateBackupPolicyPlanOptions) + createBackupPolicyPlanOptionsModel.BackupPolicyID = core.StringPtr("testString") + createBackupPolicyPlanOptionsModel.CronSpec = core.StringPtr("*/5 1,2,3 * * *") + createBackupPolicyPlanOptionsModel.Active = core.BoolPtr(true) + createBackupPolicyPlanOptionsModel.AttachUserTags = []string{"my-daily-backup-plan"} + createBackupPolicyPlanOptionsModel.CopyUserTags = core.BoolPtr(true) + createBackupPolicyPlanOptionsModel.DeletionTrigger = backupPolicyPlanDeletionTriggerPrototypeModel + createBackupPolicyPlanOptionsModel.Name = core.StringPtr("my-policy-plan") + createBackupPolicyPlanOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation + result, response, operationErr := vpcService.CreateBackupPolicyPlan(createBackupPolicyPlanOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + + // Verify a nil result + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + }) + Describe(`DeleteBackupPolicyPlan(deleteBackupPolicyPlanOptions *DeleteBackupPolicyPlanOptions) - Operation response error`, func() { + version := "testString" + deleteBackupPolicyPlanPath := "/backup_policies/testString/plans/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(deleteBackupPolicyPlanPath)) + 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.Header().Set("Content-type", "application/json") + res.WriteHeader(202) + fmt.Fprint(res, `} this is not valid json {`) + })) + }) + It(`Invoke DeleteBackupPolicyPlan 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 DeleteBackupPolicyPlanOptions model + deleteBackupPolicyPlanOptionsModel := new(vpcv1.DeleteBackupPolicyPlanOptions) + deleteBackupPolicyPlanOptionsModel.BackupPolicyID = core.StringPtr("testString") + deleteBackupPolicyPlanOptionsModel.ID = core.StringPtr("testString") + deleteBackupPolicyPlanOptionsModel.IfMatch = core.StringPtr(`W/"96d225c4-56bd-43d9-98fc-d7148e5c5028"`) + deleteBackupPolicyPlanOptionsModel.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.DeleteBackupPolicyPlan(deleteBackupPolicyPlanOptionsModel) + 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.DeleteBackupPolicyPlan(deleteBackupPolicyPlanOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + }) + Describe(`DeleteBackupPolicyPlan(deleteBackupPolicyPlanOptions *DeleteBackupPolicyPlanOptions)`, func() { + version := "testString" + deleteBackupPolicyPlanPath := "/backup_policies/testString/plans/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(deleteBackupPolicyPlanPath)) + 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))})) + // 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", `{"active": true, "attach_user_tags": ["AttachUserTags"], "copy_user_tags": true, "created_at": "2019-01-01T12:00:00.000Z", "cron_spec": "*/5 1,2,3 * * *", "deletion_trigger": {"delete_after": 20, "delete_over_count": 20}, "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", "lifecycle_state": "stable", "name": "my-policy-plan", "resource_type": "backup_policy_plan"}`) + })) + }) + It(`Invoke DeleteBackupPolicyPlan 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 DeleteBackupPolicyPlanOptions model + deleteBackupPolicyPlanOptionsModel := new(vpcv1.DeleteBackupPolicyPlanOptions) + deleteBackupPolicyPlanOptionsModel.BackupPolicyID = core.StringPtr("testString") + deleteBackupPolicyPlanOptionsModel.ID = core.StringPtr("testString") + deleteBackupPolicyPlanOptionsModel.IfMatch = core.StringPtr(`W/"96d225c4-56bd-43d9-98fc-d7148e5c5028"`) + deleteBackupPolicyPlanOptionsModel.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.DeleteBackupPolicyPlanWithContext(ctx, deleteBackupPolicyPlanOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) + + // Disable retries and test again + vpcService.DisableRetries() + result, response, operationErr := vpcService.DeleteBackupPolicyPlan(deleteBackupPolicyPlanOptionsModel) + 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.DeleteBackupPolicyPlanWithContext(ctx, deleteBackupPolicyPlanOptionsModel) + 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(deleteBackupPolicyPlanPath)) + 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))})) + // Set mock response + res.Header().Set("Content-type", "application/json") + res.WriteHeader(202) + fmt.Fprintf(res, "%s", `{"active": true, "attach_user_tags": ["AttachUserTags"], "copy_user_tags": true, "created_at": "2019-01-01T12:00:00.000Z", "cron_spec": "*/5 1,2,3 * * *", "deletion_trigger": {"delete_after": 20, "delete_over_count": 20}, "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", "lifecycle_state": "stable", "name": "my-policy-plan", "resource_type": "backup_policy_plan"}`) + })) + }) + It(`Invoke DeleteBackupPolicyPlan 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.DeleteBackupPolicyPlan(nil) + Expect(operationErr).NotTo(BeNil()) + Expect(response).To(BeNil()) + Expect(result).To(BeNil()) + + // Construct an instance of the DeleteBackupPolicyPlanOptions model + deleteBackupPolicyPlanOptionsModel := new(vpcv1.DeleteBackupPolicyPlanOptions) + deleteBackupPolicyPlanOptionsModel.BackupPolicyID = core.StringPtr("testString") + deleteBackupPolicyPlanOptionsModel.ID = core.StringPtr("testString") + deleteBackupPolicyPlanOptionsModel.IfMatch = core.StringPtr(`W/"96d225c4-56bd-43d9-98fc-d7148e5c5028"`) + deleteBackupPolicyPlanOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation with valid options model (positive test) + result, response, operationErr = vpcService.DeleteBackupPolicyPlan(deleteBackupPolicyPlanOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).ToNot(BeNil()) + + }) + It(`Invoke DeleteBackupPolicyPlan 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 DeleteBackupPolicyPlanOptions model + deleteBackupPolicyPlanOptionsModel := new(vpcv1.DeleteBackupPolicyPlanOptions) + deleteBackupPolicyPlanOptionsModel.BackupPolicyID = core.StringPtr("testString") + deleteBackupPolicyPlanOptionsModel.ID = core.StringPtr("testString") + deleteBackupPolicyPlanOptionsModel.IfMatch = core.StringPtr(`W/"96d225c4-56bd-43d9-98fc-d7148e5c5028"`) + deleteBackupPolicyPlanOptionsModel.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.DeleteBackupPolicyPlan(deleteBackupPolicyPlanOptionsModel) + 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 DeleteBackupPolicyPlanOptions model with no property values + deleteBackupPolicyPlanOptionsModelNew := new(vpcv1.DeleteBackupPolicyPlanOptions) + // Invoke operation with invalid model (negative test) + result, response, operationErr = vpcService.DeleteBackupPolicyPlan(deleteBackupPolicyPlanOptionsModelNew) + 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 DeleteBackupPolicyPlan 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 DeleteBackupPolicyPlanOptions model + deleteBackupPolicyPlanOptionsModel := new(vpcv1.DeleteBackupPolicyPlanOptions) + deleteBackupPolicyPlanOptionsModel.BackupPolicyID = core.StringPtr("testString") + deleteBackupPolicyPlanOptionsModel.ID = core.StringPtr("testString") + deleteBackupPolicyPlanOptionsModel.IfMatch = core.StringPtr(`W/"96d225c4-56bd-43d9-98fc-d7148e5c5028"`) + deleteBackupPolicyPlanOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation + result, response, operationErr := vpcService.DeleteBackupPolicyPlan(deleteBackupPolicyPlanOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + + // Verify a nil result + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + }) + Describe(`GetBackupPolicyPlan(getBackupPolicyPlanOptions *GetBackupPolicyPlanOptions) - Operation response error`, func() { + version := "testString" + getBackupPolicyPlanPath := "/backup_policies/testString/plans/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(getBackupPolicyPlanPath)) + 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 GetBackupPolicyPlan 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 GetBackupPolicyPlanOptions model + getBackupPolicyPlanOptionsModel := new(vpcv1.GetBackupPolicyPlanOptions) + getBackupPolicyPlanOptionsModel.BackupPolicyID = core.StringPtr("testString") + getBackupPolicyPlanOptionsModel.ID = core.StringPtr("testString") + getBackupPolicyPlanOptionsModel.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.GetBackupPolicyPlan(getBackupPolicyPlanOptionsModel) + 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.GetBackupPolicyPlan(getBackupPolicyPlanOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + }) + Describe(`GetBackupPolicyPlan(getBackupPolicyPlanOptions *GetBackupPolicyPlanOptions)`, func() { + version := "testString" + getBackupPolicyPlanPath := "/backup_policies/testString/plans/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(getBackupPolicyPlanPath)) + 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", `{"active": true, "attach_user_tags": ["AttachUserTags"], "copy_user_tags": true, "created_at": "2019-01-01T12:00:00.000Z", "cron_spec": "*/5 1,2,3 * * *", "deletion_trigger": {"delete_after": 20, "delete_over_count": 20}, "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", "lifecycle_state": "stable", "name": "my-policy-plan", "resource_type": "backup_policy_plan"}`) + })) + }) + It(`Invoke GetBackupPolicyPlan 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 GetBackupPolicyPlanOptions model + getBackupPolicyPlanOptionsModel := new(vpcv1.GetBackupPolicyPlanOptions) + getBackupPolicyPlanOptionsModel.BackupPolicyID = core.StringPtr("testString") + getBackupPolicyPlanOptionsModel.ID = core.StringPtr("testString") + getBackupPolicyPlanOptionsModel.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.GetBackupPolicyPlanWithContext(ctx, getBackupPolicyPlanOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) + + // Disable retries and test again + vpcService.DisableRetries() + result, response, operationErr := vpcService.GetBackupPolicyPlan(getBackupPolicyPlanOptionsModel) + 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.GetBackupPolicyPlanWithContext(ctx, getBackupPolicyPlanOptionsModel) + 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(getBackupPolicyPlanPath)) + 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", `{"active": true, "attach_user_tags": ["AttachUserTags"], "copy_user_tags": true, "created_at": "2019-01-01T12:00:00.000Z", "cron_spec": "*/5 1,2,3 * * *", "deletion_trigger": {"delete_after": 20, "delete_over_count": 20}, "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", "lifecycle_state": "stable", "name": "my-policy-plan", "resource_type": "backup_policy_plan"}`) + })) + }) + It(`Invoke GetBackupPolicyPlan 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.GetBackupPolicyPlan(nil) + Expect(operationErr).NotTo(BeNil()) + Expect(response).To(BeNil()) + Expect(result).To(BeNil()) + + // Construct an instance of the GetBackupPolicyPlanOptions model + getBackupPolicyPlanOptionsModel := new(vpcv1.GetBackupPolicyPlanOptions) + getBackupPolicyPlanOptionsModel.BackupPolicyID = core.StringPtr("testString") + getBackupPolicyPlanOptionsModel.ID = core.StringPtr("testString") + getBackupPolicyPlanOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation with valid options model (positive test) + result, response, operationErr = vpcService.GetBackupPolicyPlan(getBackupPolicyPlanOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).ToNot(BeNil()) + + }) + It(`Invoke GetBackupPolicyPlan 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 GetBackupPolicyPlanOptions model + getBackupPolicyPlanOptionsModel := new(vpcv1.GetBackupPolicyPlanOptions) + getBackupPolicyPlanOptionsModel.BackupPolicyID = core.StringPtr("testString") + getBackupPolicyPlanOptionsModel.ID = core.StringPtr("testString") + getBackupPolicyPlanOptionsModel.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.GetBackupPolicyPlan(getBackupPolicyPlanOptionsModel) + 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 GetBackupPolicyPlanOptions model with no property values + getBackupPolicyPlanOptionsModelNew := new(vpcv1.GetBackupPolicyPlanOptions) + // Invoke operation with invalid model (negative test) + result, response, operationErr = vpcService.GetBackupPolicyPlan(getBackupPolicyPlanOptionsModelNew) + 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 GetBackupPolicyPlan 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 GetBackupPolicyPlanOptions model + getBackupPolicyPlanOptionsModel := new(vpcv1.GetBackupPolicyPlanOptions) + getBackupPolicyPlanOptionsModel.BackupPolicyID = core.StringPtr("testString") + getBackupPolicyPlanOptionsModel.ID = core.StringPtr("testString") + getBackupPolicyPlanOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation + result, response, operationErr := vpcService.GetBackupPolicyPlan(getBackupPolicyPlanOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + + // Verify a nil result + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + }) + Describe(`UpdateBackupPolicyPlan(updateBackupPolicyPlanOptions *UpdateBackupPolicyPlanOptions) - Operation response error`, func() { + version := "testString" + updateBackupPolicyPlanPath := "/backup_policies/testString/plans/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(updateBackupPolicyPlanPath)) + 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 UpdateBackupPolicyPlan 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 BackupPolicyPlanDeletionTriggerPatch model + backupPolicyPlanDeletionTriggerPatchModel := new(vpcv1.BackupPolicyPlanDeletionTriggerPatch) + backupPolicyPlanDeletionTriggerPatchModel.DeleteAfter = core.Int64Ptr(int64(20)) + backupPolicyPlanDeletionTriggerPatchModel.DeleteOverCount = core.Int64Ptr(int64(38)) + + // Construct an instance of the BackupPolicyPlanPatch model + backupPolicyPlanPatchModel := new(vpcv1.BackupPolicyPlanPatch) + backupPolicyPlanPatchModel.Active = core.BoolPtr(true) + backupPolicyPlanPatchModel.AttachUserTags = []string{"my-daily-backup-plan"} + backupPolicyPlanPatchModel.CopyUserTags = core.BoolPtr(true) + backupPolicyPlanPatchModel.CronSpec = core.StringPtr("*/5 1,2,3 * * *") + backupPolicyPlanPatchModel.DeletionTrigger = backupPolicyPlanDeletionTriggerPatchModel + backupPolicyPlanPatchModel.Name = core.StringPtr("my-policy-plan") + backupPolicyPlanPatchModelAsPatch, asPatchErr := backupPolicyPlanPatchModel.AsPatch() + Expect(asPatchErr).To(BeNil()) + + // Construct an instance of the UpdateBackupPolicyPlanOptions model + updateBackupPolicyPlanOptionsModel := new(vpcv1.UpdateBackupPolicyPlanOptions) + updateBackupPolicyPlanOptionsModel.BackupPolicyID = core.StringPtr("testString") + updateBackupPolicyPlanOptionsModel.ID = core.StringPtr("testString") + updateBackupPolicyPlanOptionsModel.BackupPolicyPlanPatch = backupPolicyPlanPatchModelAsPatch + updateBackupPolicyPlanOptionsModel.IfMatch = core.StringPtr(`W/"96d225c4-56bd-43d9-98fc-d7148e5c5028"`) + updateBackupPolicyPlanOptionsModel.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.UpdateBackupPolicyPlan(updateBackupPolicyPlanOptionsModel) + 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.UpdateBackupPolicyPlan(updateBackupPolicyPlanOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + }) + Describe(`UpdateBackupPolicyPlan(updateBackupPolicyPlanOptions *UpdateBackupPolicyPlanOptions)`, func() { + version := "testString" + updateBackupPolicyPlanPath := "/backup_policies/testString/plans/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(updateBackupPolicyPlanPath)) + 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", `{"active": true, "attach_user_tags": ["AttachUserTags"], "copy_user_tags": true, "created_at": "2019-01-01T12:00:00.000Z", "cron_spec": "*/5 1,2,3 * * *", "deletion_trigger": {"delete_after": 20, "delete_over_count": 20}, "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", "lifecycle_state": "stable", "name": "my-policy-plan", "resource_type": "backup_policy_plan"}`) + })) + }) + It(`Invoke UpdateBackupPolicyPlan 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 BackupPolicyPlanDeletionTriggerPatch model + backupPolicyPlanDeletionTriggerPatchModel := new(vpcv1.BackupPolicyPlanDeletionTriggerPatch) + backupPolicyPlanDeletionTriggerPatchModel.DeleteAfter = core.Int64Ptr(int64(20)) + backupPolicyPlanDeletionTriggerPatchModel.DeleteOverCount = core.Int64Ptr(int64(38)) + + // Construct an instance of the BackupPolicyPlanPatch model + backupPolicyPlanPatchModel := new(vpcv1.BackupPolicyPlanPatch) + backupPolicyPlanPatchModel.Active = core.BoolPtr(true) + backupPolicyPlanPatchModel.AttachUserTags = []string{"my-daily-backup-plan"} + backupPolicyPlanPatchModel.CopyUserTags = core.BoolPtr(true) + backupPolicyPlanPatchModel.CronSpec = core.StringPtr("*/5 1,2,3 * * *") + backupPolicyPlanPatchModel.DeletionTrigger = backupPolicyPlanDeletionTriggerPatchModel + backupPolicyPlanPatchModel.Name = core.StringPtr("my-policy-plan") + backupPolicyPlanPatchModelAsPatch, asPatchErr := backupPolicyPlanPatchModel.AsPatch() + Expect(asPatchErr).To(BeNil()) + + // Construct an instance of the UpdateBackupPolicyPlanOptions model + updateBackupPolicyPlanOptionsModel := new(vpcv1.UpdateBackupPolicyPlanOptions) + updateBackupPolicyPlanOptionsModel.BackupPolicyID = core.StringPtr("testString") + updateBackupPolicyPlanOptionsModel.ID = core.StringPtr("testString") + updateBackupPolicyPlanOptionsModel.BackupPolicyPlanPatch = backupPolicyPlanPatchModelAsPatch + updateBackupPolicyPlanOptionsModel.IfMatch = core.StringPtr(`W/"96d225c4-56bd-43d9-98fc-d7148e5c5028"`) + updateBackupPolicyPlanOptionsModel.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.UpdateBackupPolicyPlanWithContext(ctx, updateBackupPolicyPlanOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) + + // Disable retries and test again + vpcService.DisableRetries() + result, response, operationErr := vpcService.UpdateBackupPolicyPlan(updateBackupPolicyPlanOptionsModel) + 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.UpdateBackupPolicyPlanWithContext(ctx, updateBackupPolicyPlanOptionsModel) + 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(updateBackupPolicyPlanPath)) + 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", `{"active": true, "attach_user_tags": ["AttachUserTags"], "copy_user_tags": true, "created_at": "2019-01-01T12:00:00.000Z", "cron_spec": "*/5 1,2,3 * * *", "deletion_trigger": {"delete_after": 20, "delete_over_count": 20}, "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", "lifecycle_state": "stable", "name": "my-policy-plan", "resource_type": "backup_policy_plan"}`) + })) + }) + It(`Invoke UpdateBackupPolicyPlan 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.UpdateBackupPolicyPlan(nil) + Expect(operationErr).NotTo(BeNil()) + Expect(response).To(BeNil()) + Expect(result).To(BeNil()) + + // Construct an instance of the BackupPolicyPlanDeletionTriggerPatch model + backupPolicyPlanDeletionTriggerPatchModel := new(vpcv1.BackupPolicyPlanDeletionTriggerPatch) + backupPolicyPlanDeletionTriggerPatchModel.DeleteAfter = core.Int64Ptr(int64(20)) + backupPolicyPlanDeletionTriggerPatchModel.DeleteOverCount = core.Int64Ptr(int64(38)) + + // Construct an instance of the BackupPolicyPlanPatch model + backupPolicyPlanPatchModel := new(vpcv1.BackupPolicyPlanPatch) + backupPolicyPlanPatchModel.Active = core.BoolPtr(true) + backupPolicyPlanPatchModel.AttachUserTags = []string{"my-daily-backup-plan"} + backupPolicyPlanPatchModel.CopyUserTags = core.BoolPtr(true) + backupPolicyPlanPatchModel.CronSpec = core.StringPtr("*/5 1,2,3 * * *") + backupPolicyPlanPatchModel.DeletionTrigger = backupPolicyPlanDeletionTriggerPatchModel + backupPolicyPlanPatchModel.Name = core.StringPtr("my-policy-plan") + backupPolicyPlanPatchModelAsPatch, asPatchErr := backupPolicyPlanPatchModel.AsPatch() + Expect(asPatchErr).To(BeNil()) + + // Construct an instance of the UpdateBackupPolicyPlanOptions model + updateBackupPolicyPlanOptionsModel := new(vpcv1.UpdateBackupPolicyPlanOptions) + updateBackupPolicyPlanOptionsModel.BackupPolicyID = core.StringPtr("testString") + updateBackupPolicyPlanOptionsModel.ID = core.StringPtr("testString") + updateBackupPolicyPlanOptionsModel.BackupPolicyPlanPatch = backupPolicyPlanPatchModelAsPatch + updateBackupPolicyPlanOptionsModel.IfMatch = core.StringPtr(`W/"96d225c4-56bd-43d9-98fc-d7148e5c5028"`) + updateBackupPolicyPlanOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation with valid options model (positive test) + result, response, operationErr = vpcService.UpdateBackupPolicyPlan(updateBackupPolicyPlanOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).ToNot(BeNil()) + + }) + It(`Invoke UpdateBackupPolicyPlan 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 BackupPolicyPlanDeletionTriggerPatch model + backupPolicyPlanDeletionTriggerPatchModel := new(vpcv1.BackupPolicyPlanDeletionTriggerPatch) + backupPolicyPlanDeletionTriggerPatchModel.DeleteAfter = core.Int64Ptr(int64(20)) + backupPolicyPlanDeletionTriggerPatchModel.DeleteOverCount = core.Int64Ptr(int64(38)) + + // Construct an instance of the BackupPolicyPlanPatch model + backupPolicyPlanPatchModel := new(vpcv1.BackupPolicyPlanPatch) + backupPolicyPlanPatchModel.Active = core.BoolPtr(true) + backupPolicyPlanPatchModel.AttachUserTags = []string{"my-daily-backup-plan"} + backupPolicyPlanPatchModel.CopyUserTags = core.BoolPtr(true) + backupPolicyPlanPatchModel.CronSpec = core.StringPtr("*/5 1,2,3 * * *") + backupPolicyPlanPatchModel.DeletionTrigger = backupPolicyPlanDeletionTriggerPatchModel + backupPolicyPlanPatchModel.Name = core.StringPtr("my-policy-plan") + backupPolicyPlanPatchModelAsPatch, asPatchErr := backupPolicyPlanPatchModel.AsPatch() + Expect(asPatchErr).To(BeNil()) + + // Construct an instance of the UpdateBackupPolicyPlanOptions model + updateBackupPolicyPlanOptionsModel := new(vpcv1.UpdateBackupPolicyPlanOptions) + updateBackupPolicyPlanOptionsModel.BackupPolicyID = core.StringPtr("testString") + updateBackupPolicyPlanOptionsModel.ID = core.StringPtr("testString") + updateBackupPolicyPlanOptionsModel.BackupPolicyPlanPatch = backupPolicyPlanPatchModelAsPatch + updateBackupPolicyPlanOptionsModel.IfMatch = core.StringPtr(`W/"96d225c4-56bd-43d9-98fc-d7148e5c5028"`) + updateBackupPolicyPlanOptionsModel.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.UpdateBackupPolicyPlan(updateBackupPolicyPlanOptionsModel) + 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 UpdateBackupPolicyPlanOptions model with no property values + updateBackupPolicyPlanOptionsModelNew := new(vpcv1.UpdateBackupPolicyPlanOptions) + // Invoke operation with invalid model (negative test) + result, response, operationErr = vpcService.UpdateBackupPolicyPlan(updateBackupPolicyPlanOptionsModelNew) + 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 UpdateBackupPolicyPlan 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 BackupPolicyPlanDeletionTriggerPatch model + backupPolicyPlanDeletionTriggerPatchModel := new(vpcv1.BackupPolicyPlanDeletionTriggerPatch) + backupPolicyPlanDeletionTriggerPatchModel.DeleteAfter = core.Int64Ptr(int64(20)) + backupPolicyPlanDeletionTriggerPatchModel.DeleteOverCount = core.Int64Ptr(int64(38)) + + // Construct an instance of the BackupPolicyPlanPatch model + backupPolicyPlanPatchModel := new(vpcv1.BackupPolicyPlanPatch) + backupPolicyPlanPatchModel.Active = core.BoolPtr(true) + backupPolicyPlanPatchModel.AttachUserTags = []string{"my-daily-backup-plan"} + backupPolicyPlanPatchModel.CopyUserTags = core.BoolPtr(true) + backupPolicyPlanPatchModel.CronSpec = core.StringPtr("*/5 1,2,3 * * *") + backupPolicyPlanPatchModel.DeletionTrigger = backupPolicyPlanDeletionTriggerPatchModel + backupPolicyPlanPatchModel.Name = core.StringPtr("my-policy-plan") + backupPolicyPlanPatchModelAsPatch, asPatchErr := backupPolicyPlanPatchModel.AsPatch() + Expect(asPatchErr).To(BeNil()) + + // Construct an instance of the UpdateBackupPolicyPlanOptions model + updateBackupPolicyPlanOptionsModel := new(vpcv1.UpdateBackupPolicyPlanOptions) + updateBackupPolicyPlanOptionsModel.BackupPolicyID = core.StringPtr("testString") + updateBackupPolicyPlanOptionsModel.ID = core.StringPtr("testString") + updateBackupPolicyPlanOptionsModel.BackupPolicyPlanPatch = backupPolicyPlanPatchModelAsPatch + updateBackupPolicyPlanOptionsModel.IfMatch = core.StringPtr(`W/"96d225c4-56bd-43d9-98fc-d7148e5c5028"`) + updateBackupPolicyPlanOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation + result, response, operationErr := vpcService.UpdateBackupPolicyPlan(updateBackupPolicyPlanOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + + // Verify a nil result + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + }) + Describe(`DeleteBackupPolicy(deleteBackupPolicyOptions *DeleteBackupPolicyOptions) - Operation response error`, func() { + version := "testString" + deleteBackupPolicyPath := "/backup_policies/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(deleteBackupPolicyPath)) + 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.Header().Set("Content-type", "application/json") + res.WriteHeader(202) + fmt.Fprint(res, `} this is not valid json {`) + })) + }) + It(`Invoke DeleteBackupPolicy 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 DeleteBackupPolicyOptions model + deleteBackupPolicyOptionsModel := new(vpcv1.DeleteBackupPolicyOptions) + deleteBackupPolicyOptionsModel.ID = core.StringPtr("testString") + deleteBackupPolicyOptionsModel.IfMatch = core.StringPtr(`W/"96d225c4-56bd-43d9-98fc-d7148e5c5028"`) + deleteBackupPolicyOptionsModel.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.DeleteBackupPolicy(deleteBackupPolicyOptionsModel) + 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.DeleteBackupPolicy(deleteBackupPolicyOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + }) + Describe(`DeleteBackupPolicy(deleteBackupPolicyOptions *DeleteBackupPolicyOptions)`, func() { + version := "testString" + deleteBackupPolicyPath := "/backup_policies/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(deleteBackupPolicyPath)) + 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))})) + // 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", `{"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", "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", "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"}`) + })) + }) + It(`Invoke DeleteBackupPolicy 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 DeleteBackupPolicyOptions model + deleteBackupPolicyOptionsModel := new(vpcv1.DeleteBackupPolicyOptions) + deleteBackupPolicyOptionsModel.ID = core.StringPtr("testString") + deleteBackupPolicyOptionsModel.IfMatch = core.StringPtr(`W/"96d225c4-56bd-43d9-98fc-d7148e5c5028"`) + deleteBackupPolicyOptionsModel.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.DeleteBackupPolicyWithContext(ctx, deleteBackupPolicyOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) + + // Disable retries and test again + vpcService.DisableRetries() + result, response, operationErr := vpcService.DeleteBackupPolicy(deleteBackupPolicyOptionsModel) + 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.DeleteBackupPolicyWithContext(ctx, deleteBackupPolicyOptionsModel) + 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(deleteBackupPolicyPath)) + 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))})) + // 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", "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", "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"}`) + })) + }) + It(`Invoke DeleteBackupPolicy 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.DeleteBackupPolicy(nil) + Expect(operationErr).NotTo(BeNil()) + Expect(response).To(BeNil()) + Expect(result).To(BeNil()) + + // Construct an instance of the DeleteBackupPolicyOptions model + deleteBackupPolicyOptionsModel := new(vpcv1.DeleteBackupPolicyOptions) + deleteBackupPolicyOptionsModel.ID = core.StringPtr("testString") + deleteBackupPolicyOptionsModel.IfMatch = core.StringPtr(`W/"96d225c4-56bd-43d9-98fc-d7148e5c5028"`) + deleteBackupPolicyOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation with valid options model (positive test) + result, response, operationErr = vpcService.DeleteBackupPolicy(deleteBackupPolicyOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).ToNot(BeNil()) + + }) + It(`Invoke DeleteBackupPolicy 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 DeleteBackupPolicyOptions model + deleteBackupPolicyOptionsModel := new(vpcv1.DeleteBackupPolicyOptions) + deleteBackupPolicyOptionsModel.ID = core.StringPtr("testString") + deleteBackupPolicyOptionsModel.IfMatch = core.StringPtr(`W/"96d225c4-56bd-43d9-98fc-d7148e5c5028"`) + deleteBackupPolicyOptionsModel.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.DeleteBackupPolicy(deleteBackupPolicyOptionsModel) + 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 DeleteBackupPolicyOptions model with no property values + deleteBackupPolicyOptionsModelNew := new(vpcv1.DeleteBackupPolicyOptions) + // Invoke operation with invalid model (negative test) + result, response, operationErr = vpcService.DeleteBackupPolicy(deleteBackupPolicyOptionsModelNew) + 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 DeleteBackupPolicy 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 DeleteBackupPolicyOptions model + deleteBackupPolicyOptionsModel := new(vpcv1.DeleteBackupPolicyOptions) + deleteBackupPolicyOptionsModel.ID = core.StringPtr("testString") + deleteBackupPolicyOptionsModel.IfMatch = core.StringPtr(`W/"96d225c4-56bd-43d9-98fc-d7148e5c5028"`) + deleteBackupPolicyOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation + result, response, operationErr := vpcService.DeleteBackupPolicy(deleteBackupPolicyOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + + // Verify a nil result + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + }) + Describe(`GetBackupPolicy(getBackupPolicyOptions *GetBackupPolicyOptions) - Operation response error`, func() { + version := "testString" + getBackupPolicyPath := "/backup_policies/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(getBackupPolicyPath)) + 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 GetBackupPolicy 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 GetBackupPolicyOptions model + getBackupPolicyOptionsModel := new(vpcv1.GetBackupPolicyOptions) + getBackupPolicyOptionsModel.ID = core.StringPtr("testString") + getBackupPolicyOptionsModel.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.GetBackupPolicy(getBackupPolicyOptionsModel) + 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.GetBackupPolicy(getBackupPolicyOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + }) + Describe(`GetBackupPolicy(getBackupPolicyOptions *GetBackupPolicyOptions)`, func() { + version := "testString" + getBackupPolicyPath := "/backup_policies/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(getBackupPolicyPath)) + 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", `{"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", "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", "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"}`) + })) + }) + It(`Invoke GetBackupPolicy 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 GetBackupPolicyOptions model + getBackupPolicyOptionsModel := new(vpcv1.GetBackupPolicyOptions) + getBackupPolicyOptionsModel.ID = core.StringPtr("testString") + getBackupPolicyOptionsModel.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.GetBackupPolicyWithContext(ctx, getBackupPolicyOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) + + // Disable retries and test again + vpcService.DisableRetries() + result, response, operationErr := vpcService.GetBackupPolicy(getBackupPolicyOptionsModel) + 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.GetBackupPolicyWithContext(ctx, getBackupPolicyOptionsModel) + 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(getBackupPolicyPath)) + 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", `{"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", "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", "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"}`) + })) + }) + It(`Invoke GetBackupPolicy 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.GetBackupPolicy(nil) + Expect(operationErr).NotTo(BeNil()) + Expect(response).To(BeNil()) + Expect(result).To(BeNil()) + + // Construct an instance of the GetBackupPolicyOptions model + getBackupPolicyOptionsModel := new(vpcv1.GetBackupPolicyOptions) + getBackupPolicyOptionsModel.ID = core.StringPtr("testString") + getBackupPolicyOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation with valid options model (positive test) + result, response, operationErr = vpcService.GetBackupPolicy(getBackupPolicyOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).ToNot(BeNil()) + + }) + It(`Invoke GetBackupPolicy 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 GetBackupPolicyOptions model + getBackupPolicyOptionsModel := new(vpcv1.GetBackupPolicyOptions) + getBackupPolicyOptionsModel.ID = core.StringPtr("testString") + getBackupPolicyOptionsModel.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.GetBackupPolicy(getBackupPolicyOptionsModel) + 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 GetBackupPolicyOptions model with no property values + getBackupPolicyOptionsModelNew := new(vpcv1.GetBackupPolicyOptions) + // Invoke operation with invalid model (negative test) + result, response, operationErr = vpcService.GetBackupPolicy(getBackupPolicyOptionsModelNew) + 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 GetBackupPolicy 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 GetBackupPolicyOptions model + getBackupPolicyOptionsModel := new(vpcv1.GetBackupPolicyOptions) + getBackupPolicyOptionsModel.ID = core.StringPtr("testString") + getBackupPolicyOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation + result, response, operationErr := vpcService.GetBackupPolicy(getBackupPolicyOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + + // Verify a nil result + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + }) + Describe(`UpdateBackupPolicy(updateBackupPolicyOptions *UpdateBackupPolicyOptions) - Operation response error`, func() { + version := "testString" + updateBackupPolicyPath := "/backup_policies/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(updateBackupPolicyPath)) + 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 UpdateBackupPolicy 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 BackupPolicyPatch model + backupPolicyPatchModel := new(vpcv1.BackupPolicyPatch) + backupPolicyPatchModel.MatchUserTags = []string{"my-daily-backup-policy"} + backupPolicyPatchModel.Name = core.StringPtr("my-backup-policy") + backupPolicyPatchModelAsPatch, asPatchErr := backupPolicyPatchModel.AsPatch() + Expect(asPatchErr).To(BeNil()) + + // Construct an instance of the UpdateBackupPolicyOptions model + updateBackupPolicyOptionsModel := new(vpcv1.UpdateBackupPolicyOptions) + updateBackupPolicyOptionsModel.ID = core.StringPtr("testString") + updateBackupPolicyOptionsModel.BackupPolicyPatch = backupPolicyPatchModelAsPatch + updateBackupPolicyOptionsModel.IfMatch = core.StringPtr(`W/"96d225c4-56bd-43d9-98fc-d7148e5c5028"`) + updateBackupPolicyOptionsModel.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.UpdateBackupPolicy(updateBackupPolicyOptionsModel) + 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.UpdateBackupPolicy(updateBackupPolicyOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + }) + Describe(`UpdateBackupPolicy(updateBackupPolicyOptions *UpdateBackupPolicyOptions)`, func() { + version := "testString" + updateBackupPolicyPath := "/backup_policies/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(updateBackupPolicyPath)) + 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", `{"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", "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", "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"}`) + })) + }) + It(`Invoke UpdateBackupPolicy 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 BackupPolicyPatch model + backupPolicyPatchModel := new(vpcv1.BackupPolicyPatch) + backupPolicyPatchModel.MatchUserTags = []string{"my-daily-backup-policy"} + backupPolicyPatchModel.Name = core.StringPtr("my-backup-policy") + backupPolicyPatchModelAsPatch, asPatchErr := backupPolicyPatchModel.AsPatch() + Expect(asPatchErr).To(BeNil()) + + // Construct an instance of the UpdateBackupPolicyOptions model + updateBackupPolicyOptionsModel := new(vpcv1.UpdateBackupPolicyOptions) + updateBackupPolicyOptionsModel.ID = core.StringPtr("testString") + updateBackupPolicyOptionsModel.BackupPolicyPatch = backupPolicyPatchModelAsPatch + updateBackupPolicyOptionsModel.IfMatch = core.StringPtr(`W/"96d225c4-56bd-43d9-98fc-d7148e5c5028"`) + updateBackupPolicyOptionsModel.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.UpdateBackupPolicyWithContext(ctx, updateBackupPolicyOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) + + // Disable retries and test again + vpcService.DisableRetries() + result, response, operationErr := vpcService.UpdateBackupPolicy(updateBackupPolicyOptionsModel) + 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.UpdateBackupPolicyWithContext(ctx, updateBackupPolicyOptionsModel) + 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(updateBackupPolicyPath)) + 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", `{"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", "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", "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"}`) + })) + }) + It(`Invoke UpdateBackupPolicy 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.UpdateBackupPolicy(nil) + Expect(operationErr).NotTo(BeNil()) + Expect(response).To(BeNil()) + Expect(result).To(BeNil()) + + // Construct an instance of the BackupPolicyPatch model + backupPolicyPatchModel := new(vpcv1.BackupPolicyPatch) + backupPolicyPatchModel.MatchUserTags = []string{"my-daily-backup-policy"} + backupPolicyPatchModel.Name = core.StringPtr("my-backup-policy") + backupPolicyPatchModelAsPatch, asPatchErr := backupPolicyPatchModel.AsPatch() + Expect(asPatchErr).To(BeNil()) + + // Construct an instance of the UpdateBackupPolicyOptions model + updateBackupPolicyOptionsModel := new(vpcv1.UpdateBackupPolicyOptions) + updateBackupPolicyOptionsModel.ID = core.StringPtr("testString") + updateBackupPolicyOptionsModel.BackupPolicyPatch = backupPolicyPatchModelAsPatch + updateBackupPolicyOptionsModel.IfMatch = core.StringPtr(`W/"96d225c4-56bd-43d9-98fc-d7148e5c5028"`) + updateBackupPolicyOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation with valid options model (positive test) + result, response, operationErr = vpcService.UpdateBackupPolicy(updateBackupPolicyOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).ToNot(BeNil()) + + }) + It(`Invoke UpdateBackupPolicy 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 BackupPolicyPatch model + backupPolicyPatchModel := new(vpcv1.BackupPolicyPatch) + backupPolicyPatchModel.MatchUserTags = []string{"my-daily-backup-policy"} + backupPolicyPatchModel.Name = core.StringPtr("my-backup-policy") + backupPolicyPatchModelAsPatch, asPatchErr := backupPolicyPatchModel.AsPatch() + Expect(asPatchErr).To(BeNil()) + + // Construct an instance of the UpdateBackupPolicyOptions model + updateBackupPolicyOptionsModel := new(vpcv1.UpdateBackupPolicyOptions) + updateBackupPolicyOptionsModel.ID = core.StringPtr("testString") + updateBackupPolicyOptionsModel.BackupPolicyPatch = backupPolicyPatchModelAsPatch + updateBackupPolicyOptionsModel.IfMatch = core.StringPtr(`W/"96d225c4-56bd-43d9-98fc-d7148e5c5028"`) + updateBackupPolicyOptionsModel.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.UpdateBackupPolicy(updateBackupPolicyOptionsModel) + 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 UpdateBackupPolicyOptions model with no property values + updateBackupPolicyOptionsModelNew := new(vpcv1.UpdateBackupPolicyOptions) + // Invoke operation with invalid model (negative test) + result, response, operationErr = vpcService.UpdateBackupPolicy(updateBackupPolicyOptionsModelNew) + 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 UpdateBackupPolicy 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 BackupPolicyPatch model + backupPolicyPatchModel := new(vpcv1.BackupPolicyPatch) + backupPolicyPatchModel.MatchUserTags = []string{"my-daily-backup-policy"} + backupPolicyPatchModel.Name = core.StringPtr("my-backup-policy") + backupPolicyPatchModelAsPatch, asPatchErr := backupPolicyPatchModel.AsPatch() + Expect(asPatchErr).To(BeNil()) + + // Construct an instance of the UpdateBackupPolicyOptions model + updateBackupPolicyOptionsModel := new(vpcv1.UpdateBackupPolicyOptions) + updateBackupPolicyOptionsModel.ID = core.StringPtr("testString") + updateBackupPolicyOptionsModel.BackupPolicyPatch = backupPolicyPatchModelAsPatch + updateBackupPolicyOptionsModel.IfMatch = core.StringPtr(`W/"96d225c4-56bd-43d9-98fc-d7148e5c5028"`) + updateBackupPolicyOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation + result, response, operationErr := vpcService.UpdateBackupPolicy(updateBackupPolicyOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + + // Verify a nil result + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + }) + Describe(`ListPlacementGroups(listPlacementGroupsOptions *ListPlacementGroupsOptions) - Operation response error`, func() { + version := "testString" + listPlacementGroupsPath := "/placement_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(listPlacementGroupsPath)) + 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(1))})) + res.Header().Set("Content-type", "application/json") + res.WriteHeader(200) + fmt.Fprint(res, `} this is not valid json {`) + })) + }) + It(`Invoke ListPlacementGroups 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 ListPlacementGroupsOptions model + listPlacementGroupsOptionsModel := new(vpcv1.ListPlacementGroupsOptions) + listPlacementGroupsOptionsModel.Start = core.StringPtr("testString") + listPlacementGroupsOptionsModel.Limit = core.Int64Ptr(int64(1)) + listPlacementGroupsOptionsModel.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.ListPlacementGroups(listPlacementGroupsOptionsModel) + 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.ListPlacementGroups(listPlacementGroupsOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + }) + Describe(`ListPlacementGroups(listPlacementGroupsOptions *ListPlacementGroupsOptions)`, func() { + version := "testString" + listPlacementGroupsPath := "/placement_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(listPlacementGroupsPath)) + 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(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/placement_groups?limit=20"}, "limit": 20, "next": {"href": "https://us-south.iaas.cloud.ibm.com/v1/placement_groups?start=9d5a91a3e2cbd233b5a5b33436855ed1&limit=20"}, "placement_groups": [{"created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south:a/123456::placement-group:r018-418fe842-a3e9-47b9-a938-1aa5bd632871", "href": "https://us-south.iaas.cloud.ibm.com/v1/placement_groups/r018-418fe842-a3e9-47b9-a938-1aa5bd632871", "id": "r018-418fe842-a3e9-47b9-a938-1aa5bd632871", "lifecycle_state": "stable", "name": "my-placement-group", "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "resource_type": "placement_group", "strategy": "host_spread"}], "total_count": 132}`) + })) + }) + It(`Invoke ListPlacementGroups 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 ListPlacementGroupsOptions model + listPlacementGroupsOptionsModel := new(vpcv1.ListPlacementGroupsOptions) + listPlacementGroupsOptionsModel.Start = core.StringPtr("testString") + listPlacementGroupsOptionsModel.Limit = core.Int64Ptr(int64(1)) + listPlacementGroupsOptionsModel.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.ListPlacementGroupsWithContext(ctx, listPlacementGroupsOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) + + // Disable retries and test again + vpcService.DisableRetries() + result, response, operationErr := vpcService.ListPlacementGroups(listPlacementGroupsOptionsModel) + 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.ListPlacementGroupsWithContext(ctx, listPlacementGroupsOptionsModel) + 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(listPlacementGroupsPath)) + 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(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/placement_groups?limit=20"}, "limit": 20, "next": {"href": "https://us-south.iaas.cloud.ibm.com/v1/placement_groups?start=9d5a91a3e2cbd233b5a5b33436855ed1&limit=20"}, "placement_groups": [{"created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south:a/123456::placement-group:r018-418fe842-a3e9-47b9-a938-1aa5bd632871", "href": "https://us-south.iaas.cloud.ibm.com/v1/placement_groups/r018-418fe842-a3e9-47b9-a938-1aa5bd632871", "id": "r018-418fe842-a3e9-47b9-a938-1aa5bd632871", "lifecycle_state": "stable", "name": "my-placement-group", "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "resource_type": "placement_group", "strategy": "host_spread"}], "total_count": 132}`) + })) + }) + It(`Invoke ListPlacementGroups 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.ListPlacementGroups(nil) + Expect(operationErr).NotTo(BeNil()) + Expect(response).To(BeNil()) + Expect(result).To(BeNil()) + + // Construct an instance of the ListPlacementGroupsOptions model + listPlacementGroupsOptionsModel := new(vpcv1.ListPlacementGroupsOptions) + listPlacementGroupsOptionsModel.Start = core.StringPtr("testString") + listPlacementGroupsOptionsModel.Limit = core.Int64Ptr(int64(1)) + listPlacementGroupsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation with valid options model (positive test) + result, response, operationErr = vpcService.ListPlacementGroups(listPlacementGroupsOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).ToNot(BeNil()) + + }) + It(`Invoke ListPlacementGroups 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 ListPlacementGroupsOptions model + listPlacementGroupsOptionsModel := new(vpcv1.ListPlacementGroupsOptions) + listPlacementGroupsOptionsModel.Start = core.StringPtr("testString") + listPlacementGroupsOptionsModel.Limit = core.Int64Ptr(int64(1)) + listPlacementGroupsOptionsModel.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.ListPlacementGroups(listPlacementGroupsOptionsModel) + 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 ListPlacementGroups 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 ListPlacementGroupsOptions model + listPlacementGroupsOptionsModel := new(vpcv1.ListPlacementGroupsOptions) + listPlacementGroupsOptionsModel.Start = core.StringPtr("testString") + listPlacementGroupsOptionsModel.Limit = core.Int64Ptr(int64(1)) + listPlacementGroupsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation + result, response, operationErr := vpcService.ListPlacementGroups(listPlacementGroupsOptionsModel) + 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.PlacementGroupCollection) + nextObject := new(vpcv1.PlacementGroupCollectionNext) + 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.PlacementGroupCollection) + + 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.PlacementGroupCollection) + nextObject := new(vpcv1.PlacementGroupCollectionNext) + nextObject.Href = core.StringPtr("ibm.com") + responseObject.Next = nextObject + + value, err := responseObject.GetNextStart() + Expect(err).To(BeNil()) + Expect(value).To(BeNil()) + }) + }) + }) + Describe(`CreatePlacementGroup(createPlacementGroupOptions *CreatePlacementGroupOptions) - Operation response error`, func() { + version := "testString" + createPlacementGroupPath := "/placement_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(createPlacementGroupPath)) + 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 CreatePlacementGroup 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 ResourceGroupIdentityByID model + resourceGroupIdentityModel := new(vpcv1.ResourceGroupIdentityByID) + resourceGroupIdentityModel.ID = core.StringPtr("fee82deba12e4c0fb69c3b09d1f12345") + + // Construct an instance of the CreatePlacementGroupOptions model + createPlacementGroupOptionsModel := new(vpcv1.CreatePlacementGroupOptions) + createPlacementGroupOptionsModel.Strategy = core.StringPtr("host_spread") + createPlacementGroupOptionsModel.Name = core.StringPtr("my-placement-group") + createPlacementGroupOptionsModel.ResourceGroup = resourceGroupIdentityModel + createPlacementGroupOptionsModel.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.CreatePlacementGroup(createPlacementGroupOptionsModel) + 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.CreatePlacementGroup(createPlacementGroupOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + }) + Describe(`CreatePlacementGroup(createPlacementGroupOptions *CreatePlacementGroupOptions)`, func() { + version := "testString" + createPlacementGroupPath := "/placement_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(createPlacementGroupPath)) + 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", `{"created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south:a/123456::placement-group:r018-418fe842-a3e9-47b9-a938-1aa5bd632871", "href": "https://us-south.iaas.cloud.ibm.com/v1/placement_groups/r018-418fe842-a3e9-47b9-a938-1aa5bd632871", "id": "r018-418fe842-a3e9-47b9-a938-1aa5bd632871", "lifecycle_state": "stable", "name": "my-placement-group", "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "resource_type": "placement_group", "strategy": "host_spread"}`) + })) + }) + It(`Invoke CreatePlacementGroup 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 ResourceGroupIdentityByID model + resourceGroupIdentityModel := new(vpcv1.ResourceGroupIdentityByID) + resourceGroupIdentityModel.ID = core.StringPtr("fee82deba12e4c0fb69c3b09d1f12345") + + // Construct an instance of the CreatePlacementGroupOptions model + createPlacementGroupOptionsModel := new(vpcv1.CreatePlacementGroupOptions) + createPlacementGroupOptionsModel.Strategy = core.StringPtr("host_spread") + createPlacementGroupOptionsModel.Name = core.StringPtr("my-placement-group") + createPlacementGroupOptionsModel.ResourceGroup = resourceGroupIdentityModel + createPlacementGroupOptionsModel.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.CreatePlacementGroupWithContext(ctx, createPlacementGroupOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) + + // Disable retries and test again + vpcService.DisableRetries() + result, response, operationErr := vpcService.CreatePlacementGroup(createPlacementGroupOptionsModel) + 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.CreatePlacementGroupWithContext(ctx, createPlacementGroupOptionsModel) + 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(createPlacementGroupPath)) + 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", `{"created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south:a/123456::placement-group:r018-418fe842-a3e9-47b9-a938-1aa5bd632871", "href": "https://us-south.iaas.cloud.ibm.com/v1/placement_groups/r018-418fe842-a3e9-47b9-a938-1aa5bd632871", "id": "r018-418fe842-a3e9-47b9-a938-1aa5bd632871", "lifecycle_state": "stable", "name": "my-placement-group", "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "resource_type": "placement_group", "strategy": "host_spread"}`) + })) + }) + It(`Invoke CreatePlacementGroup 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.CreatePlacementGroup(nil) + Expect(operationErr).NotTo(BeNil()) + Expect(response).To(BeNil()) + Expect(result).To(BeNil()) + + // Construct an instance of the ResourceGroupIdentityByID model + resourceGroupIdentityModel := new(vpcv1.ResourceGroupIdentityByID) + resourceGroupIdentityModel.ID = core.StringPtr("fee82deba12e4c0fb69c3b09d1f12345") + + // Construct an instance of the CreatePlacementGroupOptions model + createPlacementGroupOptionsModel := new(vpcv1.CreatePlacementGroupOptions) + createPlacementGroupOptionsModel.Strategy = core.StringPtr("host_spread") + createPlacementGroupOptionsModel.Name = core.StringPtr("my-placement-group") + createPlacementGroupOptionsModel.ResourceGroup = resourceGroupIdentityModel + createPlacementGroupOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation with valid options model (positive test) + result, response, operationErr = vpcService.CreatePlacementGroup(createPlacementGroupOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).ToNot(BeNil()) + + }) + It(`Invoke CreatePlacementGroup 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 ResourceGroupIdentityByID model + resourceGroupIdentityModel := new(vpcv1.ResourceGroupIdentityByID) + resourceGroupIdentityModel.ID = core.StringPtr("fee82deba12e4c0fb69c3b09d1f12345") + + // Construct an instance of the CreatePlacementGroupOptions model + createPlacementGroupOptionsModel := new(vpcv1.CreatePlacementGroupOptions) + createPlacementGroupOptionsModel.Strategy = core.StringPtr("host_spread") + createPlacementGroupOptionsModel.Name = core.StringPtr("my-placement-group") + createPlacementGroupOptionsModel.ResourceGroup = resourceGroupIdentityModel + createPlacementGroupOptionsModel.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.CreatePlacementGroup(createPlacementGroupOptionsModel) + 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 CreatePlacementGroupOptions model with no property values + createPlacementGroupOptionsModelNew := new(vpcv1.CreatePlacementGroupOptions) + // Invoke operation with invalid model (negative test) + result, response, operationErr = vpcService.CreatePlacementGroup(createPlacementGroupOptionsModelNew) + 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 CreatePlacementGroup 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 ResourceGroupIdentityByID model + resourceGroupIdentityModel := new(vpcv1.ResourceGroupIdentityByID) + resourceGroupIdentityModel.ID = core.StringPtr("fee82deba12e4c0fb69c3b09d1f12345") + + // Construct an instance of the CreatePlacementGroupOptions model + createPlacementGroupOptionsModel := new(vpcv1.CreatePlacementGroupOptions) + createPlacementGroupOptionsModel.Strategy = core.StringPtr("host_spread") + createPlacementGroupOptionsModel.Name = core.StringPtr("my-placement-group") + createPlacementGroupOptionsModel.ResourceGroup = resourceGroupIdentityModel + createPlacementGroupOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation + result, response, operationErr := vpcService.CreatePlacementGroup(createPlacementGroupOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + + // Verify a nil result + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + }) + Describe(`DeletePlacementGroup(deletePlacementGroupOptions *DeletePlacementGroupOptions)`, func() { + version := "testString" + deletePlacementGroupPath := "/placement_groups/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(deletePlacementGroupPath)) + 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.WriteHeader(202) + })) + }) + It(`Invoke DeletePlacementGroup 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.DeletePlacementGroup(nil) + Expect(operationErr).NotTo(BeNil()) + Expect(response).To(BeNil()) + + // Construct an instance of the DeletePlacementGroupOptions model + deletePlacementGroupOptionsModel := new(vpcv1.DeletePlacementGroupOptions) + deletePlacementGroupOptionsModel.ID = core.StringPtr("testString") + deletePlacementGroupOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation with valid options model (positive test) + response, operationErr = vpcService.DeletePlacementGroup(deletePlacementGroupOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + }) + It(`Invoke DeletePlacementGroup 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 DeletePlacementGroupOptions model + deletePlacementGroupOptionsModel := new(vpcv1.DeletePlacementGroupOptions) + deletePlacementGroupOptionsModel.ID = core.StringPtr("testString") + deletePlacementGroupOptionsModel.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.DeletePlacementGroup(deletePlacementGroupOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING)) + Expect(response).To(BeNil()) + // Construct a second instance of the DeletePlacementGroupOptions model with no property values + deletePlacementGroupOptionsModelNew := new(vpcv1.DeletePlacementGroupOptions) + // Invoke operation with invalid model (negative test) + response, operationErr = vpcService.DeletePlacementGroup(deletePlacementGroupOptionsModelNew) + Expect(operationErr).ToNot(BeNil()) + Expect(response).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + }) + Describe(`GetPlacementGroup(getPlacementGroupOptions *GetPlacementGroupOptions) - Operation response error`, func() { + version := "testString" + getPlacementGroupPath := "/placement_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(getPlacementGroupPath)) + 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 GetPlacementGroup 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 GetPlacementGroupOptions model + getPlacementGroupOptionsModel := new(vpcv1.GetPlacementGroupOptions) + getPlacementGroupOptionsModel.ID = core.StringPtr("testString") + getPlacementGroupOptionsModel.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.GetPlacementGroup(getPlacementGroupOptionsModel) + 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.GetPlacementGroup(getPlacementGroupOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + }) + Describe(`GetPlacementGroup(getPlacementGroupOptions *GetPlacementGroupOptions)`, func() { + version := "testString" + getPlacementGroupPath := "/placement_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(getPlacementGroupPath)) + 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", `{"created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south:a/123456::placement-group:r018-418fe842-a3e9-47b9-a938-1aa5bd632871", "href": "https://us-south.iaas.cloud.ibm.com/v1/placement_groups/r018-418fe842-a3e9-47b9-a938-1aa5bd632871", "id": "r018-418fe842-a3e9-47b9-a938-1aa5bd632871", "lifecycle_state": "stable", "name": "my-placement-group", "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "resource_type": "placement_group", "strategy": "host_spread"}`) + })) + }) + It(`Invoke GetPlacementGroup 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 GetPlacementGroupOptions model + getPlacementGroupOptionsModel := new(vpcv1.GetPlacementGroupOptions) + getPlacementGroupOptionsModel.ID = core.StringPtr("testString") + getPlacementGroupOptionsModel.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.GetPlacementGroupWithContext(ctx, getPlacementGroupOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) + + // Disable retries and test again + vpcService.DisableRetries() + result, response, operationErr := vpcService.GetPlacementGroup(getPlacementGroupOptionsModel) + 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.GetPlacementGroupWithContext(ctx, getPlacementGroupOptionsModel) + 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(getPlacementGroupPath)) + 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", `{"created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south:a/123456::placement-group:r018-418fe842-a3e9-47b9-a938-1aa5bd632871", "href": "https://us-south.iaas.cloud.ibm.com/v1/placement_groups/r018-418fe842-a3e9-47b9-a938-1aa5bd632871", "id": "r018-418fe842-a3e9-47b9-a938-1aa5bd632871", "lifecycle_state": "stable", "name": "my-placement-group", "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "resource_type": "placement_group", "strategy": "host_spread"}`) + })) + }) + It(`Invoke GetPlacementGroup 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.GetPlacementGroup(nil) + Expect(operationErr).NotTo(BeNil()) + Expect(response).To(BeNil()) + Expect(result).To(BeNil()) + + // Construct an instance of the GetPlacementGroupOptions model + getPlacementGroupOptionsModel := new(vpcv1.GetPlacementGroupOptions) + getPlacementGroupOptionsModel.ID = core.StringPtr("testString") + getPlacementGroupOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation with valid options model (positive test) + result, response, operationErr = vpcService.GetPlacementGroup(getPlacementGroupOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).ToNot(BeNil()) + + }) + It(`Invoke GetPlacementGroup 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 GetPlacementGroupOptions model + getPlacementGroupOptionsModel := new(vpcv1.GetPlacementGroupOptions) + getPlacementGroupOptionsModel.ID = core.StringPtr("testString") + getPlacementGroupOptionsModel.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.GetPlacementGroup(getPlacementGroupOptionsModel) + 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 GetPlacementGroupOptions model with no property values + getPlacementGroupOptionsModelNew := new(vpcv1.GetPlacementGroupOptions) + // Invoke operation with invalid model (negative test) + result, response, operationErr = vpcService.GetPlacementGroup(getPlacementGroupOptionsModelNew) + 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 GetPlacementGroup 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 GetPlacementGroupOptions model + getPlacementGroupOptionsModel := new(vpcv1.GetPlacementGroupOptions) + getPlacementGroupOptionsModel.ID = core.StringPtr("testString") + getPlacementGroupOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation + result, response, operationErr := vpcService.GetPlacementGroup(getPlacementGroupOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + + // Verify a nil result + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + }) + Describe(`UpdatePlacementGroup(updatePlacementGroupOptions *UpdatePlacementGroupOptions) - Operation response error`, func() { + version := "testString" + updatePlacementGroupPath := "/placement_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(updatePlacementGroupPath)) + Expect(req.Method).To(Equal("PATCH")) + 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 UpdatePlacementGroup 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 PlacementGroupPatch model + placementGroupPatchModel := new(vpcv1.PlacementGroupPatch) + placementGroupPatchModel.Name = core.StringPtr("my-placement-group") + placementGroupPatchModelAsPatch, asPatchErr := placementGroupPatchModel.AsPatch() + Expect(asPatchErr).To(BeNil()) + + // Construct an instance of the UpdatePlacementGroupOptions model + updatePlacementGroupOptionsModel := new(vpcv1.UpdatePlacementGroupOptions) + updatePlacementGroupOptionsModel.ID = core.StringPtr("testString") + updatePlacementGroupOptionsModel.PlacementGroupPatch = placementGroupPatchModelAsPatch + updatePlacementGroupOptionsModel.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.UpdatePlacementGroup(updatePlacementGroupOptionsModel) + 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.UpdatePlacementGroup(updatePlacementGroupOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + }) + Describe(`UpdatePlacementGroup(updatePlacementGroupOptions *UpdatePlacementGroupOptions)`, func() { + version := "testString" + updatePlacementGroupPath := "/placement_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(updatePlacementGroupPath)) + Expect(req.Method).To(Equal("PATCH")) // For gzip-disabled operation, verify Content-Encoding is not set. Expect(req.Header.Get("Content-Encoding")).To(BeEmpty()) @@ -41749,6 +44534,7 @@ var _ = Describe(`VpcV1`, func() { Expect(req.URL.Query()["source_image.id"]).To(Equal([]string{"testString"})) Expect(req.URL.Query()["source_image.crn"]).To(Equal([]string{"testString"})) Expect(req.URL.Query()["sort"]).To(Equal([]string{"name"})) + Expect(req.URL.Query()["backup_policy_plan.id"]).To(Equal([]string{"testString"})) res.Header().Set("Content-type", "application/json") res.WriteHeader(200) fmt.Fprint(res, `} this is not valid json {`) @@ -41775,6 +44561,7 @@ var _ = Describe(`VpcV1`, func() { listSnapshotsOptionsModel.SourceImageID = core.StringPtr("testString") listSnapshotsOptionsModel.SourceImageCRN = core.StringPtr("testString") listSnapshotsOptionsModel.Sort = core.StringPtr("name") + listSnapshotsOptionsModel.BackupPolicyPlanID = core.StringPtr("testString") 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) @@ -41818,13 +44605,14 @@ var _ = Describe(`VpcV1`, func() { Expect(req.URL.Query()["source_image.id"]).To(Equal([]string{"testString"})) Expect(req.URL.Query()["source_image.crn"]).To(Equal([]string{"testString"})) Expect(req.URL.Query()["sort"]).To(Equal([]string{"name"})) + Expect(req.URL.Query()["backup_policy_plan.id"]).To(Equal([]string{"testString"})) // 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": [{"bootable": true, "captured_at": "2019-01-01T12:00:00.000Z", "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/dffc98a0f1f0f95f6613b3b752286b87: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"}, "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"}, "user_tags": ["UserTags"]}], "total_count": 132}`) + 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", "resource_type": "backup_policy_plan"}, "bootable": true, "captured_at": "2019-01-01T12:00:00.000Z", "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/dffc98a0f1f0f95f6613b3b752286b87: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"}, "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"}, "user_tags": ["UserTags"]}], "total_count": 132}`) })) }) It(`Invoke ListSnapshots successfully with retries`, func() { @@ -41849,6 +44637,7 @@ var _ = Describe(`VpcV1`, func() { listSnapshotsOptionsModel.SourceImageID = core.StringPtr("testString") listSnapshotsOptionsModel.SourceImageCRN = core.StringPtr("testString") listSnapshotsOptionsModel.Sort = core.StringPtr("name") + listSnapshotsOptionsModel.BackupPolicyPlanID = core.StringPtr("testString") listSnapshotsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with a Context to test a timeout error @@ -41897,10 +44686,11 @@ var _ = Describe(`VpcV1`, func() { Expect(req.URL.Query()["source_image.id"]).To(Equal([]string{"testString"})) Expect(req.URL.Query()["source_image.crn"]).To(Equal([]string{"testString"})) Expect(req.URL.Query()["sort"]).To(Equal([]string{"name"})) + Expect(req.URL.Query()["backup_policy_plan.id"]).To(Equal([]string{"testString"})) // 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": [{"bootable": true, "captured_at": "2019-01-01T12:00:00.000Z", "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/dffc98a0f1f0f95f6613b3b752286b87: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"}, "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"}, "user_tags": ["UserTags"]}], "total_count": 132}`) + 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", "resource_type": "backup_policy_plan"}, "bootable": true, "captured_at": "2019-01-01T12:00:00.000Z", "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/dffc98a0f1f0f95f6613b3b752286b87: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"}, "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"}, "user_tags": ["UserTags"]}], "total_count": 132}`) })) }) It(`Invoke ListSnapshots successfully`, func() { @@ -41930,6 +44720,7 @@ var _ = Describe(`VpcV1`, func() { listSnapshotsOptionsModel.SourceImageID = core.StringPtr("testString") listSnapshotsOptionsModel.SourceImageCRN = core.StringPtr("testString") listSnapshotsOptionsModel.Sort = core.StringPtr("name") + listSnapshotsOptionsModel.BackupPolicyPlanID = core.StringPtr("testString") listSnapshotsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with valid options model (positive test) @@ -41960,6 +44751,7 @@ var _ = Describe(`VpcV1`, func() { listSnapshotsOptionsModel.SourceImageID = core.StringPtr("testString") listSnapshotsOptionsModel.SourceImageCRN = core.StringPtr("testString") listSnapshotsOptionsModel.Sort = core.StringPtr("name") + listSnapshotsOptionsModel.BackupPolicyPlanID = core.StringPtr("testString") listSnapshotsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with empty URL (negative test) err := vpcService.SetServiceURL("") @@ -42004,6 +44796,7 @@ var _ = Describe(`VpcV1`, func() { listSnapshotsOptionsModel.SourceImageID = core.StringPtr("testString") listSnapshotsOptionsModel.SourceImageCRN = core.StringPtr("testString") listSnapshotsOptionsModel.Sort = core.StringPtr("name") + listSnapshotsOptionsModel.BackupPolicyPlanID = core.StringPtr("testString") listSnapshotsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation @@ -42148,7 +44941,7 @@ var _ = Describe(`VpcV1`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(201) - fmt.Fprintf(res, "%s", `{"bootable": true, "captured_at": "2019-01-01T12:00:00.000Z", "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/dffc98a0f1f0f95f6613b3b752286b87: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"}, "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"}, "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", "resource_type": "backup_policy_plan"}, "bootable": true, "captured_at": "2019-01-01T12:00:00.000Z", "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/dffc98a0f1f0f95f6613b3b752286b87: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"}, "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"}, "user_tags": ["UserTags"]}`) })) }) It(`Invoke CreateSnapshot successfully with retries`, func() { @@ -42236,7 +45029,7 @@ var _ = Describe(`VpcV1`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(201) - fmt.Fprintf(res, "%s", `{"bootable": true, "captured_at": "2019-01-01T12:00:00.000Z", "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/dffc98a0f1f0f95f6613b3b752286b87: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"}, "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"}, "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", "resource_type": "backup_policy_plan"}, "bootable": true, "captured_at": "2019-01-01T12:00:00.000Z", "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/dffc98a0f1f0f95f6613b3b752286b87: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"}, "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"}, "user_tags": ["UserTags"]}`) })) }) It(`Invoke CreateSnapshot successfully`, func() { @@ -42526,7 +45319,7 @@ var _ = Describe(`VpcV1`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"bootable": true, "captured_at": "2019-01-01T12:00:00.000Z", "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/dffc98a0f1f0f95f6613b3b752286b87: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"}, "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"}, "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", "resource_type": "backup_policy_plan"}, "bootable": true, "captured_at": "2019-01-01T12:00:00.000Z", "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/dffc98a0f1f0f95f6613b3b752286b87: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"}, "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"}, "user_tags": ["UserTags"]}`) })) }) It(`Invoke GetSnapshot successfully with retries`, func() { @@ -42583,7 +45376,7 @@ var _ = Describe(`VpcV1`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"bootable": true, "captured_at": "2019-01-01T12:00:00.000Z", "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/dffc98a0f1f0f95f6613b3b752286b87: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"}, "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"}, "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", "resource_type": "backup_policy_plan"}, "bootable": true, "captured_at": "2019-01-01T12:00:00.000Z", "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/dffc98a0f1f0f95f6613b3b752286b87: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"}, "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"}, "user_tags": ["UserTags"]}`) })) }) It(`Invoke GetSnapshot successfully`, func() { @@ -42780,7 +45573,7 @@ var _ = Describe(`VpcV1`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"bootable": true, "captured_at": "2019-01-01T12:00:00.000Z", "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/dffc98a0f1f0f95f6613b3b752286b87: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"}, "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"}, "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", "resource_type": "backup_policy_plan"}, "bootable": true, "captured_at": "2019-01-01T12:00:00.000Z", "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/dffc98a0f1f0f95f6613b3b752286b87: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"}, "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"}, "user_tags": ["UserTags"]}`) })) }) It(`Invoke UpdateSnapshot successfully with retries`, func() { @@ -42864,7 +45657,7 @@ var _ = Describe(`VpcV1`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"bootable": true, "captured_at": "2019-01-01T12:00:00.000Z", "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/dffc98a0f1f0f95f6613b3b752286b87: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"}, "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"}, "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", "resource_type": "backup_policy_plan"}, "bootable": true, "captured_at": "2019-01-01T12:00:00.000Z", "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/dffc98a0f1f0f95f6613b3b752286b87: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"}, "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"}, "user_tags": ["UserTags"]}`) })) }) It(`Invoke UpdateSnapshot successfully`, func() { @@ -70617,6 +73410,12 @@ var _ = Describe(`VpcV1`, func() { Expect(addVPNGatewayConnectionPeerCIDROptionsModel.PrefixLength).To(Equal(core.StringPtr("testString"))) Expect(addVPNGatewayConnectionPeerCIDROptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) }) + It(`Invoke NewBackupPolicyPlanPrototype successfully`, func() { + cronSpec := "*/5 1,2,3 * * *" + _model, err := vpcService.NewBackupPolicyPlanPrototype(cronSpec) + Expect(_model).ToNot(BeNil()) + Expect(err).To(BeNil()) + }) It(`Invoke NewBareMetalServerInitializationPrototype successfully`, func() { var image vpcv1.ImageIdentityIntf = nil keys := []vpcv1.KeyIdentityIntf{} @@ -70666,6 +73465,84 @@ var _ = Describe(`VpcV1`, func() { Expect(checkVPNGatewayConnectionPeerCIDROptionsModel.PrefixLength).To(Equal(core.StringPtr("testString"))) Expect(checkVPNGatewayConnectionPeerCIDROptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) }) + It(`Invoke NewCreateBackupPolicyOptions successfully`, func() { + // Construct an instance of the BackupPolicyPlanDeletionTriggerPrototype model + backupPolicyPlanDeletionTriggerPrototypeModel := new(vpcv1.BackupPolicyPlanDeletionTriggerPrototype) + Expect(backupPolicyPlanDeletionTriggerPrototypeModel).ToNot(BeNil()) + backupPolicyPlanDeletionTriggerPrototypeModel.DeleteAfter = core.Int64Ptr(int64(20)) + backupPolicyPlanDeletionTriggerPrototypeModel.DeleteOverCount = core.Int64Ptr(int64(20)) + Expect(backupPolicyPlanDeletionTriggerPrototypeModel.DeleteAfter).To(Equal(core.Int64Ptr(int64(20)))) + Expect(backupPolicyPlanDeletionTriggerPrototypeModel.DeleteOverCount).To(Equal(core.Int64Ptr(int64(20)))) + + // Construct an instance of the BackupPolicyPlanPrototype model + backupPolicyPlanPrototypeModel := new(vpcv1.BackupPolicyPlanPrototype) + Expect(backupPolicyPlanPrototypeModel).ToNot(BeNil()) + backupPolicyPlanPrototypeModel.Active = core.BoolPtr(true) + backupPolicyPlanPrototypeModel.AttachUserTags = []string{"my-daily-backup-plan"} + backupPolicyPlanPrototypeModel.CopyUserTags = core.BoolPtr(true) + backupPolicyPlanPrototypeModel.CronSpec = core.StringPtr("*/5 1,2,3 * * *") + backupPolicyPlanPrototypeModel.DeletionTrigger = backupPolicyPlanDeletionTriggerPrototypeModel + backupPolicyPlanPrototypeModel.Name = core.StringPtr("my-policy-plan") + Expect(backupPolicyPlanPrototypeModel.Active).To(Equal(core.BoolPtr(true))) + Expect(backupPolicyPlanPrototypeModel.AttachUserTags).To(Equal([]string{"my-daily-backup-plan"})) + Expect(backupPolicyPlanPrototypeModel.CopyUserTags).To(Equal(core.BoolPtr(true))) + Expect(backupPolicyPlanPrototypeModel.CronSpec).To(Equal(core.StringPtr("*/5 1,2,3 * * *"))) + Expect(backupPolicyPlanPrototypeModel.DeletionTrigger).To(Equal(backupPolicyPlanDeletionTriggerPrototypeModel)) + Expect(backupPolicyPlanPrototypeModel.Name).To(Equal(core.StringPtr("my-policy-plan"))) + + // 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 CreateBackupPolicyOptions model + createBackupPolicyOptionsModel := vpcService.NewCreateBackupPolicyOptions() + createBackupPolicyOptionsModel.SetMatchResourceTypes([]string{"volume"}) + createBackupPolicyOptionsModel.SetMatchUserTags([]string{"my-daily-backup-policy"}) + createBackupPolicyOptionsModel.SetName("my-backup-policy") + createBackupPolicyOptionsModel.SetPlans([]vpcv1.BackupPolicyPlanPrototype{*backupPolicyPlanPrototypeModel}) + createBackupPolicyOptionsModel.SetResourceGroup(resourceGroupIdentityModel) + createBackupPolicyOptionsModel.SetHeaders(map[string]string{"foo": "bar"}) + Expect(createBackupPolicyOptionsModel).ToNot(BeNil()) + Expect(createBackupPolicyOptionsModel.MatchResourceTypes).To(Equal([]string{"volume"})) + Expect(createBackupPolicyOptionsModel.MatchUserTags).To(Equal([]string{"my-daily-backup-policy"})) + 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.Headers).To(Equal(map[string]string{"foo": "bar"})) + }) + It(`Invoke NewCreateBackupPolicyPlanOptions successfully`, func() { + // Construct an instance of the BackupPolicyPlanDeletionTriggerPrototype model + backupPolicyPlanDeletionTriggerPrototypeModel := new(vpcv1.BackupPolicyPlanDeletionTriggerPrototype) + Expect(backupPolicyPlanDeletionTriggerPrototypeModel).ToNot(BeNil()) + backupPolicyPlanDeletionTriggerPrototypeModel.DeleteAfter = core.Int64Ptr(int64(20)) + backupPolicyPlanDeletionTriggerPrototypeModel.DeleteOverCount = core.Int64Ptr(int64(20)) + Expect(backupPolicyPlanDeletionTriggerPrototypeModel.DeleteAfter).To(Equal(core.Int64Ptr(int64(20)))) + Expect(backupPolicyPlanDeletionTriggerPrototypeModel.DeleteOverCount).To(Equal(core.Int64Ptr(int64(20)))) + + // Construct an instance of the CreateBackupPolicyPlanOptions model + backupPolicyID := "testString" + createBackupPolicyPlanOptionsCronSpec := "*/5 1,2,3 * * *" + createBackupPolicyPlanOptionsModel := vpcService.NewCreateBackupPolicyPlanOptions(backupPolicyID, createBackupPolicyPlanOptionsCronSpec) + createBackupPolicyPlanOptionsModel.SetBackupPolicyID("testString") + createBackupPolicyPlanOptionsModel.SetCronSpec("*/5 1,2,3 * * *") + createBackupPolicyPlanOptionsModel.SetActive(true) + createBackupPolicyPlanOptionsModel.SetAttachUserTags([]string{"my-daily-backup-plan"}) + createBackupPolicyPlanOptionsModel.SetCopyUserTags(true) + createBackupPolicyPlanOptionsModel.SetDeletionTrigger(backupPolicyPlanDeletionTriggerPrototypeModel) + createBackupPolicyPlanOptionsModel.SetName("my-policy-plan") + createBackupPolicyPlanOptionsModel.SetHeaders(map[string]string{"foo": "bar"}) + Expect(createBackupPolicyPlanOptionsModel).ToNot(BeNil()) + Expect(createBackupPolicyPlanOptionsModel.BackupPolicyID).To(Equal(core.StringPtr("testString"))) + Expect(createBackupPolicyPlanOptionsModel.CronSpec).To(Equal(core.StringPtr("*/5 1,2,3 * * *"))) + Expect(createBackupPolicyPlanOptionsModel.Active).To(Equal(core.BoolPtr(true))) + Expect(createBackupPolicyPlanOptionsModel.AttachUserTags).To(Equal([]string{"my-daily-backup-plan"})) + Expect(createBackupPolicyPlanOptionsModel.CopyUserTags).To(Equal(core.BoolPtr(true))) + Expect(createBackupPolicyPlanOptionsModel.DeletionTrigger).To(Equal(backupPolicyPlanDeletionTriggerPrototypeModel)) + Expect(createBackupPolicyPlanOptionsModel.Name).To(Equal(core.StringPtr("my-policy-plan"))) + Expect(createBackupPolicyPlanOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) + }) It(`Invoke NewCreateBareMetalServerConsoleAccessTokenOptions successfully`, func() { // Construct an instance of the CreateBareMetalServerConsoleAccessTokenOptions model bareMetalServerID := "testString" @@ -72931,6 +75808,33 @@ var _ = Describe(`VpcV1`, func() { Expect(createVPNGatewayOptionsModel.VPNGatewayPrototype).To(Equal(vpnGatewayPrototypeModel)) Expect(createVPNGatewayOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) }) + It(`Invoke NewDeleteBackupPolicyOptions successfully`, func() { + // Construct an instance of the DeleteBackupPolicyOptions model + id := "testString" + deleteBackupPolicyOptionsModel := vpcService.NewDeleteBackupPolicyOptions(id) + deleteBackupPolicyOptionsModel.SetID("testString") + deleteBackupPolicyOptionsModel.SetIfMatch(`W/"96d225c4-56bd-43d9-98fc-d7148e5c5028"`) + deleteBackupPolicyOptionsModel.SetHeaders(map[string]string{"foo": "bar"}) + Expect(deleteBackupPolicyOptionsModel).ToNot(BeNil()) + Expect(deleteBackupPolicyOptionsModel.ID).To(Equal(core.StringPtr("testString"))) + Expect(deleteBackupPolicyOptionsModel.IfMatch).To(Equal(core.StringPtr(`W/"96d225c4-56bd-43d9-98fc-d7148e5c5028"`))) + Expect(deleteBackupPolicyOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) + }) + It(`Invoke NewDeleteBackupPolicyPlanOptions successfully`, func() { + // Construct an instance of the DeleteBackupPolicyPlanOptions model + backupPolicyID := "testString" + id := "testString" + deleteBackupPolicyPlanOptionsModel := vpcService.NewDeleteBackupPolicyPlanOptions(backupPolicyID, id) + deleteBackupPolicyPlanOptionsModel.SetBackupPolicyID("testString") + deleteBackupPolicyPlanOptionsModel.SetID("testString") + deleteBackupPolicyPlanOptionsModel.SetIfMatch(`W/"96d225c4-56bd-43d9-98fc-d7148e5c5028"`) + deleteBackupPolicyPlanOptionsModel.SetHeaders(map[string]string{"foo": "bar"}) + Expect(deleteBackupPolicyPlanOptionsModel).ToNot(BeNil()) + Expect(deleteBackupPolicyPlanOptionsModel.BackupPolicyID).To(Equal(core.StringPtr("testString"))) + Expect(deleteBackupPolicyPlanOptionsModel.ID).To(Equal(core.StringPtr("testString"))) + Expect(deleteBackupPolicyPlanOptionsModel.IfMatch).To(Equal(core.StringPtr(`W/"96d225c4-56bd-43d9-98fc-d7148e5c5028"`))) + Expect(deleteBackupPolicyPlanOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) + }) It(`Invoke NewDeleteBareMetalServerNetworkInterfaceOptions successfully`, func() { // Construct an instance of the DeleteBareMetalServerNetworkInterfaceOptions model bareMetalServerID := "testString" @@ -73489,6 +76393,29 @@ var _ = Describe(`VpcV1`, func() { Expect(deleteVPNGatewayOptionsModel.ID).To(Equal(core.StringPtr("testString"))) Expect(deleteVPNGatewayOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) }) + It(`Invoke NewGetBackupPolicyOptions successfully`, func() { + // Construct an instance of the GetBackupPolicyOptions model + id := "testString" + getBackupPolicyOptionsModel := vpcService.NewGetBackupPolicyOptions(id) + getBackupPolicyOptionsModel.SetID("testString") + getBackupPolicyOptionsModel.SetHeaders(map[string]string{"foo": "bar"}) + Expect(getBackupPolicyOptionsModel).ToNot(BeNil()) + Expect(getBackupPolicyOptionsModel.ID).To(Equal(core.StringPtr("testString"))) + Expect(getBackupPolicyOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) + }) + It(`Invoke NewGetBackupPolicyPlanOptions successfully`, func() { + // Construct an instance of the GetBackupPolicyPlanOptions model + backupPolicyID := "testString" + id := "testString" + getBackupPolicyPlanOptionsModel := vpcService.NewGetBackupPolicyPlanOptions(backupPolicyID, id) + getBackupPolicyPlanOptionsModel.SetBackupPolicyID("testString") + getBackupPolicyPlanOptionsModel.SetID("testString") + getBackupPolicyPlanOptionsModel.SetHeaders(map[string]string{"foo": "bar"}) + Expect(getBackupPolicyPlanOptionsModel).ToNot(BeNil()) + Expect(getBackupPolicyPlanOptionsModel.BackupPolicyID).To(Equal(core.StringPtr("testString"))) + Expect(getBackupPolicyPlanOptionsModel.ID).To(Equal(core.StringPtr("testString"))) + Expect(getBackupPolicyPlanOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) + }) It(`Invoke NewGetBareMetalServerDiskOptions successfully`, func() { // Construct an instance of the GetBareMetalServerDiskOptions model bareMetalServerID := "testString" @@ -74319,6 +77246,35 @@ var _ = Describe(`VpcV1`, func() { Expect(_model).ToNot(BeNil()) Expect(err).To(BeNil()) }) + It(`Invoke NewListBackupPoliciesOptions successfully`, func() { + // Construct an instance of the ListBackupPoliciesOptions model + listBackupPoliciesOptionsModel := vpcService.NewListBackupPoliciesOptions() + listBackupPoliciesOptionsModel.SetStart("testString") + listBackupPoliciesOptionsModel.SetLimit(int64(1)) + listBackupPoliciesOptionsModel.SetResourceGroupID("testString") + listBackupPoliciesOptionsModel.SetName("testString") + listBackupPoliciesOptionsModel.SetTag("testString") + listBackupPoliciesOptionsModel.SetHeaders(map[string]string{"foo": "bar"}) + Expect(listBackupPoliciesOptionsModel).ToNot(BeNil()) + Expect(listBackupPoliciesOptionsModel.Start).To(Equal(core.StringPtr("testString"))) + Expect(listBackupPoliciesOptionsModel.Limit).To(Equal(core.Int64Ptr(int64(1)))) + Expect(listBackupPoliciesOptionsModel.ResourceGroupID).To(Equal(core.StringPtr("testString"))) + Expect(listBackupPoliciesOptionsModel.Name).To(Equal(core.StringPtr("testString"))) + Expect(listBackupPoliciesOptionsModel.Tag).To(Equal(core.StringPtr("testString"))) + Expect(listBackupPoliciesOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) + }) + It(`Invoke NewListBackupPolicyPlansOptions successfully`, func() { + // Construct an instance of the ListBackupPolicyPlansOptions model + backupPolicyID := "testString" + listBackupPolicyPlansOptionsModel := vpcService.NewListBackupPolicyPlansOptions(backupPolicyID) + listBackupPolicyPlansOptionsModel.SetBackupPolicyID("testString") + listBackupPolicyPlansOptionsModel.SetName("testString") + listBackupPolicyPlansOptionsModel.SetHeaders(map[string]string{"foo": "bar"}) + Expect(listBackupPolicyPlansOptionsModel).ToNot(BeNil()) + Expect(listBackupPolicyPlansOptionsModel.BackupPolicyID).To(Equal(core.StringPtr("testString"))) + Expect(listBackupPolicyPlansOptionsModel.Name).To(Equal(core.StringPtr("testString"))) + Expect(listBackupPolicyPlansOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) + }) It(`Invoke NewListBareMetalServerDisksOptions successfully`, func() { // Construct an instance of the ListBareMetalServerDisksOptions model bareMetalServerID := "testString" @@ -75006,6 +77962,7 @@ var _ = Describe(`VpcV1`, func() { listSnapshotsOptionsModel.SetSourceImageID("testString") listSnapshotsOptionsModel.SetSourceImageCRN("testString") listSnapshotsOptionsModel.SetSort("name") + listSnapshotsOptionsModel.SetBackupPolicyPlanID("testString") listSnapshotsOptionsModel.SetHeaders(map[string]string{"foo": "bar"}) Expect(listSnapshotsOptionsModel).ToNot(BeNil()) Expect(listSnapshotsOptionsModel.Start).To(Equal(core.StringPtr("testString"))) @@ -75018,6 +77975,7 @@ var _ = Describe(`VpcV1`, func() { Expect(listSnapshotsOptionsModel.SourceImageID).To(Equal(core.StringPtr("testString"))) Expect(listSnapshotsOptionsModel.SourceImageCRN).To(Equal(core.StringPtr("testString"))) Expect(listSnapshotsOptionsModel.Sort).To(Equal(core.StringPtr("name"))) + Expect(listSnapshotsOptionsModel.BackupPolicyPlanID).To(Equal(core.StringPtr("testString"))) Expect(listSnapshotsOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) }) It(`Invoke NewListSubnetReservedIpsOptions successfully`, func() { @@ -75512,6 +78470,39 @@ var _ = Describe(`VpcV1`, func() { Expect(unsetSubnetPublicGatewayOptionsModel.ID).To(Equal(core.StringPtr("testString"))) Expect(unsetSubnetPublicGatewayOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) }) + It(`Invoke NewUpdateBackupPolicyOptions successfully`, func() { + // Construct an instance of the UpdateBackupPolicyOptions model + id := "testString" + backupPolicyPatch := make(map[string]interface{}) + updateBackupPolicyOptionsModel := vpcService.NewUpdateBackupPolicyOptions(id, backupPolicyPatch) + updateBackupPolicyOptionsModel.SetID("testString") + updateBackupPolicyOptionsModel.SetBackupPolicyPatch(make(map[string]interface{})) + updateBackupPolicyOptionsModel.SetIfMatch(`W/"96d225c4-56bd-43d9-98fc-d7148e5c5028"`) + updateBackupPolicyOptionsModel.SetHeaders(map[string]string{"foo": "bar"}) + Expect(updateBackupPolicyOptionsModel).ToNot(BeNil()) + Expect(updateBackupPolicyOptionsModel.ID).To(Equal(core.StringPtr("testString"))) + Expect(updateBackupPolicyOptionsModel.BackupPolicyPatch).To(Equal(make(map[string]interface{}))) + Expect(updateBackupPolicyOptionsModel.IfMatch).To(Equal(core.StringPtr(`W/"96d225c4-56bd-43d9-98fc-d7148e5c5028"`))) + Expect(updateBackupPolicyOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) + }) + It(`Invoke NewUpdateBackupPolicyPlanOptions successfully`, func() { + // Construct an instance of the UpdateBackupPolicyPlanOptions model + backupPolicyID := "testString" + id := "testString" + backupPolicyPlanPatch := make(map[string]interface{}) + updateBackupPolicyPlanOptionsModel := vpcService.NewUpdateBackupPolicyPlanOptions(backupPolicyID, id, backupPolicyPlanPatch) + updateBackupPolicyPlanOptionsModel.SetBackupPolicyID("testString") + updateBackupPolicyPlanOptionsModel.SetID("testString") + updateBackupPolicyPlanOptionsModel.SetBackupPolicyPlanPatch(make(map[string]interface{})) + updateBackupPolicyPlanOptionsModel.SetIfMatch(`W/"96d225c4-56bd-43d9-98fc-d7148e5c5028"`) + updateBackupPolicyPlanOptionsModel.SetHeaders(map[string]string{"foo": "bar"}) + Expect(updateBackupPolicyPlanOptionsModel).ToNot(BeNil()) + Expect(updateBackupPolicyPlanOptionsModel.BackupPolicyID).To(Equal(core.StringPtr("testString"))) + Expect(updateBackupPolicyPlanOptionsModel.ID).To(Equal(core.StringPtr("testString"))) + Expect(updateBackupPolicyPlanOptionsModel.BackupPolicyPlanPatch).To(Equal(make(map[string]interface{}))) + Expect(updateBackupPolicyPlanOptionsModel.IfMatch).To(Equal(core.StringPtr(`W/"96d225c4-56bd-43d9-98fc-d7148e5c5028"`))) + Expect(updateBackupPolicyPlanOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) + }) It(`Invoke NewUpdateBareMetalServerDiskOptions successfully`, func() { // Construct an instance of the UpdateBareMetalServerDiskOptions model bareMetalServerID := "testString"