diff --git a/README.md b/README.md index 2e357bd..55f4d5d 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.48.0 +# IBM Cloud VPC Go SDK Version 0.49.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.48.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.49.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.48.0 +go get github.com/IBM/vpc-go-sdk@v0.49.0 ``` @@ -90,7 +90,7 @@ to your `Gopkg.toml` file. Here is an example: ``` [[constraint]] name = "github.com/IBM/vpc-go-sdk/" - version = "0.48.0" + version = "0.49.0" ``` Then run `dep ensure`. diff --git a/common/version.go b/common/version.go index 2dab788..ad09fea 100644 --- a/common/version.go +++ b/common/version.go @@ -1,4 +1,4 @@ package common // Version of the SDK -const Version = "0.48.0" +const Version = "0.49.0" diff --git a/go.mod b/go.mod index d948940..54dc92b 100644 --- a/go.mod +++ b/go.mod @@ -3,34 +3,35 @@ module github.com/IBM/vpc-go-sdk go 1.18 require ( - github.com/IBM/go-sdk-core/v5 v5.15.0 - github.com/go-openapi/strfmt v0.21.5 - github.com/google/uuid v1.1.1 + github.com/IBM/go-sdk-core/v5 v5.15.1 + github.com/go-openapi/strfmt v0.22.0 + github.com/google/uuid v1.6.0 github.com/onsi/ginkgo v1.16.5 github.com/onsi/gomega v1.27.6 - github.com/stretchr/testify v1.8.2 + github.com/stretchr/testify v1.8.4 ) require ( github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/fsnotify/fsnotify v1.6.0 // indirect - github.com/go-openapi/errors v0.20.3 // indirect + github.com/gabriel-vasile/mimetype v1.4.3 // indirect + github.com/go-openapi/errors v0.21.0 // indirect github.com/go-playground/locales v0.14.1 // indirect github.com/go-playground/universal-translator v0.18.1 // indirect - github.com/go-playground/validator/v10 v10.13.0 // indirect + github.com/go-playground/validator/v10 v10.17.0 // indirect github.com/google/go-cmp v0.5.9 // indirect github.com/hashicorp/go-cleanhttp v0.5.2 // indirect - github.com/hashicorp/go-retryablehttp v0.7.2 // indirect - github.com/leodido/go-urn v1.2.3 // indirect + github.com/hashicorp/go-retryablehttp v0.7.5 // indirect + github.com/leodido/go-urn v1.3.0 // indirect github.com/mitchellh/mapstructure v1.5.0 // indirect github.com/nxadm/tail v1.4.8 // indirect github.com/oklog/ulid v1.3.1 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect - go.mongodb.org/mongo-driver v1.11.3 // indirect - golang.org/x/crypto v0.17.0 // indirect - golang.org/x/net v0.17.0 // indirect - golang.org/x/sys v0.15.0 // indirect + go.mongodb.org/mongo-driver v1.13.1 // indirect + golang.org/x/crypto v0.18.0 // indirect + golang.org/x/net v0.20.0 // indirect + golang.org/x/sys v0.16.0 // indirect golang.org/x/text v0.14.0 // indirect gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect diff --git a/go.sum b/go.sum index bf260bb..6ebd23b 100644 --- a/go.sum +++ b/go.sum @@ -1,9 +1,7 @@ -github.com/IBM/go-sdk-core/v5 v5.15.0 h1:AhFoWVk3i58f9vnDoEoZumI/zbtRoP5moWIz5YQOmZg= -github.com/IBM/go-sdk-core/v5 v5.15.0/go.mod h1:5Obavm/s1Tc2PxivEIfgCvj/HJ5h3QIOjLHS5y8QJf0= -github.com/asaskevich/govalidator v0.0.0-20200907205600-7a23bdc65eef/go.mod h1:WaHUgvxTVq04UNunO+XhnAqY/wQc+bxr74GqbsZ/Jqw= +github.com/IBM/go-sdk-core/v5 v5.15.1 h1:XOzNZbBgnlxOGK1JMMBtZJYSVguK4TFPJiYutuzFmdA= +github.com/IBM/go-sdk-core/v5 v5.15.1/go.mod h1:so2mbdIgSp6X8Zm/qLV+whdchTGgi04c3j4xFMsqlCc= github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 h1:DklsrG3dyBCFEj5IhUbnKptjxatkF07cF2ak3yi77so= github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2/go.mod h1:WaHUgvxTVq04UNunO+XhnAqY/wQc+bxr74GqbsZ/Jqw= -github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= @@ -11,19 +9,20 @@ github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMo github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= github.com/fsnotify/fsnotify v1.6.0 h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4HY= github.com/fsnotify/fsnotify v1.6.0/go.mod h1:sl3t1tCWJFWoRz9R8WJCbQihKKwmorjAbSClcnxKAGw= +github.com/gabriel-vasile/mimetype v1.4.3 h1:in2uUcidCuFcDKtdcBxlR0rJ1+fsokWf+uqxgUFjbI0= +github.com/gabriel-vasile/mimetype v1.4.3/go.mod h1:d8uq/6HKRL6CGdk+aubisF/M5GcPfT7nKyLpA0lbSSk= github.com/go-logr/logr v1.2.3 h1:2DntVwHkVopvECVRSlL5PSo9eG+cAkDCuckLubN+rq0= -github.com/go-openapi/errors v0.20.2/go.mod h1:cM//ZKUKyO06HSwqAelJ5NsEMMcpa6VpXe8DOa1Mi1M= -github.com/go-openapi/errors v0.20.3 h1:rz6kiC84sqNQoqrtulzaL/VERgkoCyB6WdEkc2ujzUc= -github.com/go-openapi/errors v0.20.3/go.mod h1:Z3FlZ4I8jEGxjUK+bugx3on2mIAk4txuAOhlsB1FSgk= -github.com/go-openapi/strfmt v0.21.5 h1:Z/algjpXIZpbvdN+6KbVTkpO75RuedMrqpn1GN529h4= -github.com/go-openapi/strfmt v0.21.5/go.mod h1:k+RzNO0Da+k3FrrynSNN8F7n/peCmQQqbbXjtDfvmGg= +github.com/go-openapi/errors v0.21.0 h1:FhChC/duCnfoLj1gZ0BgaBmzhJC2SL/sJr8a2vAobSY= +github.com/go-openapi/errors v0.21.0/go.mod h1:jxNTMUxRCKj65yb/okJGEtahVd7uvWnuWfj53bse4ho= +github.com/go-openapi/strfmt v0.22.0 h1:Ew9PnEYc246TwrEspvBdDHS4BVKXy/AOVsfqGDgAcaI= +github.com/go-openapi/strfmt v0.22.0/go.mod h1:HzJ9kokGIju3/K6ap8jL+OlGAbjpSv27135Yr9OivU4= github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s= github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA= github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY= github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY= github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY= -github.com/go-playground/validator/v10 v10.13.0 h1:cFRQdfaSMCOSfGCCLB20MHvuoHb/s5G8L5pu2ppK5AQ= -github.com/go-playground/validator/v10 v10.13.0/go.mod h1:dwu7+CG8/CtBiJFZDz4e+5Upb6OLw04gtBYw0mcG/z4= +github.com/go-playground/validator/v10 v10.17.0 h1:SmVVlfAOtlZncTxRuinDPomC2DkXJ4E5T9gDA0AIH74= +github.com/go-playground/validator/v10 v10.17.0/go.mod h1:9iXMNT7sEkjXb0I+enO7QXmzG6QCsPWY4zveKFVRSyU= github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE= github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 h1:tfuBGBXKqDEevZMzYi5KSi8KkcZtzBcTgAUUtapy0OI= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= @@ -42,29 +41,23 @@ github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38 h1:yAJXTCF9TqKcTiHJAE8dj7HMvPfh66eeA2JYW7eFpSE= -github.com/google/uuid v1.1.1 h1:Gkbcsh/GbpXz7lPftLA3P6TYMwjCLYm83jiFQZF/3gY= -github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= +github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/hashicorp/go-cleanhttp v0.5.2 h1:035FKYIWjmULyFRBKPs8TBQoi0x6d9G4xc9neXJWAZQ= github.com/hashicorp/go-cleanhttp v0.5.2/go.mod h1:kO/YDlP8L1346E6Sodw+PrpBSV4/SoxCXGY6BqNFT48= github.com/hashicorp/go-hclog v0.9.2 h1:CG6TE5H9/JXsFWJCfoIVpKFIkFe6ysEuHirp4DxCsHI= github.com/hashicorp/go-hclog v0.9.2/go.mod h1:5CU+agLiy3J7N7QjHK5d05KxGsuXiQLrjA0H7acj2lQ= -github.com/hashicorp/go-retryablehttp v0.7.2 h1:AcYqCvkpalPnPF2pn0KamgwamS42TqUDDYFRKq/RAd0= -github.com/hashicorp/go-retryablehttp v0.7.2/go.mod h1:Jy/gPYAdjqffZ/yFGCFV2doI5wjtH1ewM9u8iYVjtX8= +github.com/hashicorp/go-retryablehttp v0.7.5 h1:bJj+Pj19UZMIweq/iie+1u5YCdGrnxCT9yvm0e+Nd5M= +github.com/hashicorp/go-retryablehttp v0.7.5/go.mod h1:Jy/gPYAdjqffZ/yFGCFV2doI5wjtH1ewM9u8iYVjtX8= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/klauspost/compress v1.13.6/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk= -github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= -github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= -github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= -github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= -github.com/leodido/go-urn v1.2.3 h1:6BE2vPT0lqoz3fmOesHZiaiFh7889ssCo2GMvLCfiuA= -github.com/leodido/go-urn v1.2.3/go.mod h1:7ZrI8mTSeBSHl/UaRyKQW1qZeMgak41ANeCNaVckg+4= -github.com/mitchellh/mapstructure v1.3.3/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= +github.com/leodido/go-urn v1.3.0 h1:jX8FDLfW4ThVXctBNZ+3cIWnCSnrACDV73r76dy0aQQ= +github.com/leodido/go-urn v1.3.0/go.mod h1:bvxc+MVxLKB4z00jd1z+Dvzr47oO32F/QSNjSBOlFxI= github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY= github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe/go.mod h1:wL8QJuTMNUDYhXwkmfOly8iTdp5TEcJFWZD2D7SIkUc= github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs= -github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE= github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU= @@ -79,48 +72,44 @@ github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7J github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= github.com/onsi/gomega v1.27.6 h1:ENqfyGeS5AX/rlXDd/ETokDz93u0YufY1Pgxuy/PvWE= github.com/onsi/gomega v1.27.6/go.mod h1:PIQNjfQwkP3aQAH7lf7j87O/5FiNr+ZR8+ipb+qQlhg= -github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= -github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= -github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= -github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8= -github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= -github.com/tidwall/pretty v1.0.0 h1:HsD+QiTn7sK6flMKIvNmpqz1qrpP3Ps6jOKIKMooyg4= -github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk= +github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= +github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/xdg-go/pbkdf2 v1.0.0/go.mod h1:jrpuAogTd400dnrH08LKmI/xc1MbPOebTwRqcT5RDeI= -github.com/xdg-go/scram v1.1.1/go.mod h1:RaEWvsqvNKKvBPvcKeFjrG2cJqOkHTiyTpzz23ni57g= -github.com/xdg-go/stringprep v1.0.3/go.mod h1:W3f5j4i+9rC0kuIEJL0ky1VpHXQU3ocBgklLGvcBnW8= +github.com/xdg-go/scram v1.1.2/go.mod h1:RT/sEzTbU5y00aCK8UOx6R7YryM0iF1N2MOmC3kKLN4= +github.com/xdg-go/stringprep v1.0.4/go.mod h1:mPGuuIYwz7CmR2bT9j4GbQqutWS1zV24gijq1dTyGkM= github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d/go.mod h1:rHwXgn7JulP+udvsHwJoVG1YGAP6VLg4y9I5dyZdqmA= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -go.mongodb.org/mongo-driver v1.10.0/go.mod h1:wsihk0Kdgv8Kqu1Anit4sfK+22vSFbUrAVEYRhCXrA8= -go.mongodb.org/mongo-driver v1.11.3 h1:Ql6K6qYHEzB6xvu4+AU0BoRoqf9vFPcc4o7MUIdPW8Y= -go.mongodb.org/mongo-driver v1.11.3/go.mod h1:PTSz5yu21bkT/wXpkS7WR5f0ddqw5quethTUn9WM+2g= +github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= +go.mongodb.org/mongo-driver v1.13.1 h1:YIc7HTYsKndGK4RFzJ3covLz1byri52x0IoMB0Pt/vk= +go.mongodb.org/mongo-driver v1.13.1/go.mod h1:wcDf1JBCXy2mOW0bWHwO/IOYqdca1MPCwDtFu/Z9+eo= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/crypto v0.17.0 h1:r8bRNjWL3GshPW3gkd+RpvzWrZAwPS49OmTGZ/uhM4k= -golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= +golang.org/x/crypto v0.18.0 h1:PGVlW0xEltQnzFZ55hkuX5+KLyrMYhHld1YHO4AKcdc= +golang.org/x/crypto v0.18.0/go.mod h1:R0j02AL6hcrfOiy9T4ZYp/rcWeMxM3L6QYxlOuEG1mg= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM= -golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE= +golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= +golang.org/x/net v0.20.0 h1:aCL9BSgETF1k+blQaYUBx9hJ9LOGP3gAVemcZlf1Kpo= +golang.org/x/net v0.20.0/go.mod h1:z8BVo6PvndSri0LbOE3hAn0apkU+1YvI6E70E9jsnvY= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -133,19 +122,25 @@ golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20210112080510-489259a85091/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc= -golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.16.0 h1:xWw16ngr6ZMtmxDyKyIgsE93KNKz5HKmMa3b8ALHidU= +golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= +golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= +golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ= +golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= golang.org/x/tools v0.7.0 h1:W4OVu8VVOaIO0yzWMNdepAulS7YfoS3Zabrm8DOXXU4= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -159,16 +154,12 @@ google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzi google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= google.golang.org/protobuf v1.28.0 h1:w43yiav+6bVFTBQFZX0r7ipe9JQ1QsbMgHwbBziscLw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f h1:BLraFXnmrev5lT+xlilqcH8XK9/i0At2xKjWk4p6zsU= -gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -gopkg.in/yaml.v3 v3.0.0-20200605160147-a5ece683394c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/vpcv1/vpc_v1.go b/vpcv1/vpc_v1.go index 16d11da..1035d23 100644 --- a/vpcv1/vpc_v1.go +++ b/vpcv1/vpc_v1.go @@ -15,7 +15,7 @@ */ /* - * IBM OpenAPI SDK Code Generator Version: 3.84.0-a4533f12-20240103-170852 + * IBM OpenAPI SDK Code Generator Version: 3.85.0-75c38f8f-20240206-210220 */ // Package vpcv1 : Operations and models for the VpcV1 service @@ -38,7 +38,7 @@ import ( // VpcV1 : The IBM Cloud Virtual Private Cloud (VPC) API can be used to programmatically provision and manage virtual // server instances, along with subnets, volumes, load balancers, and more. // -// API Version: 2024-01-24 +// API Version: 2024-03-20 type VpcV1 struct { Service *core.BaseService @@ -47,7 +47,7 @@ type VpcV1 struct { generation *int64 // The API version, in format `YYYY-MM-DD`. For the API behavior documented here, specify any date between `2023-12-05` - // and `2024-01-29`. + // and `2024-03-20`. Version *string } @@ -64,7 +64,7 @@ type VpcV1Options struct { Authenticator core.Authenticator // The API version, in format `YYYY-MM-DD`. For the API behavior documented here, specify any date between `2023-12-05` - // and `2024-01-29`. + // and `2024-03-20`. Version *string } @@ -122,7 +122,7 @@ func NewVpcV1(options *VpcV1Options) (service *VpcV1, err error) { } if options.Version == nil { - options.Version = core.StringPtr("2024-01-24") + options.Version = core.StringPtr("2024-03-19") } service = &VpcV1{ @@ -7105,12 +7105,15 @@ func (vpc *VpcV1) AddInstanceNetworkInterfaceFloatingIPWithContext(ctx context.C // ListInstanceNetworkInterfaceIps : List the primary reserved IP for an instance network interface // This request lists the primary reserved IP for an instance network interface. +// Deprecated: this method is deprecated and may be removed in a future release. func (vpc *VpcV1) ListInstanceNetworkInterfaceIps(listInstanceNetworkInterfaceIpsOptions *ListInstanceNetworkInterfaceIpsOptions) (result *ReservedIPCollectionInstanceNetworkInterfaceContext, response *core.DetailedResponse, err error) { return vpc.ListInstanceNetworkInterfaceIpsWithContext(context.Background(), listInstanceNetworkInterfaceIpsOptions) } // ListInstanceNetworkInterfaceIpsWithContext is an alternate form of the ListInstanceNetworkInterfaceIps method which supports a Context parameter +// Deprecated: this method is deprecated and may be removed in a future release. func (vpc *VpcV1) ListInstanceNetworkInterfaceIpsWithContext(ctx context.Context, listInstanceNetworkInterfaceIpsOptions *ListInstanceNetworkInterfaceIpsOptions) (result *ReservedIPCollectionInstanceNetworkInterfaceContext, response *core.DetailedResponse, err error) { + core.GetLogger().Warn("A deprecated operation has been invoked: ListInstanceNetworkInterfaceIps") err = core.ValidateNotNil(listInstanceNetworkInterfaceIpsOptions, "listInstanceNetworkInterfaceIpsOptions cannot be nil") if err != nil { return @@ -7175,12 +7178,15 @@ func (vpc *VpcV1) ListInstanceNetworkInterfaceIpsWithContext(ctx context.Context // GetInstanceNetworkInterfaceIP : Retrieve the primary reserved IP // This request retrieves the primary reserved IP for an instance network interface. +// Deprecated: this method is deprecated and may be removed in a future release. func (vpc *VpcV1) GetInstanceNetworkInterfaceIP(getInstanceNetworkInterfaceIPOptions *GetInstanceNetworkInterfaceIPOptions) (result *ReservedIP, response *core.DetailedResponse, err error) { return vpc.GetInstanceNetworkInterfaceIPWithContext(context.Background(), getInstanceNetworkInterfaceIPOptions) } // GetInstanceNetworkInterfaceIPWithContext is an alternate form of the GetInstanceNetworkInterfaceIP method which supports a Context parameter +// Deprecated: this method is deprecated and may be removed in a future release. func (vpc *VpcV1) GetInstanceNetworkInterfaceIPWithContext(ctx context.Context, getInstanceNetworkInterfaceIPOptions *GetInstanceNetworkInterfaceIPOptions) (result *ReservedIP, response *core.DetailedResponse, err error) { + core.GetLogger().Warn("A deprecated operation has been invoked: GetInstanceNetworkInterfaceIP") err = core.ValidateNotNil(getInstanceNetworkInterfaceIPOptions, "getInstanceNetworkInterfaceIPOptions cannot be nil") if err != nil { return @@ -10645,16 +10651,15 @@ 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) +// 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) { + return vpc.ListPlacementGroupsWithContext(context.Background(), listPlacementGroupsOptions) } -// 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") +// ListPlacementGroupsWithContext is an alternate form of the ListPlacementGroups method which supports a Context parameter +func (vpc *VpcV1) ListPlacementGroupsWithContext(ctx context.Context, listPlacementGroupsOptions *ListPlacementGroupsOptions) (result *PlacementGroupCollection, response *core.DetailedResponse, err error) { + err = core.ValidateStruct(listPlacementGroupsOptions, "listPlacementGroupsOptions") if err != nil { return } @@ -10662,16 +10667,16 @@ func (vpc *VpcV1) ListBackupPoliciesWithContext(ctx context.Context, listBackupP builder := core.NewRequestBuilder(core.GET) builder = builder.WithContext(ctx) builder.EnableGzipCompression = vpc.GetEnableGzipCompression() - _, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/backup_policies`, nil) + _, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/placement_groups`, nil) if err != nil { return } - for headerName, headerValue := range listBackupPoliciesOptions.Headers { + for headerName, headerValue := range listPlacementGroupsOptions.Headers { builder.AddHeader(headerName, headerValue) } - sdkHeaders := common.GetSdkHeaders("vpc", "V1", "ListBackupPolicies") + sdkHeaders := common.GetSdkHeaders("vpc", "V1", "ListPlacementGroups") for headerName, headerValue := range sdkHeaders { builder.AddHeader(headerName, headerValue) } @@ -10679,20 +10684,11 @@ func (vpc *VpcV1) ListBackupPoliciesWithContext(ctx context.Context, listBackupP 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 listPlacementGroupsOptions.Start != nil { + builder.AddQuery("start", fmt.Sprint(*listPlacementGroupsOptions.Start)) } - if listBackupPoliciesOptions.Tag != nil { - builder.AddQuery("tag", fmt.Sprint(*listBackupPoliciesOptions.Tag)) + if listPlacementGroupsOptions.Limit != nil { + builder.AddQuery("limit", fmt.Sprint(*listPlacementGroupsOptions.Limit)) } request, err := builder.Build() @@ -10706,7 +10702,7 @@ func (vpc *VpcV1) ListBackupPoliciesWithContext(ctx context.Context, listBackupP return } if rawResponse != nil { - err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalBackupPolicyCollection) + err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalPlacementGroupCollection) if err != nil { return } @@ -10716,20 +10712,19 @@ func (vpc *VpcV1) ListBackupPoliciesWithContext(ctx context.Context, listBackupP 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 BackupPolicyIntf, response *core.DetailedResponse, err error) { - return vpc.CreateBackupPolicyWithContext(context.Background(), createBackupPolicyOptions) +// CreatePlacementGroup : Create a placement group +// This request creates a new placement group. +func (vpc *VpcV1) CreatePlacementGroup(createPlacementGroupOptions *CreatePlacementGroupOptions) (result *PlacementGroup, response *core.DetailedResponse, err error) { + return vpc.CreatePlacementGroupWithContext(context.Background(), createPlacementGroupOptions) } -// CreateBackupPolicyWithContext is an alternate form of the CreateBackupPolicy method which supports a Context parameter -func (vpc *VpcV1) CreateBackupPolicyWithContext(ctx context.Context, createBackupPolicyOptions *CreateBackupPolicyOptions) (result BackupPolicyIntf, response *core.DetailedResponse, err error) { - err = core.ValidateNotNil(createBackupPolicyOptions, "createBackupPolicyOptions cannot be nil") +// CreatePlacementGroupWithContext is an alternate form of the CreatePlacementGroup method which supports a Context parameter +func (vpc *VpcV1) CreatePlacementGroupWithContext(ctx context.Context, createPlacementGroupOptions *CreatePlacementGroupOptions) (result *PlacementGroup, response *core.DetailedResponse, err error) { + err = core.ValidateNotNil(createPlacementGroupOptions, "createPlacementGroupOptions cannot be nil") if err != nil { return } - err = core.ValidateStruct(createBackupPolicyOptions, "createBackupPolicyOptions") + err = core.ValidateStruct(createPlacementGroupOptions, "createPlacementGroupOptions") if err != nil { return } @@ -10737,16 +10732,16 @@ func (vpc *VpcV1) CreateBackupPolicyWithContext(ctx context.Context, createBacku builder := core.NewRequestBuilder(core.POST) builder = builder.WithContext(ctx) builder.EnableGzipCompression = vpc.GetEnableGzipCompression() - _, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/backup_policies`, nil) + _, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/placement_groups`, nil) if err != nil { return } - for headerName, headerValue := range createBackupPolicyOptions.Headers { + for headerName, headerValue := range createPlacementGroupOptions.Headers { builder.AddHeader(headerName, headerValue) } - sdkHeaders := common.GetSdkHeaders("vpc", "V1", "CreateBackupPolicy") + sdkHeaders := common.GetSdkHeaders("vpc", "V1", "CreatePlacementGroup") for headerName, headerValue := range sdkHeaders { builder.AddHeader(headerName, headerValue) } @@ -10756,7 +10751,17 @@ func (vpc *VpcV1) CreateBackupPolicyWithContext(ctx context.Context, createBacku builder.AddQuery("version", fmt.Sprint(*vpc.Version)) builder.AddQuery("generation", fmt.Sprint(*vpc.generation)) - _, err = builder.SetBodyContentJSON(createBackupPolicyOptions.BackupPolicyPrototype) + body := make(map[string]interface{}) + if createPlacementGroupOptions.Strategy != nil { + body["strategy"] = createPlacementGroupOptions.Strategy + } + if createPlacementGroupOptions.Name != nil { + body["name"] = createPlacementGroupOptions.Name + } + if createPlacementGroupOptions.ResourceGroup != nil { + body["resource_group"] = createPlacementGroupOptions.ResourceGroup + } + _, err = builder.SetBodyContentJSON(body) if err != nil { return } @@ -10772,7 +10777,7 @@ func (vpc *VpcV1) CreateBackupPolicyWithContext(ctx context.Context, createBacku return } if rawResponse != nil { - err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalBackupPolicy) + err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalPlacementGroup) if err != nil { return } @@ -10782,129 +10787,92 @@ func (vpc *VpcV1) CreateBackupPolicyWithContext(ctx context.Context, createBacku return } -// ListBackupPolicyJobs : List all jobs for a backup policy -// This request retrieves all jobs for a backup policy. A backup job represents the execution of a backup policy plan -// for a resource matching the policy's criteria. -func (vpc *VpcV1) ListBackupPolicyJobs(listBackupPolicyJobsOptions *ListBackupPolicyJobsOptions) (result *BackupPolicyJobCollection, response *core.DetailedResponse, err error) { - return vpc.ListBackupPolicyJobsWithContext(context.Background(), listBackupPolicyJobsOptions) +// DeletePlacementGroup : Delete a placement group +// This request deletes a placement group. This operation cannot be reversed. For this request to succeed, the placement +// group must not be associated with an instance. +func (vpc *VpcV1) DeletePlacementGroup(deletePlacementGroupOptions *DeletePlacementGroupOptions) (response *core.DetailedResponse, err error) { + return vpc.DeletePlacementGroupWithContext(context.Background(), deletePlacementGroupOptions) } -// ListBackupPolicyJobsWithContext is an alternate form of the ListBackupPolicyJobs method which supports a Context parameter -func (vpc *VpcV1) ListBackupPolicyJobsWithContext(ctx context.Context, listBackupPolicyJobsOptions *ListBackupPolicyJobsOptions) (result *BackupPolicyJobCollection, response *core.DetailedResponse, err error) { - err = core.ValidateNotNil(listBackupPolicyJobsOptions, "listBackupPolicyJobsOptions cannot be nil") +// DeletePlacementGroupWithContext is an alternate form of the DeletePlacementGroup method which supports a Context parameter +func (vpc *VpcV1) DeletePlacementGroupWithContext(ctx context.Context, deletePlacementGroupOptions *DeletePlacementGroupOptions) (response *core.DetailedResponse, err error) { + err = core.ValidateNotNil(deletePlacementGroupOptions, "deletePlacementGroupOptions cannot be nil") if err != nil { return } - err = core.ValidateStruct(listBackupPolicyJobsOptions, "listBackupPolicyJobsOptions") + err = core.ValidateStruct(deletePlacementGroupOptions, "deletePlacementGroupOptions") if err != nil { return } pathParamsMap := map[string]string{ - "backup_policy_id": *listBackupPolicyJobsOptions.BackupPolicyID, + "id": *deletePlacementGroupOptions.ID, } - builder := core.NewRequestBuilder(core.GET) + 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}/jobs`, pathParamsMap) + _, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/placement_groups/{id}`, pathParamsMap) if err != nil { return } - for headerName, headerValue := range listBackupPolicyJobsOptions.Headers { + for headerName, headerValue := range deletePlacementGroupOptions.Headers { builder.AddHeader(headerName, headerValue) } - sdkHeaders := common.GetSdkHeaders("vpc", "V1", "ListBackupPolicyJobs") + sdkHeaders := common.GetSdkHeaders("vpc", "V1", "DeletePlacementGroup") 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 listBackupPolicyJobsOptions.Status != nil { - builder.AddQuery("status", fmt.Sprint(*listBackupPolicyJobsOptions.Status)) - } - if listBackupPolicyJobsOptions.BackupPolicyPlanID != nil { - builder.AddQuery("backup_policy_plan.id", fmt.Sprint(*listBackupPolicyJobsOptions.BackupPolicyPlanID)) - } - if listBackupPolicyJobsOptions.Start != nil { - builder.AddQuery("start", fmt.Sprint(*listBackupPolicyJobsOptions.Start)) - } - if listBackupPolicyJobsOptions.Limit != nil { - builder.AddQuery("limit", fmt.Sprint(*listBackupPolicyJobsOptions.Limit)) - } - if listBackupPolicyJobsOptions.Sort != nil { - builder.AddQuery("sort", fmt.Sprint(*listBackupPolicyJobsOptions.Sort)) - } - if listBackupPolicyJobsOptions.SourceID != nil { - builder.AddQuery("source.id", fmt.Sprint(*listBackupPolicyJobsOptions.SourceID)) - } - if listBackupPolicyJobsOptions.TargetSnapshotsID != nil { - builder.AddQuery("target_snapshots[].id", fmt.Sprint(*listBackupPolicyJobsOptions.TargetSnapshotsID)) - } - if listBackupPolicyJobsOptions.TargetSnapshotsCRN != nil { - builder.AddQuery("target_snapshots[].crn", fmt.Sprint(*listBackupPolicyJobsOptions.TargetSnapshotsCRN)) - } 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, UnmarshalBackupPolicyJobCollection) - if err != nil { - return - } - response.Result = result - } + response, err = vpc.Service.Request(request, nil) return } -// GetBackupPolicyJob : Retrieve a backup policy job -// This request retrieves a single backup policy job specified by the identifier in the URL. -func (vpc *VpcV1) GetBackupPolicyJob(getBackupPolicyJobOptions *GetBackupPolicyJobOptions) (result *BackupPolicyJob, response *core.DetailedResponse, err error) { - return vpc.GetBackupPolicyJobWithContext(context.Background(), getBackupPolicyJobOptions) +// GetPlacementGroup : Retrieve a placement group +// This request retrieves a single placement group specified by identifier in the URL. +func (vpc *VpcV1) GetPlacementGroup(getPlacementGroupOptions *GetPlacementGroupOptions) (result *PlacementGroup, response *core.DetailedResponse, err error) { + return vpc.GetPlacementGroupWithContext(context.Background(), getPlacementGroupOptions) } -// GetBackupPolicyJobWithContext is an alternate form of the GetBackupPolicyJob method which supports a Context parameter -func (vpc *VpcV1) GetBackupPolicyJobWithContext(ctx context.Context, getBackupPolicyJobOptions *GetBackupPolicyJobOptions) (result *BackupPolicyJob, response *core.DetailedResponse, err error) { - err = core.ValidateNotNil(getBackupPolicyJobOptions, "getBackupPolicyJobOptions cannot be nil") +// GetPlacementGroupWithContext is an alternate form of the GetPlacementGroup method which supports a Context parameter +func (vpc *VpcV1) GetPlacementGroupWithContext(ctx context.Context, getPlacementGroupOptions *GetPlacementGroupOptions) (result *PlacementGroup, response *core.DetailedResponse, err error) { + err = core.ValidateNotNil(getPlacementGroupOptions, "getPlacementGroupOptions cannot be nil") if err != nil { return } - err = core.ValidateStruct(getBackupPolicyJobOptions, "getBackupPolicyJobOptions") + err = core.ValidateStruct(getPlacementGroupOptions, "getPlacementGroupOptions") if err != nil { return } pathParamsMap := map[string]string{ - "backup_policy_id": *getBackupPolicyJobOptions.BackupPolicyID, - "id": *getBackupPolicyJobOptions.ID, + "id": *getPlacementGroupOptions.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}/jobs/{id}`, pathParamsMap) + _, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/placement_groups/{id}`, pathParamsMap) if err != nil { return } - for headerName, headerValue := range getBackupPolicyJobOptions.Headers { + for headerName, headerValue := range getPlacementGroupOptions.Headers { builder.AddHeader(headerName, headerValue) } - sdkHeaders := common.GetSdkHeaders("vpc", "V1", "GetBackupPolicyJob") + sdkHeaders := common.GetSdkHeaders("vpc", "V1", "GetPlacementGroup") for headerName, headerValue := range sdkHeaders { builder.AddHeader(headerName, headerValue) } @@ -10924,7 +10892,7 @@ func (vpc *VpcV1) GetBackupPolicyJobWithContext(ctx context.Context, getBackupPo return } if rawResponse != nil { - err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalBackupPolicyJob) + err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalPlacementGroup) if err != nil { return } @@ -10934,49 +10902,53 @@ func (vpc *VpcV1) GetBackupPolicyJobWithContext(ctx context.Context, getBackupPo 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) +// UpdatePlacementGroup : Update a placement group +// This request updates a placement group with the information provided placement group patch. The placement group patch +// object is structured in the same way as a retrieved placement group and contains only the information to be updated. +func (vpc *VpcV1) UpdatePlacementGroup(updatePlacementGroupOptions *UpdatePlacementGroupOptions) (result *PlacementGroup, response *core.DetailedResponse, err error) { + return vpc.UpdatePlacementGroupWithContext(context.Background(), updatePlacementGroupOptions) } -// 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") +// UpdatePlacementGroupWithContext is an alternate form of the UpdatePlacementGroup method which supports a Context parameter +func (vpc *VpcV1) UpdatePlacementGroupWithContext(ctx context.Context, updatePlacementGroupOptions *UpdatePlacementGroupOptions) (result *PlacementGroup, response *core.DetailedResponse, err error) { + err = core.ValidateNotNil(updatePlacementGroupOptions, "updatePlacementGroupOptions cannot be nil") if err != nil { return } - err = core.ValidateStruct(listBackupPolicyPlansOptions, "listBackupPolicyPlansOptions") + err = core.ValidateStruct(updatePlacementGroupOptions, "updatePlacementGroupOptions") if err != nil { return } pathParamsMap := map[string]string{ - "backup_policy_id": *listBackupPolicyPlansOptions.BackupPolicyID, + "id": *updatePlacementGroupOptions.ID, } - builder := core.NewRequestBuilder(core.GET) + 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`, pathParamsMap) + _, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/placement_groups/{id}`, pathParamsMap) if err != nil { return } - for headerName, headerValue := range listBackupPolicyPlansOptions.Headers { + for headerName, headerValue := range updatePlacementGroupOptions.Headers { builder.AddHeader(headerName, headerValue) } - sdkHeaders := common.GetSdkHeaders("vpc", "V1", "ListBackupPolicyPlans") + sdkHeaders := common.GetSdkHeaders("vpc", "V1", "UpdatePlacementGroup") for headerName, headerValue := range sdkHeaders { builder.AddHeader(headerName, headerValue) } builder.AddHeader("Accept", "application/json") + builder.AddHeader("Content-Type", "application/merge-patch+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)) + + _, err = builder.SetBodyContentJSON(updatePlacementGroupOptions.PlacementGroupPatch) + if err != nil { + return } request, err := builder.Build() @@ -10990,7 +10962,7 @@ func (vpc *VpcV1) ListBackupPolicyPlansWithContext(ctx context.Context, listBack return } if rawResponse != nil { - err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalBackupPolicyPlanCollection) + err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalPlacementGroup) if err != nil { return } @@ -11000,84 +10972,46 @@ func (vpc *VpcV1) ListBackupPolicyPlansWithContext(ctx context.Context, listBack 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) +// ListBareMetalServerProfiles : List all bare metal server profiles +// This request lists all [bare metal server +// profiles](https://cloud.ibm.com/docs/vpc?topic=vpc-bare-metal-servers-profile) available in the region. A bare metal +// server profile specifies the performance characteristics and pricing model for a bare metal server. +func (vpc *VpcV1) ListBareMetalServerProfiles(listBareMetalServerProfilesOptions *ListBareMetalServerProfilesOptions) (result *BareMetalServerProfileCollection, response *core.DetailedResponse, err error) { + return vpc.ListBareMetalServerProfilesWithContext(context.Background(), listBareMetalServerProfilesOptions) } -// 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") +// ListBareMetalServerProfilesWithContext is an alternate form of the ListBareMetalServerProfiles method which supports a Context parameter +func (vpc *VpcV1) ListBareMetalServerProfilesWithContext(ctx context.Context, listBareMetalServerProfilesOptions *ListBareMetalServerProfilesOptions) (result *BareMetalServerProfileCollection, response *core.DetailedResponse, err error) { + err = core.ValidateStruct(listBareMetalServerProfilesOptions, "listBareMetalServerProfilesOptions") if err != nil { return } - pathParamsMap := map[string]string{ - "backup_policy_id": *createBackupPolicyPlanOptions.BackupPolicyID, - } - - builder := core.NewRequestBuilder(core.POST) + 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) + _, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/bare_metal_server/profiles`, nil) if err != nil { return } - for headerName, headerValue := range createBackupPolicyPlanOptions.Headers { + for headerName, headerValue := range listBareMetalServerProfilesOptions.Headers { builder.AddHeader(headerName, headerValue) } - sdkHeaders := common.GetSdkHeaders("vpc", "V1", "CreateBackupPolicyPlan") + sdkHeaders := common.GetSdkHeaders("vpc", "V1", "ListBareMetalServerProfiles") 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.ClonePolicy != nil { - body["clone_policy"] = createBackupPolicyPlanOptions.ClonePolicy - } - 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 - } - if createBackupPolicyPlanOptions.RemoteRegionPolicies != nil { - body["remote_region_policies"] = createBackupPolicyPlanOptions.RemoteRegionPolicies + if listBareMetalServerProfilesOptions.Start != nil { + builder.AddQuery("start", fmt.Sprint(*listBareMetalServerProfilesOptions.Start)) } - _, err = builder.SetBodyContentJSON(body) - if err != nil { - return + if listBareMetalServerProfilesOptions.Limit != nil { + builder.AddQuery("limit", fmt.Sprint(*listBareMetalServerProfilesOptions.Limit)) } request, err := builder.Build() @@ -11091,7 +11025,7 @@ func (vpc *VpcV1) CreateBackupPolicyPlanWithContext(ctx context.Context, createB return } if rawResponse != nil { - err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalBackupPolicyPlan) + err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalBareMetalServerProfileCollection) if err != nil { return } @@ -11101,53 +11035,44 @@ func (vpc *VpcV1) CreateBackupPolicyPlanWithContext(ctx context.Context, createB 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) +// GetBareMetalServerProfile : Retrieve a bare metal server profile +// This request retrieves a single bare metal server profile specified by the name in the URL. +func (vpc *VpcV1) GetBareMetalServerProfile(getBareMetalServerProfileOptions *GetBareMetalServerProfileOptions) (result *BareMetalServerProfile, response *core.DetailedResponse, err error) { + return vpc.GetBareMetalServerProfileWithContext(context.Background(), getBareMetalServerProfileOptions) } -// 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") +// GetBareMetalServerProfileWithContext is an alternate form of the GetBareMetalServerProfile method which supports a Context parameter +func (vpc *VpcV1) GetBareMetalServerProfileWithContext(ctx context.Context, getBareMetalServerProfileOptions *GetBareMetalServerProfileOptions) (result *BareMetalServerProfile, response *core.DetailedResponse, err error) { + err = core.ValidateNotNil(getBareMetalServerProfileOptions, "getBareMetalServerProfileOptions cannot be nil") if err != nil { return } - err = core.ValidateStruct(deleteBackupPolicyPlanOptions, "deleteBackupPolicyPlanOptions") + err = core.ValidateStruct(getBareMetalServerProfileOptions, "getBareMetalServerProfileOptions") if err != nil { return } pathParamsMap := map[string]string{ - "backup_policy_id": *deleteBackupPolicyPlanOptions.BackupPolicyID, - "id": *deleteBackupPolicyPlanOptions.ID, + "name": *getBareMetalServerProfileOptions.Name, } - builder := core.NewRequestBuilder(core.DELETE) + 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) + _, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/bare_metal_server/profiles/{name}`, pathParamsMap) if err != nil { return } - for headerName, headerValue := range deleteBackupPolicyPlanOptions.Headers { + for headerName, headerValue := range getBareMetalServerProfileOptions.Headers { builder.AddHeader(headerName, headerValue) } - sdkHeaders := common.GetSdkHeaders("vpc", "V1", "DeleteBackupPolicyPlan") + sdkHeaders := common.GetSdkHeaders("vpc", "V1", "GetBareMetalServerProfile") 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)) @@ -11163,7 +11088,7 @@ func (vpc *VpcV1) DeleteBackupPolicyPlanWithContext(ctx context.Context, deleteB return } if rawResponse != nil { - err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalBackupPolicyPlan) + err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalBareMetalServerProfile) if err != nil { return } @@ -11173,41 +11098,32 @@ func (vpc *VpcV1) DeleteBackupPolicyPlanWithContext(ctx context.Context, deleteB 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) +// ListBareMetalServers : List all bare metal servers +// This request lists all bare metal servers in the region. +func (vpc *VpcV1) ListBareMetalServers(listBareMetalServersOptions *ListBareMetalServersOptions) (result *BareMetalServerCollection, response *core.DetailedResponse, err error) { + return vpc.ListBareMetalServersWithContext(context.Background(), listBareMetalServersOptions) } -// 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") +// ListBareMetalServersWithContext is an alternate form of the ListBareMetalServers method which supports a Context parameter +func (vpc *VpcV1) ListBareMetalServersWithContext(ctx context.Context, listBareMetalServersOptions *ListBareMetalServersOptions) (result *BareMetalServerCollection, response *core.DetailedResponse, err error) { + err = core.ValidateStruct(listBareMetalServersOptions, "listBareMetalServersOptions") 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) + _, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/bare_metal_servers`, nil) if err != nil { return } - for headerName, headerValue := range getBackupPolicyPlanOptions.Headers { + for headerName, headerValue := range listBareMetalServersOptions.Headers { builder.AddHeader(headerName, headerValue) } - sdkHeaders := common.GetSdkHeaders("vpc", "V1", "GetBackupPolicyPlan") + sdkHeaders := common.GetSdkHeaders("vpc", "V1", "ListBareMetalServers") for headerName, headerValue := range sdkHeaders { builder.AddHeader(headerName, headerValue) } @@ -11215,6 +11131,27 @@ func (vpc *VpcV1) GetBackupPolicyPlanWithContext(ctx context.Context, getBackupP builder.AddQuery("version", fmt.Sprint(*vpc.Version)) builder.AddQuery("generation", fmt.Sprint(*vpc.generation)) + if listBareMetalServersOptions.Start != nil { + builder.AddQuery("start", fmt.Sprint(*listBareMetalServersOptions.Start)) + } + if listBareMetalServersOptions.Limit != nil { + builder.AddQuery("limit", fmt.Sprint(*listBareMetalServersOptions.Limit)) + } + if listBareMetalServersOptions.ResourceGroupID != nil { + builder.AddQuery("resource_group.id", fmt.Sprint(*listBareMetalServersOptions.ResourceGroupID)) + } + if listBareMetalServersOptions.Name != nil { + builder.AddQuery("name", fmt.Sprint(*listBareMetalServersOptions.Name)) + } + if listBareMetalServersOptions.VPCID != nil { + builder.AddQuery("vpc.id", fmt.Sprint(*listBareMetalServersOptions.VPCID)) + } + if listBareMetalServersOptions.VPCCRN != nil { + builder.AddQuery("vpc.crn", fmt.Sprint(*listBareMetalServersOptions.VPCCRN)) + } + if listBareMetalServersOptions.VPCName != nil { + builder.AddQuery("vpc.name", fmt.Sprint(*listBareMetalServersOptions.VPCName)) + } request, err := builder.Build() if err != nil { @@ -11227,7 +11164,7 @@ func (vpc *VpcV1) GetBackupPolicyPlanWithContext(ctx context.Context, getBackupP return } if rawResponse != nil { - err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalBackupPolicyPlan) + err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalBareMetalServerCollection) if err != nil { return } @@ -11237,55 +11174,48 @@ func (vpc *VpcV1) GetBackupPolicyPlanWithContext(ctx context.Context, getBackupP 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) +// CreateBareMetalServer : Create a bare metal server +// This request provisions a new bare metal server from a prototype object. The prototype object is structured in the +// same way as a retrieved bare metal server, and contains the information necessary to provision the new bare metal +// server. The bare metal server is automatically started. +func (vpc *VpcV1) CreateBareMetalServer(createBareMetalServerOptions *CreateBareMetalServerOptions) (result *BareMetalServer, response *core.DetailedResponse, err error) { + return vpc.CreateBareMetalServerWithContext(context.Background(), createBareMetalServerOptions) } -// 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") +// CreateBareMetalServerWithContext is an alternate form of the CreateBareMetalServer method which supports a Context parameter +func (vpc *VpcV1) CreateBareMetalServerWithContext(ctx context.Context, createBareMetalServerOptions *CreateBareMetalServerOptions) (result *BareMetalServer, response *core.DetailedResponse, err error) { + err = core.ValidateNotNil(createBareMetalServerOptions, "createBareMetalServerOptions cannot be nil") if err != nil { return } - err = core.ValidateStruct(updateBackupPolicyPlanOptions, "updateBackupPolicyPlanOptions") + err = core.ValidateStruct(createBareMetalServerOptions, "createBareMetalServerOptions") if err != nil { return } - pathParamsMap := map[string]string{ - "backup_policy_id": *updateBackupPolicyPlanOptions.BackupPolicyID, - "id": *updateBackupPolicyPlanOptions.ID, - } - - builder := core.NewRequestBuilder(core.PATCH) + 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/{id}`, pathParamsMap) + _, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/bare_metal_servers`, nil) if err != nil { return } - for headerName, headerValue := range updateBackupPolicyPlanOptions.Headers { + for headerName, headerValue := range createBareMetalServerOptions.Headers { builder.AddHeader(headerName, headerValue) } - sdkHeaders := common.GetSdkHeaders("vpc", "V1", "UpdateBackupPolicyPlan") + sdkHeaders := common.GetSdkHeaders("vpc", "V1", "CreateBareMetalServer") 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.AddHeader("Content-Type", "application/json") builder.AddQuery("version", fmt.Sprint(*vpc.Version)) builder.AddQuery("generation", fmt.Sprint(*vpc.generation)) - _, err = builder.SetBodyContentJSON(updateBackupPolicyPlanOptions.BackupPolicyPlanPatch) + _, err = builder.SetBodyContentJSON(createBareMetalServerOptions.BareMetalServerPrototype) if err != nil { return } @@ -11301,7 +11231,7 @@ func (vpc *VpcV1) UpdateBackupPolicyPlanWithContext(ctx context.Context, updateB return } if rawResponse != nil { - err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalBackupPolicyPlan) + err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalBareMetalServer) if err != nil { return } @@ -11311,54 +11241,64 @@ func (vpc *VpcV1) UpdateBackupPolicyPlanWithContext(ctx context.Context, updateB 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 BackupPolicyIntf, response *core.DetailedResponse, err error) { - return vpc.DeleteBackupPolicyWithContext(context.Background(), deleteBackupPolicyOptions) +// CreateBareMetalServerConsoleAccessToken : Create a console access token for a bare metal server +// This request creates a new single-use console access token for a bare metal server. All console configuration is +// provided at token create time, and the token is subsequently used in the `access_token` query parameter for the +// WebSocket request. The access token is only valid for a short period of time, and a maximum of one token is valid +// for a given bare metal server at a time. +func (vpc *VpcV1) CreateBareMetalServerConsoleAccessToken(createBareMetalServerConsoleAccessTokenOptions *CreateBareMetalServerConsoleAccessTokenOptions) (result *BareMetalServerConsoleAccessToken, response *core.DetailedResponse, err error) { + return vpc.CreateBareMetalServerConsoleAccessTokenWithContext(context.Background(), createBareMetalServerConsoleAccessTokenOptions) } -// DeleteBackupPolicyWithContext is an alternate form of the DeleteBackupPolicy method which supports a Context parameter -func (vpc *VpcV1) DeleteBackupPolicyWithContext(ctx context.Context, deleteBackupPolicyOptions *DeleteBackupPolicyOptions) (result BackupPolicyIntf, response *core.DetailedResponse, err error) { - err = core.ValidateNotNil(deleteBackupPolicyOptions, "deleteBackupPolicyOptions cannot be nil") +// CreateBareMetalServerConsoleAccessTokenWithContext is an alternate form of the CreateBareMetalServerConsoleAccessToken method which supports a Context parameter +func (vpc *VpcV1) CreateBareMetalServerConsoleAccessTokenWithContext(ctx context.Context, createBareMetalServerConsoleAccessTokenOptions *CreateBareMetalServerConsoleAccessTokenOptions) (result *BareMetalServerConsoleAccessToken, response *core.DetailedResponse, err error) { + err = core.ValidateNotNil(createBareMetalServerConsoleAccessTokenOptions, "createBareMetalServerConsoleAccessTokenOptions cannot be nil") if err != nil { return } - err = core.ValidateStruct(deleteBackupPolicyOptions, "deleteBackupPolicyOptions") + err = core.ValidateStruct(createBareMetalServerConsoleAccessTokenOptions, "createBareMetalServerConsoleAccessTokenOptions") if err != nil { return } pathParamsMap := map[string]string{ - "id": *deleteBackupPolicyOptions.ID, + "bare_metal_server_id": *createBareMetalServerConsoleAccessTokenOptions.BareMetalServerID, } - builder := core.NewRequestBuilder(core.DELETE) + builder := core.NewRequestBuilder(core.POST) builder = builder.WithContext(ctx) builder.EnableGzipCompression = vpc.GetEnableGzipCompression() - _, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/backup_policies/{id}`, pathParamsMap) + _, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/bare_metal_servers/{bare_metal_server_id}/console_access_token`, pathParamsMap) if err != nil { return } - for headerName, headerValue := range deleteBackupPolicyOptions.Headers { + for headerName, headerValue := range createBareMetalServerConsoleAccessTokenOptions.Headers { builder.AddHeader(headerName, headerValue) } - sdkHeaders := common.GetSdkHeaders("vpc", "V1", "DeleteBackupPolicy") + sdkHeaders := common.GetSdkHeaders("vpc", "V1", "CreateBareMetalServerConsoleAccessToken") 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.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 createBareMetalServerConsoleAccessTokenOptions.ConsoleType != nil { + body["console_type"] = createBareMetalServerConsoleAccessTokenOptions.ConsoleType + } + if createBareMetalServerConsoleAccessTokenOptions.Force != nil { + body["force"] = createBareMetalServerConsoleAccessTokenOptions.Force + } + _, err = builder.SetBodyContentJSON(body) + if err != nil { + return + } + request, err := builder.Build() if err != nil { return @@ -11370,7 +11310,7 @@ func (vpc *VpcV1) DeleteBackupPolicyWithContext(ctx context.Context, deleteBacku return } if rawResponse != nil { - err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalBackupPolicy) + err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalBareMetalServerConsoleAccessToken) if err != nil { return } @@ -11380,40 +11320,42 @@ func (vpc *VpcV1) DeleteBackupPolicyWithContext(ctx context.Context, deleteBacku 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 BackupPolicyIntf, response *core.DetailedResponse, err error) { - return vpc.GetBackupPolicyWithContext(context.Background(), getBackupPolicyOptions) +// ListBareMetalServerDisks : List all disks on a bare metal server +// This request lists all disks on a bare metal server. A disk is a block device that is locally attached to the +// physical server. By default, the listed disks are sorted by their `created_at` property values, with the newest disk +// first. +func (vpc *VpcV1) ListBareMetalServerDisks(listBareMetalServerDisksOptions *ListBareMetalServerDisksOptions) (result *BareMetalServerDiskCollection, response *core.DetailedResponse, err error) { + return vpc.ListBareMetalServerDisksWithContext(context.Background(), listBareMetalServerDisksOptions) } -// GetBackupPolicyWithContext is an alternate form of the GetBackupPolicy method which supports a Context parameter -func (vpc *VpcV1) GetBackupPolicyWithContext(ctx context.Context, getBackupPolicyOptions *GetBackupPolicyOptions) (result BackupPolicyIntf, response *core.DetailedResponse, err error) { - err = core.ValidateNotNil(getBackupPolicyOptions, "getBackupPolicyOptions cannot be nil") +// ListBareMetalServerDisksWithContext is an alternate form of the ListBareMetalServerDisks method which supports a Context parameter +func (vpc *VpcV1) ListBareMetalServerDisksWithContext(ctx context.Context, listBareMetalServerDisksOptions *ListBareMetalServerDisksOptions) (result *BareMetalServerDiskCollection, response *core.DetailedResponse, err error) { + err = core.ValidateNotNil(listBareMetalServerDisksOptions, "listBareMetalServerDisksOptions cannot be nil") if err != nil { return } - err = core.ValidateStruct(getBackupPolicyOptions, "getBackupPolicyOptions") + err = core.ValidateStruct(listBareMetalServerDisksOptions, "listBareMetalServerDisksOptions") if err != nil { return } pathParamsMap := map[string]string{ - "id": *getBackupPolicyOptions.ID, + "bare_metal_server_id": *listBareMetalServerDisksOptions.BareMetalServerID, } builder := core.NewRequestBuilder(core.GET) builder = builder.WithContext(ctx) builder.EnableGzipCompression = vpc.GetEnableGzipCompression() - _, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/backup_policies/{id}`, pathParamsMap) + _, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/bare_metal_servers/{bare_metal_server_id}/disks`, pathParamsMap) if err != nil { return } - for headerName, headerValue := range getBackupPolicyOptions.Headers { + for headerName, headerValue := range listBareMetalServerDisksOptions.Headers { builder.AddHeader(headerName, headerValue) } - sdkHeaders := common.GetSdkHeaders("vpc", "V1", "GetBackupPolicy") + sdkHeaders := common.GetSdkHeaders("vpc", "V1", "ListBareMetalServerDisks") for headerName, headerValue := range sdkHeaders { builder.AddHeader(headerName, headerValue) } @@ -11433,7 +11375,7 @@ func (vpc *VpcV1) GetBackupPolicyWithContext(ctx context.Context, getBackupPolic return } if rawResponse != nil { - err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalBackupPolicy) + err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalBareMetalServerDiskCollection) if err != nil { return } @@ -11443,54 +11385,115 @@ func (vpc *VpcV1) GetBackupPolicyWithContext(ctx context.Context, getBackupPolic 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 BackupPolicyIntf, response *core.DetailedResponse, err error) { - return vpc.UpdateBackupPolicyWithContext(context.Background(), updateBackupPolicyOptions) +// GetBareMetalServerDisk : Retrieve a bare metal server disk +// This request retrieves a single disk specified by the identifier in the URL. +func (vpc *VpcV1) GetBareMetalServerDisk(getBareMetalServerDiskOptions *GetBareMetalServerDiskOptions) (result *BareMetalServerDisk, response *core.DetailedResponse, err error) { + return vpc.GetBareMetalServerDiskWithContext(context.Background(), getBareMetalServerDiskOptions) } -// UpdateBackupPolicyWithContext is an alternate form of the UpdateBackupPolicy method which supports a Context parameter -func (vpc *VpcV1) UpdateBackupPolicyWithContext(ctx context.Context, updateBackupPolicyOptions *UpdateBackupPolicyOptions) (result BackupPolicyIntf, response *core.DetailedResponse, err error) { - err = core.ValidateNotNil(updateBackupPolicyOptions, "updateBackupPolicyOptions cannot be nil") +// GetBareMetalServerDiskWithContext is an alternate form of the GetBareMetalServerDisk method which supports a Context parameter +func (vpc *VpcV1) GetBareMetalServerDiskWithContext(ctx context.Context, getBareMetalServerDiskOptions *GetBareMetalServerDiskOptions) (result *BareMetalServerDisk, response *core.DetailedResponse, err error) { + err = core.ValidateNotNil(getBareMetalServerDiskOptions, "getBareMetalServerDiskOptions cannot be nil") if err != nil { return } - err = core.ValidateStruct(updateBackupPolicyOptions, "updateBackupPolicyOptions") + err = core.ValidateStruct(getBareMetalServerDiskOptions, "getBareMetalServerDiskOptions") if err != nil { return } pathParamsMap := map[string]string{ - "id": *updateBackupPolicyOptions.ID, + "bare_metal_server_id": *getBareMetalServerDiskOptions.BareMetalServerID, + "id": *getBareMetalServerDiskOptions.ID, + } + + builder := core.NewRequestBuilder(core.GET) + builder = builder.WithContext(ctx) + builder.EnableGzipCompression = vpc.GetEnableGzipCompression() + _, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/bare_metal_servers/{bare_metal_server_id}/disks/{id}`, pathParamsMap) + if err != nil { + return + } + + for headerName, headerValue := range getBareMetalServerDiskOptions.Headers { + builder.AddHeader(headerName, headerValue) + } + + sdkHeaders := common.GetSdkHeaders("vpc", "V1", "GetBareMetalServerDisk") + 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, UnmarshalBareMetalServerDisk) + if err != nil { + return + } + response.Result = result + } + + return +} + +// UpdateBareMetalServerDisk : Update a bare metal server disk +// This request updates the bare metal server disk with the information in a provided patch. +func (vpc *VpcV1) UpdateBareMetalServerDisk(updateBareMetalServerDiskOptions *UpdateBareMetalServerDiskOptions) (result *BareMetalServerDisk, response *core.DetailedResponse, err error) { + return vpc.UpdateBareMetalServerDiskWithContext(context.Background(), updateBareMetalServerDiskOptions) +} + +// UpdateBareMetalServerDiskWithContext is an alternate form of the UpdateBareMetalServerDisk method which supports a Context parameter +func (vpc *VpcV1) UpdateBareMetalServerDiskWithContext(ctx context.Context, updateBareMetalServerDiskOptions *UpdateBareMetalServerDiskOptions) (result *BareMetalServerDisk, response *core.DetailedResponse, err error) { + err = core.ValidateNotNil(updateBareMetalServerDiskOptions, "updateBareMetalServerDiskOptions cannot be nil") + if err != nil { + return + } + err = core.ValidateStruct(updateBareMetalServerDiskOptions, "updateBareMetalServerDiskOptions") + if err != nil { + return + } + + pathParamsMap := map[string]string{ + "bare_metal_server_id": *updateBareMetalServerDiskOptions.BareMetalServerID, + "id": *updateBareMetalServerDiskOptions.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) + _, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/bare_metal_servers/{bare_metal_server_id}/disks/{id}`, pathParamsMap) if err != nil { return } - for headerName, headerValue := range updateBackupPolicyOptions.Headers { + for headerName, headerValue := range updateBareMetalServerDiskOptions.Headers { builder.AddHeader(headerName, headerValue) } - sdkHeaders := common.GetSdkHeaders("vpc", "V1", "UpdateBackupPolicy") + sdkHeaders := common.GetSdkHeaders("vpc", "V1", "UpdateBareMetalServerDisk") 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) + _, err = builder.SetBodyContentJSON(updateBareMetalServerDiskOptions.BareMetalServerDiskPatch) if err != nil { return } @@ -11506,7 +11509,7 @@ func (vpc *VpcV1) UpdateBackupPolicyWithContext(ctx context.Context, updateBacku return } if rawResponse != nil { - err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalBackupPolicy) + err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalBareMetalServerDisk) if err != nil { return } @@ -11516,32 +11519,47 @@ func (vpc *VpcV1) UpdateBackupPolicyWithContext(ctx context.Context, updateBacku 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) { - return vpc.ListPlacementGroupsWithContext(context.Background(), listPlacementGroupsOptions) +// ListBareMetalServerNetworkAttachments : List all network attachments on a bare metal server +// This request lists all network attachments on a bare metal server. A bare metal server network attachment is an +// abstract representation of a network device and attaches a bare metal server to a single subnet. Each network +// interface on a bare metal server can attach to any subnet in the zone, including subnets that are already attached to +// the bare metal server. +// +// The network attachments will be sorted by their `created_at` property values, with newest network attachments first. +// Network attachments with identical `created_at` property values will in turn be sorted by ascending `name` property +// values. +func (vpc *VpcV1) ListBareMetalServerNetworkAttachments(listBareMetalServerNetworkAttachmentsOptions *ListBareMetalServerNetworkAttachmentsOptions) (result *BareMetalServerNetworkAttachmentCollection, response *core.DetailedResponse, err error) { + return vpc.ListBareMetalServerNetworkAttachmentsWithContext(context.Background(), listBareMetalServerNetworkAttachmentsOptions) } -// ListPlacementGroupsWithContext is an alternate form of the ListPlacementGroups method which supports a Context parameter -func (vpc *VpcV1) ListPlacementGroupsWithContext(ctx context.Context, listPlacementGroupsOptions *ListPlacementGroupsOptions) (result *PlacementGroupCollection, response *core.DetailedResponse, err error) { - err = core.ValidateStruct(listPlacementGroupsOptions, "listPlacementGroupsOptions") +// ListBareMetalServerNetworkAttachmentsWithContext is an alternate form of the ListBareMetalServerNetworkAttachments method which supports a Context parameter +func (vpc *VpcV1) ListBareMetalServerNetworkAttachmentsWithContext(ctx context.Context, listBareMetalServerNetworkAttachmentsOptions *ListBareMetalServerNetworkAttachmentsOptions) (result *BareMetalServerNetworkAttachmentCollection, response *core.DetailedResponse, err error) { + err = core.ValidateNotNil(listBareMetalServerNetworkAttachmentsOptions, "listBareMetalServerNetworkAttachmentsOptions cannot be nil") + if err != nil { + return + } + err = core.ValidateStruct(listBareMetalServerNetworkAttachmentsOptions, "listBareMetalServerNetworkAttachmentsOptions") if err != nil { return } + pathParamsMap := map[string]string{ + "bare_metal_server_id": *listBareMetalServerNetworkAttachmentsOptions.BareMetalServerID, + } + builder := core.NewRequestBuilder(core.GET) builder = builder.WithContext(ctx) builder.EnableGzipCompression = vpc.GetEnableGzipCompression() - _, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/placement_groups`, nil) + _, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/bare_metal_servers/{bare_metal_server_id}/network_attachments`, pathParamsMap) if err != nil { return } - for headerName, headerValue := range listPlacementGroupsOptions.Headers { + for headerName, headerValue := range listBareMetalServerNetworkAttachmentsOptions.Headers { builder.AddHeader(headerName, headerValue) } - sdkHeaders := common.GetSdkHeaders("vpc", "V1", "ListPlacementGroups") + sdkHeaders := common.GetSdkHeaders("vpc", "V1", "ListBareMetalServerNetworkAttachments") for headerName, headerValue := range sdkHeaders { builder.AddHeader(headerName, headerValue) } @@ -11549,11 +11567,11 @@ func (vpc *VpcV1) ListPlacementGroupsWithContext(ctx context.Context, listPlacem builder.AddQuery("version", fmt.Sprint(*vpc.Version)) builder.AddQuery("generation", fmt.Sprint(*vpc.generation)) - if listPlacementGroupsOptions.Start != nil { - builder.AddQuery("start", fmt.Sprint(*listPlacementGroupsOptions.Start)) + if listBareMetalServerNetworkAttachmentsOptions.Start != nil { + builder.AddQuery("start", fmt.Sprint(*listBareMetalServerNetworkAttachmentsOptions.Start)) } - if listPlacementGroupsOptions.Limit != nil { - builder.AddQuery("limit", fmt.Sprint(*listPlacementGroupsOptions.Limit)) + if listBareMetalServerNetworkAttachmentsOptions.Limit != nil { + builder.AddQuery("limit", fmt.Sprint(*listBareMetalServerNetworkAttachmentsOptions.Limit)) } request, err := builder.Build() @@ -11567,7 +11585,7 @@ func (vpc *VpcV1) ListPlacementGroupsWithContext(ctx context.Context, listPlacem return } if rawResponse != nil { - err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalPlacementGroupCollection) + err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalBareMetalServerNetworkAttachmentCollection) if err != nil { return } @@ -11577,36 +11595,42 @@ func (vpc *VpcV1) ListPlacementGroupsWithContext(ctx context.Context, listPlacem return } -// CreatePlacementGroup : Create a placement group -// This request creates a new placement group. -func (vpc *VpcV1) CreatePlacementGroup(createPlacementGroupOptions *CreatePlacementGroupOptions) (result *PlacementGroup, response *core.DetailedResponse, err error) { - return vpc.CreatePlacementGroupWithContext(context.Background(), createPlacementGroupOptions) +// CreateBareMetalServerNetworkAttachment : Create a network attachment on a bare metal server +// This request creates a new bare metal server network attachment from a bare metal server network attachment prototype +// object. The prototype object is structured in the same way as a retrieved bare metal server network attachment, and +// contains the information necessary to create the new bare metal server network attachment. +func (vpc *VpcV1) CreateBareMetalServerNetworkAttachment(createBareMetalServerNetworkAttachmentOptions *CreateBareMetalServerNetworkAttachmentOptions) (result BareMetalServerNetworkAttachmentIntf, response *core.DetailedResponse, err error) { + return vpc.CreateBareMetalServerNetworkAttachmentWithContext(context.Background(), createBareMetalServerNetworkAttachmentOptions) } -// CreatePlacementGroupWithContext is an alternate form of the CreatePlacementGroup method which supports a Context parameter -func (vpc *VpcV1) CreatePlacementGroupWithContext(ctx context.Context, createPlacementGroupOptions *CreatePlacementGroupOptions) (result *PlacementGroup, response *core.DetailedResponse, err error) { - err = core.ValidateNotNil(createPlacementGroupOptions, "createPlacementGroupOptions cannot be nil") +// CreateBareMetalServerNetworkAttachmentWithContext is an alternate form of the CreateBareMetalServerNetworkAttachment method which supports a Context parameter +func (vpc *VpcV1) CreateBareMetalServerNetworkAttachmentWithContext(ctx context.Context, createBareMetalServerNetworkAttachmentOptions *CreateBareMetalServerNetworkAttachmentOptions) (result BareMetalServerNetworkAttachmentIntf, response *core.DetailedResponse, err error) { + err = core.ValidateNotNil(createBareMetalServerNetworkAttachmentOptions, "createBareMetalServerNetworkAttachmentOptions cannot be nil") if err != nil { return } - err = core.ValidateStruct(createPlacementGroupOptions, "createPlacementGroupOptions") + err = core.ValidateStruct(createBareMetalServerNetworkAttachmentOptions, "createBareMetalServerNetworkAttachmentOptions") if err != nil { return } + pathParamsMap := map[string]string{ + "bare_metal_server_id": *createBareMetalServerNetworkAttachmentOptions.BareMetalServerID, + } + builder := core.NewRequestBuilder(core.POST) builder = builder.WithContext(ctx) builder.EnableGzipCompression = vpc.GetEnableGzipCompression() - _, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/placement_groups`, nil) + _, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/bare_metal_servers/{bare_metal_server_id}/network_attachments`, pathParamsMap) if err != nil { return } - for headerName, headerValue := range createPlacementGroupOptions.Headers { + for headerName, headerValue := range createBareMetalServerNetworkAttachmentOptions.Headers { builder.AddHeader(headerName, headerValue) } - sdkHeaders := common.GetSdkHeaders("vpc", "V1", "CreatePlacementGroup") + sdkHeaders := common.GetSdkHeaders("vpc", "V1", "CreateBareMetalServerNetworkAttachment") for headerName, headerValue := range sdkHeaders { builder.AddHeader(headerName, headerValue) } @@ -11616,17 +11640,7 @@ func (vpc *VpcV1) CreatePlacementGroupWithContext(ctx context.Context, createPla builder.AddQuery("version", fmt.Sprint(*vpc.Version)) builder.AddQuery("generation", fmt.Sprint(*vpc.generation)) - body := make(map[string]interface{}) - if createPlacementGroupOptions.Strategy != nil { - body["strategy"] = createPlacementGroupOptions.Strategy - } - if createPlacementGroupOptions.Name != nil { - body["name"] = createPlacementGroupOptions.Name - } - if createPlacementGroupOptions.ResourceGroup != nil { - body["resource_group"] = createPlacementGroupOptions.ResourceGroup - } - _, err = builder.SetBodyContentJSON(body) + _, err = builder.SetBodyContentJSON(createBareMetalServerNetworkAttachmentOptions.BareMetalServerNetworkAttachmentPrototype) if err != nil { return } @@ -11642,7 +11656,7 @@ func (vpc *VpcV1) CreatePlacementGroupWithContext(ctx context.Context, createPla return } if rawResponse != nil { - err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalPlacementGroup) + err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalBareMetalServerNetworkAttachment) if err != nil { return } @@ -11652,41 +11666,44 @@ func (vpc *VpcV1) CreatePlacementGroupWithContext(ctx context.Context, createPla return } -// DeletePlacementGroup : Delete a placement group -// This request deletes a placement group. This operation cannot be reversed. For this request to succeed, the placement -// group must not be associated with an instance. -func (vpc *VpcV1) DeletePlacementGroup(deletePlacementGroupOptions *DeletePlacementGroupOptions) (response *core.DetailedResponse, err error) { - return vpc.DeletePlacementGroupWithContext(context.Background(), deletePlacementGroupOptions) +// DeleteBareMetalServerNetworkAttachment : Delete a bare metal server network attachment +// This request deletes a bare metal server network attachment. This operation cannot be reversed. Any floating IPs +// associated with the bare metal server network attachment are implicitly disassociated. +// +// The bare metal server's primary network attachment cannot be deleted. +func (vpc *VpcV1) DeleteBareMetalServerNetworkAttachment(deleteBareMetalServerNetworkAttachmentOptions *DeleteBareMetalServerNetworkAttachmentOptions) (response *core.DetailedResponse, err error) { + return vpc.DeleteBareMetalServerNetworkAttachmentWithContext(context.Background(), deleteBareMetalServerNetworkAttachmentOptions) } -// DeletePlacementGroupWithContext is an alternate form of the DeletePlacementGroup method which supports a Context parameter -func (vpc *VpcV1) DeletePlacementGroupWithContext(ctx context.Context, deletePlacementGroupOptions *DeletePlacementGroupOptions) (response *core.DetailedResponse, err error) { - err = core.ValidateNotNil(deletePlacementGroupOptions, "deletePlacementGroupOptions cannot be nil") +// DeleteBareMetalServerNetworkAttachmentWithContext is an alternate form of the DeleteBareMetalServerNetworkAttachment method which supports a Context parameter +func (vpc *VpcV1) DeleteBareMetalServerNetworkAttachmentWithContext(ctx context.Context, deleteBareMetalServerNetworkAttachmentOptions *DeleteBareMetalServerNetworkAttachmentOptions) (response *core.DetailedResponse, err error) { + err = core.ValidateNotNil(deleteBareMetalServerNetworkAttachmentOptions, "deleteBareMetalServerNetworkAttachmentOptions cannot be nil") if err != nil { return } - err = core.ValidateStruct(deletePlacementGroupOptions, "deletePlacementGroupOptions") + err = core.ValidateStruct(deleteBareMetalServerNetworkAttachmentOptions, "deleteBareMetalServerNetworkAttachmentOptions") if err != nil { return } pathParamsMap := map[string]string{ - "id": *deletePlacementGroupOptions.ID, + "bare_metal_server_id": *deleteBareMetalServerNetworkAttachmentOptions.BareMetalServerID, + "id": *deleteBareMetalServerNetworkAttachmentOptions.ID, } builder := core.NewRequestBuilder(core.DELETE) builder = builder.WithContext(ctx) builder.EnableGzipCompression = vpc.GetEnableGzipCompression() - _, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/placement_groups/{id}`, pathParamsMap) + _, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/bare_metal_servers/{bare_metal_server_id}/network_attachments/{id}`, pathParamsMap) if err != nil { return } - for headerName, headerValue := range deletePlacementGroupOptions.Headers { + for headerName, headerValue := range deleteBareMetalServerNetworkAttachmentOptions.Headers { builder.AddHeader(headerName, headerValue) } - sdkHeaders := common.GetSdkHeaders("vpc", "V1", "DeletePlacementGroup") + sdkHeaders := common.GetSdkHeaders("vpc", "V1", "DeleteBareMetalServerNetworkAttachment") for headerName, headerValue := range sdkHeaders { builder.AddHeader(headerName, headerValue) } @@ -11704,40 +11721,41 @@ func (vpc *VpcV1) DeletePlacementGroupWithContext(ctx context.Context, deletePla return } -// GetPlacementGroup : Retrieve a placement group -// This request retrieves a single placement group specified by identifier in the URL. -func (vpc *VpcV1) GetPlacementGroup(getPlacementGroupOptions *GetPlacementGroupOptions) (result *PlacementGroup, response *core.DetailedResponse, err error) { - return vpc.GetPlacementGroupWithContext(context.Background(), getPlacementGroupOptions) +// GetBareMetalServerNetworkAttachment : Retrieve a bare metal server network attachment +// This request retrieves a single bare metal server network attachment specified by the identifier in the URL. +func (vpc *VpcV1) GetBareMetalServerNetworkAttachment(getBareMetalServerNetworkAttachmentOptions *GetBareMetalServerNetworkAttachmentOptions) (result BareMetalServerNetworkAttachmentIntf, response *core.DetailedResponse, err error) { + return vpc.GetBareMetalServerNetworkAttachmentWithContext(context.Background(), getBareMetalServerNetworkAttachmentOptions) } -// GetPlacementGroupWithContext is an alternate form of the GetPlacementGroup method which supports a Context parameter -func (vpc *VpcV1) GetPlacementGroupWithContext(ctx context.Context, getPlacementGroupOptions *GetPlacementGroupOptions) (result *PlacementGroup, response *core.DetailedResponse, err error) { - err = core.ValidateNotNil(getPlacementGroupOptions, "getPlacementGroupOptions cannot be nil") +// GetBareMetalServerNetworkAttachmentWithContext is an alternate form of the GetBareMetalServerNetworkAttachment method which supports a Context parameter +func (vpc *VpcV1) GetBareMetalServerNetworkAttachmentWithContext(ctx context.Context, getBareMetalServerNetworkAttachmentOptions *GetBareMetalServerNetworkAttachmentOptions) (result BareMetalServerNetworkAttachmentIntf, response *core.DetailedResponse, err error) { + err = core.ValidateNotNil(getBareMetalServerNetworkAttachmentOptions, "getBareMetalServerNetworkAttachmentOptions cannot be nil") if err != nil { return } - err = core.ValidateStruct(getPlacementGroupOptions, "getPlacementGroupOptions") + err = core.ValidateStruct(getBareMetalServerNetworkAttachmentOptions, "getBareMetalServerNetworkAttachmentOptions") if err != nil { return } pathParamsMap := map[string]string{ - "id": *getPlacementGroupOptions.ID, + "bare_metal_server_id": *getBareMetalServerNetworkAttachmentOptions.BareMetalServerID, + "id": *getBareMetalServerNetworkAttachmentOptions.ID, } builder := core.NewRequestBuilder(core.GET) builder = builder.WithContext(ctx) builder.EnableGzipCompression = vpc.GetEnableGzipCompression() - _, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/placement_groups/{id}`, pathParamsMap) + _, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/bare_metal_servers/{bare_metal_server_id}/network_attachments/{id}`, pathParamsMap) if err != nil { return } - for headerName, headerValue := range getPlacementGroupOptions.Headers { + for headerName, headerValue := range getBareMetalServerNetworkAttachmentOptions.Headers { builder.AddHeader(headerName, headerValue) } - sdkHeaders := common.GetSdkHeaders("vpc", "V1", "GetPlacementGroup") + sdkHeaders := common.GetSdkHeaders("vpc", "V1", "GetBareMetalServerNetworkAttachment") for headerName, headerValue := range sdkHeaders { builder.AddHeader(headerName, headerValue) } @@ -11757,7 +11775,7 @@ func (vpc *VpcV1) GetPlacementGroupWithContext(ctx context.Context, getPlacement return } if rawResponse != nil { - err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalPlacementGroup) + err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalBareMetalServerNetworkAttachment) if err != nil { return } @@ -11767,41 +11785,43 @@ func (vpc *VpcV1) GetPlacementGroupWithContext(ctx context.Context, getPlacement return } -// UpdatePlacementGroup : Update a placement group -// This request updates a placement group with the information provided placement group patch. The placement group patch -// object is structured in the same way as a retrieved placement group and contains only the information to be updated. -func (vpc *VpcV1) UpdatePlacementGroup(updatePlacementGroupOptions *UpdatePlacementGroupOptions) (result *PlacementGroup, response *core.DetailedResponse, err error) { - return vpc.UpdatePlacementGroupWithContext(context.Background(), updatePlacementGroupOptions) +// UpdateBareMetalServerNetworkAttachment : Update a bare metal server network attachment +// This request updates a bare metal server network attachment with the information provided in a bare metal server +// network attachment patch object. The bare metal server network attachment patch object is structured in the same way +// as a retrieved bare metal server network attachment and contains only the information to be updated. +func (vpc *VpcV1) UpdateBareMetalServerNetworkAttachment(updateBareMetalServerNetworkAttachmentOptions *UpdateBareMetalServerNetworkAttachmentOptions) (result BareMetalServerNetworkAttachmentIntf, response *core.DetailedResponse, err error) { + return vpc.UpdateBareMetalServerNetworkAttachmentWithContext(context.Background(), updateBareMetalServerNetworkAttachmentOptions) } -// UpdatePlacementGroupWithContext is an alternate form of the UpdatePlacementGroup method which supports a Context parameter -func (vpc *VpcV1) UpdatePlacementGroupWithContext(ctx context.Context, updatePlacementGroupOptions *UpdatePlacementGroupOptions) (result *PlacementGroup, response *core.DetailedResponse, err error) { - err = core.ValidateNotNil(updatePlacementGroupOptions, "updatePlacementGroupOptions cannot be nil") +// UpdateBareMetalServerNetworkAttachmentWithContext is an alternate form of the UpdateBareMetalServerNetworkAttachment method which supports a Context parameter +func (vpc *VpcV1) UpdateBareMetalServerNetworkAttachmentWithContext(ctx context.Context, updateBareMetalServerNetworkAttachmentOptions *UpdateBareMetalServerNetworkAttachmentOptions) (result BareMetalServerNetworkAttachmentIntf, response *core.DetailedResponse, err error) { + err = core.ValidateNotNil(updateBareMetalServerNetworkAttachmentOptions, "updateBareMetalServerNetworkAttachmentOptions cannot be nil") if err != nil { return } - err = core.ValidateStruct(updatePlacementGroupOptions, "updatePlacementGroupOptions") + err = core.ValidateStruct(updateBareMetalServerNetworkAttachmentOptions, "updateBareMetalServerNetworkAttachmentOptions") if err != nil { return } pathParamsMap := map[string]string{ - "id": *updatePlacementGroupOptions.ID, + "bare_metal_server_id": *updateBareMetalServerNetworkAttachmentOptions.BareMetalServerID, + "id": *updateBareMetalServerNetworkAttachmentOptions.ID, } builder := core.NewRequestBuilder(core.PATCH) builder = builder.WithContext(ctx) builder.EnableGzipCompression = vpc.GetEnableGzipCompression() - _, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/placement_groups/{id}`, pathParamsMap) + _, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/bare_metal_servers/{bare_metal_server_id}/network_attachments/{id}`, pathParamsMap) if err != nil { return } - for headerName, headerValue := range updatePlacementGroupOptions.Headers { + for headerName, headerValue := range updateBareMetalServerNetworkAttachmentOptions.Headers { builder.AddHeader(headerName, headerValue) } - sdkHeaders := common.GetSdkHeaders("vpc", "V1", "UpdatePlacementGroup") + sdkHeaders := common.GetSdkHeaders("vpc", "V1", "UpdateBareMetalServerNetworkAttachment") for headerName, headerValue := range sdkHeaders { builder.AddHeader(headerName, headerValue) } @@ -11811,7 +11831,7 @@ func (vpc *VpcV1) UpdatePlacementGroupWithContext(ctx context.Context, updatePla builder.AddQuery("version", fmt.Sprint(*vpc.Version)) builder.AddQuery("generation", fmt.Sprint(*vpc.generation)) - _, err = builder.SetBodyContentJSON(updatePlacementGroupOptions.PlacementGroupPatch) + _, err = builder.SetBodyContentJSON(updateBareMetalServerNetworkAttachmentOptions.BareMetalServerNetworkAttachmentPatch) if err != nil { return } @@ -11827,7 +11847,7 @@ func (vpc *VpcV1) UpdatePlacementGroupWithContext(ctx context.Context, updatePla return } if rawResponse != nil { - err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalPlacementGroup) + err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalBareMetalServerNetworkAttachment) if err != nil { return } @@ -11837,34 +11857,47 @@ func (vpc *VpcV1) UpdatePlacementGroupWithContext(ctx context.Context, updatePla return } -// ListBareMetalServerProfiles : List all bare metal server profiles -// This request lists all [bare metal server -// profiles](https://cloud.ibm.com/docs/vpc?topic=vpc-bare-metal-servers-profile) available in the region. A bare metal -// server profile specifies the performance characteristics and pricing model for a bare metal server. -func (vpc *VpcV1) ListBareMetalServerProfiles(listBareMetalServerProfilesOptions *ListBareMetalServerProfilesOptions) (result *BareMetalServerProfileCollection, response *core.DetailedResponse, err error) { - return vpc.ListBareMetalServerProfilesWithContext(context.Background(), listBareMetalServerProfilesOptions) +// ListBareMetalServerNetworkInterfaces : List all network interfaces on a bare metal server +// This request lists all network interfaces on a bare metal server. A bare metal server network interface is an +// abstract representation of a network device and attaches a bare metal server to a single subnet. Each network +// interface on a bare metal server can attach to any subnet in the zone, including subnets that are already attached to +// the bare metal server. +// +// If this bare metal server has network attachments, each returned network interface is a [read-only +// representation](https://cloud.ibm.com/docs/vpc?topic=vpc-vni-about#vni-old-api-clients) of its corresponding network +// attachment and its attached virtual network interface. +func (vpc *VpcV1) ListBareMetalServerNetworkInterfaces(listBareMetalServerNetworkInterfacesOptions *ListBareMetalServerNetworkInterfacesOptions) (result *BareMetalServerNetworkInterfaceCollection, response *core.DetailedResponse, err error) { + return vpc.ListBareMetalServerNetworkInterfacesWithContext(context.Background(), listBareMetalServerNetworkInterfacesOptions) } -// ListBareMetalServerProfilesWithContext is an alternate form of the ListBareMetalServerProfiles method which supports a Context parameter -func (vpc *VpcV1) ListBareMetalServerProfilesWithContext(ctx context.Context, listBareMetalServerProfilesOptions *ListBareMetalServerProfilesOptions) (result *BareMetalServerProfileCollection, response *core.DetailedResponse, err error) { - err = core.ValidateStruct(listBareMetalServerProfilesOptions, "listBareMetalServerProfilesOptions") +// ListBareMetalServerNetworkInterfacesWithContext is an alternate form of the ListBareMetalServerNetworkInterfaces method which supports a Context parameter +func (vpc *VpcV1) ListBareMetalServerNetworkInterfacesWithContext(ctx context.Context, listBareMetalServerNetworkInterfacesOptions *ListBareMetalServerNetworkInterfacesOptions) (result *BareMetalServerNetworkInterfaceCollection, response *core.DetailedResponse, err error) { + err = core.ValidateNotNil(listBareMetalServerNetworkInterfacesOptions, "listBareMetalServerNetworkInterfacesOptions cannot be nil") + if err != nil { + return + } + err = core.ValidateStruct(listBareMetalServerNetworkInterfacesOptions, "listBareMetalServerNetworkInterfacesOptions") if err != nil { return } + pathParamsMap := map[string]string{ + "bare_metal_server_id": *listBareMetalServerNetworkInterfacesOptions.BareMetalServerID, + } + builder := core.NewRequestBuilder(core.GET) builder = builder.WithContext(ctx) builder.EnableGzipCompression = vpc.GetEnableGzipCompression() - _, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/bare_metal_server/profiles`, nil) + _, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/bare_metal_servers/{bare_metal_server_id}/network_interfaces`, pathParamsMap) if err != nil { return } - for headerName, headerValue := range listBareMetalServerProfilesOptions.Headers { + for headerName, headerValue := range listBareMetalServerNetworkInterfacesOptions.Headers { builder.AddHeader(headerName, headerValue) } - sdkHeaders := common.GetSdkHeaders("vpc", "V1", "ListBareMetalServerProfiles") + sdkHeaders := common.GetSdkHeaders("vpc", "V1", "ListBareMetalServerNetworkInterfaces") for headerName, headerValue := range sdkHeaders { builder.AddHeader(headerName, headerValue) } @@ -11872,11 +11905,11 @@ func (vpc *VpcV1) ListBareMetalServerProfilesWithContext(ctx context.Context, li builder.AddQuery("version", fmt.Sprint(*vpc.Version)) builder.AddQuery("generation", fmt.Sprint(*vpc.generation)) - if listBareMetalServerProfilesOptions.Start != nil { - builder.AddQuery("start", fmt.Sprint(*listBareMetalServerProfilesOptions.Start)) + if listBareMetalServerNetworkInterfacesOptions.Start != nil { + builder.AddQuery("start", fmt.Sprint(*listBareMetalServerNetworkInterfacesOptions.Start)) } - if listBareMetalServerProfilesOptions.Limit != nil { - builder.AddQuery("limit", fmt.Sprint(*listBareMetalServerProfilesOptions.Limit)) + if listBareMetalServerNetworkInterfacesOptions.Limit != nil { + builder.AddQuery("limit", fmt.Sprint(*listBareMetalServerNetworkInterfacesOptions.Limit)) } request, err := builder.Build() @@ -11890,7 +11923,7 @@ func (vpc *VpcV1) ListBareMetalServerProfilesWithContext(ctx context.Context, li return } if rawResponse != nil { - err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalBareMetalServerProfileCollection) + err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalBareMetalServerNetworkInterfaceCollection) if err != nil { return } @@ -11900,48 +11933,62 @@ func (vpc *VpcV1) ListBareMetalServerProfilesWithContext(ctx context.Context, li return } -// GetBareMetalServerProfile : Retrieve a bare metal server profile -// This request retrieves a single bare metal server profile specified by the name in the URL. -func (vpc *VpcV1) GetBareMetalServerProfile(getBareMetalServerProfileOptions *GetBareMetalServerProfileOptions) (result *BareMetalServerProfile, response *core.DetailedResponse, err error) { - return vpc.GetBareMetalServerProfileWithContext(context.Background(), getBareMetalServerProfileOptions) +// CreateBareMetalServerNetworkInterface : Create a network interface on a bare metal server +// This request creates a new bare metal server network interface from a bare metal server network interface prototype +// object. The prototype object is structured in the same way as a retrieved bare metal server network interface, and +// contains the information necessary to create the new bare metal server network interface. Any subnet in the bare +// metal server's VPC may be specified, even if it is already attached to another bare metal server network interface. +// Addresses on the bare metal server network interface must be within the specified subnet's CIDR blocks. +// +// If this bare metal server has network attachments, each network interface is a [read-only +// representation](https://cloud.ibm.com/docs/vpc?topic=vpc-vni-about#vni-old-api-clients) of its corresponding network +// attachment and its attached virtual network interface, and new network interfaces are not allowed to be created. +func (vpc *VpcV1) CreateBareMetalServerNetworkInterface(createBareMetalServerNetworkInterfaceOptions *CreateBareMetalServerNetworkInterfaceOptions) (result BareMetalServerNetworkInterfaceIntf, response *core.DetailedResponse, err error) { + return vpc.CreateBareMetalServerNetworkInterfaceWithContext(context.Background(), createBareMetalServerNetworkInterfaceOptions) } -// GetBareMetalServerProfileWithContext is an alternate form of the GetBareMetalServerProfile method which supports a Context parameter -func (vpc *VpcV1) GetBareMetalServerProfileWithContext(ctx context.Context, getBareMetalServerProfileOptions *GetBareMetalServerProfileOptions) (result *BareMetalServerProfile, response *core.DetailedResponse, err error) { - err = core.ValidateNotNil(getBareMetalServerProfileOptions, "getBareMetalServerProfileOptions cannot be nil") +// CreateBareMetalServerNetworkInterfaceWithContext is an alternate form of the CreateBareMetalServerNetworkInterface method which supports a Context parameter +func (vpc *VpcV1) CreateBareMetalServerNetworkInterfaceWithContext(ctx context.Context, createBareMetalServerNetworkInterfaceOptions *CreateBareMetalServerNetworkInterfaceOptions) (result BareMetalServerNetworkInterfaceIntf, response *core.DetailedResponse, err error) { + err = core.ValidateNotNil(createBareMetalServerNetworkInterfaceOptions, "createBareMetalServerNetworkInterfaceOptions cannot be nil") if err != nil { return } - err = core.ValidateStruct(getBareMetalServerProfileOptions, "getBareMetalServerProfileOptions") + err = core.ValidateStruct(createBareMetalServerNetworkInterfaceOptions, "createBareMetalServerNetworkInterfaceOptions") if err != nil { return } pathParamsMap := map[string]string{ - "name": *getBareMetalServerProfileOptions.Name, + "bare_metal_server_id": *createBareMetalServerNetworkInterfaceOptions.BareMetalServerID, } - builder := core.NewRequestBuilder(core.GET) + builder := core.NewRequestBuilder(core.POST) builder = builder.WithContext(ctx) builder.EnableGzipCompression = vpc.GetEnableGzipCompression() - _, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/bare_metal_server/profiles/{name}`, pathParamsMap) + _, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/bare_metal_servers/{bare_metal_server_id}/network_interfaces`, pathParamsMap) if err != nil { return } - for headerName, headerValue := range getBareMetalServerProfileOptions.Headers { + for headerName, headerValue := range createBareMetalServerNetworkInterfaceOptions.Headers { builder.AddHeader(headerName, headerValue) } - sdkHeaders := common.GetSdkHeaders("vpc", "V1", "GetBareMetalServerProfile") + sdkHeaders := common.GetSdkHeaders("vpc", "V1", "CreateBareMetalServerNetworkInterface") for headerName, headerValue := range sdkHeaders { builder.AddHeader(headerName, headerValue) } builder.AddHeader("Accept", "application/json") + builder.AddHeader("Content-Type", "application/json") builder.AddQuery("version", fmt.Sprint(*vpc.Version)) builder.AddQuery("generation", fmt.Sprint(*vpc.generation)) + _, err = builder.SetBodyContentJSON(createBareMetalServerNetworkInterfaceOptions.BareMetalServerNetworkInterfacePrototype) + if err != nil { + return + } + request, err := builder.Build() if err != nil { return @@ -11953,7 +12000,7 @@ func (vpc *VpcV1) GetBareMetalServerProfileWithContext(ctx context.Context, getB return } if rawResponse != nil { - err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalBareMetalServerProfile) + err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalBareMetalServerNetworkInterface) if err != nil { return } @@ -11963,128 +12010,111 @@ func (vpc *VpcV1) GetBareMetalServerProfileWithContext(ctx context.Context, getB return } -// ListBareMetalServers : List all bare metal servers -// This request lists all bare metal servers in the region. -func (vpc *VpcV1) ListBareMetalServers(listBareMetalServersOptions *ListBareMetalServersOptions) (result *BareMetalServerCollection, response *core.DetailedResponse, err error) { - return vpc.ListBareMetalServersWithContext(context.Background(), listBareMetalServersOptions) +// DeleteBareMetalServerNetworkInterface : Delete a bare metal server network interface +// This request deletes a bare metal server network interface. This operation cannot be reversed. Any floating IPs +// associated with the bare metal server network interface are implicitly disassociated. The primary bare metal server +// network interface is not allowed to be deleted. +// +// If this bare metal server has network attachments, this network interface is a [read-only +// representation](https://cloud.ibm.com/docs/vpc?topic=vpc-vni-about#vni-old-api-clients) of its corresponding network +// attachment and its attached virtual network interface, and is not allowed to be deleted. +func (vpc *VpcV1) DeleteBareMetalServerNetworkInterface(deleteBareMetalServerNetworkInterfaceOptions *DeleteBareMetalServerNetworkInterfaceOptions) (response *core.DetailedResponse, err error) { + return vpc.DeleteBareMetalServerNetworkInterfaceWithContext(context.Background(), deleteBareMetalServerNetworkInterfaceOptions) } -// ListBareMetalServersWithContext is an alternate form of the ListBareMetalServers method which supports a Context parameter -func (vpc *VpcV1) ListBareMetalServersWithContext(ctx context.Context, listBareMetalServersOptions *ListBareMetalServersOptions) (result *BareMetalServerCollection, response *core.DetailedResponse, err error) { - err = core.ValidateStruct(listBareMetalServersOptions, "listBareMetalServersOptions") +// DeleteBareMetalServerNetworkInterfaceWithContext is an alternate form of the DeleteBareMetalServerNetworkInterface method which supports a Context parameter +func (vpc *VpcV1) DeleteBareMetalServerNetworkInterfaceWithContext(ctx context.Context, deleteBareMetalServerNetworkInterfaceOptions *DeleteBareMetalServerNetworkInterfaceOptions) (response *core.DetailedResponse, err error) { + err = core.ValidateNotNil(deleteBareMetalServerNetworkInterfaceOptions, "deleteBareMetalServerNetworkInterfaceOptions cannot be nil") + if err != nil { + return + } + err = core.ValidateStruct(deleteBareMetalServerNetworkInterfaceOptions, "deleteBareMetalServerNetworkInterfaceOptions") if err != nil { return } - builder := core.NewRequestBuilder(core.GET) + pathParamsMap := map[string]string{ + "bare_metal_server_id": *deleteBareMetalServerNetworkInterfaceOptions.BareMetalServerID, + "id": *deleteBareMetalServerNetworkInterfaceOptions.ID, + } + + builder := core.NewRequestBuilder(core.DELETE) builder = builder.WithContext(ctx) builder.EnableGzipCompression = vpc.GetEnableGzipCompression() - _, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/bare_metal_servers`, nil) + _, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/bare_metal_servers/{bare_metal_server_id}/network_interfaces/{id}`, pathParamsMap) if err != nil { return } - for headerName, headerValue := range listBareMetalServersOptions.Headers { + for headerName, headerValue := range deleteBareMetalServerNetworkInterfaceOptions.Headers { builder.AddHeader(headerName, headerValue) } - sdkHeaders := common.GetSdkHeaders("vpc", "V1", "ListBareMetalServers") + sdkHeaders := common.GetSdkHeaders("vpc", "V1", "DeleteBareMetalServerNetworkInterface") 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 listBareMetalServersOptions.Start != nil { - builder.AddQuery("start", fmt.Sprint(*listBareMetalServersOptions.Start)) - } - if listBareMetalServersOptions.Limit != nil { - builder.AddQuery("limit", fmt.Sprint(*listBareMetalServersOptions.Limit)) - } - if listBareMetalServersOptions.ResourceGroupID != nil { - builder.AddQuery("resource_group.id", fmt.Sprint(*listBareMetalServersOptions.ResourceGroupID)) - } - if listBareMetalServersOptions.Name != nil { - builder.AddQuery("name", fmt.Sprint(*listBareMetalServersOptions.Name)) - } - if listBareMetalServersOptions.VPCID != nil { - builder.AddQuery("vpc.id", fmt.Sprint(*listBareMetalServersOptions.VPCID)) - } - if listBareMetalServersOptions.VPCCRN != nil { - builder.AddQuery("vpc.crn", fmt.Sprint(*listBareMetalServersOptions.VPCCRN)) - } - if listBareMetalServersOptions.VPCName != nil { - builder.AddQuery("vpc.name", fmt.Sprint(*listBareMetalServersOptions.VPCName)) - } 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, UnmarshalBareMetalServerCollection) - if err != nil { - return - } - response.Result = result - } + response, err = vpc.Service.Request(request, nil) return } -// CreateBareMetalServer : Create a bare metal server -// This request provisions a new bare metal server from a prototype object. The prototype object is structured in the -// same way as a retrieved bare metal server, and contains the information necessary to provision the new bare metal -// server. The bare metal server is automatically started. -func (vpc *VpcV1) CreateBareMetalServer(createBareMetalServerOptions *CreateBareMetalServerOptions) (result *BareMetalServer, response *core.DetailedResponse, err error) { - return vpc.CreateBareMetalServerWithContext(context.Background(), createBareMetalServerOptions) +// GetBareMetalServerNetworkInterface : Retrieve a bare metal server network interface +// This request retrieves a single bare metal server network interface specified by the identifier in the URL. +// +// If this bare metal server has network attachments, the retrieved network interface is a [read-only +// representation](https://cloud.ibm.com/docs/vpc?topic=vpc-vni-about#vni-old-api-clients) of its corresponding network +// attachment and its attached virtual network interface. +func (vpc *VpcV1) GetBareMetalServerNetworkInterface(getBareMetalServerNetworkInterfaceOptions *GetBareMetalServerNetworkInterfaceOptions) (result BareMetalServerNetworkInterfaceIntf, response *core.DetailedResponse, err error) { + return vpc.GetBareMetalServerNetworkInterfaceWithContext(context.Background(), getBareMetalServerNetworkInterfaceOptions) } -// CreateBareMetalServerWithContext is an alternate form of the CreateBareMetalServer method which supports a Context parameter -func (vpc *VpcV1) CreateBareMetalServerWithContext(ctx context.Context, createBareMetalServerOptions *CreateBareMetalServerOptions) (result *BareMetalServer, response *core.DetailedResponse, err error) { - err = core.ValidateNotNil(createBareMetalServerOptions, "createBareMetalServerOptions cannot be nil") +// GetBareMetalServerNetworkInterfaceWithContext is an alternate form of the GetBareMetalServerNetworkInterface method which supports a Context parameter +func (vpc *VpcV1) GetBareMetalServerNetworkInterfaceWithContext(ctx context.Context, getBareMetalServerNetworkInterfaceOptions *GetBareMetalServerNetworkInterfaceOptions) (result BareMetalServerNetworkInterfaceIntf, response *core.DetailedResponse, err error) { + err = core.ValidateNotNil(getBareMetalServerNetworkInterfaceOptions, "getBareMetalServerNetworkInterfaceOptions cannot be nil") if err != nil { return } - err = core.ValidateStruct(createBareMetalServerOptions, "createBareMetalServerOptions") + err = core.ValidateStruct(getBareMetalServerNetworkInterfaceOptions, "getBareMetalServerNetworkInterfaceOptions") if err != nil { return } - builder := core.NewRequestBuilder(core.POST) + pathParamsMap := map[string]string{ + "bare_metal_server_id": *getBareMetalServerNetworkInterfaceOptions.BareMetalServerID, + "id": *getBareMetalServerNetworkInterfaceOptions.ID, + } + + builder := core.NewRequestBuilder(core.GET) builder = builder.WithContext(ctx) builder.EnableGzipCompression = vpc.GetEnableGzipCompression() - _, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/bare_metal_servers`, nil) + _, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/bare_metal_servers/{bare_metal_server_id}/network_interfaces/{id}`, pathParamsMap) if err != nil { return } - for headerName, headerValue := range createBareMetalServerOptions.Headers { + for headerName, headerValue := range getBareMetalServerNetworkInterfaceOptions.Headers { builder.AddHeader(headerName, headerValue) } - sdkHeaders := common.GetSdkHeaders("vpc", "V1", "CreateBareMetalServer") + sdkHeaders := common.GetSdkHeaders("vpc", "V1", "GetBareMetalServerNetworkInterface") for headerName, headerValue := range sdkHeaders { builder.AddHeader(headerName, headerValue) } builder.AddHeader("Accept", "application/json") - builder.AddHeader("Content-Type", "application/json") builder.AddQuery("version", fmt.Sprint(*vpc.Version)) builder.AddQuery("generation", fmt.Sprint(*vpc.generation)) - _, err = builder.SetBodyContentJSON(createBareMetalServerOptions.BareMetalServerPrototype) - if err != nil { - return - } - request, err := builder.Build() if err != nil { return @@ -12096,7 +12126,7 @@ func (vpc *VpcV1) CreateBareMetalServerWithContext(ctx context.Context, createBa return } if rawResponse != nil { - err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalBareMetalServer) + err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalBareMetalServerNetworkInterface) if err != nil { return } @@ -12106,60 +12136,57 @@ func (vpc *VpcV1) CreateBareMetalServerWithContext(ctx context.Context, createBa return } -// CreateBareMetalServerConsoleAccessToken : Create a console access token for a bare metal server -// This request creates a new single-use console access token for a bare metal server. All console configuration is -// provided at token create time, and the token is subsequently used in the `access_token` query parameter for the -// WebSocket request. The access token is only valid for a short period of time, and a maximum of one token is valid -// for a given bare metal server at a time. -func (vpc *VpcV1) CreateBareMetalServerConsoleAccessToken(createBareMetalServerConsoleAccessTokenOptions *CreateBareMetalServerConsoleAccessTokenOptions) (result *BareMetalServerConsoleAccessToken, response *core.DetailedResponse, err error) { - return vpc.CreateBareMetalServerConsoleAccessTokenWithContext(context.Background(), createBareMetalServerConsoleAccessTokenOptions) +// UpdateBareMetalServerNetworkInterface : Update a bare metal server network interface +// This request updates a bare metal server network interface with the information provided in a bare metal server +// network interface patch object. The bare metal server network interface patch object is structured in the same way as +// a retrieved bare metal server network interface and needs to contain only the information to be updated. +// +// If this bare metal server has network attachments, this network interface is a [read-only +// representation](https://cloud.ibm.com/docs/vpc?topic=vpc-vni-about#vni-old-api-clients) of its corresponding network +// attachment and its attached virtual network interface, and is not allowed to be updated. +func (vpc *VpcV1) UpdateBareMetalServerNetworkInterface(updateBareMetalServerNetworkInterfaceOptions *UpdateBareMetalServerNetworkInterfaceOptions) (result BareMetalServerNetworkInterfaceIntf, response *core.DetailedResponse, err error) { + return vpc.UpdateBareMetalServerNetworkInterfaceWithContext(context.Background(), updateBareMetalServerNetworkInterfaceOptions) } -// CreateBareMetalServerConsoleAccessTokenWithContext is an alternate form of the CreateBareMetalServerConsoleAccessToken method which supports a Context parameter -func (vpc *VpcV1) CreateBareMetalServerConsoleAccessTokenWithContext(ctx context.Context, createBareMetalServerConsoleAccessTokenOptions *CreateBareMetalServerConsoleAccessTokenOptions) (result *BareMetalServerConsoleAccessToken, response *core.DetailedResponse, err error) { - err = core.ValidateNotNil(createBareMetalServerConsoleAccessTokenOptions, "createBareMetalServerConsoleAccessTokenOptions cannot be nil") +// UpdateBareMetalServerNetworkInterfaceWithContext is an alternate form of the UpdateBareMetalServerNetworkInterface method which supports a Context parameter +func (vpc *VpcV1) UpdateBareMetalServerNetworkInterfaceWithContext(ctx context.Context, updateBareMetalServerNetworkInterfaceOptions *UpdateBareMetalServerNetworkInterfaceOptions) (result BareMetalServerNetworkInterfaceIntf, response *core.DetailedResponse, err error) { + err = core.ValidateNotNil(updateBareMetalServerNetworkInterfaceOptions, "updateBareMetalServerNetworkInterfaceOptions cannot be nil") if err != nil { return } - err = core.ValidateStruct(createBareMetalServerConsoleAccessTokenOptions, "createBareMetalServerConsoleAccessTokenOptions") + err = core.ValidateStruct(updateBareMetalServerNetworkInterfaceOptions, "updateBareMetalServerNetworkInterfaceOptions") if err != nil { return } pathParamsMap := map[string]string{ - "bare_metal_server_id": *createBareMetalServerConsoleAccessTokenOptions.BareMetalServerID, + "bare_metal_server_id": *updateBareMetalServerNetworkInterfaceOptions.BareMetalServerID, + "id": *updateBareMetalServerNetworkInterfaceOptions.ID, } - builder := core.NewRequestBuilder(core.POST) + builder := core.NewRequestBuilder(core.PATCH) builder = builder.WithContext(ctx) builder.EnableGzipCompression = vpc.GetEnableGzipCompression() - _, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/bare_metal_servers/{bare_metal_server_id}/console_access_token`, pathParamsMap) + _, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/bare_metal_servers/{bare_metal_server_id}/network_interfaces/{id}`, pathParamsMap) if err != nil { return } - for headerName, headerValue := range createBareMetalServerConsoleAccessTokenOptions.Headers { + for headerName, headerValue := range updateBareMetalServerNetworkInterfaceOptions.Headers { builder.AddHeader(headerName, headerValue) } - sdkHeaders := common.GetSdkHeaders("vpc", "V1", "CreateBareMetalServerConsoleAccessToken") + sdkHeaders := common.GetSdkHeaders("vpc", "V1", "UpdateBareMetalServerNetworkInterface") for headerName, headerValue := range sdkHeaders { builder.AddHeader(headerName, headerValue) } builder.AddHeader("Accept", "application/json") - builder.AddHeader("Content-Type", "application/json") + builder.AddHeader("Content-Type", "application/merge-patch+json") builder.AddQuery("version", fmt.Sprint(*vpc.Version)) builder.AddQuery("generation", fmt.Sprint(*vpc.generation)) - body := make(map[string]interface{}) - if createBareMetalServerConsoleAccessTokenOptions.ConsoleType != nil { - body["console_type"] = createBareMetalServerConsoleAccessTokenOptions.ConsoleType - } - if createBareMetalServerConsoleAccessTokenOptions.Force != nil { - body["force"] = createBareMetalServerConsoleAccessTokenOptions.Force - } - _, err = builder.SetBodyContentJSON(body) + _, err = builder.SetBodyContentJSON(updateBareMetalServerNetworkInterfaceOptions.BareMetalServerNetworkInterfacePatch) if err != nil { return } @@ -12175,7 +12202,7 @@ func (vpc *VpcV1) CreateBareMetalServerConsoleAccessTokenWithContext(ctx context return } if rawResponse != nil { - err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalBareMetalServerConsoleAccessToken) + err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalBareMetalServerNetworkInterface) if err != nil { return } @@ -12185,42 +12212,41 @@ func (vpc *VpcV1) CreateBareMetalServerConsoleAccessTokenWithContext(ctx context return } -// ListBareMetalServerDisks : List all disks on a bare metal server -// This request lists all disks on a bare metal server. A disk is a block device that is locally attached to the -// physical server. By default, the listed disks are sorted by their `created_at` property values, with the newest disk -// first. -func (vpc *VpcV1) ListBareMetalServerDisks(listBareMetalServerDisksOptions *ListBareMetalServerDisksOptions) (result *BareMetalServerDiskCollection, response *core.DetailedResponse, err error) { - return vpc.ListBareMetalServerDisksWithContext(context.Background(), listBareMetalServerDisksOptions) -} +// ListBareMetalServerNetworkInterfaceFloatingIps : List all floating IPs associated with a bare metal server network interface +// This request lists all floating IPs associated with a bare metal server network interface. +func (vpc *VpcV1) ListBareMetalServerNetworkInterfaceFloatingIps(listBareMetalServerNetworkInterfaceFloatingIpsOptions *ListBareMetalServerNetworkInterfaceFloatingIpsOptions) (result *FloatingIPUnpaginatedCollection, response *core.DetailedResponse, err error) { + return vpc.ListBareMetalServerNetworkInterfaceFloatingIpsWithContext(context.Background(), listBareMetalServerNetworkInterfaceFloatingIpsOptions) +} -// ListBareMetalServerDisksWithContext is an alternate form of the ListBareMetalServerDisks method which supports a Context parameter -func (vpc *VpcV1) ListBareMetalServerDisksWithContext(ctx context.Context, listBareMetalServerDisksOptions *ListBareMetalServerDisksOptions) (result *BareMetalServerDiskCollection, response *core.DetailedResponse, err error) { - err = core.ValidateNotNil(listBareMetalServerDisksOptions, "listBareMetalServerDisksOptions cannot be nil") +// ListBareMetalServerNetworkInterfaceFloatingIpsWithContext is an alternate form of the ListBareMetalServerNetworkInterfaceFloatingIps method which supports a Context parameter +func (vpc *VpcV1) ListBareMetalServerNetworkInterfaceFloatingIpsWithContext(ctx context.Context, listBareMetalServerNetworkInterfaceFloatingIpsOptions *ListBareMetalServerNetworkInterfaceFloatingIpsOptions) (result *FloatingIPUnpaginatedCollection, response *core.DetailedResponse, err error) { + err = core.ValidateNotNil(listBareMetalServerNetworkInterfaceFloatingIpsOptions, "listBareMetalServerNetworkInterfaceFloatingIpsOptions cannot be nil") if err != nil { return } - err = core.ValidateStruct(listBareMetalServerDisksOptions, "listBareMetalServerDisksOptions") + err = core.ValidateStruct(listBareMetalServerNetworkInterfaceFloatingIpsOptions, "listBareMetalServerNetworkInterfaceFloatingIpsOptions") if err != nil { return } pathParamsMap := map[string]string{ - "bare_metal_server_id": *listBareMetalServerDisksOptions.BareMetalServerID, + "bare_metal_server_id": *listBareMetalServerNetworkInterfaceFloatingIpsOptions.BareMetalServerID, + "network_interface_id": *listBareMetalServerNetworkInterfaceFloatingIpsOptions.NetworkInterfaceID, } builder := core.NewRequestBuilder(core.GET) builder = builder.WithContext(ctx) builder.EnableGzipCompression = vpc.GetEnableGzipCompression() - _, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/bare_metal_servers/{bare_metal_server_id}/disks`, pathParamsMap) + _, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/bare_metal_servers/{bare_metal_server_id}/network_interfaces/{network_interface_id}/floating_ips`, pathParamsMap) if err != nil { return } - for headerName, headerValue := range listBareMetalServerDisksOptions.Headers { + for headerName, headerValue := range listBareMetalServerNetworkInterfaceFloatingIpsOptions.Headers { builder.AddHeader(headerName, headerValue) } - sdkHeaders := common.GetSdkHeaders("vpc", "V1", "ListBareMetalServerDisks") + sdkHeaders := common.GetSdkHeaders("vpc", "V1", "ListBareMetalServerNetworkInterfaceFloatingIps") for headerName, headerValue := range sdkHeaders { builder.AddHeader(headerName, headerValue) } @@ -12240,7 +12266,7 @@ func (vpc *VpcV1) ListBareMetalServerDisksWithContext(ctx context.Context, listB return } if rawResponse != nil { - err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalBareMetalServerDiskCollection) + err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalFloatingIPUnpaginatedCollection) if err != nil { return } @@ -12250,41 +12276,96 @@ func (vpc *VpcV1) ListBareMetalServerDisksWithContext(ctx context.Context, listB return } -// GetBareMetalServerDisk : Retrieve a bare metal server disk -// This request retrieves a single disk specified by the identifier in the URL. -func (vpc *VpcV1) GetBareMetalServerDisk(getBareMetalServerDiskOptions *GetBareMetalServerDiskOptions) (result *BareMetalServerDisk, response *core.DetailedResponse, err error) { - return vpc.GetBareMetalServerDiskWithContext(context.Background(), getBareMetalServerDiskOptions) +// RemoveBareMetalServerNetworkInterfaceFloatingIP : Disassociate a floating IP from a bare metal server network interface +// This request disassociates the specified floating IP from the specified bare metal server network interface. +func (vpc *VpcV1) RemoveBareMetalServerNetworkInterfaceFloatingIP(removeBareMetalServerNetworkInterfaceFloatingIPOptions *RemoveBareMetalServerNetworkInterfaceFloatingIPOptions) (response *core.DetailedResponse, err error) { + return vpc.RemoveBareMetalServerNetworkInterfaceFloatingIPWithContext(context.Background(), removeBareMetalServerNetworkInterfaceFloatingIPOptions) } -// GetBareMetalServerDiskWithContext is an alternate form of the GetBareMetalServerDisk method which supports a Context parameter -func (vpc *VpcV1) GetBareMetalServerDiskWithContext(ctx context.Context, getBareMetalServerDiskOptions *GetBareMetalServerDiskOptions) (result *BareMetalServerDisk, response *core.DetailedResponse, err error) { - err = core.ValidateNotNil(getBareMetalServerDiskOptions, "getBareMetalServerDiskOptions cannot be nil") +// RemoveBareMetalServerNetworkInterfaceFloatingIPWithContext is an alternate form of the RemoveBareMetalServerNetworkInterfaceFloatingIP method which supports a Context parameter +func (vpc *VpcV1) RemoveBareMetalServerNetworkInterfaceFloatingIPWithContext(ctx context.Context, removeBareMetalServerNetworkInterfaceFloatingIPOptions *RemoveBareMetalServerNetworkInterfaceFloatingIPOptions) (response *core.DetailedResponse, err error) { + err = core.ValidateNotNil(removeBareMetalServerNetworkInterfaceFloatingIPOptions, "removeBareMetalServerNetworkInterfaceFloatingIPOptions cannot be nil") if err != nil { return } - err = core.ValidateStruct(getBareMetalServerDiskOptions, "getBareMetalServerDiskOptions") + err = core.ValidateStruct(removeBareMetalServerNetworkInterfaceFloatingIPOptions, "removeBareMetalServerNetworkInterfaceFloatingIPOptions") if err != nil { return } pathParamsMap := map[string]string{ - "bare_metal_server_id": *getBareMetalServerDiskOptions.BareMetalServerID, - "id": *getBareMetalServerDiskOptions.ID, + "bare_metal_server_id": *removeBareMetalServerNetworkInterfaceFloatingIPOptions.BareMetalServerID, + "network_interface_id": *removeBareMetalServerNetworkInterfaceFloatingIPOptions.NetworkInterfaceID, + "id": *removeBareMetalServerNetworkInterfaceFloatingIPOptions.ID, + } + + builder := core.NewRequestBuilder(core.DELETE) + builder = builder.WithContext(ctx) + builder.EnableGzipCompression = vpc.GetEnableGzipCompression() + _, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/bare_metal_servers/{bare_metal_server_id}/network_interfaces/{network_interface_id}/floating_ips/{id}`, pathParamsMap) + if err != nil { + return + } + + for headerName, headerValue := range removeBareMetalServerNetworkInterfaceFloatingIPOptions.Headers { + builder.AddHeader(headerName, headerValue) + } + + sdkHeaders := common.GetSdkHeaders("vpc", "V1", "RemoveBareMetalServerNetworkInterfaceFloatingIP") + for headerName, headerValue := range sdkHeaders { + builder.AddHeader(headerName, headerValue) + } + + builder.AddQuery("version", fmt.Sprint(*vpc.Version)) + builder.AddQuery("generation", fmt.Sprint(*vpc.generation)) + + request, err := builder.Build() + if err != nil { + return + } + + response, err = vpc.Service.Request(request, nil) + + return +} + +// GetBareMetalServerNetworkInterfaceFloatingIP : Retrieve associated floating IP +// This request retrieves a specified floating IP if it is associated with the bare metal server network interface +// specified in the URL. +func (vpc *VpcV1) GetBareMetalServerNetworkInterfaceFloatingIP(getBareMetalServerNetworkInterfaceFloatingIPOptions *GetBareMetalServerNetworkInterfaceFloatingIPOptions) (result *FloatingIP, response *core.DetailedResponse, err error) { + return vpc.GetBareMetalServerNetworkInterfaceFloatingIPWithContext(context.Background(), getBareMetalServerNetworkInterfaceFloatingIPOptions) +} + +// GetBareMetalServerNetworkInterfaceFloatingIPWithContext is an alternate form of the GetBareMetalServerNetworkInterfaceFloatingIP method which supports a Context parameter +func (vpc *VpcV1) GetBareMetalServerNetworkInterfaceFloatingIPWithContext(ctx context.Context, getBareMetalServerNetworkInterfaceFloatingIPOptions *GetBareMetalServerNetworkInterfaceFloatingIPOptions) (result *FloatingIP, response *core.DetailedResponse, err error) { + err = core.ValidateNotNil(getBareMetalServerNetworkInterfaceFloatingIPOptions, "getBareMetalServerNetworkInterfaceFloatingIPOptions cannot be nil") + if err != nil { + return + } + err = core.ValidateStruct(getBareMetalServerNetworkInterfaceFloatingIPOptions, "getBareMetalServerNetworkInterfaceFloatingIPOptions") + if err != nil { + return + } + + pathParamsMap := map[string]string{ + "bare_metal_server_id": *getBareMetalServerNetworkInterfaceFloatingIPOptions.BareMetalServerID, + "network_interface_id": *getBareMetalServerNetworkInterfaceFloatingIPOptions.NetworkInterfaceID, + "id": *getBareMetalServerNetworkInterfaceFloatingIPOptions.ID, } builder := core.NewRequestBuilder(core.GET) builder = builder.WithContext(ctx) builder.EnableGzipCompression = vpc.GetEnableGzipCompression() - _, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/bare_metal_servers/{bare_metal_server_id}/disks/{id}`, pathParamsMap) + _, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/bare_metal_servers/{bare_metal_server_id}/network_interfaces/{network_interface_id}/floating_ips/{id}`, pathParamsMap) if err != nil { return } - for headerName, headerValue := range getBareMetalServerDiskOptions.Headers { + for headerName, headerValue := range getBareMetalServerNetworkInterfaceFloatingIPOptions.Headers { builder.AddHeader(headerName, headerValue) } - sdkHeaders := common.GetSdkHeaders("vpc", "V1", "GetBareMetalServerDisk") + sdkHeaders := common.GetSdkHeaders("vpc", "V1", "GetBareMetalServerNetworkInterfaceFloatingIP") for headerName, headerValue := range sdkHeaders { builder.AddHeader(headerName, headerValue) } @@ -12304,7 +12385,7 @@ func (vpc *VpcV1) GetBareMetalServerDiskWithContext(ctx context.Context, getBare return } if rawResponse != nil { - err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalBareMetalServerDisk) + err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalFloatingIP) if err != nil { return } @@ -12314,55 +12395,58 @@ func (vpc *VpcV1) GetBareMetalServerDiskWithContext(ctx context.Context, getBare return } -// UpdateBareMetalServerDisk : Update a bare metal server disk -// This request updates the bare metal server disk with the information in a provided patch. -func (vpc *VpcV1) UpdateBareMetalServerDisk(updateBareMetalServerDiskOptions *UpdateBareMetalServerDiskOptions) (result *BareMetalServerDisk, response *core.DetailedResponse, err error) { - return vpc.UpdateBareMetalServerDiskWithContext(context.Background(), updateBareMetalServerDiskOptions) +// AddBareMetalServerNetworkInterfaceFloatingIP : Associate a floating IP with a bare metal server network interface +// This request associates the specified floating IP with the specified bare metal server network interface. If +// `enable_infrastructure_nat` is `false`, this adds the IP to any existing associations. If `enable_infrastructure_nat` +// is `true`, this replaces any existing association. +// +// The existing floating IP must: +// - not be required by another resource, such as a public gateway +// - be in the same `zone` as the bare metal server +// +// A request body is not required, and if provided, is ignored. +func (vpc *VpcV1) AddBareMetalServerNetworkInterfaceFloatingIP(addBareMetalServerNetworkInterfaceFloatingIPOptions *AddBareMetalServerNetworkInterfaceFloatingIPOptions) (result *FloatingIP, response *core.DetailedResponse, err error) { + return vpc.AddBareMetalServerNetworkInterfaceFloatingIPWithContext(context.Background(), addBareMetalServerNetworkInterfaceFloatingIPOptions) } -// UpdateBareMetalServerDiskWithContext is an alternate form of the UpdateBareMetalServerDisk method which supports a Context parameter -func (vpc *VpcV1) UpdateBareMetalServerDiskWithContext(ctx context.Context, updateBareMetalServerDiskOptions *UpdateBareMetalServerDiskOptions) (result *BareMetalServerDisk, response *core.DetailedResponse, err error) { - err = core.ValidateNotNil(updateBareMetalServerDiskOptions, "updateBareMetalServerDiskOptions cannot be nil") +// AddBareMetalServerNetworkInterfaceFloatingIPWithContext is an alternate form of the AddBareMetalServerNetworkInterfaceFloatingIP method which supports a Context parameter +func (vpc *VpcV1) AddBareMetalServerNetworkInterfaceFloatingIPWithContext(ctx context.Context, addBareMetalServerNetworkInterfaceFloatingIPOptions *AddBareMetalServerNetworkInterfaceFloatingIPOptions) (result *FloatingIP, response *core.DetailedResponse, err error) { + err = core.ValidateNotNil(addBareMetalServerNetworkInterfaceFloatingIPOptions, "addBareMetalServerNetworkInterfaceFloatingIPOptions cannot be nil") if err != nil { return } - err = core.ValidateStruct(updateBareMetalServerDiskOptions, "updateBareMetalServerDiskOptions") + err = core.ValidateStruct(addBareMetalServerNetworkInterfaceFloatingIPOptions, "addBareMetalServerNetworkInterfaceFloatingIPOptions") if err != nil { return } pathParamsMap := map[string]string{ - "bare_metal_server_id": *updateBareMetalServerDiskOptions.BareMetalServerID, - "id": *updateBareMetalServerDiskOptions.ID, + "bare_metal_server_id": *addBareMetalServerNetworkInterfaceFloatingIPOptions.BareMetalServerID, + "network_interface_id": *addBareMetalServerNetworkInterfaceFloatingIPOptions.NetworkInterfaceID, + "id": *addBareMetalServerNetworkInterfaceFloatingIPOptions.ID, } - builder := core.NewRequestBuilder(core.PATCH) + builder := core.NewRequestBuilder(core.PUT) builder = builder.WithContext(ctx) builder.EnableGzipCompression = vpc.GetEnableGzipCompression() - _, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/bare_metal_servers/{bare_metal_server_id}/disks/{id}`, pathParamsMap) + _, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/bare_metal_servers/{bare_metal_server_id}/network_interfaces/{network_interface_id}/floating_ips/{id}`, pathParamsMap) if err != nil { return } - for headerName, headerValue := range updateBareMetalServerDiskOptions.Headers { + for headerName, headerValue := range addBareMetalServerNetworkInterfaceFloatingIPOptions.Headers { builder.AddHeader(headerName, headerValue) } - sdkHeaders := common.GetSdkHeaders("vpc", "V1", "UpdateBareMetalServerDisk") + sdkHeaders := common.GetSdkHeaders("vpc", "V1", "AddBareMetalServerNetworkInterfaceFloatingIP") for headerName, headerValue := range sdkHeaders { builder.AddHeader(headerName, headerValue) } builder.AddHeader("Accept", "application/json") - builder.AddHeader("Content-Type", "application/merge-patch+json") builder.AddQuery("version", fmt.Sprint(*vpc.Version)) builder.AddQuery("generation", fmt.Sprint(*vpc.generation)) - _, err = builder.SetBodyContentJSON(updateBareMetalServerDiskOptions.BareMetalServerDiskPatch) - if err != nil { - return - } - request, err := builder.Build() if err != nil { return @@ -12374,7 +12458,7 @@ func (vpc *VpcV1) UpdateBareMetalServerDiskWithContext(ctx context.Context, upda return } if rawResponse != nil { - err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalBareMetalServerDisk) + err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalFloatingIP) if err != nil { return } @@ -12384,47 +12468,44 @@ func (vpc *VpcV1) UpdateBareMetalServerDiskWithContext(ctx context.Context, upda return } -// ListBareMetalServerNetworkAttachments : List all network attachments on a bare metal server -// This request lists all network attachments on a bare metal server. A bare metal server network attachment is an -// abstract representation of a network device and attaches a bare metal server to a single subnet. Each network -// interface on a bare metal server can attach to any subnet in the zone, including subnets that are already attached to -// the bare metal server. -// -// The network attachments will be sorted by their `created_at` property values, with newest network attachments first. -// Network attachments with identical `created_at` property values will in turn be sorted by ascending `name` property -// values. -func (vpc *VpcV1) ListBareMetalServerNetworkAttachments(listBareMetalServerNetworkAttachmentsOptions *ListBareMetalServerNetworkAttachmentsOptions) (result *BareMetalServerNetworkAttachmentCollection, response *core.DetailedResponse, err error) { - return vpc.ListBareMetalServerNetworkAttachmentsWithContext(context.Background(), listBareMetalServerNetworkAttachmentsOptions) +// ListBareMetalServerNetworkInterfaceIps : List the primary reserved IP for a bare metal server network interface +// This request lists the primary reserved IP for a bare metal server network interface. +// Deprecated: this method is deprecated and may be removed in a future release. +func (vpc *VpcV1) ListBareMetalServerNetworkInterfaceIps(listBareMetalServerNetworkInterfaceIpsOptions *ListBareMetalServerNetworkInterfaceIpsOptions) (result *ReservedIPCollectionBareMetalServerNetworkInterfaceContext, response *core.DetailedResponse, err error) { + return vpc.ListBareMetalServerNetworkInterfaceIpsWithContext(context.Background(), listBareMetalServerNetworkInterfaceIpsOptions) } -// ListBareMetalServerNetworkAttachmentsWithContext is an alternate form of the ListBareMetalServerNetworkAttachments method which supports a Context parameter -func (vpc *VpcV1) ListBareMetalServerNetworkAttachmentsWithContext(ctx context.Context, listBareMetalServerNetworkAttachmentsOptions *ListBareMetalServerNetworkAttachmentsOptions) (result *BareMetalServerNetworkAttachmentCollection, response *core.DetailedResponse, err error) { - err = core.ValidateNotNil(listBareMetalServerNetworkAttachmentsOptions, "listBareMetalServerNetworkAttachmentsOptions cannot be nil") +// ListBareMetalServerNetworkInterfaceIpsWithContext is an alternate form of the ListBareMetalServerNetworkInterfaceIps method which supports a Context parameter +// Deprecated: this method is deprecated and may be removed in a future release. +func (vpc *VpcV1) ListBareMetalServerNetworkInterfaceIpsWithContext(ctx context.Context, listBareMetalServerNetworkInterfaceIpsOptions *ListBareMetalServerNetworkInterfaceIpsOptions) (result *ReservedIPCollectionBareMetalServerNetworkInterfaceContext, response *core.DetailedResponse, err error) { + core.GetLogger().Warn("A deprecated operation has been invoked: ListBareMetalServerNetworkInterfaceIps") + err = core.ValidateNotNil(listBareMetalServerNetworkInterfaceIpsOptions, "listBareMetalServerNetworkInterfaceIpsOptions cannot be nil") if err != nil { return } - err = core.ValidateStruct(listBareMetalServerNetworkAttachmentsOptions, "listBareMetalServerNetworkAttachmentsOptions") + err = core.ValidateStruct(listBareMetalServerNetworkInterfaceIpsOptions, "listBareMetalServerNetworkInterfaceIpsOptions") if err != nil { return } pathParamsMap := map[string]string{ - "bare_metal_server_id": *listBareMetalServerNetworkAttachmentsOptions.BareMetalServerID, + "bare_metal_server_id": *listBareMetalServerNetworkInterfaceIpsOptions.BareMetalServerID, + "network_interface_id": *listBareMetalServerNetworkInterfaceIpsOptions.NetworkInterfaceID, } builder := core.NewRequestBuilder(core.GET) builder = builder.WithContext(ctx) builder.EnableGzipCompression = vpc.GetEnableGzipCompression() - _, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/bare_metal_servers/{bare_metal_server_id}/network_attachments`, pathParamsMap) + _, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/bare_metal_servers/{bare_metal_server_id}/network_interfaces/{network_interface_id}/ips`, pathParamsMap) if err != nil { return } - for headerName, headerValue := range listBareMetalServerNetworkAttachmentsOptions.Headers { + for headerName, headerValue := range listBareMetalServerNetworkInterfaceIpsOptions.Headers { builder.AddHeader(headerName, headerValue) } - sdkHeaders := common.GetSdkHeaders("vpc", "V1", "ListBareMetalServerNetworkAttachments") + sdkHeaders := common.GetSdkHeaders("vpc", "V1", "ListBareMetalServerNetworkInterfaceIps") for headerName, headerValue := range sdkHeaders { builder.AddHeader(headerName, headerValue) } @@ -12432,12 +12513,6 @@ func (vpc *VpcV1) ListBareMetalServerNetworkAttachmentsWithContext(ctx context.C builder.AddQuery("version", fmt.Sprint(*vpc.Version)) builder.AddQuery("generation", fmt.Sprint(*vpc.generation)) - if listBareMetalServerNetworkAttachmentsOptions.Start != nil { - builder.AddQuery("start", fmt.Sprint(*listBareMetalServerNetworkAttachmentsOptions.Start)) - } - if listBareMetalServerNetworkAttachmentsOptions.Limit != nil { - builder.AddQuery("limit", fmt.Sprint(*listBareMetalServerNetworkAttachmentsOptions.Limit)) - } request, err := builder.Build() if err != nil { @@ -12450,7 +12525,7 @@ func (vpc *VpcV1) ListBareMetalServerNetworkAttachmentsWithContext(ctx context.C return } if rawResponse != nil { - err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalBareMetalServerNetworkAttachmentCollection) + err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalReservedIPCollectionBareMetalServerNetworkInterfaceContext) if err != nil { return } @@ -12460,56 +12535,53 @@ func (vpc *VpcV1) ListBareMetalServerNetworkAttachmentsWithContext(ctx context.C return } -// CreateBareMetalServerNetworkAttachment : Create a network attachment on a bare metal server -// This request creates a new bare metal server network attachment from a bare metal server network attachment prototype -// object. The prototype object is structured in the same way as a retrieved bare metal server network attachment, and -// contains the information necessary to create the new bare metal server network attachment. -func (vpc *VpcV1) CreateBareMetalServerNetworkAttachment(createBareMetalServerNetworkAttachmentOptions *CreateBareMetalServerNetworkAttachmentOptions) (result BareMetalServerNetworkAttachmentIntf, response *core.DetailedResponse, err error) { - return vpc.CreateBareMetalServerNetworkAttachmentWithContext(context.Background(), createBareMetalServerNetworkAttachmentOptions) +// GetBareMetalServerNetworkInterfaceIP : Retrieve the primary reserved IP +// This request retrieves the primary reserved IP for a bare metal server network interface. +// Deprecated: this method is deprecated and may be removed in a future release. +func (vpc *VpcV1) GetBareMetalServerNetworkInterfaceIP(getBareMetalServerNetworkInterfaceIPOptions *GetBareMetalServerNetworkInterfaceIPOptions) (result *ReservedIP, response *core.DetailedResponse, err error) { + return vpc.GetBareMetalServerNetworkInterfaceIPWithContext(context.Background(), getBareMetalServerNetworkInterfaceIPOptions) } -// CreateBareMetalServerNetworkAttachmentWithContext is an alternate form of the CreateBareMetalServerNetworkAttachment method which supports a Context parameter -func (vpc *VpcV1) CreateBareMetalServerNetworkAttachmentWithContext(ctx context.Context, createBareMetalServerNetworkAttachmentOptions *CreateBareMetalServerNetworkAttachmentOptions) (result BareMetalServerNetworkAttachmentIntf, response *core.DetailedResponse, err error) { - err = core.ValidateNotNil(createBareMetalServerNetworkAttachmentOptions, "createBareMetalServerNetworkAttachmentOptions cannot be nil") +// GetBareMetalServerNetworkInterfaceIPWithContext is an alternate form of the GetBareMetalServerNetworkInterfaceIP method which supports a Context parameter +// Deprecated: this method is deprecated and may be removed in a future release. +func (vpc *VpcV1) GetBareMetalServerNetworkInterfaceIPWithContext(ctx context.Context, getBareMetalServerNetworkInterfaceIPOptions *GetBareMetalServerNetworkInterfaceIPOptions) (result *ReservedIP, response *core.DetailedResponse, err error) { + core.GetLogger().Warn("A deprecated operation has been invoked: GetBareMetalServerNetworkInterfaceIP") + err = core.ValidateNotNil(getBareMetalServerNetworkInterfaceIPOptions, "getBareMetalServerNetworkInterfaceIPOptions cannot be nil") if err != nil { return } - err = core.ValidateStruct(createBareMetalServerNetworkAttachmentOptions, "createBareMetalServerNetworkAttachmentOptions") + err = core.ValidateStruct(getBareMetalServerNetworkInterfaceIPOptions, "getBareMetalServerNetworkInterfaceIPOptions") if err != nil { return } pathParamsMap := map[string]string{ - "bare_metal_server_id": *createBareMetalServerNetworkAttachmentOptions.BareMetalServerID, + "bare_metal_server_id": *getBareMetalServerNetworkInterfaceIPOptions.BareMetalServerID, + "network_interface_id": *getBareMetalServerNetworkInterfaceIPOptions.NetworkInterfaceID, + "id": *getBareMetalServerNetworkInterfaceIPOptions.ID, } - builder := core.NewRequestBuilder(core.POST) + builder := core.NewRequestBuilder(core.GET) builder = builder.WithContext(ctx) builder.EnableGzipCompression = vpc.GetEnableGzipCompression() - _, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/bare_metal_servers/{bare_metal_server_id}/network_attachments`, pathParamsMap) + _, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/bare_metal_servers/{bare_metal_server_id}/network_interfaces/{network_interface_id}/ips/{id}`, pathParamsMap) if err != nil { return } - for headerName, headerValue := range createBareMetalServerNetworkAttachmentOptions.Headers { + for headerName, headerValue := range getBareMetalServerNetworkInterfaceIPOptions.Headers { builder.AddHeader(headerName, headerValue) } - sdkHeaders := common.GetSdkHeaders("vpc", "V1", "CreateBareMetalServerNetworkAttachment") + sdkHeaders := common.GetSdkHeaders("vpc", "V1", "GetBareMetalServerNetworkInterfaceIP") for headerName, headerValue := range sdkHeaders { builder.AddHeader(headerName, headerValue) } builder.AddHeader("Accept", "application/json") - builder.AddHeader("Content-Type", "application/json") builder.AddQuery("version", fmt.Sprint(*vpc.Version)) builder.AddQuery("generation", fmt.Sprint(*vpc.generation)) - _, err = builder.SetBodyContentJSON(createBareMetalServerNetworkAttachmentOptions.BareMetalServerNetworkAttachmentPrototype) - if err != nil { - return - } - request, err := builder.Build() if err != nil { return @@ -12521,7 +12593,7 @@ func (vpc *VpcV1) CreateBareMetalServerNetworkAttachmentWithContext(ctx context. return } if rawResponse != nil { - err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalBareMetalServerNetworkAttachment) + err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalReservedIP) if err != nil { return } @@ -12531,44 +12603,41 @@ func (vpc *VpcV1) CreateBareMetalServerNetworkAttachmentWithContext(ctx context. return } -// DeleteBareMetalServerNetworkAttachment : Delete a bare metal server network attachment -// This request deletes a bare metal server network attachment. This operation cannot be reversed. Any floating IPs -// associated with the bare metal server network attachment are implicitly disassociated. -// -// The bare metal server's primary network attachment cannot be deleted. -func (vpc *VpcV1) DeleteBareMetalServerNetworkAttachment(deleteBareMetalServerNetworkAttachmentOptions *DeleteBareMetalServerNetworkAttachmentOptions) (response *core.DetailedResponse, err error) { - return vpc.DeleteBareMetalServerNetworkAttachmentWithContext(context.Background(), deleteBareMetalServerNetworkAttachmentOptions) +// DeleteBareMetalServer : Delete a bare metal server +// This request deletes a bare metal server. This operation cannot be reversed. Any floating IPs associated with the +// bare metal server network interfaces are implicitly disassociated. +func (vpc *VpcV1) DeleteBareMetalServer(deleteBareMetalServerOptions *DeleteBareMetalServerOptions) (response *core.DetailedResponse, err error) { + return vpc.DeleteBareMetalServerWithContext(context.Background(), deleteBareMetalServerOptions) } -// DeleteBareMetalServerNetworkAttachmentWithContext is an alternate form of the DeleteBareMetalServerNetworkAttachment method which supports a Context parameter -func (vpc *VpcV1) DeleteBareMetalServerNetworkAttachmentWithContext(ctx context.Context, deleteBareMetalServerNetworkAttachmentOptions *DeleteBareMetalServerNetworkAttachmentOptions) (response *core.DetailedResponse, err error) { - err = core.ValidateNotNil(deleteBareMetalServerNetworkAttachmentOptions, "deleteBareMetalServerNetworkAttachmentOptions cannot be nil") +// DeleteBareMetalServerWithContext is an alternate form of the DeleteBareMetalServer method which supports a Context parameter +func (vpc *VpcV1) DeleteBareMetalServerWithContext(ctx context.Context, deleteBareMetalServerOptions *DeleteBareMetalServerOptions) (response *core.DetailedResponse, err error) { + err = core.ValidateNotNil(deleteBareMetalServerOptions, "deleteBareMetalServerOptions cannot be nil") if err != nil { return } - err = core.ValidateStruct(deleteBareMetalServerNetworkAttachmentOptions, "deleteBareMetalServerNetworkAttachmentOptions") + err = core.ValidateStruct(deleteBareMetalServerOptions, "deleteBareMetalServerOptions") if err != nil { return } pathParamsMap := map[string]string{ - "bare_metal_server_id": *deleteBareMetalServerNetworkAttachmentOptions.BareMetalServerID, - "id": *deleteBareMetalServerNetworkAttachmentOptions.ID, + "id": *deleteBareMetalServerOptions.ID, } builder := core.NewRequestBuilder(core.DELETE) builder = builder.WithContext(ctx) builder.EnableGzipCompression = vpc.GetEnableGzipCompression() - _, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/bare_metal_servers/{bare_metal_server_id}/network_attachments/{id}`, pathParamsMap) + _, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/bare_metal_servers/{id}`, pathParamsMap) if err != nil { return } - for headerName, headerValue := range deleteBareMetalServerNetworkAttachmentOptions.Headers { + for headerName, headerValue := range deleteBareMetalServerOptions.Headers { builder.AddHeader(headerName, headerValue) } - sdkHeaders := common.GetSdkHeaders("vpc", "V1", "DeleteBareMetalServerNetworkAttachment") + sdkHeaders := common.GetSdkHeaders("vpc", "V1", "DeleteBareMetalServer") for headerName, headerValue := range sdkHeaders { builder.AddHeader(headerName, headerValue) } @@ -12586,41 +12655,40 @@ func (vpc *VpcV1) DeleteBareMetalServerNetworkAttachmentWithContext(ctx context. return } -// GetBareMetalServerNetworkAttachment : Retrieve a bare metal server network attachment -// This request retrieves a single bare metal server network attachment specified by the identifier in the URL. -func (vpc *VpcV1) GetBareMetalServerNetworkAttachment(getBareMetalServerNetworkAttachmentOptions *GetBareMetalServerNetworkAttachmentOptions) (result BareMetalServerNetworkAttachmentIntf, response *core.DetailedResponse, err error) { - return vpc.GetBareMetalServerNetworkAttachmentWithContext(context.Background(), getBareMetalServerNetworkAttachmentOptions) +// GetBareMetalServer : Retrieve a bare metal server +// This request retrieves a single bare metal server specified by the identifier in the URL. +func (vpc *VpcV1) GetBareMetalServer(getBareMetalServerOptions *GetBareMetalServerOptions) (result *BareMetalServer, response *core.DetailedResponse, err error) { + return vpc.GetBareMetalServerWithContext(context.Background(), getBareMetalServerOptions) } -// GetBareMetalServerNetworkAttachmentWithContext is an alternate form of the GetBareMetalServerNetworkAttachment method which supports a Context parameter -func (vpc *VpcV1) GetBareMetalServerNetworkAttachmentWithContext(ctx context.Context, getBareMetalServerNetworkAttachmentOptions *GetBareMetalServerNetworkAttachmentOptions) (result BareMetalServerNetworkAttachmentIntf, response *core.DetailedResponse, err error) { - err = core.ValidateNotNil(getBareMetalServerNetworkAttachmentOptions, "getBareMetalServerNetworkAttachmentOptions cannot be nil") +// GetBareMetalServerWithContext is an alternate form of the GetBareMetalServer method which supports a Context parameter +func (vpc *VpcV1) GetBareMetalServerWithContext(ctx context.Context, getBareMetalServerOptions *GetBareMetalServerOptions) (result *BareMetalServer, response *core.DetailedResponse, err error) { + err = core.ValidateNotNil(getBareMetalServerOptions, "getBareMetalServerOptions cannot be nil") if err != nil { return } - err = core.ValidateStruct(getBareMetalServerNetworkAttachmentOptions, "getBareMetalServerNetworkAttachmentOptions") + err = core.ValidateStruct(getBareMetalServerOptions, "getBareMetalServerOptions") if err != nil { return } pathParamsMap := map[string]string{ - "bare_metal_server_id": *getBareMetalServerNetworkAttachmentOptions.BareMetalServerID, - "id": *getBareMetalServerNetworkAttachmentOptions.ID, + "id": *getBareMetalServerOptions.ID, } builder := core.NewRequestBuilder(core.GET) builder = builder.WithContext(ctx) builder.EnableGzipCompression = vpc.GetEnableGzipCompression() - _, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/bare_metal_servers/{bare_metal_server_id}/network_attachments/{id}`, pathParamsMap) + _, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/bare_metal_servers/{id}`, pathParamsMap) if err != nil { return } - for headerName, headerValue := range getBareMetalServerNetworkAttachmentOptions.Headers { + for headerName, headerValue := range getBareMetalServerOptions.Headers { builder.AddHeader(headerName, headerValue) } - sdkHeaders := common.GetSdkHeaders("vpc", "V1", "GetBareMetalServerNetworkAttachment") + sdkHeaders := common.GetSdkHeaders("vpc", "V1", "GetBareMetalServer") for headerName, headerValue := range sdkHeaders { builder.AddHeader(headerName, headerValue) } @@ -12640,7 +12708,7 @@ func (vpc *VpcV1) GetBareMetalServerNetworkAttachmentWithContext(ctx context.Con return } if rawResponse != nil { - err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalBareMetalServerNetworkAttachment) + err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalBareMetalServer) if err != nil { return } @@ -12650,43 +12718,41 @@ func (vpc *VpcV1) GetBareMetalServerNetworkAttachmentWithContext(ctx context.Con return } -// UpdateBareMetalServerNetworkAttachment : Update a bare metal server network attachment -// This request updates a bare metal server network attachment with the information provided in a bare metal server -// network attachment patch object. The bare metal server network attachment patch object is structured in the same way -// as a retrieved bare metal server network attachment and contains only the information to be updated. -func (vpc *VpcV1) UpdateBareMetalServerNetworkAttachment(updateBareMetalServerNetworkAttachmentOptions *UpdateBareMetalServerNetworkAttachmentOptions) (result BareMetalServerNetworkAttachmentIntf, response *core.DetailedResponse, err error) { - return vpc.UpdateBareMetalServerNetworkAttachmentWithContext(context.Background(), updateBareMetalServerNetworkAttachmentOptions) +// UpdateBareMetalServer : Update a bare metal server +// This request updates a bare metal server with the information in a provided patch. The bare metal server patch object +// is structured in the same way as a retrieved bare metal server and contains only the information to be updated. +func (vpc *VpcV1) UpdateBareMetalServer(updateBareMetalServerOptions *UpdateBareMetalServerOptions) (result *BareMetalServer, response *core.DetailedResponse, err error) { + return vpc.UpdateBareMetalServerWithContext(context.Background(), updateBareMetalServerOptions) } -// UpdateBareMetalServerNetworkAttachmentWithContext is an alternate form of the UpdateBareMetalServerNetworkAttachment method which supports a Context parameter -func (vpc *VpcV1) UpdateBareMetalServerNetworkAttachmentWithContext(ctx context.Context, updateBareMetalServerNetworkAttachmentOptions *UpdateBareMetalServerNetworkAttachmentOptions) (result BareMetalServerNetworkAttachmentIntf, response *core.DetailedResponse, err error) { - err = core.ValidateNotNil(updateBareMetalServerNetworkAttachmentOptions, "updateBareMetalServerNetworkAttachmentOptions cannot be nil") +// UpdateBareMetalServerWithContext is an alternate form of the UpdateBareMetalServer method which supports a Context parameter +func (vpc *VpcV1) UpdateBareMetalServerWithContext(ctx context.Context, updateBareMetalServerOptions *UpdateBareMetalServerOptions) (result *BareMetalServer, response *core.DetailedResponse, err error) { + err = core.ValidateNotNil(updateBareMetalServerOptions, "updateBareMetalServerOptions cannot be nil") if err != nil { return } - err = core.ValidateStruct(updateBareMetalServerNetworkAttachmentOptions, "updateBareMetalServerNetworkAttachmentOptions") + err = core.ValidateStruct(updateBareMetalServerOptions, "updateBareMetalServerOptions") if err != nil { return } pathParamsMap := map[string]string{ - "bare_metal_server_id": *updateBareMetalServerNetworkAttachmentOptions.BareMetalServerID, - "id": *updateBareMetalServerNetworkAttachmentOptions.ID, + "id": *updateBareMetalServerOptions.ID, } builder := core.NewRequestBuilder(core.PATCH) builder = builder.WithContext(ctx) builder.EnableGzipCompression = vpc.GetEnableGzipCompression() - _, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/bare_metal_servers/{bare_metal_server_id}/network_attachments/{id}`, pathParamsMap) + _, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/bare_metal_servers/{id}`, pathParamsMap) if err != nil { return } - for headerName, headerValue := range updateBareMetalServerNetworkAttachmentOptions.Headers { + for headerName, headerValue := range updateBareMetalServerOptions.Headers { builder.AddHeader(headerName, headerValue) } - sdkHeaders := common.GetSdkHeaders("vpc", "V1", "UpdateBareMetalServerNetworkAttachment") + sdkHeaders := common.GetSdkHeaders("vpc", "V1", "UpdateBareMetalServer") for headerName, headerValue := range sdkHeaders { builder.AddHeader(headerName, headerValue) } @@ -12696,7 +12762,7 @@ func (vpc *VpcV1) UpdateBareMetalServerNetworkAttachmentWithContext(ctx context. builder.AddQuery("version", fmt.Sprint(*vpc.Version)) builder.AddQuery("generation", fmt.Sprint(*vpc.generation)) - _, err = builder.SetBodyContentJSON(updateBareMetalServerNetworkAttachmentOptions.BareMetalServerNetworkAttachmentPatch) + _, err = builder.SetBodyContentJSON(updateBareMetalServerOptions.BareMetalServerPatch) if err != nil { return } @@ -12712,7 +12778,7 @@ func (vpc *VpcV1) UpdateBareMetalServerNetworkAttachmentWithContext(ctx context. return } if rawResponse != nil { - err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalBareMetalServerNetworkAttachment) + err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalBareMetalServer) if err != nil { return } @@ -12722,47 +12788,42 @@ func (vpc *VpcV1) UpdateBareMetalServerNetworkAttachmentWithContext(ctx context. return } -// ListBareMetalServerNetworkInterfaces : List all network interfaces on a bare metal server -// This request lists all network interfaces on a bare metal server. A bare metal server network interface is an -// abstract representation of a network device and attaches a bare metal server to a single subnet. Each network -// interface on a bare metal server can attach to any subnet in the zone, including subnets that are already attached to -// the bare metal server. -// -// If this bare metal server has network attachments, each returned network interface is a [read-only -// representation](https://cloud.ibm.com/docs/vpc?topic=vpc-vni-about#vni-old-api-clients) of its corresponding network -// attachment and its attached virtual network interface. -func (vpc *VpcV1) ListBareMetalServerNetworkInterfaces(listBareMetalServerNetworkInterfacesOptions *ListBareMetalServerNetworkInterfacesOptions) (result *BareMetalServerNetworkInterfaceCollection, response *core.DetailedResponse, err error) { - return vpc.ListBareMetalServerNetworkInterfacesWithContext(context.Background(), listBareMetalServerNetworkInterfacesOptions) +// GetBareMetalServerInitialization : Retrieve initialization configuration for a bare metal server +// This request retrieves configuration used to initialize the bare metal server, such as the image used, SSH keys, and +// any configured usernames and passwords. These can subsequently be changed on the server and therefore may not be +// current. +func (vpc *VpcV1) GetBareMetalServerInitialization(getBareMetalServerInitializationOptions *GetBareMetalServerInitializationOptions) (result *BareMetalServerInitialization, response *core.DetailedResponse, err error) { + return vpc.GetBareMetalServerInitializationWithContext(context.Background(), getBareMetalServerInitializationOptions) } -// ListBareMetalServerNetworkInterfacesWithContext is an alternate form of the ListBareMetalServerNetworkInterfaces method which supports a Context parameter -func (vpc *VpcV1) ListBareMetalServerNetworkInterfacesWithContext(ctx context.Context, listBareMetalServerNetworkInterfacesOptions *ListBareMetalServerNetworkInterfacesOptions) (result *BareMetalServerNetworkInterfaceCollection, response *core.DetailedResponse, err error) { - err = core.ValidateNotNil(listBareMetalServerNetworkInterfacesOptions, "listBareMetalServerNetworkInterfacesOptions cannot be nil") +// GetBareMetalServerInitializationWithContext is an alternate form of the GetBareMetalServerInitialization method which supports a Context parameter +func (vpc *VpcV1) GetBareMetalServerInitializationWithContext(ctx context.Context, getBareMetalServerInitializationOptions *GetBareMetalServerInitializationOptions) (result *BareMetalServerInitialization, response *core.DetailedResponse, err error) { + err = core.ValidateNotNil(getBareMetalServerInitializationOptions, "getBareMetalServerInitializationOptions cannot be nil") if err != nil { return } - err = core.ValidateStruct(listBareMetalServerNetworkInterfacesOptions, "listBareMetalServerNetworkInterfacesOptions") + err = core.ValidateStruct(getBareMetalServerInitializationOptions, "getBareMetalServerInitializationOptions") if err != nil { return } pathParamsMap := map[string]string{ - "bare_metal_server_id": *listBareMetalServerNetworkInterfacesOptions.BareMetalServerID, + "id": *getBareMetalServerInitializationOptions.ID, } builder := core.NewRequestBuilder(core.GET) builder = builder.WithContext(ctx) builder.EnableGzipCompression = vpc.GetEnableGzipCompression() - _, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/bare_metal_servers/{bare_metal_server_id}/network_interfaces`, pathParamsMap) + _, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/bare_metal_servers/{id}/initialization`, pathParamsMap) if err != nil { return } - for headerName, headerValue := range listBareMetalServerNetworkInterfacesOptions.Headers { + for headerName, headerValue := range getBareMetalServerInitializationOptions.Headers { builder.AddHeader(headerName, headerValue) } - sdkHeaders := common.GetSdkHeaders("vpc", "V1", "ListBareMetalServerNetworkInterfaces") + sdkHeaders := common.GetSdkHeaders("vpc", "V1", "GetBareMetalServerInitialization") for headerName, headerValue := range sdkHeaders { builder.AddHeader(headerName, headerValue) } @@ -12770,12 +12831,6 @@ func (vpc *VpcV1) ListBareMetalServerNetworkInterfacesWithContext(ctx context.Co builder.AddQuery("version", fmt.Sprint(*vpc.Version)) builder.AddQuery("generation", fmt.Sprint(*vpc.generation)) - if listBareMetalServerNetworkInterfacesOptions.Start != nil { - builder.AddQuery("start", fmt.Sprint(*listBareMetalServerNetworkInterfacesOptions.Start)) - } - if listBareMetalServerNetworkInterfacesOptions.Limit != nil { - builder.AddQuery("limit", fmt.Sprint(*listBareMetalServerNetworkInterfacesOptions.Limit)) - } request, err := builder.Build() if err != nil { @@ -12788,7 +12843,7 @@ func (vpc *VpcV1) ListBareMetalServerNetworkInterfacesWithContext(ctx context.Co return } if rawResponse != nil { - err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalBareMetalServerNetworkInterfaceCollection) + err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalBareMetalServerInitialization) if err != nil { return } @@ -12798,124 +12853,91 @@ func (vpc *VpcV1) ListBareMetalServerNetworkInterfacesWithContext(ctx context.Co return } -// CreateBareMetalServerNetworkInterface : Create a network interface on a bare metal server -// This request creates a new bare metal server network interface from a bare metal server network interface prototype -// object. The prototype object is structured in the same way as a retrieved bare metal server network interface, and -// contains the information necessary to create the new bare metal server network interface. Any subnet in the bare -// metal server's VPC may be specified, even if it is already attached to another bare metal server network interface. -// Addresses on the bare metal server network interface must be within the specified subnet's CIDR blocks. -// -// If this bare metal server has network attachments, each network interface is a [read-only -// representation](https://cloud.ibm.com/docs/vpc?topic=vpc-vni-about#vni-old-api-clients) of its corresponding network -// attachment and its attached virtual network interface, and new network interfaces are not allowed to be created. -func (vpc *VpcV1) CreateBareMetalServerNetworkInterface(createBareMetalServerNetworkInterfaceOptions *CreateBareMetalServerNetworkInterfaceOptions) (result BareMetalServerNetworkInterfaceIntf, response *core.DetailedResponse, err error) { - return vpc.CreateBareMetalServerNetworkInterfaceWithContext(context.Background(), createBareMetalServerNetworkInterfaceOptions) +// RestartBareMetalServer : Restart a bare metal server +// This request restarts a bare metal server. It will run immediately regardless of the state of the server. +func (vpc *VpcV1) RestartBareMetalServer(restartBareMetalServerOptions *RestartBareMetalServerOptions) (response *core.DetailedResponse, err error) { + return vpc.RestartBareMetalServerWithContext(context.Background(), restartBareMetalServerOptions) } -// CreateBareMetalServerNetworkInterfaceWithContext is an alternate form of the CreateBareMetalServerNetworkInterface method which supports a Context parameter -func (vpc *VpcV1) CreateBareMetalServerNetworkInterfaceWithContext(ctx context.Context, createBareMetalServerNetworkInterfaceOptions *CreateBareMetalServerNetworkInterfaceOptions) (result BareMetalServerNetworkInterfaceIntf, response *core.DetailedResponse, err error) { - err = core.ValidateNotNil(createBareMetalServerNetworkInterfaceOptions, "createBareMetalServerNetworkInterfaceOptions cannot be nil") +// RestartBareMetalServerWithContext is an alternate form of the RestartBareMetalServer method which supports a Context parameter +func (vpc *VpcV1) RestartBareMetalServerWithContext(ctx context.Context, restartBareMetalServerOptions *RestartBareMetalServerOptions) (response *core.DetailedResponse, err error) { + err = core.ValidateNotNil(restartBareMetalServerOptions, "restartBareMetalServerOptions cannot be nil") if err != nil { return } - err = core.ValidateStruct(createBareMetalServerNetworkInterfaceOptions, "createBareMetalServerNetworkInterfaceOptions") + err = core.ValidateStruct(restartBareMetalServerOptions, "restartBareMetalServerOptions") if err != nil { return } pathParamsMap := map[string]string{ - "bare_metal_server_id": *createBareMetalServerNetworkInterfaceOptions.BareMetalServerID, + "id": *restartBareMetalServerOptions.ID, } builder := core.NewRequestBuilder(core.POST) builder = builder.WithContext(ctx) builder.EnableGzipCompression = vpc.GetEnableGzipCompression() - _, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/bare_metal_servers/{bare_metal_server_id}/network_interfaces`, pathParamsMap) + _, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/bare_metal_servers/{id}/restart`, pathParamsMap) if err != nil { return } - for headerName, headerValue := range createBareMetalServerNetworkInterfaceOptions.Headers { + for headerName, headerValue := range restartBareMetalServerOptions.Headers { builder.AddHeader(headerName, headerValue) } - sdkHeaders := common.GetSdkHeaders("vpc", "V1", "CreateBareMetalServerNetworkInterface") + sdkHeaders := common.GetSdkHeaders("vpc", "V1", "RestartBareMetalServer") for headerName, headerValue := range sdkHeaders { builder.AddHeader(headerName, headerValue) } - builder.AddHeader("Accept", "application/json") - builder.AddHeader("Content-Type", "application/json") builder.AddQuery("version", fmt.Sprint(*vpc.Version)) builder.AddQuery("generation", fmt.Sprint(*vpc.generation)) - _, err = builder.SetBodyContentJSON(createBareMetalServerNetworkInterfaceOptions.BareMetalServerNetworkInterfacePrototype) - 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, UnmarshalBareMetalServerNetworkInterface) - if err != nil { - return - } - response.Result = result - } + response, err = vpc.Service.Request(request, nil) return } -// DeleteBareMetalServerNetworkInterface : Delete a bare metal server network interface -// This request deletes a bare metal server network interface. This operation cannot be reversed. Any floating IPs -// associated with the bare metal server network interface are implicitly disassociated. The primary bare metal server -// network interface is not allowed to be deleted. -// -// If this bare metal server has network attachments, this network interface is a [read-only -// representation](https://cloud.ibm.com/docs/vpc?topic=vpc-vni-about#vni-old-api-clients) of its corresponding network -// attachment and its attached virtual network interface, and is not allowed to be deleted. -func (vpc *VpcV1) DeleteBareMetalServerNetworkInterface(deleteBareMetalServerNetworkInterfaceOptions *DeleteBareMetalServerNetworkInterfaceOptions) (response *core.DetailedResponse, err error) { - return vpc.DeleteBareMetalServerNetworkInterfaceWithContext(context.Background(), deleteBareMetalServerNetworkInterfaceOptions) +// StartBareMetalServer : Start a bare metal server +// This request starts a bare metal server. It will run immediately provided the server is stopped. +func (vpc *VpcV1) StartBareMetalServer(startBareMetalServerOptions *StartBareMetalServerOptions) (response *core.DetailedResponse, err error) { + return vpc.StartBareMetalServerWithContext(context.Background(), startBareMetalServerOptions) } -// DeleteBareMetalServerNetworkInterfaceWithContext is an alternate form of the DeleteBareMetalServerNetworkInterface method which supports a Context parameter -func (vpc *VpcV1) DeleteBareMetalServerNetworkInterfaceWithContext(ctx context.Context, deleteBareMetalServerNetworkInterfaceOptions *DeleteBareMetalServerNetworkInterfaceOptions) (response *core.DetailedResponse, err error) { - err = core.ValidateNotNil(deleteBareMetalServerNetworkInterfaceOptions, "deleteBareMetalServerNetworkInterfaceOptions cannot be nil") +// StartBareMetalServerWithContext is an alternate form of the StartBareMetalServer method which supports a Context parameter +func (vpc *VpcV1) StartBareMetalServerWithContext(ctx context.Context, startBareMetalServerOptions *StartBareMetalServerOptions) (response *core.DetailedResponse, err error) { + err = core.ValidateNotNil(startBareMetalServerOptions, "startBareMetalServerOptions cannot be nil") if err != nil { return } - err = core.ValidateStruct(deleteBareMetalServerNetworkInterfaceOptions, "deleteBareMetalServerNetworkInterfaceOptions") + err = core.ValidateStruct(startBareMetalServerOptions, "startBareMetalServerOptions") if err != nil { return } pathParamsMap := map[string]string{ - "bare_metal_server_id": *deleteBareMetalServerNetworkInterfaceOptions.BareMetalServerID, - "id": *deleteBareMetalServerNetworkInterfaceOptions.ID, + "id": *startBareMetalServerOptions.ID, } - builder := core.NewRequestBuilder(core.DELETE) + builder := core.NewRequestBuilder(core.POST) builder = builder.WithContext(ctx) builder.EnableGzipCompression = vpc.GetEnableGzipCompression() - _, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/bare_metal_servers/{bare_metal_server_id}/network_interfaces/{id}`, pathParamsMap) + _, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/bare_metal_servers/{id}/start`, pathParamsMap) if err != nil { return } - for headerName, headerValue := range deleteBareMetalServerNetworkInterfaceOptions.Headers { + for headerName, headerValue := range startBareMetalServerOptions.Headers { builder.AddHeader(headerName, headerValue) } - sdkHeaders := common.GetSdkHeaders("vpc", "V1", "DeleteBareMetalServerNetworkInterface") + sdkHeaders := common.GetSdkHeaders("vpc", "V1", "StartBareMetalServer") for headerName, headerValue := range sdkHeaders { builder.AddHeader(headerName, headerValue) } @@ -12933,127 +12955,107 @@ func (vpc *VpcV1) DeleteBareMetalServerNetworkInterfaceWithContext(ctx context.C return } -// GetBareMetalServerNetworkInterface : Retrieve a bare metal server network interface -// This request retrieves a single bare metal server network interface specified by the identifier in the URL. -// -// If this bare metal server has network attachments, the retrieved network interface is a [read-only -// representation](https://cloud.ibm.com/docs/vpc?topic=vpc-vni-about#vni-old-api-clients) of its corresponding network -// attachment and its attached virtual network interface. -func (vpc *VpcV1) GetBareMetalServerNetworkInterface(getBareMetalServerNetworkInterfaceOptions *GetBareMetalServerNetworkInterfaceOptions) (result BareMetalServerNetworkInterfaceIntf, response *core.DetailedResponse, err error) { - return vpc.GetBareMetalServerNetworkInterfaceWithContext(context.Background(), getBareMetalServerNetworkInterfaceOptions) +// StopBareMetalServer : Stop a bare metal server +// This request stops a bare metal server. It will run immediately provided the server is running. Note: A soft stop may +// not complete as it relies on the operating system to perform the operation. +func (vpc *VpcV1) StopBareMetalServer(stopBareMetalServerOptions *StopBareMetalServerOptions) (response *core.DetailedResponse, err error) { + return vpc.StopBareMetalServerWithContext(context.Background(), stopBareMetalServerOptions) } -// GetBareMetalServerNetworkInterfaceWithContext is an alternate form of the GetBareMetalServerNetworkInterface method which supports a Context parameter -func (vpc *VpcV1) GetBareMetalServerNetworkInterfaceWithContext(ctx context.Context, getBareMetalServerNetworkInterfaceOptions *GetBareMetalServerNetworkInterfaceOptions) (result BareMetalServerNetworkInterfaceIntf, response *core.DetailedResponse, err error) { - err = core.ValidateNotNil(getBareMetalServerNetworkInterfaceOptions, "getBareMetalServerNetworkInterfaceOptions cannot be nil") +// StopBareMetalServerWithContext is an alternate form of the StopBareMetalServer method which supports a Context parameter +func (vpc *VpcV1) StopBareMetalServerWithContext(ctx context.Context, stopBareMetalServerOptions *StopBareMetalServerOptions) (response *core.DetailedResponse, err error) { + err = core.ValidateNotNil(stopBareMetalServerOptions, "stopBareMetalServerOptions cannot be nil") if err != nil { return } - err = core.ValidateStruct(getBareMetalServerNetworkInterfaceOptions, "getBareMetalServerNetworkInterfaceOptions") + err = core.ValidateStruct(stopBareMetalServerOptions, "stopBareMetalServerOptions") if err != nil { return } pathParamsMap := map[string]string{ - "bare_metal_server_id": *getBareMetalServerNetworkInterfaceOptions.BareMetalServerID, - "id": *getBareMetalServerNetworkInterfaceOptions.ID, + "id": *stopBareMetalServerOptions.ID, } - builder := core.NewRequestBuilder(core.GET) + builder := core.NewRequestBuilder(core.POST) builder = builder.WithContext(ctx) builder.EnableGzipCompression = vpc.GetEnableGzipCompression() - _, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/bare_metal_servers/{bare_metal_server_id}/network_interfaces/{id}`, pathParamsMap) + _, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/bare_metal_servers/{id}/stop`, pathParamsMap) if err != nil { return } - for headerName, headerValue := range getBareMetalServerNetworkInterfaceOptions.Headers { + for headerName, headerValue := range stopBareMetalServerOptions.Headers { builder.AddHeader(headerName, headerValue) } - sdkHeaders := common.GetSdkHeaders("vpc", "V1", "GetBareMetalServerNetworkInterface") + sdkHeaders := common.GetSdkHeaders("vpc", "V1", "StopBareMetalServer") 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)) - request, err := builder.Build() + body := make(map[string]interface{}) + if stopBareMetalServerOptions.Type != nil { + body["type"] = stopBareMetalServerOptions.Type + } + _, err = builder.SetBodyContentJSON(body) if err != nil { return } - var rawResponse map[string]json.RawMessage - response, err = vpc.Service.Request(request, &rawResponse) + request, err := builder.Build() if err != nil { return } - if rawResponse != nil { - err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalBareMetalServerNetworkInterface) - if err != nil { - return - } - response.Result = result - } - return -} + response, err = vpc.Service.Request(request, nil) -// UpdateBareMetalServerNetworkInterface : Update a bare metal server network interface -// This request updates a bare metal server network interface with the information provided in a bare metal server -// network interface patch object. The bare metal server network interface patch object is structured in the same way as -// a retrieved bare metal server network interface and needs to contain only the information to be updated. -// -// If this bare metal server has network attachments, this network interface is a [read-only -// representation](https://cloud.ibm.com/docs/vpc?topic=vpc-vni-about#vni-old-api-clients) of its corresponding network -// attachment and its attached virtual network interface, and is not allowed to be updated. -func (vpc *VpcV1) UpdateBareMetalServerNetworkInterface(updateBareMetalServerNetworkInterfaceOptions *UpdateBareMetalServerNetworkInterfaceOptions) (result BareMetalServerNetworkInterfaceIntf, response *core.DetailedResponse, err error) { - return vpc.UpdateBareMetalServerNetworkInterfaceWithContext(context.Background(), updateBareMetalServerNetworkInterfaceOptions) + return } -// UpdateBareMetalServerNetworkInterfaceWithContext is an alternate form of the UpdateBareMetalServerNetworkInterface method which supports a Context parameter -func (vpc *VpcV1) UpdateBareMetalServerNetworkInterfaceWithContext(ctx context.Context, updateBareMetalServerNetworkInterfaceOptions *UpdateBareMetalServerNetworkInterfaceOptions) (result BareMetalServerNetworkInterfaceIntf, response *core.DetailedResponse, err error) { - err = core.ValidateNotNil(updateBareMetalServerNetworkInterfaceOptions, "updateBareMetalServerNetworkInterfaceOptions cannot be nil") - if err != nil { - return - } - err = core.ValidateStruct(updateBareMetalServerNetworkInterfaceOptions, "updateBareMetalServerNetworkInterfaceOptions") +// ListVolumeProfiles : List all volume profiles +// This request lists all [volume profiles](https://cloud.ibm.com/docs/vpc?topic=vpc-block-storage-profiles) available +// in the region. A volume profile specifies the performance characteristics and pricing model for a volume. +func (vpc *VpcV1) ListVolumeProfiles(listVolumeProfilesOptions *ListVolumeProfilesOptions) (result *VolumeProfileCollection, response *core.DetailedResponse, err error) { + return vpc.ListVolumeProfilesWithContext(context.Background(), listVolumeProfilesOptions) +} + +// ListVolumeProfilesWithContext is an alternate form of the ListVolumeProfiles method which supports a Context parameter +func (vpc *VpcV1) ListVolumeProfilesWithContext(ctx context.Context, listVolumeProfilesOptions *ListVolumeProfilesOptions) (result *VolumeProfileCollection, response *core.DetailedResponse, err error) { + err = core.ValidateStruct(listVolumeProfilesOptions, "listVolumeProfilesOptions") if err != nil { return } - pathParamsMap := map[string]string{ - "bare_metal_server_id": *updateBareMetalServerNetworkInterfaceOptions.BareMetalServerID, - "id": *updateBareMetalServerNetworkInterfaceOptions.ID, - } - - builder := core.NewRequestBuilder(core.PATCH) + builder := core.NewRequestBuilder(core.GET) builder = builder.WithContext(ctx) builder.EnableGzipCompression = vpc.GetEnableGzipCompression() - _, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/bare_metal_servers/{bare_metal_server_id}/network_interfaces/{id}`, pathParamsMap) + _, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/volume/profiles`, nil) if err != nil { return } - for headerName, headerValue := range updateBareMetalServerNetworkInterfaceOptions.Headers { + for headerName, headerValue := range listVolumeProfilesOptions.Headers { builder.AddHeader(headerName, headerValue) } - sdkHeaders := common.GetSdkHeaders("vpc", "V1", "UpdateBareMetalServerNetworkInterface") + sdkHeaders := common.GetSdkHeaders("vpc", "V1", "ListVolumeProfiles") for headerName, headerValue := range sdkHeaders { builder.AddHeader(headerName, headerValue) } builder.AddHeader("Accept", "application/json") - builder.AddHeader("Content-Type", "application/merge-patch+json") builder.AddQuery("version", fmt.Sprint(*vpc.Version)) builder.AddQuery("generation", fmt.Sprint(*vpc.generation)) - - _, err = builder.SetBodyContentJSON(updateBareMetalServerNetworkInterfaceOptions.BareMetalServerNetworkInterfacePatch) - if err != nil { - return + if listVolumeProfilesOptions.Start != nil { + builder.AddQuery("start", fmt.Sprint(*listVolumeProfilesOptions.Start)) + } + if listVolumeProfilesOptions.Limit != nil { + builder.AddQuery("limit", fmt.Sprint(*listVolumeProfilesOptions.Limit)) } request, err := builder.Build() @@ -13067,7 +13069,7 @@ func (vpc *VpcV1) UpdateBareMetalServerNetworkInterfaceWithContext(ctx context.C return } if rawResponse != nil { - err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalBareMetalServerNetworkInterface) + err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalVolumeProfileCollection) if err != nil { return } @@ -13077,41 +13079,40 @@ func (vpc *VpcV1) UpdateBareMetalServerNetworkInterfaceWithContext(ctx context.C return } -// ListBareMetalServerNetworkInterfaceFloatingIps : List all floating IPs associated with a bare metal server network interface -// This request lists all floating IPs associated with a bare metal server network interface. -func (vpc *VpcV1) ListBareMetalServerNetworkInterfaceFloatingIps(listBareMetalServerNetworkInterfaceFloatingIpsOptions *ListBareMetalServerNetworkInterfaceFloatingIpsOptions) (result *FloatingIPUnpaginatedCollection, response *core.DetailedResponse, err error) { - return vpc.ListBareMetalServerNetworkInterfaceFloatingIpsWithContext(context.Background(), listBareMetalServerNetworkInterfaceFloatingIpsOptions) +// GetVolumeProfile : Retrieve a volume profile +// This request retrieves a single volume profile specified by the name in the URL. +func (vpc *VpcV1) GetVolumeProfile(getVolumeProfileOptions *GetVolumeProfileOptions) (result *VolumeProfile, response *core.DetailedResponse, err error) { + return vpc.GetVolumeProfileWithContext(context.Background(), getVolumeProfileOptions) } -// ListBareMetalServerNetworkInterfaceFloatingIpsWithContext is an alternate form of the ListBareMetalServerNetworkInterfaceFloatingIps method which supports a Context parameter -func (vpc *VpcV1) ListBareMetalServerNetworkInterfaceFloatingIpsWithContext(ctx context.Context, listBareMetalServerNetworkInterfaceFloatingIpsOptions *ListBareMetalServerNetworkInterfaceFloatingIpsOptions) (result *FloatingIPUnpaginatedCollection, response *core.DetailedResponse, err error) { - err = core.ValidateNotNil(listBareMetalServerNetworkInterfaceFloatingIpsOptions, "listBareMetalServerNetworkInterfaceFloatingIpsOptions cannot be nil") +// GetVolumeProfileWithContext is an alternate form of the GetVolumeProfile method which supports a Context parameter +func (vpc *VpcV1) GetVolumeProfileWithContext(ctx context.Context, getVolumeProfileOptions *GetVolumeProfileOptions) (result *VolumeProfile, response *core.DetailedResponse, err error) { + err = core.ValidateNotNil(getVolumeProfileOptions, "getVolumeProfileOptions cannot be nil") if err != nil { return } - err = core.ValidateStruct(listBareMetalServerNetworkInterfaceFloatingIpsOptions, "listBareMetalServerNetworkInterfaceFloatingIpsOptions") + err = core.ValidateStruct(getVolumeProfileOptions, "getVolumeProfileOptions") if err != nil { return } pathParamsMap := map[string]string{ - "bare_metal_server_id": *listBareMetalServerNetworkInterfaceFloatingIpsOptions.BareMetalServerID, - "network_interface_id": *listBareMetalServerNetworkInterfaceFloatingIpsOptions.NetworkInterfaceID, + "name": *getVolumeProfileOptions.Name, } builder := core.NewRequestBuilder(core.GET) builder = builder.WithContext(ctx) builder.EnableGzipCompression = vpc.GetEnableGzipCompression() - _, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/bare_metal_servers/{bare_metal_server_id}/network_interfaces/{network_interface_id}/floating_ips`, pathParamsMap) + _, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/volume/profiles/{name}`, pathParamsMap) if err != nil { return } - for headerName, headerValue := range listBareMetalServerNetworkInterfaceFloatingIpsOptions.Headers { + for headerName, headerValue := range getVolumeProfileOptions.Headers { builder.AddHeader(headerName, headerValue) } - sdkHeaders := common.GetSdkHeaders("vpc", "V1", "ListBareMetalServerNetworkInterfaceFloatingIps") + sdkHeaders := common.GetSdkHeaders("vpc", "V1", "GetVolumeProfile") for headerName, headerValue := range sdkHeaders { builder.AddHeader(headerName, headerValue) } @@ -13131,7 +13132,7 @@ func (vpc *VpcV1) ListBareMetalServerNetworkInterfaceFloatingIpsWithContext(ctx return } if rawResponse != nil { - err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalFloatingIPUnpaginatedCollection) + err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalVolumeProfile) if err != nil { return } @@ -13141,104 +13142,134 @@ func (vpc *VpcV1) ListBareMetalServerNetworkInterfaceFloatingIpsWithContext(ctx return } -// RemoveBareMetalServerNetworkInterfaceFloatingIP : Disassociate a floating IP from a bare metal server network interface -// This request disassociates the specified floating IP from the specified bare metal server network interface. -func (vpc *VpcV1) RemoveBareMetalServerNetworkInterfaceFloatingIP(removeBareMetalServerNetworkInterfaceFloatingIPOptions *RemoveBareMetalServerNetworkInterfaceFloatingIPOptions) (response *core.DetailedResponse, err error) { - return vpc.RemoveBareMetalServerNetworkInterfaceFloatingIPWithContext(context.Background(), removeBareMetalServerNetworkInterfaceFloatingIPOptions) +// ListVolumes : List all volumes +// This request lists all volumes in the region. Volumes are network-connected block storage devices that may be +// attached to one or more instances in the same region. +func (vpc *VpcV1) ListVolumes(listVolumesOptions *ListVolumesOptions) (result *VolumeCollection, response *core.DetailedResponse, err error) { + return vpc.ListVolumesWithContext(context.Background(), listVolumesOptions) } -// RemoveBareMetalServerNetworkInterfaceFloatingIPWithContext is an alternate form of the RemoveBareMetalServerNetworkInterfaceFloatingIP method which supports a Context parameter -func (vpc *VpcV1) RemoveBareMetalServerNetworkInterfaceFloatingIPWithContext(ctx context.Context, removeBareMetalServerNetworkInterfaceFloatingIPOptions *RemoveBareMetalServerNetworkInterfaceFloatingIPOptions) (response *core.DetailedResponse, err error) { - err = core.ValidateNotNil(removeBareMetalServerNetworkInterfaceFloatingIPOptions, "removeBareMetalServerNetworkInterfaceFloatingIPOptions cannot be nil") - if err != nil { - return - } - err = core.ValidateStruct(removeBareMetalServerNetworkInterfaceFloatingIPOptions, "removeBareMetalServerNetworkInterfaceFloatingIPOptions") +// ListVolumesWithContext is an alternate form of the ListVolumes method which supports a Context parameter +func (vpc *VpcV1) ListVolumesWithContext(ctx context.Context, listVolumesOptions *ListVolumesOptions) (result *VolumeCollection, response *core.DetailedResponse, err error) { + err = core.ValidateStruct(listVolumesOptions, "listVolumesOptions") if err != nil { return } - pathParamsMap := map[string]string{ - "bare_metal_server_id": *removeBareMetalServerNetworkInterfaceFloatingIPOptions.BareMetalServerID, - "network_interface_id": *removeBareMetalServerNetworkInterfaceFloatingIPOptions.NetworkInterfaceID, - "id": *removeBareMetalServerNetworkInterfaceFloatingIPOptions.ID, - } - - builder := core.NewRequestBuilder(core.DELETE) + builder := core.NewRequestBuilder(core.GET) builder = builder.WithContext(ctx) builder.EnableGzipCompression = vpc.GetEnableGzipCompression() - _, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/bare_metal_servers/{bare_metal_server_id}/network_interfaces/{network_interface_id}/floating_ips/{id}`, pathParamsMap) + _, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/volumes`, nil) if err != nil { return } - for headerName, headerValue := range removeBareMetalServerNetworkInterfaceFloatingIPOptions.Headers { + for headerName, headerValue := range listVolumesOptions.Headers { builder.AddHeader(headerName, headerValue) } - sdkHeaders := common.GetSdkHeaders("vpc", "V1", "RemoveBareMetalServerNetworkInterfaceFloatingIP") + sdkHeaders := common.GetSdkHeaders("vpc", "V1", "ListVolumes") 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 listVolumesOptions.Start != nil { + builder.AddQuery("start", fmt.Sprint(*listVolumesOptions.Start)) + } + if listVolumesOptions.Limit != nil { + builder.AddQuery("limit", fmt.Sprint(*listVolumesOptions.Limit)) + } + if listVolumesOptions.Name != nil { + builder.AddQuery("name", fmt.Sprint(*listVolumesOptions.Name)) + } + if listVolumesOptions.AttachmentState != nil { + builder.AddQuery("attachment_state", fmt.Sprint(*listVolumesOptions.AttachmentState)) + } + if listVolumesOptions.Encryption != nil { + builder.AddQuery("encryption", fmt.Sprint(*listVolumesOptions.Encryption)) + } + if listVolumesOptions.OperatingSystemFamily != nil { + builder.AddQuery("operating_system.family", fmt.Sprint(*listVolumesOptions.OperatingSystemFamily)) + } + if listVolumesOptions.OperatingSystemArchitecture != nil { + builder.AddQuery("operating_system.architecture", fmt.Sprint(*listVolumesOptions.OperatingSystemArchitecture)) + } + if listVolumesOptions.ZoneName != nil { + builder.AddQuery("zone.name", fmt.Sprint(*listVolumesOptions.ZoneName)) + } + if listVolumesOptions.Tag != nil { + builder.AddQuery("tag", fmt.Sprint(*listVolumesOptions.Tag)) + } request, err := builder.Build() if err != nil { return } - response, err = vpc.Service.Request(request, nil) + 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, UnmarshalVolumeCollection) + if err != nil { + return + } + response.Result = result + } return } -// GetBareMetalServerNetworkInterfaceFloatingIP : Retrieve associated floating IP -// This request retrieves a specified floating IP if it is associated with the bare metal server network interface -// specified in the URL. -func (vpc *VpcV1) GetBareMetalServerNetworkInterfaceFloatingIP(getBareMetalServerNetworkInterfaceFloatingIPOptions *GetBareMetalServerNetworkInterfaceFloatingIPOptions) (result *FloatingIP, response *core.DetailedResponse, err error) { - return vpc.GetBareMetalServerNetworkInterfaceFloatingIPWithContext(context.Background(), getBareMetalServerNetworkInterfaceFloatingIPOptions) +// CreateVolume : Create a volume +// This request creates a new volume from a volume prototype object. The prototype object is structured in the same way +// as a retrieved volume, and contains the information necessary to create the new volume. +func (vpc *VpcV1) CreateVolume(createVolumeOptions *CreateVolumeOptions) (result *Volume, response *core.DetailedResponse, err error) { + return vpc.CreateVolumeWithContext(context.Background(), createVolumeOptions) } -// GetBareMetalServerNetworkInterfaceFloatingIPWithContext is an alternate form of the GetBareMetalServerNetworkInterfaceFloatingIP method which supports a Context parameter -func (vpc *VpcV1) GetBareMetalServerNetworkInterfaceFloatingIPWithContext(ctx context.Context, getBareMetalServerNetworkInterfaceFloatingIPOptions *GetBareMetalServerNetworkInterfaceFloatingIPOptions) (result *FloatingIP, response *core.DetailedResponse, err error) { - err = core.ValidateNotNil(getBareMetalServerNetworkInterfaceFloatingIPOptions, "getBareMetalServerNetworkInterfaceFloatingIPOptions cannot be nil") +// CreateVolumeWithContext is an alternate form of the CreateVolume method which supports a Context parameter +func (vpc *VpcV1) CreateVolumeWithContext(ctx context.Context, createVolumeOptions *CreateVolumeOptions) (result *Volume, response *core.DetailedResponse, err error) { + err = core.ValidateNotNil(createVolumeOptions, "createVolumeOptions cannot be nil") if err != nil { return } - err = core.ValidateStruct(getBareMetalServerNetworkInterfaceFloatingIPOptions, "getBareMetalServerNetworkInterfaceFloatingIPOptions") + err = core.ValidateStruct(createVolumeOptions, "createVolumeOptions") if err != nil { return } - pathParamsMap := map[string]string{ - "bare_metal_server_id": *getBareMetalServerNetworkInterfaceFloatingIPOptions.BareMetalServerID, - "network_interface_id": *getBareMetalServerNetworkInterfaceFloatingIPOptions.NetworkInterfaceID, - "id": *getBareMetalServerNetworkInterfaceFloatingIPOptions.ID, - } - - builder := core.NewRequestBuilder(core.GET) + builder := core.NewRequestBuilder(core.POST) builder = builder.WithContext(ctx) builder.EnableGzipCompression = vpc.GetEnableGzipCompression() - _, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/bare_metal_servers/{bare_metal_server_id}/network_interfaces/{network_interface_id}/floating_ips/{id}`, pathParamsMap) + _, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/volumes`, nil) if err != nil { return } - for headerName, headerValue := range getBareMetalServerNetworkInterfaceFloatingIPOptions.Headers { + for headerName, headerValue := range createVolumeOptions.Headers { builder.AddHeader(headerName, headerValue) } - sdkHeaders := common.GetSdkHeaders("vpc", "V1", "GetBareMetalServerNetworkInterfaceFloatingIP") + sdkHeaders := common.GetSdkHeaders("vpc", "V1", "CreateVolume") for headerName, headerValue := range sdkHeaders { builder.AddHeader(headerName, headerValue) } builder.AddHeader("Accept", "application/json") + builder.AddHeader("Content-Type", "application/json") builder.AddQuery("version", fmt.Sprint(*vpc.Version)) builder.AddQuery("generation", fmt.Sprint(*vpc.generation)) + _, err = builder.SetBodyContentJSON(createVolumeOptions.VolumePrototype) + if err != nil { + return + } + request, err := builder.Build() if err != nil { return @@ -13250,7 +13281,7 @@ func (vpc *VpcV1) GetBareMetalServerNetworkInterfaceFloatingIPWithContext(ctx co return } if rawResponse != nil { - err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalFloatingIP) + err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalVolume) if err != nil { return } @@ -13260,54 +13291,47 @@ func (vpc *VpcV1) GetBareMetalServerNetworkInterfaceFloatingIPWithContext(ctx co return } -// AddBareMetalServerNetworkInterfaceFloatingIP : Associate a floating IP with a bare metal server network interface -// This request associates the specified floating IP with the specified bare metal server network interface. If -// `enable_infrastructure_nat` is `false`, this adds the IP to any existing associations. If `enable_infrastructure_nat` -// is `true`, this replaces any existing association. -// -// The existing floating IP must: -// - not be required by another resource, such as a public gateway -// - be in the same `zone` as the bare metal server -// -// A request body is not required, and if provided, is ignored. -func (vpc *VpcV1) AddBareMetalServerNetworkInterfaceFloatingIP(addBareMetalServerNetworkInterfaceFloatingIPOptions *AddBareMetalServerNetworkInterfaceFloatingIPOptions) (result *FloatingIP, response *core.DetailedResponse, err error) { - return vpc.AddBareMetalServerNetworkInterfaceFloatingIPWithContext(context.Background(), addBareMetalServerNetworkInterfaceFloatingIPOptions) +// DeleteVolume : Delete a volume +// This request deletes a volume. This operation cannot be reversed. For this request to succeed, the volume must not be +// attached to any instances. +func (vpc *VpcV1) DeleteVolume(deleteVolumeOptions *DeleteVolumeOptions) (response *core.DetailedResponse, err error) { + return vpc.DeleteVolumeWithContext(context.Background(), deleteVolumeOptions) } -// AddBareMetalServerNetworkInterfaceFloatingIPWithContext is an alternate form of the AddBareMetalServerNetworkInterfaceFloatingIP method which supports a Context parameter -func (vpc *VpcV1) AddBareMetalServerNetworkInterfaceFloatingIPWithContext(ctx context.Context, addBareMetalServerNetworkInterfaceFloatingIPOptions *AddBareMetalServerNetworkInterfaceFloatingIPOptions) (result *FloatingIP, response *core.DetailedResponse, err error) { - err = core.ValidateNotNil(addBareMetalServerNetworkInterfaceFloatingIPOptions, "addBareMetalServerNetworkInterfaceFloatingIPOptions cannot be nil") +// DeleteVolumeWithContext is an alternate form of the DeleteVolume method which supports a Context parameter +func (vpc *VpcV1) DeleteVolumeWithContext(ctx context.Context, deleteVolumeOptions *DeleteVolumeOptions) (response *core.DetailedResponse, err error) { + err = core.ValidateNotNil(deleteVolumeOptions, "deleteVolumeOptions cannot be nil") if err != nil { return } - err = core.ValidateStruct(addBareMetalServerNetworkInterfaceFloatingIPOptions, "addBareMetalServerNetworkInterfaceFloatingIPOptions") + err = core.ValidateStruct(deleteVolumeOptions, "deleteVolumeOptions") if err != nil { return } pathParamsMap := map[string]string{ - "bare_metal_server_id": *addBareMetalServerNetworkInterfaceFloatingIPOptions.BareMetalServerID, - "network_interface_id": *addBareMetalServerNetworkInterfaceFloatingIPOptions.NetworkInterfaceID, - "id": *addBareMetalServerNetworkInterfaceFloatingIPOptions.ID, + "id": *deleteVolumeOptions.ID, } - builder := core.NewRequestBuilder(core.PUT) + builder := core.NewRequestBuilder(core.DELETE) builder = builder.WithContext(ctx) builder.EnableGzipCompression = vpc.GetEnableGzipCompression() - _, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/bare_metal_servers/{bare_metal_server_id}/network_interfaces/{network_interface_id}/floating_ips/{id}`, pathParamsMap) + _, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/volumes/{id}`, pathParamsMap) if err != nil { return } - for headerName, headerValue := range addBareMetalServerNetworkInterfaceFloatingIPOptions.Headers { + for headerName, headerValue := range deleteVolumeOptions.Headers { builder.AddHeader(headerName, headerValue) } - sdkHeaders := common.GetSdkHeaders("vpc", "V1", "AddBareMetalServerNetworkInterfaceFloatingIP") + sdkHeaders := common.GetSdkHeaders("vpc", "V1", "DeleteVolume") for headerName, headerValue := range sdkHeaders { builder.AddHeader(headerName, headerValue) } - builder.AddHeader("Accept", "application/json") + if deleteVolumeOptions.IfMatch != nil { + builder.AddHeader("If-Match", fmt.Sprint(*deleteVolumeOptions.IfMatch)) + } builder.AddQuery("version", fmt.Sprint(*vpc.Version)) builder.AddQuery("generation", fmt.Sprint(*vpc.generation)) @@ -13317,57 +13341,45 @@ func (vpc *VpcV1) AddBareMetalServerNetworkInterfaceFloatingIPWithContext(ctx co 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, UnmarshalFloatingIP) - if err != nil { - return - } - response.Result = result - } + response, err = vpc.Service.Request(request, nil) return } -// ListBareMetalServerNetworkInterfaceIps : List the primary reserved IP for a bare metal server network interface -// This request lists the primary reserved IP for a bare metal server network interface. -func (vpc *VpcV1) ListBareMetalServerNetworkInterfaceIps(listBareMetalServerNetworkInterfaceIpsOptions *ListBareMetalServerNetworkInterfaceIpsOptions) (result *ReservedIPCollectionBareMetalServerNetworkInterfaceContext, response *core.DetailedResponse, err error) { - return vpc.ListBareMetalServerNetworkInterfaceIpsWithContext(context.Background(), listBareMetalServerNetworkInterfaceIpsOptions) +// GetVolume : Retrieve a volume +// This request retrieves a single volume specified by the identifier in the URL. +func (vpc *VpcV1) GetVolume(getVolumeOptions *GetVolumeOptions) (result *Volume, response *core.DetailedResponse, err error) { + return vpc.GetVolumeWithContext(context.Background(), getVolumeOptions) } -// ListBareMetalServerNetworkInterfaceIpsWithContext is an alternate form of the ListBareMetalServerNetworkInterfaceIps method which supports a Context parameter -func (vpc *VpcV1) ListBareMetalServerNetworkInterfaceIpsWithContext(ctx context.Context, listBareMetalServerNetworkInterfaceIpsOptions *ListBareMetalServerNetworkInterfaceIpsOptions) (result *ReservedIPCollectionBareMetalServerNetworkInterfaceContext, response *core.DetailedResponse, err error) { - err = core.ValidateNotNil(listBareMetalServerNetworkInterfaceIpsOptions, "listBareMetalServerNetworkInterfaceIpsOptions cannot be nil") +// GetVolumeWithContext is an alternate form of the GetVolume method which supports a Context parameter +func (vpc *VpcV1) GetVolumeWithContext(ctx context.Context, getVolumeOptions *GetVolumeOptions) (result *Volume, response *core.DetailedResponse, err error) { + err = core.ValidateNotNil(getVolumeOptions, "getVolumeOptions cannot be nil") if err != nil { return } - err = core.ValidateStruct(listBareMetalServerNetworkInterfaceIpsOptions, "listBareMetalServerNetworkInterfaceIpsOptions") + err = core.ValidateStruct(getVolumeOptions, "getVolumeOptions") if err != nil { return } pathParamsMap := map[string]string{ - "bare_metal_server_id": *listBareMetalServerNetworkInterfaceIpsOptions.BareMetalServerID, - "network_interface_id": *listBareMetalServerNetworkInterfaceIpsOptions.NetworkInterfaceID, + "id": *getVolumeOptions.ID, } builder := core.NewRequestBuilder(core.GET) builder = builder.WithContext(ctx) builder.EnableGzipCompression = vpc.GetEnableGzipCompression() - _, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/bare_metal_servers/{bare_metal_server_id}/network_interfaces/{network_interface_id}/ips`, pathParamsMap) + _, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/volumes/{id}`, pathParamsMap) if err != nil { return } - for headerName, headerValue := range listBareMetalServerNetworkInterfaceIpsOptions.Headers { + for headerName, headerValue := range getVolumeOptions.Headers { builder.AddHeader(headerName, headerValue) } - sdkHeaders := common.GetSdkHeaders("vpc", "V1", "ListBareMetalServerNetworkInterfaceIps") + sdkHeaders := common.GetSdkHeaders("vpc", "V1", "GetVolume") for headerName, headerValue := range sdkHeaders { builder.AddHeader(headerName, headerValue) } @@ -13387,7 +13399,7 @@ func (vpc *VpcV1) ListBareMetalServerNetworkInterfaceIpsWithContext(ctx context. return } if rawResponse != nil { - err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalReservedIPCollectionBareMetalServerNetworkInterfaceContext) + err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalVolume) if err != nil { return } @@ -13397,50 +13409,58 @@ func (vpc *VpcV1) ListBareMetalServerNetworkInterfaceIpsWithContext(ctx context. return } -// GetBareMetalServerNetworkInterfaceIP : Retrieve the primary reserved IP -// This request retrieves the primary reserved IP for a bare metal server network interface. -func (vpc *VpcV1) GetBareMetalServerNetworkInterfaceIP(getBareMetalServerNetworkInterfaceIPOptions *GetBareMetalServerNetworkInterfaceIPOptions) (result *ReservedIP, response *core.DetailedResponse, err error) { - return vpc.GetBareMetalServerNetworkInterfaceIPWithContext(context.Background(), getBareMetalServerNetworkInterfaceIPOptions) +// UpdateVolume : Update a volume +// This request updates a volume with the information in a provided volume patch. The volume patch object is structured +// in the same way as a retrieved volume and contains only the information to be updated. +func (vpc *VpcV1) UpdateVolume(updateVolumeOptions *UpdateVolumeOptions) (result *Volume, response *core.DetailedResponse, err error) { + return vpc.UpdateVolumeWithContext(context.Background(), updateVolumeOptions) } -// GetBareMetalServerNetworkInterfaceIPWithContext is an alternate form of the GetBareMetalServerNetworkInterfaceIP method which supports a Context parameter -func (vpc *VpcV1) GetBareMetalServerNetworkInterfaceIPWithContext(ctx context.Context, getBareMetalServerNetworkInterfaceIPOptions *GetBareMetalServerNetworkInterfaceIPOptions) (result *ReservedIP, response *core.DetailedResponse, err error) { - err = core.ValidateNotNil(getBareMetalServerNetworkInterfaceIPOptions, "getBareMetalServerNetworkInterfaceIPOptions cannot be nil") +// UpdateVolumeWithContext is an alternate form of the UpdateVolume method which supports a Context parameter +func (vpc *VpcV1) UpdateVolumeWithContext(ctx context.Context, updateVolumeOptions *UpdateVolumeOptions) (result *Volume, response *core.DetailedResponse, err error) { + err = core.ValidateNotNil(updateVolumeOptions, "updateVolumeOptions cannot be nil") if err != nil { return } - err = core.ValidateStruct(getBareMetalServerNetworkInterfaceIPOptions, "getBareMetalServerNetworkInterfaceIPOptions") + err = core.ValidateStruct(updateVolumeOptions, "updateVolumeOptions") if err != nil { return } pathParamsMap := map[string]string{ - "bare_metal_server_id": *getBareMetalServerNetworkInterfaceIPOptions.BareMetalServerID, - "network_interface_id": *getBareMetalServerNetworkInterfaceIPOptions.NetworkInterfaceID, - "id": *getBareMetalServerNetworkInterfaceIPOptions.ID, + "id": *updateVolumeOptions.ID, } - builder := core.NewRequestBuilder(core.GET) + builder := core.NewRequestBuilder(core.PATCH) builder = builder.WithContext(ctx) builder.EnableGzipCompression = vpc.GetEnableGzipCompression() - _, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/bare_metal_servers/{bare_metal_server_id}/network_interfaces/{network_interface_id}/ips/{id}`, pathParamsMap) + _, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/volumes/{id}`, pathParamsMap) if err != nil { return } - for headerName, headerValue := range getBareMetalServerNetworkInterfaceIPOptions.Headers { + for headerName, headerValue := range updateVolumeOptions.Headers { builder.AddHeader(headerName, headerValue) } - sdkHeaders := common.GetSdkHeaders("vpc", "V1", "GetBareMetalServerNetworkInterfaceIP") + sdkHeaders := common.GetSdkHeaders("vpc", "V1", "UpdateVolume") for headerName, headerValue := range sdkHeaders { builder.AddHeader(headerName, headerValue) } builder.AddHeader("Accept", "application/json") + builder.AddHeader("Content-Type", "application/merge-patch+json") + if updateVolumeOptions.IfMatch != nil { + builder.AddHeader("If-Match", fmt.Sprint(*updateVolumeOptions.IfMatch)) + } builder.AddQuery("version", fmt.Sprint(*vpc.Version)) builder.AddQuery("generation", fmt.Sprint(*vpc.generation)) + _, err = builder.SetBodyContentJSON(updateVolumeOptions.VolumePatch) + if err != nil { + return + } + request, err := builder.Build() if err != nil { return @@ -13452,7 +13472,7 @@ func (vpc *VpcV1) GetBareMetalServerNetworkInterfaceIPWithContext(ctx context.Co return } if rawResponse != nil { - err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalReservedIP) + err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalVolume) if err != nil { return } @@ -13462,100 +13482,126 @@ func (vpc *VpcV1) GetBareMetalServerNetworkInterfaceIPWithContext(ctx context.Co return } -// DeleteBareMetalServer : Delete a bare metal server -// This request deletes a bare metal server. This operation cannot be reversed. Any floating IPs associated with the -// bare metal server network interfaces are implicitly disassociated. -func (vpc *VpcV1) DeleteBareMetalServer(deleteBareMetalServerOptions *DeleteBareMetalServerOptions) (response *core.DetailedResponse, err error) { - return vpc.DeleteBareMetalServerWithContext(context.Background(), deleteBareMetalServerOptions) +// ListSnapshotConsistencyGroups : List all snapshot consistency groups +// This request lists all snapshot consistency groups in the region. A snapshot consistency group is a collection of +// individual snapshots taken at the same time. +func (vpc *VpcV1) ListSnapshotConsistencyGroups(listSnapshotConsistencyGroupsOptions *ListSnapshotConsistencyGroupsOptions) (result *SnapshotConsistencyGroupCollection, response *core.DetailedResponse, err error) { + return vpc.ListSnapshotConsistencyGroupsWithContext(context.Background(), listSnapshotConsistencyGroupsOptions) } -// DeleteBareMetalServerWithContext is an alternate form of the DeleteBareMetalServer method which supports a Context parameter -func (vpc *VpcV1) DeleteBareMetalServerWithContext(ctx context.Context, deleteBareMetalServerOptions *DeleteBareMetalServerOptions) (response *core.DetailedResponse, err error) { - err = core.ValidateNotNil(deleteBareMetalServerOptions, "deleteBareMetalServerOptions cannot be nil") - if err != nil { - return - } - err = core.ValidateStruct(deleteBareMetalServerOptions, "deleteBareMetalServerOptions") +// ListSnapshotConsistencyGroupsWithContext is an alternate form of the ListSnapshotConsistencyGroups method which supports a Context parameter +func (vpc *VpcV1) ListSnapshotConsistencyGroupsWithContext(ctx context.Context, listSnapshotConsistencyGroupsOptions *ListSnapshotConsistencyGroupsOptions) (result *SnapshotConsistencyGroupCollection, response *core.DetailedResponse, err error) { + err = core.ValidateStruct(listSnapshotConsistencyGroupsOptions, "listSnapshotConsistencyGroupsOptions") if err != nil { return } - pathParamsMap := map[string]string{ - "id": *deleteBareMetalServerOptions.ID, - } - - builder := core.NewRequestBuilder(core.DELETE) + builder := core.NewRequestBuilder(core.GET) builder = builder.WithContext(ctx) builder.EnableGzipCompression = vpc.GetEnableGzipCompression() - _, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/bare_metal_servers/{id}`, pathParamsMap) + _, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/snapshot_consistency_groups`, nil) if err != nil { return } - for headerName, headerValue := range deleteBareMetalServerOptions.Headers { + for headerName, headerValue := range listSnapshotConsistencyGroupsOptions.Headers { builder.AddHeader(headerName, headerValue) } - sdkHeaders := common.GetSdkHeaders("vpc", "V1", "DeleteBareMetalServer") + sdkHeaders := common.GetSdkHeaders("vpc", "V1", "ListSnapshotConsistencyGroups") for headerName, headerValue := range sdkHeaders { builder.AddHeader(headerName, headerValue) } + builder.AddHeader("Accept", "application/json") builder.AddQuery("version", fmt.Sprint(*vpc.Version)) builder.AddQuery("generation", fmt.Sprint(*vpc.generation)) + if listSnapshotConsistencyGroupsOptions.Start != nil { + builder.AddQuery("start", fmt.Sprint(*listSnapshotConsistencyGroupsOptions.Start)) + } + if listSnapshotConsistencyGroupsOptions.Limit != nil { + builder.AddQuery("limit", fmt.Sprint(*listSnapshotConsistencyGroupsOptions.Limit)) + } + if listSnapshotConsistencyGroupsOptions.ResourceGroupID != nil { + builder.AddQuery("resource_group.id", fmt.Sprint(*listSnapshotConsistencyGroupsOptions.ResourceGroupID)) + } + if listSnapshotConsistencyGroupsOptions.Name != nil { + builder.AddQuery("name", fmt.Sprint(*listSnapshotConsistencyGroupsOptions.Name)) + } + if listSnapshotConsistencyGroupsOptions.Sort != nil { + builder.AddQuery("sort", fmt.Sprint(*listSnapshotConsistencyGroupsOptions.Sort)) + } + if listSnapshotConsistencyGroupsOptions.BackupPolicyPlanID != nil { + builder.AddQuery("backup_policy_plan.id", fmt.Sprint(*listSnapshotConsistencyGroupsOptions.BackupPolicyPlanID)) + } request, err := builder.Build() if err != nil { return } - response, err = vpc.Service.Request(request, nil) + var rawResponse map[string]json.RawMessage + response, err = vpc.Service.Request(request, &rawResponse) + if err != nil { + return + } + if rawResponse != nil { + err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalSnapshotConsistencyGroupCollection) + if err != nil { + return + } + response.Result = result + } return } -// GetBareMetalServer : Retrieve a bare metal server -// This request retrieves a single bare metal server specified by the identifier in the URL. -func (vpc *VpcV1) GetBareMetalServer(getBareMetalServerOptions *GetBareMetalServerOptions) (result *BareMetalServer, response *core.DetailedResponse, err error) { - return vpc.GetBareMetalServerWithContext(context.Background(), getBareMetalServerOptions) +// CreateSnapshotConsistencyGroup : Create a snapshot consistency group +// This request creates a new snapshot consistency group from a snapshot consistency group object. The prototype object +// is structured in the same way as a retrieved consistency group, and contains the information necessary to provision +// the new snapshot consistency group. +func (vpc *VpcV1) CreateSnapshotConsistencyGroup(createSnapshotConsistencyGroupOptions *CreateSnapshotConsistencyGroupOptions) (result *SnapshotConsistencyGroup, response *core.DetailedResponse, err error) { + return vpc.CreateSnapshotConsistencyGroupWithContext(context.Background(), createSnapshotConsistencyGroupOptions) } -// GetBareMetalServerWithContext is an alternate form of the GetBareMetalServer method which supports a Context parameter -func (vpc *VpcV1) GetBareMetalServerWithContext(ctx context.Context, getBareMetalServerOptions *GetBareMetalServerOptions) (result *BareMetalServer, response *core.DetailedResponse, err error) { - err = core.ValidateNotNil(getBareMetalServerOptions, "getBareMetalServerOptions cannot be nil") +// CreateSnapshotConsistencyGroupWithContext is an alternate form of the CreateSnapshotConsistencyGroup method which supports a Context parameter +func (vpc *VpcV1) CreateSnapshotConsistencyGroupWithContext(ctx context.Context, createSnapshotConsistencyGroupOptions *CreateSnapshotConsistencyGroupOptions) (result *SnapshotConsistencyGroup, response *core.DetailedResponse, err error) { + err = core.ValidateNotNil(createSnapshotConsistencyGroupOptions, "createSnapshotConsistencyGroupOptions cannot be nil") if err != nil { return } - err = core.ValidateStruct(getBareMetalServerOptions, "getBareMetalServerOptions") + err = core.ValidateStruct(createSnapshotConsistencyGroupOptions, "createSnapshotConsistencyGroupOptions") if err != nil { return } - pathParamsMap := map[string]string{ - "id": *getBareMetalServerOptions.ID, - } - - builder := core.NewRequestBuilder(core.GET) + builder := core.NewRequestBuilder(core.POST) builder = builder.WithContext(ctx) builder.EnableGzipCompression = vpc.GetEnableGzipCompression() - _, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/bare_metal_servers/{id}`, pathParamsMap) + _, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/snapshot_consistency_groups`, nil) if err != nil { return } - for headerName, headerValue := range getBareMetalServerOptions.Headers { + for headerName, headerValue := range createSnapshotConsistencyGroupOptions.Headers { builder.AddHeader(headerName, headerValue) } - sdkHeaders := common.GetSdkHeaders("vpc", "V1", "GetBareMetalServer") + sdkHeaders := common.GetSdkHeaders("vpc", "V1", "CreateSnapshotConsistencyGroup") for headerName, headerValue := range sdkHeaders { builder.AddHeader(headerName, headerValue) } builder.AddHeader("Accept", "application/json") + builder.AddHeader("Content-Type", "application/json") builder.AddQuery("version", fmt.Sprint(*vpc.Version)) builder.AddQuery("generation", fmt.Sprint(*vpc.generation)) + _, err = builder.SetBodyContentJSON(createSnapshotConsistencyGroupOptions.SnapshotConsistencyGroupPrototype) + if err != nil { + return + } + request, err := builder.Build() if err != nil { return @@ -13567,7 +13613,7 @@ func (vpc *VpcV1) GetBareMetalServerWithContext(ctx context.Context, getBareMeta return } if rawResponse != nil { - err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalBareMetalServer) + err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalSnapshotConsistencyGroup) if err != nil { return } @@ -13577,55 +13623,49 @@ func (vpc *VpcV1) GetBareMetalServerWithContext(ctx context.Context, getBareMeta return } -// UpdateBareMetalServer : Update a bare metal server -// This request updates a bare metal server with the information in a provided patch. The bare metal server patch object -// is structured in the same way as a retrieved bare metal server and contains only the information to be updated. -func (vpc *VpcV1) UpdateBareMetalServer(updateBareMetalServerOptions *UpdateBareMetalServerOptions) (result *BareMetalServer, response *core.DetailedResponse, err error) { - return vpc.UpdateBareMetalServerWithContext(context.Background(), updateBareMetalServerOptions) +// DeleteSnapshotConsistencyGroup : Delete a snapshot consistency group +// This request deletes snapshot consistency group. This operation cannot be reversed. If the +// `delete_snapshots_on_delete` property is `true`, all snapshots in the consistency group will also be deleted. +func (vpc *VpcV1) DeleteSnapshotConsistencyGroup(deleteSnapshotConsistencyGroupOptions *DeleteSnapshotConsistencyGroupOptions) (result *SnapshotConsistencyGroup, response *core.DetailedResponse, err error) { + return vpc.DeleteSnapshotConsistencyGroupWithContext(context.Background(), deleteSnapshotConsistencyGroupOptions) } -// UpdateBareMetalServerWithContext is an alternate form of the UpdateBareMetalServer method which supports a Context parameter -func (vpc *VpcV1) UpdateBareMetalServerWithContext(ctx context.Context, updateBareMetalServerOptions *UpdateBareMetalServerOptions) (result *BareMetalServer, response *core.DetailedResponse, err error) { - err = core.ValidateNotNil(updateBareMetalServerOptions, "updateBareMetalServerOptions cannot be nil") +// DeleteSnapshotConsistencyGroupWithContext is an alternate form of the DeleteSnapshotConsistencyGroup method which supports a Context parameter +func (vpc *VpcV1) DeleteSnapshotConsistencyGroupWithContext(ctx context.Context, deleteSnapshotConsistencyGroupOptions *DeleteSnapshotConsistencyGroupOptions) (result *SnapshotConsistencyGroup, response *core.DetailedResponse, err error) { + err = core.ValidateNotNil(deleteSnapshotConsistencyGroupOptions, "deleteSnapshotConsistencyGroupOptions cannot be nil") if err != nil { return } - err = core.ValidateStruct(updateBareMetalServerOptions, "updateBareMetalServerOptions") + err = core.ValidateStruct(deleteSnapshotConsistencyGroupOptions, "deleteSnapshotConsistencyGroupOptions") if err != nil { return } pathParamsMap := map[string]string{ - "id": *updateBareMetalServerOptions.ID, + "id": *deleteSnapshotConsistencyGroupOptions.ID, } - builder := core.NewRequestBuilder(core.PATCH) + builder := core.NewRequestBuilder(core.DELETE) builder = builder.WithContext(ctx) builder.EnableGzipCompression = vpc.GetEnableGzipCompression() - _, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/bare_metal_servers/{id}`, pathParamsMap) + _, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/snapshot_consistency_groups/{id}`, pathParamsMap) if err != nil { return } - for headerName, headerValue := range updateBareMetalServerOptions.Headers { + for headerName, headerValue := range deleteSnapshotConsistencyGroupOptions.Headers { builder.AddHeader(headerName, headerValue) } - sdkHeaders := common.GetSdkHeaders("vpc", "V1", "UpdateBareMetalServer") + sdkHeaders := common.GetSdkHeaders("vpc", "V1", "DeleteSnapshotConsistencyGroup") for headerName, headerValue := range sdkHeaders { builder.AddHeader(headerName, headerValue) } builder.AddHeader("Accept", "application/json") - builder.AddHeader("Content-Type", "application/merge-patch+json") builder.AddQuery("version", fmt.Sprint(*vpc.Version)) builder.AddQuery("generation", fmt.Sprint(*vpc.generation)) - _, err = builder.SetBodyContentJSON(updateBareMetalServerOptions.BareMetalServerPatch) - if err != nil { - return - } - request, err := builder.Build() if err != nil { return @@ -13637,7 +13677,7 @@ func (vpc *VpcV1) UpdateBareMetalServerWithContext(ctx context.Context, updateBa return } if rawResponse != nil { - err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalBareMetalServer) + err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalSnapshotConsistencyGroup) if err != nil { return } @@ -13647,42 +13687,40 @@ func (vpc *VpcV1) UpdateBareMetalServerWithContext(ctx context.Context, updateBa return } -// GetBareMetalServerInitialization : Retrieve initialization configuration for a bare metal server -// This request retrieves configuration used to initialize the bare metal server, such as the image used, SSH keys, and -// any configured usernames and passwords. These can subsequently be changed on the server and therefore may not be -// current. -func (vpc *VpcV1) GetBareMetalServerInitialization(getBareMetalServerInitializationOptions *GetBareMetalServerInitializationOptions) (result *BareMetalServerInitialization, response *core.DetailedResponse, err error) { - return vpc.GetBareMetalServerInitializationWithContext(context.Background(), getBareMetalServerInitializationOptions) +// GetSnapshotConsistencyGroup : Retrieve a snapshot consistency group +// This request retrieves a single snapshot consistency group specified by the identifier in the URL. +func (vpc *VpcV1) GetSnapshotConsistencyGroup(getSnapshotConsistencyGroupOptions *GetSnapshotConsistencyGroupOptions) (result *SnapshotConsistencyGroup, response *core.DetailedResponse, err error) { + return vpc.GetSnapshotConsistencyGroupWithContext(context.Background(), getSnapshotConsistencyGroupOptions) } -// GetBareMetalServerInitializationWithContext is an alternate form of the GetBareMetalServerInitialization method which supports a Context parameter -func (vpc *VpcV1) GetBareMetalServerInitializationWithContext(ctx context.Context, getBareMetalServerInitializationOptions *GetBareMetalServerInitializationOptions) (result *BareMetalServerInitialization, response *core.DetailedResponse, err error) { - err = core.ValidateNotNil(getBareMetalServerInitializationOptions, "getBareMetalServerInitializationOptions cannot be nil") +// GetSnapshotConsistencyGroupWithContext is an alternate form of the GetSnapshotConsistencyGroup method which supports a Context parameter +func (vpc *VpcV1) GetSnapshotConsistencyGroupWithContext(ctx context.Context, getSnapshotConsistencyGroupOptions *GetSnapshotConsistencyGroupOptions) (result *SnapshotConsistencyGroup, response *core.DetailedResponse, err error) { + err = core.ValidateNotNil(getSnapshotConsistencyGroupOptions, "getSnapshotConsistencyGroupOptions cannot be nil") if err != nil { return } - err = core.ValidateStruct(getBareMetalServerInitializationOptions, "getBareMetalServerInitializationOptions") + err = core.ValidateStruct(getSnapshotConsistencyGroupOptions, "getSnapshotConsistencyGroupOptions") if err != nil { return } pathParamsMap := map[string]string{ - "id": *getBareMetalServerInitializationOptions.ID, + "id": *getSnapshotConsistencyGroupOptions.ID, } builder := core.NewRequestBuilder(core.GET) builder = builder.WithContext(ctx) builder.EnableGzipCompression = vpc.GetEnableGzipCompression() - _, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/bare_metal_servers/{id}/initialization`, pathParamsMap) + _, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/snapshot_consistency_groups/{id}`, pathParamsMap) if err != nil { return } - for headerName, headerValue := range getBareMetalServerInitializationOptions.Headers { + for headerName, headerValue := range getSnapshotConsistencyGroupOptions.Headers { builder.AddHeader(headerName, headerValue) } - sdkHeaders := common.GetSdkHeaders("vpc", "V1", "GetBareMetalServerInitialization") + sdkHeaders := common.GetSdkHeaders("vpc", "V1", "GetSnapshotConsistencyGroup") for headerName, headerValue := range sdkHeaders { builder.AddHeader(headerName, headerValue) } @@ -13702,7 +13740,7 @@ func (vpc *VpcV1) GetBareMetalServerInitializationWithContext(ctx context.Contex return } if rawResponse != nil { - err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalBareMetalServerInitialization) + err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalSnapshotConsistencyGroup) if err != nil { return } @@ -13712,97 +13750,117 @@ func (vpc *VpcV1) GetBareMetalServerInitializationWithContext(ctx context.Contex return } -// RestartBareMetalServer : Restart a bare metal server -// This request restarts a bare metal server. It will run immediately regardless of the state of the server. -func (vpc *VpcV1) RestartBareMetalServer(restartBareMetalServerOptions *RestartBareMetalServerOptions) (response *core.DetailedResponse, err error) { - return vpc.RestartBareMetalServerWithContext(context.Background(), restartBareMetalServerOptions) +// UpdateSnapshotConsistencyGroup : Update a snapshot consistency group +// This request updates a snapshot consistency group with the information in a provided snapshot consistency group +// patch. The snapshot consistency group patch object is structured in the same way as a retrieved snapshot consistency +// group and contains only the information to be updated. +func (vpc *VpcV1) UpdateSnapshotConsistencyGroup(updateSnapshotConsistencyGroupOptions *UpdateSnapshotConsistencyGroupOptions) (result *SnapshotConsistencyGroup, response *core.DetailedResponse, err error) { + return vpc.UpdateSnapshotConsistencyGroupWithContext(context.Background(), updateSnapshotConsistencyGroupOptions) } -// RestartBareMetalServerWithContext is an alternate form of the RestartBareMetalServer method which supports a Context parameter -func (vpc *VpcV1) RestartBareMetalServerWithContext(ctx context.Context, restartBareMetalServerOptions *RestartBareMetalServerOptions) (response *core.DetailedResponse, err error) { - err = core.ValidateNotNil(restartBareMetalServerOptions, "restartBareMetalServerOptions cannot be nil") +// UpdateSnapshotConsistencyGroupWithContext is an alternate form of the UpdateSnapshotConsistencyGroup method which supports a Context parameter +func (vpc *VpcV1) UpdateSnapshotConsistencyGroupWithContext(ctx context.Context, updateSnapshotConsistencyGroupOptions *UpdateSnapshotConsistencyGroupOptions) (result *SnapshotConsistencyGroup, response *core.DetailedResponse, err error) { + err = core.ValidateNotNil(updateSnapshotConsistencyGroupOptions, "updateSnapshotConsistencyGroupOptions cannot be nil") if err != nil { return } - err = core.ValidateStruct(restartBareMetalServerOptions, "restartBareMetalServerOptions") + err = core.ValidateStruct(updateSnapshotConsistencyGroupOptions, "updateSnapshotConsistencyGroupOptions") if err != nil { return } pathParamsMap := map[string]string{ - "id": *restartBareMetalServerOptions.ID, + "id": *updateSnapshotConsistencyGroupOptions.ID, } - builder := core.NewRequestBuilder(core.POST) + builder := core.NewRequestBuilder(core.PATCH) builder = builder.WithContext(ctx) builder.EnableGzipCompression = vpc.GetEnableGzipCompression() - _, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/bare_metal_servers/{id}/restart`, pathParamsMap) + _, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/snapshot_consistency_groups/{id}`, pathParamsMap) if err != nil { return } - for headerName, headerValue := range restartBareMetalServerOptions.Headers { + for headerName, headerValue := range updateSnapshotConsistencyGroupOptions.Headers { builder.AddHeader(headerName, headerValue) } - sdkHeaders := common.GetSdkHeaders("vpc", "V1", "RestartBareMetalServer") + sdkHeaders := common.GetSdkHeaders("vpc", "V1", "UpdateSnapshotConsistencyGroup") for headerName, headerValue := range sdkHeaders { builder.AddHeader(headerName, headerValue) } + builder.AddHeader("Accept", "application/json") + builder.AddHeader("Content-Type", "application/merge-patch+json") + if updateSnapshotConsistencyGroupOptions.IfMatch != nil { + builder.AddHeader("If-Match", fmt.Sprint(*updateSnapshotConsistencyGroupOptions.IfMatch)) + } builder.AddQuery("version", fmt.Sprint(*vpc.Version)) builder.AddQuery("generation", fmt.Sprint(*vpc.generation)) - request, err := builder.Build() + _, err = builder.SetBodyContentJSON(updateSnapshotConsistencyGroupOptions.SnapshotConsistencyGroupPatch) if err != nil { return } - response, err = vpc.Service.Request(request, nil) - - return -} + request, err := builder.Build() + if err != nil { + return + } -// StartBareMetalServer : Start a bare metal server -// This request starts a bare metal server. It will run immediately provided the server is stopped. -func (vpc *VpcV1) StartBareMetalServer(startBareMetalServerOptions *StartBareMetalServerOptions) (response *core.DetailedResponse, err error) { - return vpc.StartBareMetalServerWithContext(context.Background(), startBareMetalServerOptions) + var rawResponse map[string]json.RawMessage + response, err = vpc.Service.Request(request, &rawResponse) + if err != nil { + return + } + if rawResponse != nil { + err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalSnapshotConsistencyGroup) + if err != nil { + return + } + response.Result = result + } + + return } -// StartBareMetalServerWithContext is an alternate form of the StartBareMetalServer method which supports a Context parameter -func (vpc *VpcV1) StartBareMetalServerWithContext(ctx context.Context, startBareMetalServerOptions *StartBareMetalServerOptions) (response *core.DetailedResponse, err error) { - err = core.ValidateNotNil(startBareMetalServerOptions, "startBareMetalServerOptions cannot be nil") +// DeleteSnapshots : Delete a filtered collection of snapshots +// This request deletes all snapshots created from a specific source volume. +func (vpc *VpcV1) DeleteSnapshots(deleteSnapshotsOptions *DeleteSnapshotsOptions) (response *core.DetailedResponse, err error) { + return vpc.DeleteSnapshotsWithContext(context.Background(), deleteSnapshotsOptions) +} + +// DeleteSnapshotsWithContext is an alternate form of the DeleteSnapshots method which supports a Context parameter +func (vpc *VpcV1) DeleteSnapshotsWithContext(ctx context.Context, deleteSnapshotsOptions *DeleteSnapshotsOptions) (response *core.DetailedResponse, err error) { + err = core.ValidateNotNil(deleteSnapshotsOptions, "deleteSnapshotsOptions cannot be nil") if err != nil { return } - err = core.ValidateStruct(startBareMetalServerOptions, "startBareMetalServerOptions") + err = core.ValidateStruct(deleteSnapshotsOptions, "deleteSnapshotsOptions") if err != nil { return } - pathParamsMap := map[string]string{ - "id": *startBareMetalServerOptions.ID, - } - - builder := core.NewRequestBuilder(core.POST) + builder := core.NewRequestBuilder(core.DELETE) builder = builder.WithContext(ctx) builder.EnableGzipCompression = vpc.GetEnableGzipCompression() - _, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/bare_metal_servers/{id}/start`, pathParamsMap) + _, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/snapshots`, nil) if err != nil { return } - for headerName, headerValue := range startBareMetalServerOptions.Headers { + for headerName, headerValue := range deleteSnapshotsOptions.Headers { builder.AddHeader(headerName, headerValue) } - sdkHeaders := common.GetSdkHeaders("vpc", "V1", "StartBareMetalServer") + sdkHeaders := common.GetSdkHeaders("vpc", "V1", "DeleteSnapshots") for headerName, headerValue := range sdkHeaders { builder.AddHeader(headerName, headerValue) } builder.AddQuery("version", fmt.Sprint(*vpc.Version)) builder.AddQuery("generation", fmt.Sprint(*vpc.generation)) + builder.AddQuery("source_volume.id", fmt.Sprint(*deleteSnapshotsOptions.SourceVolumeID)) request, err := builder.Build() if err != nil { @@ -13814,56 +13872,105 @@ func (vpc *VpcV1) StartBareMetalServerWithContext(ctx context.Context, startBare return } -// StopBareMetalServer : Stop a bare metal server -// This request stops a bare metal server. It will run immediately provided the server is running. Note: A soft stop may -// not complete as it relies on the operating system to perform the operation. -func (vpc *VpcV1) StopBareMetalServer(stopBareMetalServerOptions *StopBareMetalServerOptions) (response *core.DetailedResponse, err error) { - return vpc.StopBareMetalServerWithContext(context.Background(), stopBareMetalServerOptions) +// ListSnapshots : List all snapshots +// This request lists all snapshots in the region. A snapshot preserves the data of a volume at the time the snapshot is +// created. +func (vpc *VpcV1) ListSnapshots(listSnapshotsOptions *ListSnapshotsOptions) (result *SnapshotCollection, response *core.DetailedResponse, err error) { + return vpc.ListSnapshotsWithContext(context.Background(), listSnapshotsOptions) } -// StopBareMetalServerWithContext is an alternate form of the StopBareMetalServer method which supports a Context parameter -func (vpc *VpcV1) StopBareMetalServerWithContext(ctx context.Context, stopBareMetalServerOptions *StopBareMetalServerOptions) (response *core.DetailedResponse, err error) { - err = core.ValidateNotNil(stopBareMetalServerOptions, "stopBareMetalServerOptions cannot be nil") - if err != nil { - return - } - err = core.ValidateStruct(stopBareMetalServerOptions, "stopBareMetalServerOptions") +// ListSnapshotsWithContext is an alternate form of the ListSnapshots method which supports a Context parameter +func (vpc *VpcV1) ListSnapshotsWithContext(ctx context.Context, listSnapshotsOptions *ListSnapshotsOptions) (result *SnapshotCollection, response *core.DetailedResponse, err error) { + err = core.ValidateStruct(listSnapshotsOptions, "listSnapshotsOptions") if err != nil { return } - pathParamsMap := map[string]string{ - "id": *stopBareMetalServerOptions.ID, - } - - builder := core.NewRequestBuilder(core.POST) + builder := core.NewRequestBuilder(core.GET) builder = builder.WithContext(ctx) builder.EnableGzipCompression = vpc.GetEnableGzipCompression() - _, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/bare_metal_servers/{id}/stop`, pathParamsMap) + _, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/snapshots`, nil) if err != nil { return } - for headerName, headerValue := range stopBareMetalServerOptions.Headers { + for headerName, headerValue := range listSnapshotsOptions.Headers { builder.AddHeader(headerName, headerValue) } - sdkHeaders := common.GetSdkHeaders("vpc", "V1", "StopBareMetalServer") + sdkHeaders := common.GetSdkHeaders("vpc", "V1", "ListSnapshots") for headerName, headerValue := range sdkHeaders { builder.AddHeader(headerName, headerValue) } - builder.AddHeader("Content-Type", "application/json") + builder.AddHeader("Accept", "application/json") builder.AddQuery("version", fmt.Sprint(*vpc.Version)) builder.AddQuery("generation", fmt.Sprint(*vpc.generation)) - - body := make(map[string]interface{}) - if stopBareMetalServerOptions.Type != nil { - body["type"] = stopBareMetalServerOptions.Type + if listSnapshotsOptions.Start != nil { + builder.AddQuery("start", fmt.Sprint(*listSnapshotsOptions.Start)) } - _, err = builder.SetBodyContentJSON(body) - if err != nil { - return + if listSnapshotsOptions.Limit != nil { + builder.AddQuery("limit", fmt.Sprint(*listSnapshotsOptions.Limit)) + } + if listSnapshotsOptions.Tag != nil { + builder.AddQuery("tag", fmt.Sprint(*listSnapshotsOptions.Tag)) + } + if listSnapshotsOptions.ResourceGroupID != nil { + builder.AddQuery("resource_group.id", fmt.Sprint(*listSnapshotsOptions.ResourceGroupID)) + } + if listSnapshotsOptions.Name != nil { + builder.AddQuery("name", fmt.Sprint(*listSnapshotsOptions.Name)) + } + if listSnapshotsOptions.SourceVolumeID != nil { + builder.AddQuery("source_volume.id", fmt.Sprint(*listSnapshotsOptions.SourceVolumeID)) + } + if listSnapshotsOptions.SourceVolumeCRN != nil { + builder.AddQuery("source_volume.crn", fmt.Sprint(*listSnapshotsOptions.SourceVolumeCRN)) + } + if listSnapshotsOptions.SourceImageID != nil { + builder.AddQuery("source_image.id", fmt.Sprint(*listSnapshotsOptions.SourceImageID)) + } + if listSnapshotsOptions.SourceImageCRN != nil { + builder.AddQuery("source_image.crn", fmt.Sprint(*listSnapshotsOptions.SourceImageCRN)) + } + 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)) + } + if listSnapshotsOptions.CopiesID != nil { + builder.AddQuery("copies[].id", fmt.Sprint(*listSnapshotsOptions.CopiesID)) + } + if listSnapshotsOptions.CopiesName != nil { + builder.AddQuery("copies[].name", fmt.Sprint(*listSnapshotsOptions.CopiesName)) + } + if listSnapshotsOptions.CopiesCRN != nil { + builder.AddQuery("copies[].crn", fmt.Sprint(*listSnapshotsOptions.CopiesCRN)) + } + if listSnapshotsOptions.CopiesRemoteRegionName != nil { + builder.AddQuery("copies[].remote.region.name", fmt.Sprint(*listSnapshotsOptions.CopiesRemoteRegionName)) + } + if listSnapshotsOptions.SourceSnapshotID != nil { + builder.AddQuery("source_snapshot.id", fmt.Sprint(*listSnapshotsOptions.SourceSnapshotID)) + } + if listSnapshotsOptions.SourceSnapshotRemoteRegionName != nil { + builder.AddQuery("source_snapshot.remote.region.name", fmt.Sprint(*listSnapshotsOptions.SourceSnapshotRemoteRegionName)) + } + if listSnapshotsOptions.SourceVolumeRemoteRegionName != nil { + builder.AddQuery("source_volume.remote.region.name", fmt.Sprint(*listSnapshotsOptions.SourceVolumeRemoteRegionName)) + } + if listSnapshotsOptions.SourceImageRemoteRegionName != nil { + builder.AddQuery("source_image.remote.region.name", fmt.Sprint(*listSnapshotsOptions.SourceImageRemoteRegionName)) + } + if listSnapshotsOptions.ClonesZoneName != nil { + builder.AddQuery("clones[].zone.name", fmt.Sprint(*listSnapshotsOptions.ClonesZoneName)) + } + if listSnapshotsOptions.SnapshotConsistencyGroupID != nil { + builder.AddQuery("snapshot_consistency_group.id", fmt.Sprint(*listSnapshotsOptions.SnapshotConsistencyGroupID)) + } + if listSnapshotsOptions.SnapshotConsistencyGroupCRN != nil { + builder.AddQuery("snapshot_consistency_group.crn", fmt.Sprint(*listSnapshotsOptions.SnapshotConsistencyGroupCRN)) } request, err := builder.Build() @@ -13871,50 +13978,65 @@ func (vpc *VpcV1) StopBareMetalServerWithContext(ctx context.Context, stopBareMe return } - response, err = vpc.Service.Request(request, nil) + 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, UnmarshalSnapshotCollection) + if err != nil { + return + } + response.Result = result + } return } -// ListVolumeProfiles : List all volume profiles -// This request lists all [volume profiles](https://cloud.ibm.com/docs/vpc?topic=vpc-block-storage-profiles) available -// in the region. A volume profile specifies the performance characteristics and pricing model for a volume. -func (vpc *VpcV1) ListVolumeProfiles(listVolumeProfilesOptions *ListVolumeProfilesOptions) (result *VolumeProfileCollection, response *core.DetailedResponse, err error) { - return vpc.ListVolumeProfilesWithContext(context.Background(), listVolumeProfilesOptions) +// CreateSnapshot : Create a snapshot +// This request creates a new snapshot from a snapshot prototype object. The prototype object is structured in the same +// way as a retrieved snapshot, and contains the information necessary to provision the new snapshot. +func (vpc *VpcV1) CreateSnapshot(createSnapshotOptions *CreateSnapshotOptions) (result *Snapshot, response *core.DetailedResponse, err error) { + return vpc.CreateSnapshotWithContext(context.Background(), createSnapshotOptions) } -// ListVolumeProfilesWithContext is an alternate form of the ListVolumeProfiles method which supports a Context parameter -func (vpc *VpcV1) ListVolumeProfilesWithContext(ctx context.Context, listVolumeProfilesOptions *ListVolumeProfilesOptions) (result *VolumeProfileCollection, response *core.DetailedResponse, err error) { - err = core.ValidateStruct(listVolumeProfilesOptions, "listVolumeProfilesOptions") +// CreateSnapshotWithContext is an alternate form of the CreateSnapshot method which supports a Context parameter +func (vpc *VpcV1) CreateSnapshotWithContext(ctx context.Context, createSnapshotOptions *CreateSnapshotOptions) (result *Snapshot, response *core.DetailedResponse, err error) { + err = core.ValidateNotNil(createSnapshotOptions, "createSnapshotOptions cannot be nil") + if err != nil { + return + } + err = core.ValidateStruct(createSnapshotOptions, "createSnapshotOptions") if err != nil { return } - builder := core.NewRequestBuilder(core.GET) + builder := core.NewRequestBuilder(core.POST) builder = builder.WithContext(ctx) builder.EnableGzipCompression = vpc.GetEnableGzipCompression() - _, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/volume/profiles`, nil) + _, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/snapshots`, nil) if err != nil { return } - for headerName, headerValue := range listVolumeProfilesOptions.Headers { + for headerName, headerValue := range createSnapshotOptions.Headers { builder.AddHeader(headerName, headerValue) } - sdkHeaders := common.GetSdkHeaders("vpc", "V1", "ListVolumeProfiles") + sdkHeaders := common.GetSdkHeaders("vpc", "V1", "CreateSnapshot") 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)) - if listVolumeProfilesOptions.Start != nil { - builder.AddQuery("start", fmt.Sprint(*listVolumeProfilesOptions.Start)) - } - if listVolumeProfilesOptions.Limit != nil { - builder.AddQuery("limit", fmt.Sprint(*listVolumeProfilesOptions.Limit)) + + _, err = builder.SetBodyContentJSON(createSnapshotOptions.SnapshotPrototype) + if err != nil { + return } request, err := builder.Build() @@ -13928,7 +14050,7 @@ func (vpc *VpcV1) ListVolumeProfilesWithContext(ctx context.Context, listVolumeP return } if rawResponse != nil { - err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalVolumeProfileCollection) + err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalSnapshot) if err != nil { return } @@ -13938,44 +14060,46 @@ func (vpc *VpcV1) ListVolumeProfilesWithContext(ctx context.Context, listVolumeP return } -// GetVolumeProfile : Retrieve a volume profile -// This request retrieves a single volume profile specified by the name in the URL. -func (vpc *VpcV1) GetVolumeProfile(getVolumeProfileOptions *GetVolumeProfileOptions) (result *VolumeProfile, response *core.DetailedResponse, err error) { - return vpc.GetVolumeProfileWithContext(context.Background(), getVolumeProfileOptions) +// DeleteSnapshot : Delete a snapshot +// This request deletes a snapshot. This operation cannot be reversed. +func (vpc *VpcV1) DeleteSnapshot(deleteSnapshotOptions *DeleteSnapshotOptions) (response *core.DetailedResponse, err error) { + return vpc.DeleteSnapshotWithContext(context.Background(), deleteSnapshotOptions) } -// GetVolumeProfileWithContext is an alternate form of the GetVolumeProfile method which supports a Context parameter -func (vpc *VpcV1) GetVolumeProfileWithContext(ctx context.Context, getVolumeProfileOptions *GetVolumeProfileOptions) (result *VolumeProfile, response *core.DetailedResponse, err error) { - err = core.ValidateNotNil(getVolumeProfileOptions, "getVolumeProfileOptions cannot be nil") +// DeleteSnapshotWithContext is an alternate form of the DeleteSnapshot method which supports a Context parameter +func (vpc *VpcV1) DeleteSnapshotWithContext(ctx context.Context, deleteSnapshotOptions *DeleteSnapshotOptions) (response *core.DetailedResponse, err error) { + err = core.ValidateNotNil(deleteSnapshotOptions, "deleteSnapshotOptions cannot be nil") if err != nil { return } - err = core.ValidateStruct(getVolumeProfileOptions, "getVolumeProfileOptions") + err = core.ValidateStruct(deleteSnapshotOptions, "deleteSnapshotOptions") if err != nil { return } pathParamsMap := map[string]string{ - "name": *getVolumeProfileOptions.Name, + "id": *deleteSnapshotOptions.ID, } - builder := core.NewRequestBuilder(core.GET) + builder := core.NewRequestBuilder(core.DELETE) builder = builder.WithContext(ctx) builder.EnableGzipCompression = vpc.GetEnableGzipCompression() - _, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/volume/profiles/{name}`, pathParamsMap) + _, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/snapshots/{id}`, pathParamsMap) if err != nil { return } - for headerName, headerValue := range getVolumeProfileOptions.Headers { + for headerName, headerValue := range deleteSnapshotOptions.Headers { builder.AddHeader(headerName, headerValue) } - sdkHeaders := common.GetSdkHeaders("vpc", "V1", "GetVolumeProfile") + sdkHeaders := common.GetSdkHeaders("vpc", "V1", "DeleteSnapshot") for headerName, headerValue := range sdkHeaders { builder.AddHeader(headerName, headerValue) } - builder.AddHeader("Accept", "application/json") + if deleteSnapshotOptions.IfMatch != nil { + builder.AddHeader("If-Match", fmt.Sprint(*deleteSnapshotOptions.IfMatch)) + } builder.AddQuery("version", fmt.Sprint(*vpc.Version)) builder.AddQuery("generation", fmt.Sprint(*vpc.generation)) @@ -13985,49 +14109,45 @@ func (vpc *VpcV1) GetVolumeProfileWithContext(ctx context.Context, getVolumeProf 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, UnmarshalVolumeProfile) - if err != nil { - return - } - response.Result = result - } + response, err = vpc.Service.Request(request, nil) return } -// ListVolumes : List all volumes -// This request lists all volumes in the region. Volumes are network-connected block storage devices that may be -// attached to one or more instances in the same region. -func (vpc *VpcV1) ListVolumes(listVolumesOptions *ListVolumesOptions) (result *VolumeCollection, response *core.DetailedResponse, err error) { - return vpc.ListVolumesWithContext(context.Background(), listVolumesOptions) +// GetSnapshot : Retrieve a snapshot +// This request retrieves a single snapshot specified by the identifier in the URL. +func (vpc *VpcV1) GetSnapshot(getSnapshotOptions *GetSnapshotOptions) (result *Snapshot, response *core.DetailedResponse, err error) { + return vpc.GetSnapshotWithContext(context.Background(), getSnapshotOptions) } -// ListVolumesWithContext is an alternate form of the ListVolumes method which supports a Context parameter -func (vpc *VpcV1) ListVolumesWithContext(ctx context.Context, listVolumesOptions *ListVolumesOptions) (result *VolumeCollection, response *core.DetailedResponse, err error) { - err = core.ValidateStruct(listVolumesOptions, "listVolumesOptions") +// GetSnapshotWithContext is an alternate form of the GetSnapshot method which supports a Context parameter +func (vpc *VpcV1) GetSnapshotWithContext(ctx context.Context, getSnapshotOptions *GetSnapshotOptions) (result *Snapshot, response *core.DetailedResponse, err error) { + err = core.ValidateNotNil(getSnapshotOptions, "getSnapshotOptions cannot be nil") + if err != nil { + return + } + err = core.ValidateStruct(getSnapshotOptions, "getSnapshotOptions") if err != nil { return } + pathParamsMap := map[string]string{ + "id": *getSnapshotOptions.ID, + } + builder := core.NewRequestBuilder(core.GET) builder = builder.WithContext(ctx) builder.EnableGzipCompression = vpc.GetEnableGzipCompression() - _, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/volumes`, nil) + _, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/snapshots/{id}`, pathParamsMap) if err != nil { return } - for headerName, headerValue := range listVolumesOptions.Headers { + for headerName, headerValue := range getSnapshotOptions.Headers { builder.AddHeader(headerName, headerValue) } - sdkHeaders := common.GetSdkHeaders("vpc", "V1", "ListVolumes") + sdkHeaders := common.GetSdkHeaders("vpc", "V1", "GetSnapshot") for headerName, headerValue := range sdkHeaders { builder.AddHeader(headerName, headerValue) } @@ -14035,30 +14155,6 @@ func (vpc *VpcV1) ListVolumesWithContext(ctx context.Context, listVolumesOptions builder.AddQuery("version", fmt.Sprint(*vpc.Version)) builder.AddQuery("generation", fmt.Sprint(*vpc.generation)) - if listVolumesOptions.Start != nil { - builder.AddQuery("start", fmt.Sprint(*listVolumesOptions.Start)) - } - if listVolumesOptions.Limit != nil { - builder.AddQuery("limit", fmt.Sprint(*listVolumesOptions.Limit)) - } - if listVolumesOptions.Name != nil { - builder.AddQuery("name", fmt.Sprint(*listVolumesOptions.Name)) - } - if listVolumesOptions.AttachmentState != nil { - builder.AddQuery("attachment_state", fmt.Sprint(*listVolumesOptions.AttachmentState)) - } - if listVolumesOptions.Encryption != nil { - builder.AddQuery("encryption", fmt.Sprint(*listVolumesOptions.Encryption)) - } - if listVolumesOptions.OperatingSystemFamily != nil { - builder.AddQuery("operating_system.family", fmt.Sprint(*listVolumesOptions.OperatingSystemFamily)) - } - if listVolumesOptions.OperatingSystemArchitecture != nil { - builder.AddQuery("operating_system.architecture", fmt.Sprint(*listVolumesOptions.OperatingSystemArchitecture)) - } - if listVolumesOptions.ZoneName != nil { - builder.AddQuery("zone.name", fmt.Sprint(*listVolumesOptions.ZoneName)) - } request, err := builder.Build() if err != nil { @@ -14071,7 +14167,7 @@ func (vpc *VpcV1) ListVolumesWithContext(ctx context.Context, listVolumesOptions return } if rawResponse != nil { - err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalVolumeCollection) + err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalSnapshot) if err != nil { return } @@ -14081,47 +14177,54 @@ func (vpc *VpcV1) ListVolumesWithContext(ctx context.Context, listVolumesOptions return } -// CreateVolume : Create a volume -// This request creates a new volume from a volume prototype object. The prototype object is structured in the same way -// as a retrieved volume, and contains the information necessary to create the new volume. -func (vpc *VpcV1) CreateVolume(createVolumeOptions *CreateVolumeOptions) (result *Volume, response *core.DetailedResponse, err error) { - return vpc.CreateVolumeWithContext(context.Background(), createVolumeOptions) +// UpdateSnapshot : Update a snapshot +// This request updates a snapshot with the information in a provided snapshot patch. The snapshot consistency group +// patch object is structured in the same way as a retrieved snapshot and contains only the information to be updated. +func (vpc *VpcV1) UpdateSnapshot(updateSnapshotOptions *UpdateSnapshotOptions) (result *Snapshot, response *core.DetailedResponse, err error) { + return vpc.UpdateSnapshotWithContext(context.Background(), updateSnapshotOptions) } -// CreateVolumeWithContext is an alternate form of the CreateVolume method which supports a Context parameter -func (vpc *VpcV1) CreateVolumeWithContext(ctx context.Context, createVolumeOptions *CreateVolumeOptions) (result *Volume, response *core.DetailedResponse, err error) { - err = core.ValidateNotNil(createVolumeOptions, "createVolumeOptions cannot be nil") +// UpdateSnapshotWithContext is an alternate form of the UpdateSnapshot method which supports a Context parameter +func (vpc *VpcV1) UpdateSnapshotWithContext(ctx context.Context, updateSnapshotOptions *UpdateSnapshotOptions) (result *Snapshot, response *core.DetailedResponse, err error) { + err = core.ValidateNotNil(updateSnapshotOptions, "updateSnapshotOptions cannot be nil") if err != nil { return } - err = core.ValidateStruct(createVolumeOptions, "createVolumeOptions") + err = core.ValidateStruct(updateSnapshotOptions, "updateSnapshotOptions") if err != nil { return } - builder := core.NewRequestBuilder(core.POST) + pathParamsMap := map[string]string{ + "id": *updateSnapshotOptions.ID, + } + + builder := core.NewRequestBuilder(core.PATCH) builder = builder.WithContext(ctx) builder.EnableGzipCompression = vpc.GetEnableGzipCompression() - _, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/volumes`, nil) + _, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/snapshots/{id}`, pathParamsMap) if err != nil { return } - for headerName, headerValue := range createVolumeOptions.Headers { + for headerName, headerValue := range updateSnapshotOptions.Headers { builder.AddHeader(headerName, headerValue) } - sdkHeaders := common.GetSdkHeaders("vpc", "V1", "CreateVolume") + sdkHeaders := common.GetSdkHeaders("vpc", "V1", "UpdateSnapshot") for headerName, headerValue := range sdkHeaders { builder.AddHeader(headerName, headerValue) } builder.AddHeader("Accept", "application/json") - builder.AddHeader("Content-Type", "application/json") + builder.AddHeader("Content-Type", "application/merge-patch+json") + if updateSnapshotOptions.IfMatch != nil { + builder.AddHeader("If-Match", fmt.Sprint(*updateSnapshotOptions.IfMatch)) + } builder.AddQuery("version", fmt.Sprint(*vpc.Version)) builder.AddQuery("generation", fmt.Sprint(*vpc.generation)) - _, err = builder.SetBodyContentJSON(createVolumeOptions.VolumePrototype) + _, err = builder.SetBodyContentJSON(updateSnapshotOptions.SnapshotPatch) if err != nil { return } @@ -14137,7 +14240,7 @@ func (vpc *VpcV1) CreateVolumeWithContext(ctx context.Context, createVolumeOptio return } if rawResponse != nil { - err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalVolume) + err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalSnapshot) if err != nil { return } @@ -14147,47 +14250,44 @@ func (vpc *VpcV1) CreateVolumeWithContext(ctx context.Context, createVolumeOptio return } -// DeleteVolume : Delete a volume -// This request deletes a volume. This operation cannot be reversed. For this request to succeed, the volume must not be -// attached to any instances. -func (vpc *VpcV1) DeleteVolume(deleteVolumeOptions *DeleteVolumeOptions) (response *core.DetailedResponse, err error) { - return vpc.DeleteVolumeWithContext(context.Background(), deleteVolumeOptions) +// ListSnapshotClones : List all clones for a snapshot +// This request lists all clones for a snapshot. Use a clone to quickly restore a snapshot within the clone's zone. +func (vpc *VpcV1) ListSnapshotClones(listSnapshotClonesOptions *ListSnapshotClonesOptions) (result *SnapshotCloneCollection, response *core.DetailedResponse, err error) { + return vpc.ListSnapshotClonesWithContext(context.Background(), listSnapshotClonesOptions) } -// DeleteVolumeWithContext is an alternate form of the DeleteVolume method which supports a Context parameter -func (vpc *VpcV1) DeleteVolumeWithContext(ctx context.Context, deleteVolumeOptions *DeleteVolumeOptions) (response *core.DetailedResponse, err error) { - err = core.ValidateNotNil(deleteVolumeOptions, "deleteVolumeOptions cannot be nil") +// ListSnapshotClonesWithContext is an alternate form of the ListSnapshotClones method which supports a Context parameter +func (vpc *VpcV1) ListSnapshotClonesWithContext(ctx context.Context, listSnapshotClonesOptions *ListSnapshotClonesOptions) (result *SnapshotCloneCollection, response *core.DetailedResponse, err error) { + err = core.ValidateNotNil(listSnapshotClonesOptions, "listSnapshotClonesOptions cannot be nil") if err != nil { return } - err = core.ValidateStruct(deleteVolumeOptions, "deleteVolumeOptions") + err = core.ValidateStruct(listSnapshotClonesOptions, "listSnapshotClonesOptions") if err != nil { return } pathParamsMap := map[string]string{ - "id": *deleteVolumeOptions.ID, + "id": *listSnapshotClonesOptions.ID, } - builder := core.NewRequestBuilder(core.DELETE) + builder := core.NewRequestBuilder(core.GET) builder = builder.WithContext(ctx) builder.EnableGzipCompression = vpc.GetEnableGzipCompression() - _, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/volumes/{id}`, pathParamsMap) + _, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/snapshots/{id}/clones`, pathParamsMap) if err != nil { return } - for headerName, headerValue := range deleteVolumeOptions.Headers { + for headerName, headerValue := range listSnapshotClonesOptions.Headers { builder.AddHeader(headerName, headerValue) } - sdkHeaders := common.GetSdkHeaders("vpc", "V1", "DeleteVolume") + sdkHeaders := common.GetSdkHeaders("vpc", "V1", "ListSnapshotClones") for headerName, headerValue := range sdkHeaders { builder.AddHeader(headerName, headerValue) } - if deleteVolumeOptions.IfMatch != nil { - builder.AddHeader("If-Match", fmt.Sprint(*deleteVolumeOptions.IfMatch)) - } + builder.AddHeader("Accept", "application/json") builder.AddQuery("version", fmt.Sprint(*vpc.Version)) builder.AddQuery("generation", fmt.Sprint(*vpc.generation)) @@ -14197,49 +14297,61 @@ func (vpc *VpcV1) DeleteVolumeWithContext(ctx context.Context, deleteVolumeOptio return } - response, err = vpc.Service.Request(request, nil) + 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, UnmarshalSnapshotCloneCollection) + if err != nil { + return + } + response.Result = result + } return } -// GetVolume : Retrieve a volume -// This request retrieves a single volume specified by the identifier in the URL. -func (vpc *VpcV1) GetVolume(getVolumeOptions *GetVolumeOptions) (result *Volume, response *core.DetailedResponse, err error) { - return vpc.GetVolumeWithContext(context.Background(), getVolumeOptions) +// DeleteSnapshotClone : Delete a snapshot clone +// This request deletes a snapshot clone. This operation cannot be reversed, but an equivalent clone may be recreated +// from the snapshot. +func (vpc *VpcV1) DeleteSnapshotClone(deleteSnapshotCloneOptions *DeleteSnapshotCloneOptions) (response *core.DetailedResponse, err error) { + return vpc.DeleteSnapshotCloneWithContext(context.Background(), deleteSnapshotCloneOptions) } -// GetVolumeWithContext is an alternate form of the GetVolume method which supports a Context parameter -func (vpc *VpcV1) GetVolumeWithContext(ctx context.Context, getVolumeOptions *GetVolumeOptions) (result *Volume, response *core.DetailedResponse, err error) { - err = core.ValidateNotNil(getVolumeOptions, "getVolumeOptions cannot be nil") +// DeleteSnapshotCloneWithContext is an alternate form of the DeleteSnapshotClone method which supports a Context parameter +func (vpc *VpcV1) DeleteSnapshotCloneWithContext(ctx context.Context, deleteSnapshotCloneOptions *DeleteSnapshotCloneOptions) (response *core.DetailedResponse, err error) { + err = core.ValidateNotNil(deleteSnapshotCloneOptions, "deleteSnapshotCloneOptions cannot be nil") if err != nil { return } - err = core.ValidateStruct(getVolumeOptions, "getVolumeOptions") + err = core.ValidateStruct(deleteSnapshotCloneOptions, "deleteSnapshotCloneOptions") if err != nil { return } pathParamsMap := map[string]string{ - "id": *getVolumeOptions.ID, + "id": *deleteSnapshotCloneOptions.ID, + "zone_name": *deleteSnapshotCloneOptions.ZoneName, } - builder := core.NewRequestBuilder(core.GET) + builder := core.NewRequestBuilder(core.DELETE) builder = builder.WithContext(ctx) builder.EnableGzipCompression = vpc.GetEnableGzipCompression() - _, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/volumes/{id}`, pathParamsMap) + _, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/snapshots/{id}/clones/{zone_name}`, pathParamsMap) if err != nil { return } - for headerName, headerValue := range getVolumeOptions.Headers { + for headerName, headerValue := range deleteSnapshotCloneOptions.Headers { builder.AddHeader(headerName, headerValue) } - sdkHeaders := common.GetSdkHeaders("vpc", "V1", "GetVolume") + sdkHeaders := common.GetSdkHeaders("vpc", "V1", "DeleteSnapshotClone") 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)) @@ -14249,74 +14361,54 @@ func (vpc *VpcV1) GetVolumeWithContext(ctx context.Context, getVolumeOptions *Ge 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, UnmarshalVolume) - if err != nil { - return - } - response.Result = result - } + response, err = vpc.Service.Request(request, nil) return } -// UpdateVolume : Update a volume -// This request updates a volume with the information in a provided volume patch. The volume patch object is structured -// in the same way as a retrieved volume and contains only the information to be updated. -func (vpc *VpcV1) UpdateVolume(updateVolumeOptions *UpdateVolumeOptions) (result *Volume, response *core.DetailedResponse, err error) { - return vpc.UpdateVolumeWithContext(context.Background(), updateVolumeOptions) +// GetSnapshotClone : Retrieve a snapshot clone +// This request retrieves a single clone specified by the snapshot identifier and zone name in the URL. +func (vpc *VpcV1) GetSnapshotClone(getSnapshotCloneOptions *GetSnapshotCloneOptions) (result *SnapshotClone, response *core.DetailedResponse, err error) { + return vpc.GetSnapshotCloneWithContext(context.Background(), getSnapshotCloneOptions) } -// UpdateVolumeWithContext is an alternate form of the UpdateVolume method which supports a Context parameter -func (vpc *VpcV1) UpdateVolumeWithContext(ctx context.Context, updateVolumeOptions *UpdateVolumeOptions) (result *Volume, response *core.DetailedResponse, err error) { - err = core.ValidateNotNil(updateVolumeOptions, "updateVolumeOptions cannot be nil") +// GetSnapshotCloneWithContext is an alternate form of the GetSnapshotClone method which supports a Context parameter +func (vpc *VpcV1) GetSnapshotCloneWithContext(ctx context.Context, getSnapshotCloneOptions *GetSnapshotCloneOptions) (result *SnapshotClone, response *core.DetailedResponse, err error) { + err = core.ValidateNotNil(getSnapshotCloneOptions, "getSnapshotCloneOptions cannot be nil") if err != nil { return } - err = core.ValidateStruct(updateVolumeOptions, "updateVolumeOptions") + err = core.ValidateStruct(getSnapshotCloneOptions, "getSnapshotCloneOptions") if err != nil { return } pathParamsMap := map[string]string{ - "id": *updateVolumeOptions.ID, + "id": *getSnapshotCloneOptions.ID, + "zone_name": *getSnapshotCloneOptions.ZoneName, } - builder := core.NewRequestBuilder(core.PATCH) + builder := core.NewRequestBuilder(core.GET) builder = builder.WithContext(ctx) builder.EnableGzipCompression = vpc.GetEnableGzipCompression() - _, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/volumes/{id}`, pathParamsMap) + _, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/snapshots/{id}/clones/{zone_name}`, pathParamsMap) if err != nil { return } - for headerName, headerValue := range updateVolumeOptions.Headers { + for headerName, headerValue := range getSnapshotCloneOptions.Headers { builder.AddHeader(headerName, headerValue) } - sdkHeaders := common.GetSdkHeaders("vpc", "V1", "UpdateVolume") + sdkHeaders := common.GetSdkHeaders("vpc", "V1", "GetSnapshotClone") for headerName, headerValue := range sdkHeaders { builder.AddHeader(headerName, headerValue) } builder.AddHeader("Accept", "application/json") - builder.AddHeader("Content-Type", "application/merge-patch+json") - if updateVolumeOptions.IfMatch != nil { - builder.AddHeader("If-Match", fmt.Sprint(*updateVolumeOptions.IfMatch)) - } builder.AddQuery("version", fmt.Sprint(*vpc.Version)) builder.AddQuery("generation", fmt.Sprint(*vpc.generation)) - _, err = builder.SetBodyContentJSON(updateVolumeOptions.VolumePatch) - if err != nil { - return - } - request, err := builder.Build() if err != nil { return @@ -14328,7 +14420,7 @@ func (vpc *VpcV1) UpdateVolumeWithContext(ctx context.Context, updateVolumeOptio return } if rawResponse != nil { - err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalVolume) + err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalSnapshotClone) if err != nil { return } @@ -14338,33 +14430,42 @@ func (vpc *VpcV1) UpdateVolumeWithContext(ctx context.Context, updateVolumeOptio return } -// ListSnapshotConsistencyGroups : List all snapshot consistency groups -// This request lists all snapshot consistency groups in the region. A snapshot consistency group is a collection of -// individual snapshots taken at the same time. -func (vpc *VpcV1) ListSnapshotConsistencyGroups(listSnapshotConsistencyGroupsOptions *ListSnapshotConsistencyGroupsOptions) (result *SnapshotConsistencyGroupCollection, response *core.DetailedResponse, err error) { - return vpc.ListSnapshotConsistencyGroupsWithContext(context.Background(), listSnapshotConsistencyGroupsOptions) +// CreateSnapshotClone : Create a clone for a snapshot +// This request creates a new clone for a snapshot in the specified zone. A request body is not required, and if +// provided, is ignored. If the snapshot already has a clone in the zone, it is returned. +func (vpc *VpcV1) CreateSnapshotClone(createSnapshotCloneOptions *CreateSnapshotCloneOptions) (result *SnapshotClone, response *core.DetailedResponse, err error) { + return vpc.CreateSnapshotCloneWithContext(context.Background(), createSnapshotCloneOptions) } -// ListSnapshotConsistencyGroupsWithContext is an alternate form of the ListSnapshotConsistencyGroups method which supports a Context parameter -func (vpc *VpcV1) ListSnapshotConsistencyGroupsWithContext(ctx context.Context, listSnapshotConsistencyGroupsOptions *ListSnapshotConsistencyGroupsOptions) (result *SnapshotConsistencyGroupCollection, response *core.DetailedResponse, err error) { - err = core.ValidateStruct(listSnapshotConsistencyGroupsOptions, "listSnapshotConsistencyGroupsOptions") +// CreateSnapshotCloneWithContext is an alternate form of the CreateSnapshotClone method which supports a Context parameter +func (vpc *VpcV1) CreateSnapshotCloneWithContext(ctx context.Context, createSnapshotCloneOptions *CreateSnapshotCloneOptions) (result *SnapshotClone, response *core.DetailedResponse, err error) { + err = core.ValidateNotNil(createSnapshotCloneOptions, "createSnapshotCloneOptions cannot be nil") + if err != nil { + return + } + err = core.ValidateStruct(createSnapshotCloneOptions, "createSnapshotCloneOptions") if err != nil { return } - builder := core.NewRequestBuilder(core.GET) + pathParamsMap := map[string]string{ + "id": *createSnapshotCloneOptions.ID, + "zone_name": *createSnapshotCloneOptions.ZoneName, + } + + builder := core.NewRequestBuilder(core.PUT) builder = builder.WithContext(ctx) builder.EnableGzipCompression = vpc.GetEnableGzipCompression() - _, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/snapshot_consistency_groups`, nil) + _, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/snapshots/{id}/clones/{zone_name}`, pathParamsMap) if err != nil { return } - for headerName, headerValue := range listSnapshotConsistencyGroupsOptions.Headers { + for headerName, headerValue := range createSnapshotCloneOptions.Headers { builder.AddHeader(headerName, headerValue) } - sdkHeaders := common.GetSdkHeaders("vpc", "V1", "ListSnapshotConsistencyGroups") + sdkHeaders := common.GetSdkHeaders("vpc", "V1", "CreateSnapshotClone") for headerName, headerValue := range sdkHeaders { builder.AddHeader(headerName, headerValue) } @@ -14372,24 +14473,6 @@ func (vpc *VpcV1) ListSnapshotConsistencyGroupsWithContext(ctx context.Context, builder.AddQuery("version", fmt.Sprint(*vpc.Version)) builder.AddQuery("generation", fmt.Sprint(*vpc.generation)) - if listSnapshotConsistencyGroupsOptions.Start != nil { - builder.AddQuery("start", fmt.Sprint(*listSnapshotConsistencyGroupsOptions.Start)) - } - if listSnapshotConsistencyGroupsOptions.Limit != nil { - builder.AddQuery("limit", fmt.Sprint(*listSnapshotConsistencyGroupsOptions.Limit)) - } - if listSnapshotConsistencyGroupsOptions.ResourceGroupID != nil { - builder.AddQuery("resource_group.id", fmt.Sprint(*listSnapshotConsistencyGroupsOptions.ResourceGroupID)) - } - if listSnapshotConsistencyGroupsOptions.Name != nil { - builder.AddQuery("name", fmt.Sprint(*listSnapshotConsistencyGroupsOptions.Name)) - } - if listSnapshotConsistencyGroupsOptions.Sort != nil { - builder.AddQuery("sort", fmt.Sprint(*listSnapshotConsistencyGroupsOptions.Sort)) - } - if listSnapshotConsistencyGroupsOptions.BackupPolicyPlanID != nil { - builder.AddQuery("backup_policy_plan.id", fmt.Sprint(*listSnapshotConsistencyGroupsOptions.BackupPolicyPlanID)) - } request, err := builder.Build() if err != nil { @@ -14402,7 +14485,7 @@ func (vpc *VpcV1) ListSnapshotConsistencyGroupsWithContext(ctx context.Context, return } if rawResponse != nil { - err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalSnapshotConsistencyGroupCollection) + err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalSnapshotClone) if err != nil { return } @@ -14412,50 +14495,49 @@ func (vpc *VpcV1) ListSnapshotConsistencyGroupsWithContext(ctx context.Context, return } -// CreateSnapshotConsistencyGroup : Create a snapshot consistency group -// This request creates a new snapshot consistency group from a snapshot consistency group object. The prototype object -// is structured in the same way as a retrieved consistency group, and contains the information necessary to provision -// the new snapshot consistency group. -func (vpc *VpcV1) CreateSnapshotConsistencyGroup(createSnapshotConsistencyGroupOptions *CreateSnapshotConsistencyGroupOptions) (result *SnapshotConsistencyGroup, response *core.DetailedResponse, err error) { - return vpc.CreateSnapshotConsistencyGroupWithContext(context.Background(), createSnapshotConsistencyGroupOptions) +// ListShareProfiles : List all file share profiles +// This request lists all [file share profiles](https://cloud.ibm.com/docs/vpc?topic=vpc-file-storage-profiles) +// available in the region. A file share profile specifies the performance characteristics and pricing model for a file +// share. +func (vpc *VpcV1) ListShareProfiles(listShareProfilesOptions *ListShareProfilesOptions) (result *ShareProfileCollection, response *core.DetailedResponse, err error) { + return vpc.ListShareProfilesWithContext(context.Background(), listShareProfilesOptions) } -// CreateSnapshotConsistencyGroupWithContext is an alternate form of the CreateSnapshotConsistencyGroup method which supports a Context parameter -func (vpc *VpcV1) CreateSnapshotConsistencyGroupWithContext(ctx context.Context, createSnapshotConsistencyGroupOptions *CreateSnapshotConsistencyGroupOptions) (result *SnapshotConsistencyGroup, response *core.DetailedResponse, err error) { - err = core.ValidateNotNil(createSnapshotConsistencyGroupOptions, "createSnapshotConsistencyGroupOptions cannot be nil") - if err != nil { - return - } - err = core.ValidateStruct(createSnapshotConsistencyGroupOptions, "createSnapshotConsistencyGroupOptions") +// ListShareProfilesWithContext is an alternate form of the ListShareProfiles method which supports a Context parameter +func (vpc *VpcV1) ListShareProfilesWithContext(ctx context.Context, listShareProfilesOptions *ListShareProfilesOptions) (result *ShareProfileCollection, response *core.DetailedResponse, err error) { + err = core.ValidateStruct(listShareProfilesOptions, "listShareProfilesOptions") if err != nil { return } - builder := core.NewRequestBuilder(core.POST) + builder := core.NewRequestBuilder(core.GET) builder = builder.WithContext(ctx) builder.EnableGzipCompression = vpc.GetEnableGzipCompression() - _, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/snapshot_consistency_groups`, nil) + _, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/share/profiles`, nil) if err != nil { return } - for headerName, headerValue := range createSnapshotConsistencyGroupOptions.Headers { + for headerName, headerValue := range listShareProfilesOptions.Headers { builder.AddHeader(headerName, headerValue) } - sdkHeaders := common.GetSdkHeaders("vpc", "V1", "CreateSnapshotConsistencyGroup") + sdkHeaders := common.GetSdkHeaders("vpc", "V1", "ListShareProfiles") for headerName, headerValue := range sdkHeaders { builder.AddHeader(headerName, headerValue) } builder.AddHeader("Accept", "application/json") - builder.AddHeader("Content-Type", "application/json") builder.AddQuery("version", fmt.Sprint(*vpc.Version)) builder.AddQuery("generation", fmt.Sprint(*vpc.generation)) - - _, err = builder.SetBodyContentJSON(createSnapshotConsistencyGroupOptions.SnapshotConsistencyGroupPrototype) - if err != nil { - return + if listShareProfilesOptions.Start != nil { + builder.AddQuery("start", fmt.Sprint(*listShareProfilesOptions.Start)) + } + if listShareProfilesOptions.Limit != nil { + builder.AddQuery("limit", fmt.Sprint(*listShareProfilesOptions.Limit)) + } + if listShareProfilesOptions.Sort != nil { + builder.AddQuery("sort", fmt.Sprint(*listShareProfilesOptions.Sort)) } request, err := builder.Build() @@ -14469,7 +14551,7 @@ func (vpc *VpcV1) CreateSnapshotConsistencyGroupWithContext(ctx context.Context, return } if rawResponse != nil { - err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalSnapshotConsistencyGroup) + err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalShareProfileCollection) if err != nil { return } @@ -14479,41 +14561,40 @@ func (vpc *VpcV1) CreateSnapshotConsistencyGroupWithContext(ctx context.Context, return } -// DeleteSnapshotConsistencyGroup : Delete a snapshot consistency group -// This request deletes snapshot consistency group. This operation cannot be reversed. If the -// `delete_snapshots_on_delete` property is `true`, all snapshots in the consistency group will also be deleted. -func (vpc *VpcV1) DeleteSnapshotConsistencyGroup(deleteSnapshotConsistencyGroupOptions *DeleteSnapshotConsistencyGroupOptions) (result *SnapshotConsistencyGroup, response *core.DetailedResponse, err error) { - return vpc.DeleteSnapshotConsistencyGroupWithContext(context.Background(), deleteSnapshotConsistencyGroupOptions) +// GetShareProfile : Retrieve a file share profile +// This request retrieves a single file share profile specified by the name in the URL. +func (vpc *VpcV1) GetShareProfile(getShareProfileOptions *GetShareProfileOptions) (result *ShareProfile, response *core.DetailedResponse, err error) { + return vpc.GetShareProfileWithContext(context.Background(), getShareProfileOptions) } -// DeleteSnapshotConsistencyGroupWithContext is an alternate form of the DeleteSnapshotConsistencyGroup method which supports a Context parameter -func (vpc *VpcV1) DeleteSnapshotConsistencyGroupWithContext(ctx context.Context, deleteSnapshotConsistencyGroupOptions *DeleteSnapshotConsistencyGroupOptions) (result *SnapshotConsistencyGroup, response *core.DetailedResponse, err error) { - err = core.ValidateNotNil(deleteSnapshotConsistencyGroupOptions, "deleteSnapshotConsistencyGroupOptions cannot be nil") +// GetShareProfileWithContext is an alternate form of the GetShareProfile method which supports a Context parameter +func (vpc *VpcV1) GetShareProfileWithContext(ctx context.Context, getShareProfileOptions *GetShareProfileOptions) (result *ShareProfile, response *core.DetailedResponse, err error) { + err = core.ValidateNotNil(getShareProfileOptions, "getShareProfileOptions cannot be nil") if err != nil { return } - err = core.ValidateStruct(deleteSnapshotConsistencyGroupOptions, "deleteSnapshotConsistencyGroupOptions") + err = core.ValidateStruct(getShareProfileOptions, "getShareProfileOptions") if err != nil { return } pathParamsMap := map[string]string{ - "id": *deleteSnapshotConsistencyGroupOptions.ID, + "name": *getShareProfileOptions.Name, } - builder := core.NewRequestBuilder(core.DELETE) + builder := core.NewRequestBuilder(core.GET) builder = builder.WithContext(ctx) builder.EnableGzipCompression = vpc.GetEnableGzipCompression() - _, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/snapshot_consistency_groups/{id}`, pathParamsMap) + _, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/share/profiles/{name}`, pathParamsMap) if err != nil { return } - for headerName, headerValue := range deleteSnapshotConsistencyGroupOptions.Headers { + for headerName, headerValue := range getShareProfileOptions.Headers { builder.AddHeader(headerName, headerValue) } - sdkHeaders := common.GetSdkHeaders("vpc", "V1", "DeleteSnapshotConsistencyGroup") + sdkHeaders := common.GetSdkHeaders("vpc", "V1", "GetShareProfile") for headerName, headerValue := range sdkHeaders { builder.AddHeader(headerName, headerValue) } @@ -14533,7 +14614,7 @@ func (vpc *VpcV1) DeleteSnapshotConsistencyGroupWithContext(ctx context.Context, return } if rawResponse != nil { - err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalSnapshotConsistencyGroup) + err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalShareProfile) if err != nil { return } @@ -14543,40 +14624,32 @@ func (vpc *VpcV1) DeleteSnapshotConsistencyGroupWithContext(ctx context.Context, return } -// GetSnapshotConsistencyGroup : Retrieve a snapshot consistency group -// This request retrieves a single snapshot consistency group specified by the identifier in the URL. -func (vpc *VpcV1) GetSnapshotConsistencyGroup(getSnapshotConsistencyGroupOptions *GetSnapshotConsistencyGroupOptions) (result *SnapshotConsistencyGroup, response *core.DetailedResponse, err error) { - return vpc.GetSnapshotConsistencyGroupWithContext(context.Background(), getSnapshotConsistencyGroupOptions) +// ListShares : List all file shares +// This request lists all file shares in the region. +func (vpc *VpcV1) ListShares(listSharesOptions *ListSharesOptions) (result *ShareCollection, response *core.DetailedResponse, err error) { + return vpc.ListSharesWithContext(context.Background(), listSharesOptions) } -// GetSnapshotConsistencyGroupWithContext is an alternate form of the GetSnapshotConsistencyGroup method which supports a Context parameter -func (vpc *VpcV1) GetSnapshotConsistencyGroupWithContext(ctx context.Context, getSnapshotConsistencyGroupOptions *GetSnapshotConsistencyGroupOptions) (result *SnapshotConsistencyGroup, response *core.DetailedResponse, err error) { - err = core.ValidateNotNil(getSnapshotConsistencyGroupOptions, "getSnapshotConsistencyGroupOptions cannot be nil") - if err != nil { - return - } - err = core.ValidateStruct(getSnapshotConsistencyGroupOptions, "getSnapshotConsistencyGroupOptions") +// ListSharesWithContext is an alternate form of the ListShares method which supports a Context parameter +func (vpc *VpcV1) ListSharesWithContext(ctx context.Context, listSharesOptions *ListSharesOptions) (result *ShareCollection, response *core.DetailedResponse, err error) { + err = core.ValidateStruct(listSharesOptions, "listSharesOptions") if err != nil { return } - pathParamsMap := map[string]string{ - "id": *getSnapshotConsistencyGroupOptions.ID, - } - builder := core.NewRequestBuilder(core.GET) builder = builder.WithContext(ctx) builder.EnableGzipCompression = vpc.GetEnableGzipCompression() - _, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/snapshot_consistency_groups/{id}`, pathParamsMap) + _, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/shares`, nil) if err != nil { return } - for headerName, headerValue := range getSnapshotConsistencyGroupOptions.Headers { + for headerName, headerValue := range listSharesOptions.Headers { builder.AddHeader(headerName, headerValue) } - sdkHeaders := common.GetSdkHeaders("vpc", "V1", "GetSnapshotConsistencyGroup") + sdkHeaders := common.GetSdkHeaders("vpc", "V1", "ListShares") for headerName, headerValue := range sdkHeaders { builder.AddHeader(headerName, headerValue) } @@ -14584,6 +14657,24 @@ func (vpc *VpcV1) GetSnapshotConsistencyGroupWithContext(ctx context.Context, ge builder.AddQuery("version", fmt.Sprint(*vpc.Version)) builder.AddQuery("generation", fmt.Sprint(*vpc.generation)) + if listSharesOptions.Start != nil { + builder.AddQuery("start", fmt.Sprint(*listSharesOptions.Start)) + } + if listSharesOptions.Limit != nil { + builder.AddQuery("limit", fmt.Sprint(*listSharesOptions.Limit)) + } + if listSharesOptions.ResourceGroupID != nil { + builder.AddQuery("resource_group.id", fmt.Sprint(*listSharesOptions.ResourceGroupID)) + } + if listSharesOptions.Name != nil { + builder.AddQuery("name", fmt.Sprint(*listSharesOptions.Name)) + } + if listSharesOptions.Sort != nil { + builder.AddQuery("sort", fmt.Sprint(*listSharesOptions.Sort)) + } + if listSharesOptions.ReplicationRole != nil { + builder.AddQuery("replication_role", fmt.Sprint(*listSharesOptions.ReplicationRole)) + } request, err := builder.Build() if err != nil { @@ -14596,7 +14687,7 @@ func (vpc *VpcV1) GetSnapshotConsistencyGroupWithContext(ctx context.Context, ge return } if rawResponse != nil { - err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalSnapshotConsistencyGroup) + err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalShareCollection) if err != nil { return } @@ -14606,55 +14697,50 @@ func (vpc *VpcV1) GetSnapshotConsistencyGroupWithContext(ctx context.Context, ge return } -// UpdateSnapshotConsistencyGroup : Update a snapshot consistency group -// This request updates a snapshot consistency group with the information in a provided snapshot consistency group -// patch. The snapshot consistency group patch object is structured in the same way as a retrieved snapshot consistency -// group and contains only the information to be updated. -func (vpc *VpcV1) UpdateSnapshotConsistencyGroup(updateSnapshotConsistencyGroupOptions *UpdateSnapshotConsistencyGroupOptions) (result *SnapshotConsistencyGroup, response *core.DetailedResponse, err error) { - return vpc.UpdateSnapshotConsistencyGroupWithContext(context.Background(), updateSnapshotConsistencyGroupOptions) +// CreateShare : Create a file share +// This request provisions new file shares from a share prototype object. The new file shares can be a standalone share, +// a replica share, or both a source and replica share. +// +// The prototype object is structured in the same way as a retrieved share, and contains the information necessary to +// provision the new file shares. +func (vpc *VpcV1) CreateShare(createShareOptions *CreateShareOptions) (result *Share, response *core.DetailedResponse, err error) { + return vpc.CreateShareWithContext(context.Background(), createShareOptions) } -// UpdateSnapshotConsistencyGroupWithContext is an alternate form of the UpdateSnapshotConsistencyGroup method which supports a Context parameter -func (vpc *VpcV1) UpdateSnapshotConsistencyGroupWithContext(ctx context.Context, updateSnapshotConsistencyGroupOptions *UpdateSnapshotConsistencyGroupOptions) (result *SnapshotConsistencyGroup, response *core.DetailedResponse, err error) { - err = core.ValidateNotNil(updateSnapshotConsistencyGroupOptions, "updateSnapshotConsistencyGroupOptions cannot be nil") +// CreateShareWithContext is an alternate form of the CreateShare method which supports a Context parameter +func (vpc *VpcV1) CreateShareWithContext(ctx context.Context, createShareOptions *CreateShareOptions) (result *Share, response *core.DetailedResponse, err error) { + err = core.ValidateNotNil(createShareOptions, "createShareOptions cannot be nil") if err != nil { return } - err = core.ValidateStruct(updateSnapshotConsistencyGroupOptions, "updateSnapshotConsistencyGroupOptions") + err = core.ValidateStruct(createShareOptions, "createShareOptions") if err != nil { return } - pathParamsMap := map[string]string{ - "id": *updateSnapshotConsistencyGroupOptions.ID, - } - - builder := core.NewRequestBuilder(core.PATCH) + builder := core.NewRequestBuilder(core.POST) builder = builder.WithContext(ctx) builder.EnableGzipCompression = vpc.GetEnableGzipCompression() - _, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/snapshot_consistency_groups/{id}`, pathParamsMap) + _, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/shares`, nil) if err != nil { return } - for headerName, headerValue := range updateSnapshotConsistencyGroupOptions.Headers { + for headerName, headerValue := range createShareOptions.Headers { builder.AddHeader(headerName, headerValue) } - sdkHeaders := common.GetSdkHeaders("vpc", "V1", "UpdateSnapshotConsistencyGroup") + sdkHeaders := common.GetSdkHeaders("vpc", "V1", "CreateShare") for headerName, headerValue := range sdkHeaders { builder.AddHeader(headerName, headerValue) } builder.AddHeader("Accept", "application/json") - builder.AddHeader("Content-Type", "application/merge-patch+json") - if updateSnapshotConsistencyGroupOptions.IfMatch != nil { - builder.AddHeader("If-Match", fmt.Sprint(*updateSnapshotConsistencyGroupOptions.IfMatch)) - } + builder.AddHeader("Content-Type", "application/json") builder.AddQuery("version", fmt.Sprint(*vpc.Version)) builder.AddQuery("generation", fmt.Sprint(*vpc.generation)) - _, err = builder.SetBodyContentJSON(updateSnapshotConsistencyGroupOptions.SnapshotConsistencyGroupPatch) + _, err = builder.SetBodyContentJSON(createShareOptions.SharePrototype) if err != nil { return } @@ -14670,7 +14756,7 @@ func (vpc *VpcV1) UpdateSnapshotConsistencyGroupWithContext(ctx context.Context, return } if rawResponse != nil { - err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalSnapshotConsistencyGroup) + err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalShare) if err != nil { return } @@ -14680,154 +14766,56 @@ func (vpc *VpcV1) UpdateSnapshotConsistencyGroupWithContext(ctx context.Context, return } -// DeleteSnapshots : Delete a filtered collection of snapshots -// This request deletes all snapshots created from a specific source volume. -func (vpc *VpcV1) DeleteSnapshots(deleteSnapshotsOptions *DeleteSnapshotsOptions) (response *core.DetailedResponse, err error) { - return vpc.DeleteSnapshotsWithContext(context.Background(), deleteSnapshotsOptions) +// DeleteShare : Delete a file share +// This request deletes a share. This operation cannot be reversed. A share cannot be deleted if it: +// - has share mount targets +// - has a `lifecycle_state` of `updating` +// - has a replication operation in progress +// +// If the request is accepted, the share `lifecycle_state` will be set to `deleting`. Once deletion processing +// completes, it will no longer be retrievable. +func (vpc *VpcV1) DeleteShare(deleteShareOptions *DeleteShareOptions) (result *Share, response *core.DetailedResponse, err error) { + return vpc.DeleteShareWithContext(context.Background(), deleteShareOptions) } -// DeleteSnapshotsWithContext is an alternate form of the DeleteSnapshots method which supports a Context parameter -func (vpc *VpcV1) DeleteSnapshotsWithContext(ctx context.Context, deleteSnapshotsOptions *DeleteSnapshotsOptions) (response *core.DetailedResponse, err error) { - err = core.ValidateNotNil(deleteSnapshotsOptions, "deleteSnapshotsOptions cannot be nil") - if err != nil { - return - } - err = core.ValidateStruct(deleteSnapshotsOptions, "deleteSnapshotsOptions") - if err != nil { - return - } - - builder := core.NewRequestBuilder(core.DELETE) - builder = builder.WithContext(ctx) - builder.EnableGzipCompression = vpc.GetEnableGzipCompression() - _, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/snapshots`, nil) +// DeleteShareWithContext is an alternate form of the DeleteShare method which supports a Context parameter +func (vpc *VpcV1) DeleteShareWithContext(ctx context.Context, deleteShareOptions *DeleteShareOptions) (result *Share, response *core.DetailedResponse, err error) { + err = core.ValidateNotNil(deleteShareOptions, "deleteShareOptions cannot be nil") if err != nil { return } - - for headerName, headerValue := range deleteSnapshotsOptions.Headers { - builder.AddHeader(headerName, headerValue) - } - - sdkHeaders := common.GetSdkHeaders("vpc", "V1", "DeleteSnapshots") - for headerName, headerValue := range sdkHeaders { - builder.AddHeader(headerName, headerValue) - } - - builder.AddQuery("version", fmt.Sprint(*vpc.Version)) - builder.AddQuery("generation", fmt.Sprint(*vpc.generation)) - builder.AddQuery("source_volume.id", fmt.Sprint(*deleteSnapshotsOptions.SourceVolumeID)) - - request, err := builder.Build() + err = core.ValidateStruct(deleteShareOptions, "deleteShareOptions") if err != nil { return } - response, err = vpc.Service.Request(request, nil) - - return -} - -// ListSnapshots : List all snapshots -// This request lists all snapshots in the region. A snapshot preserves the data of a volume at the time the snapshot is -// created. -func (vpc *VpcV1) ListSnapshots(listSnapshotsOptions *ListSnapshotsOptions) (result *SnapshotCollection, response *core.DetailedResponse, err error) { - return vpc.ListSnapshotsWithContext(context.Background(), listSnapshotsOptions) -} - -// ListSnapshotsWithContext is an alternate form of the ListSnapshots method which supports a Context parameter -func (vpc *VpcV1) ListSnapshotsWithContext(ctx context.Context, listSnapshotsOptions *ListSnapshotsOptions) (result *SnapshotCollection, response *core.DetailedResponse, err error) { - err = core.ValidateStruct(listSnapshotsOptions, "listSnapshotsOptions") - if err != nil { - return + pathParamsMap := map[string]string{ + "id": *deleteShareOptions.ID, } - builder := core.NewRequestBuilder(core.GET) + builder := core.NewRequestBuilder(core.DELETE) builder = builder.WithContext(ctx) builder.EnableGzipCompression = vpc.GetEnableGzipCompression() - _, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/snapshots`, nil) + _, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/shares/{id}`, pathParamsMap) if err != nil { return } - for headerName, headerValue := range listSnapshotsOptions.Headers { + for headerName, headerValue := range deleteShareOptions.Headers { builder.AddHeader(headerName, headerValue) } - sdkHeaders := common.GetSdkHeaders("vpc", "V1", "ListSnapshots") + sdkHeaders := common.GetSdkHeaders("vpc", "V1", "DeleteShare") for headerName, headerValue := range sdkHeaders { builder.AddHeader(headerName, headerValue) } builder.AddHeader("Accept", "application/json") + if deleteShareOptions.IfMatch != nil { + builder.AddHeader("If-Match", fmt.Sprint(*deleteShareOptions.IfMatch)) + } builder.AddQuery("version", fmt.Sprint(*vpc.Version)) builder.AddQuery("generation", fmt.Sprint(*vpc.generation)) - if listSnapshotsOptions.Start != nil { - builder.AddQuery("start", fmt.Sprint(*listSnapshotsOptions.Start)) - } - if listSnapshotsOptions.Limit != nil { - builder.AddQuery("limit", fmt.Sprint(*listSnapshotsOptions.Limit)) - } - if listSnapshotsOptions.Tag != nil { - builder.AddQuery("tag", fmt.Sprint(*listSnapshotsOptions.Tag)) - } - if listSnapshotsOptions.ResourceGroupID != nil { - builder.AddQuery("resource_group.id", fmt.Sprint(*listSnapshotsOptions.ResourceGroupID)) - } - if listSnapshotsOptions.Name != nil { - builder.AddQuery("name", fmt.Sprint(*listSnapshotsOptions.Name)) - } - if listSnapshotsOptions.SourceVolumeID != nil { - builder.AddQuery("source_volume.id", fmt.Sprint(*listSnapshotsOptions.SourceVolumeID)) - } - if listSnapshotsOptions.SourceVolumeCRN != nil { - builder.AddQuery("source_volume.crn", fmt.Sprint(*listSnapshotsOptions.SourceVolumeCRN)) - } - if listSnapshotsOptions.SourceImageID != nil { - builder.AddQuery("source_image.id", fmt.Sprint(*listSnapshotsOptions.SourceImageID)) - } - if listSnapshotsOptions.SourceImageCRN != nil { - builder.AddQuery("source_image.crn", fmt.Sprint(*listSnapshotsOptions.SourceImageCRN)) - } - 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)) - } - if listSnapshotsOptions.CopiesID != nil { - builder.AddQuery("copies[].id", fmt.Sprint(*listSnapshotsOptions.CopiesID)) - } - if listSnapshotsOptions.CopiesName != nil { - builder.AddQuery("copies[].name", fmt.Sprint(*listSnapshotsOptions.CopiesName)) - } - if listSnapshotsOptions.CopiesCRN != nil { - builder.AddQuery("copies[].crn", fmt.Sprint(*listSnapshotsOptions.CopiesCRN)) - } - if listSnapshotsOptions.CopiesRemoteRegionName != nil { - builder.AddQuery("copies[].remote.region.name", fmt.Sprint(*listSnapshotsOptions.CopiesRemoteRegionName)) - } - if listSnapshotsOptions.SourceSnapshotID != nil { - builder.AddQuery("source_snapshot.id", fmt.Sprint(*listSnapshotsOptions.SourceSnapshotID)) - } - if listSnapshotsOptions.SourceSnapshotRemoteRegionName != nil { - builder.AddQuery("source_snapshot.remote.region.name", fmt.Sprint(*listSnapshotsOptions.SourceSnapshotRemoteRegionName)) - } - if listSnapshotsOptions.SourceVolumeRemoteRegionName != nil { - builder.AddQuery("source_volume.remote.region.name", fmt.Sprint(*listSnapshotsOptions.SourceVolumeRemoteRegionName)) - } - if listSnapshotsOptions.SourceImageRemoteRegionName != nil { - builder.AddQuery("source_image.remote.region.name", fmt.Sprint(*listSnapshotsOptions.SourceImageRemoteRegionName)) - } - if listSnapshotsOptions.ClonesZoneName != nil { - builder.AddQuery("clones[].zone.name", fmt.Sprint(*listSnapshotsOptions.ClonesZoneName)) - } - if listSnapshotsOptions.SnapshotConsistencyGroupID != nil { - builder.AddQuery("snapshot_consistency_group.id", fmt.Sprint(*listSnapshotsOptions.SnapshotConsistencyGroupID)) - } - if listSnapshotsOptions.SnapshotConsistencyGroupCRN != nil { - builder.AddQuery("snapshot_consistency_group.crn", fmt.Sprint(*listSnapshotsOptions.SnapshotConsistencyGroupCRN)) - } request, err := builder.Build() if err != nil { @@ -14840,7 +14828,7 @@ func (vpc *VpcV1) ListSnapshotsWithContext(ctx context.Context, listSnapshotsOpt return } if rawResponse != nil { - err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalSnapshotCollection) + err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalShare) if err != nil { return } @@ -14850,51 +14838,48 @@ func (vpc *VpcV1) ListSnapshotsWithContext(ctx context.Context, listSnapshotsOpt return } -// CreateSnapshot : Create a snapshot -// This request creates a new snapshot from a snapshot prototype object. The prototype object is structured in the same -// way as a retrieved snapshot, and contains the information necessary to provision the new snapshot. -func (vpc *VpcV1) CreateSnapshot(createSnapshotOptions *CreateSnapshotOptions) (result *Snapshot, response *core.DetailedResponse, err error) { - return vpc.CreateSnapshotWithContext(context.Background(), createSnapshotOptions) +// GetShare : Retrieve a file share +// This request retrieves a single file share specified by the identifier in the URL. +func (vpc *VpcV1) GetShare(getShareOptions *GetShareOptions) (result *Share, response *core.DetailedResponse, err error) { + return vpc.GetShareWithContext(context.Background(), getShareOptions) } -// CreateSnapshotWithContext is an alternate form of the CreateSnapshot method which supports a Context parameter -func (vpc *VpcV1) CreateSnapshotWithContext(ctx context.Context, createSnapshotOptions *CreateSnapshotOptions) (result *Snapshot, response *core.DetailedResponse, err error) { - err = core.ValidateNotNil(createSnapshotOptions, "createSnapshotOptions cannot be nil") +// GetShareWithContext is an alternate form of the GetShare method which supports a Context parameter +func (vpc *VpcV1) GetShareWithContext(ctx context.Context, getShareOptions *GetShareOptions) (result *Share, response *core.DetailedResponse, err error) { + err = core.ValidateNotNil(getShareOptions, "getShareOptions cannot be nil") if err != nil { return } - err = core.ValidateStruct(createSnapshotOptions, "createSnapshotOptions") + err = core.ValidateStruct(getShareOptions, "getShareOptions") if err != nil { return } - builder := core.NewRequestBuilder(core.POST) + pathParamsMap := map[string]string{ + "id": *getShareOptions.ID, + } + + builder := core.NewRequestBuilder(core.GET) builder = builder.WithContext(ctx) builder.EnableGzipCompression = vpc.GetEnableGzipCompression() - _, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/snapshots`, nil) + _, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/shares/{id}`, pathParamsMap) if err != nil { return } - for headerName, headerValue := range createSnapshotOptions.Headers { + for headerName, headerValue := range getShareOptions.Headers { builder.AddHeader(headerName, headerValue) } - sdkHeaders := common.GetSdkHeaders("vpc", "V1", "CreateSnapshot") + sdkHeaders := common.GetSdkHeaders("vpc", "V1", "GetShare") for headerName, headerValue := range sdkHeaders { builder.AddHeader(headerName, headerValue) } builder.AddHeader("Accept", "application/json") - builder.AddHeader("Content-Type", "application/json") builder.AddQuery("version", fmt.Sprint(*vpc.Version)) builder.AddQuery("generation", fmt.Sprint(*vpc.generation)) - _, err = builder.SetBodyContentJSON(createSnapshotOptions.SnapshotPrototype) - if err != nil { - return - } - request, err := builder.Build() if err != nil { return @@ -14906,7 +14891,7 @@ func (vpc *VpcV1) CreateSnapshotWithContext(ctx context.Context, createSnapshotO return } if rawResponse != nil { - err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalSnapshot) + err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalShare) if err != nil { return } @@ -14916,173 +14901,201 @@ func (vpc *VpcV1) CreateSnapshotWithContext(ctx context.Context, createSnapshotO return } -// DeleteSnapshot : Delete a snapshot -// This request deletes a snapshot. This operation cannot be reversed. -func (vpc *VpcV1) DeleteSnapshot(deleteSnapshotOptions *DeleteSnapshotOptions) (response *core.DetailedResponse, err error) { - return vpc.DeleteSnapshotWithContext(context.Background(), deleteSnapshotOptions) +// UpdateShare : Update a file share +// This request updates a share with the information in a provided share patch. The share patch object is structured in +// the same way as a retrieved share and contains only the information to be updated. +func (vpc *VpcV1) UpdateShare(updateShareOptions *UpdateShareOptions) (result *Share, response *core.DetailedResponse, err error) { + return vpc.UpdateShareWithContext(context.Background(), updateShareOptions) } -// DeleteSnapshotWithContext is an alternate form of the DeleteSnapshot method which supports a Context parameter -func (vpc *VpcV1) DeleteSnapshotWithContext(ctx context.Context, deleteSnapshotOptions *DeleteSnapshotOptions) (response *core.DetailedResponse, err error) { - err = core.ValidateNotNil(deleteSnapshotOptions, "deleteSnapshotOptions cannot be nil") +// UpdateShareWithContext is an alternate form of the UpdateShare method which supports a Context parameter +func (vpc *VpcV1) UpdateShareWithContext(ctx context.Context, updateShareOptions *UpdateShareOptions) (result *Share, response *core.DetailedResponse, err error) { + err = core.ValidateNotNil(updateShareOptions, "updateShareOptions cannot be nil") if err != nil { return } - err = core.ValidateStruct(deleteSnapshotOptions, "deleteSnapshotOptions") + err = core.ValidateStruct(updateShareOptions, "updateShareOptions") if err != nil { return } pathParamsMap := map[string]string{ - "id": *deleteSnapshotOptions.ID, + "id": *updateShareOptions.ID, } - builder := core.NewRequestBuilder(core.DELETE) + builder := core.NewRequestBuilder(core.PATCH) builder = builder.WithContext(ctx) builder.EnableGzipCompression = vpc.GetEnableGzipCompression() - _, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/snapshots/{id}`, pathParamsMap) + _, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/shares/{id}`, pathParamsMap) if err != nil { return } - for headerName, headerValue := range deleteSnapshotOptions.Headers { + for headerName, headerValue := range updateShareOptions.Headers { builder.AddHeader(headerName, headerValue) } - sdkHeaders := common.GetSdkHeaders("vpc", "V1", "DeleteSnapshot") + sdkHeaders := common.GetSdkHeaders("vpc", "V1", "UpdateShare") for headerName, headerValue := range sdkHeaders { builder.AddHeader(headerName, headerValue) } - if deleteSnapshotOptions.IfMatch != nil { - builder.AddHeader("If-Match", fmt.Sprint(*deleteSnapshotOptions.IfMatch)) + builder.AddHeader("Accept", "application/json") + builder.AddHeader("Content-Type", "application/merge-patch+json") + if updateShareOptions.IfMatch != nil { + builder.AddHeader("If-Match", fmt.Sprint(*updateShareOptions.IfMatch)) } builder.AddQuery("version", fmt.Sprint(*vpc.Version)) builder.AddQuery("generation", fmt.Sprint(*vpc.generation)) + _, err = builder.SetBodyContentJSON(updateShareOptions.SharePatch) + if err != nil { + return + } + request, err := builder.Build() if err != nil { return } - response, err = vpc.Service.Request(request, nil) + 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, UnmarshalShare) + if err != nil { + return + } + response.Result = result + } return } -// GetSnapshot : Retrieve a snapshot -// This request retrieves a single snapshot specified by the identifier in the URL. -func (vpc *VpcV1) GetSnapshot(getSnapshotOptions *GetSnapshotOptions) (result *Snapshot, response *core.DetailedResponse, err error) { - return vpc.GetSnapshotWithContext(context.Background(), getSnapshotOptions) +// FailoverShare : Failover to replica file share +// This request triggers a failover to the replica file share specified by the identifier in the URL. The failover +// cannot be started if a source share or the replica share has a `lifecycle_state` of `updating`, or has a replication +// operation in progress. +// +// If `fallback_policy` is specified as `split`, and the request is accepted but the failover operation cannot be +// performed, a split will be triggered. +func (vpc *VpcV1) FailoverShare(failoverShareOptions *FailoverShareOptions) (response *core.DetailedResponse, err error) { + return vpc.FailoverShareWithContext(context.Background(), failoverShareOptions) } -// GetSnapshotWithContext is an alternate form of the GetSnapshot method which supports a Context parameter -func (vpc *VpcV1) GetSnapshotWithContext(ctx context.Context, getSnapshotOptions *GetSnapshotOptions) (result *Snapshot, response *core.DetailedResponse, err error) { - err = core.ValidateNotNil(getSnapshotOptions, "getSnapshotOptions cannot be nil") +// FailoverShareWithContext is an alternate form of the FailoverShare method which supports a Context parameter +func (vpc *VpcV1) FailoverShareWithContext(ctx context.Context, failoverShareOptions *FailoverShareOptions) (response *core.DetailedResponse, err error) { + err = core.ValidateNotNil(failoverShareOptions, "failoverShareOptions cannot be nil") if err != nil { return } - err = core.ValidateStruct(getSnapshotOptions, "getSnapshotOptions") + err = core.ValidateStruct(failoverShareOptions, "failoverShareOptions") if err != nil { return } pathParamsMap := map[string]string{ - "id": *getSnapshotOptions.ID, + "share_id": *failoverShareOptions.ShareID, } - builder := core.NewRequestBuilder(core.GET) + builder := core.NewRequestBuilder(core.POST) builder = builder.WithContext(ctx) builder.EnableGzipCompression = vpc.GetEnableGzipCompression() - _, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/snapshots/{id}`, pathParamsMap) + _, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/shares/{share_id}/failover`, pathParamsMap) if err != nil { return } - for headerName, headerValue := range getSnapshotOptions.Headers { + for headerName, headerValue := range failoverShareOptions.Headers { builder.AddHeader(headerName, headerValue) } - sdkHeaders := common.GetSdkHeaders("vpc", "V1", "GetSnapshot") + sdkHeaders := common.GetSdkHeaders("vpc", "V1", "FailoverShare") 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)) - request, err := builder.Build() + body := make(map[string]interface{}) + if failoverShareOptions.FallbackPolicy != nil { + body["fallback_policy"] = failoverShareOptions.FallbackPolicy + } + if failoverShareOptions.Timeout != nil { + body["timeout"] = failoverShareOptions.Timeout + } + _, err = builder.SetBodyContentJSON(body) if err != nil { return } - var rawResponse map[string]json.RawMessage - response, err = vpc.Service.Request(request, &rawResponse) + request, err := builder.Build() if err != nil { return } - if rawResponse != nil { - err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalSnapshot) - if err != nil { - return - } - response.Result = result - } + + response, err = vpc.Service.Request(request, nil) return } -// UpdateSnapshot : Update a snapshot -// This request updates a snapshot with the information in a provided snapshot patch. The snapshot consistency group -// patch object is structured in the same way as a retrieved snapshot and contains only the information to be updated. -func (vpc *VpcV1) UpdateSnapshot(updateSnapshotOptions *UpdateSnapshotOptions) (result *Snapshot, response *core.DetailedResponse, err error) { - return vpc.UpdateSnapshotWithContext(context.Background(), updateSnapshotOptions) +// ListShareMountTargets : List all mount targets for a file share +// This request retrieves all share mount targets for a file share. A share mount target is a network endpoint at which +// a file share may be mounted. The file share can be mounted by clients in the same VPC and zone after creating share +// mount targets. +// +// The share mount targets will be sorted by their `created_at` property values, with newest targets first. +func (vpc *VpcV1) ListShareMountTargets(listShareMountTargetsOptions *ListShareMountTargetsOptions) (result *ShareMountTargetCollection, response *core.DetailedResponse, err error) { + return vpc.ListShareMountTargetsWithContext(context.Background(), listShareMountTargetsOptions) } -// UpdateSnapshotWithContext is an alternate form of the UpdateSnapshot method which supports a Context parameter -func (vpc *VpcV1) UpdateSnapshotWithContext(ctx context.Context, updateSnapshotOptions *UpdateSnapshotOptions) (result *Snapshot, response *core.DetailedResponse, err error) { - err = core.ValidateNotNil(updateSnapshotOptions, "updateSnapshotOptions cannot be nil") +// ListShareMountTargetsWithContext is an alternate form of the ListShareMountTargets method which supports a Context parameter +func (vpc *VpcV1) ListShareMountTargetsWithContext(ctx context.Context, listShareMountTargetsOptions *ListShareMountTargetsOptions) (result *ShareMountTargetCollection, response *core.DetailedResponse, err error) { + err = core.ValidateNotNil(listShareMountTargetsOptions, "listShareMountTargetsOptions cannot be nil") if err != nil { return } - err = core.ValidateStruct(updateSnapshotOptions, "updateSnapshotOptions") + err = core.ValidateStruct(listShareMountTargetsOptions, "listShareMountTargetsOptions") if err != nil { return } pathParamsMap := map[string]string{ - "id": *updateSnapshotOptions.ID, + "share_id": *listShareMountTargetsOptions.ShareID, } - builder := core.NewRequestBuilder(core.PATCH) + builder := core.NewRequestBuilder(core.GET) builder = builder.WithContext(ctx) builder.EnableGzipCompression = vpc.GetEnableGzipCompression() - _, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/snapshots/{id}`, pathParamsMap) + _, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/shares/{share_id}/mount_targets`, pathParamsMap) if err != nil { return } - for headerName, headerValue := range updateSnapshotOptions.Headers { + for headerName, headerValue := range listShareMountTargetsOptions.Headers { builder.AddHeader(headerName, headerValue) } - sdkHeaders := common.GetSdkHeaders("vpc", "V1", "UpdateSnapshot") + sdkHeaders := common.GetSdkHeaders("vpc", "V1", "ListShareMountTargets") for headerName, headerValue := range sdkHeaders { builder.AddHeader(headerName, headerValue) } builder.AddHeader("Accept", "application/json") - builder.AddHeader("Content-Type", "application/merge-patch+json") - if updateSnapshotOptions.IfMatch != nil { - builder.AddHeader("If-Match", fmt.Sprint(*updateSnapshotOptions.IfMatch)) - } builder.AddQuery("version", fmt.Sprint(*vpc.Version)) builder.AddQuery("generation", fmt.Sprint(*vpc.generation)) - - _, err = builder.SetBodyContentJSON(updateSnapshotOptions.SnapshotPatch) - if err != nil { - return + if listShareMountTargetsOptions.Name != nil { + builder.AddQuery("name", fmt.Sprint(*listShareMountTargetsOptions.Name)) + } + if listShareMountTargetsOptions.Start != nil { + builder.AddQuery("start", fmt.Sprint(*listShareMountTargetsOptions.Start)) + } + if listShareMountTargetsOptions.Limit != nil { + builder.AddQuery("limit", fmt.Sprint(*listShareMountTargetsOptions.Limit)) } request, err := builder.Build() @@ -15096,7 +15109,7 @@ func (vpc *VpcV1) UpdateSnapshotWithContext(ctx context.Context, updateSnapshotO return } if rawResponse != nil { - err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalSnapshot) + err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalShareMountTargetCollection) if err != nil { return } @@ -15106,48 +15119,57 @@ func (vpc *VpcV1) UpdateSnapshotWithContext(ctx context.Context, updateSnapshotO return } -// ListSnapshotClones : List all clones for a snapshot -// This request lists all clones for a snapshot. Use a clone to quickly restore a snapshot within the clone's zone. -func (vpc *VpcV1) ListSnapshotClones(listSnapshotClonesOptions *ListSnapshotClonesOptions) (result *SnapshotCloneCollection, response *core.DetailedResponse, err error) { - return vpc.ListSnapshotClonesWithContext(context.Background(), listSnapshotClonesOptions) +// CreateShareMountTarget : Create a mount target for a file share +// This request creates a new share mount target from a share mount target prototype object. +// +// The prototype object is structured in the same way as a retrieved share mount target, and contains the information +// necessary to provision the new file share mount target. +func (vpc *VpcV1) CreateShareMountTarget(createShareMountTargetOptions *CreateShareMountTargetOptions) (result *ShareMountTarget, response *core.DetailedResponse, err error) { + return vpc.CreateShareMountTargetWithContext(context.Background(), createShareMountTargetOptions) } -// ListSnapshotClonesWithContext is an alternate form of the ListSnapshotClones method which supports a Context parameter -func (vpc *VpcV1) ListSnapshotClonesWithContext(ctx context.Context, listSnapshotClonesOptions *ListSnapshotClonesOptions) (result *SnapshotCloneCollection, response *core.DetailedResponse, err error) { - err = core.ValidateNotNil(listSnapshotClonesOptions, "listSnapshotClonesOptions cannot be nil") +// CreateShareMountTargetWithContext is an alternate form of the CreateShareMountTarget method which supports a Context parameter +func (vpc *VpcV1) CreateShareMountTargetWithContext(ctx context.Context, createShareMountTargetOptions *CreateShareMountTargetOptions) (result *ShareMountTarget, response *core.DetailedResponse, err error) { + err = core.ValidateNotNil(createShareMountTargetOptions, "createShareMountTargetOptions cannot be nil") if err != nil { return } - err = core.ValidateStruct(listSnapshotClonesOptions, "listSnapshotClonesOptions") + err = core.ValidateStruct(createShareMountTargetOptions, "createShareMountTargetOptions") if err != nil { return } pathParamsMap := map[string]string{ - "id": *listSnapshotClonesOptions.ID, + "share_id": *createShareMountTargetOptions.ShareID, } - builder := core.NewRequestBuilder(core.GET) + builder := core.NewRequestBuilder(core.POST) builder = builder.WithContext(ctx) builder.EnableGzipCompression = vpc.GetEnableGzipCompression() - _, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/snapshots/{id}/clones`, pathParamsMap) + _, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/shares/{share_id}/mount_targets`, pathParamsMap) if err != nil { return } - for headerName, headerValue := range listSnapshotClonesOptions.Headers { + for headerName, headerValue := range createShareMountTargetOptions.Headers { builder.AddHeader(headerName, headerValue) } - sdkHeaders := common.GetSdkHeaders("vpc", "V1", "ListSnapshotClones") + sdkHeaders := common.GetSdkHeaders("vpc", "V1", "CreateShareMountTarget") for headerName, headerValue := range sdkHeaders { builder.AddHeader(headerName, headerValue) } builder.AddHeader("Accept", "application/json") + builder.AddHeader("Content-Type", "application/json") builder.AddQuery("version", fmt.Sprint(*vpc.Version)) builder.AddQuery("generation", fmt.Sprint(*vpc.generation)) + _, err = builder.SetBodyContentJSON(createShareMountTargetOptions.ShareMountTargetPrototype) + if err != nil { + return + } + request, err := builder.Build() if err != nil { return @@ -15159,7 +15181,7 @@ func (vpc *VpcV1) ListSnapshotClonesWithContext(ctx context.Context, listSnapsho return } if rawResponse != nil { - err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalSnapshotCloneCollection) + err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalShareMountTarget) if err != nil { return } @@ -15169,45 +15191,48 @@ func (vpc *VpcV1) ListSnapshotClonesWithContext(ctx context.Context, listSnapsho return } -// DeleteSnapshotClone : Delete a snapshot clone -// This request deletes a snapshot clone. This operation cannot be reversed, but an equivalent clone may be recreated -// from the snapshot. -func (vpc *VpcV1) DeleteSnapshotClone(deleteSnapshotCloneOptions *DeleteSnapshotCloneOptions) (response *core.DetailedResponse, err error) { - return vpc.DeleteSnapshotCloneWithContext(context.Background(), deleteSnapshotCloneOptions) +// DeleteShareMountTarget : Delete a share mount target +// This request deletes a share mount target. This operation cannot be reversed. +// +// If the request is accepted, the share mount target `lifecycle_state` will be set to +// `deleting`. Once deletion processing completes, it will no longer be retrievable. +func (vpc *VpcV1) DeleteShareMountTarget(deleteShareMountTargetOptions *DeleteShareMountTargetOptions) (result *ShareMountTarget, response *core.DetailedResponse, err error) { + return vpc.DeleteShareMountTargetWithContext(context.Background(), deleteShareMountTargetOptions) } -// DeleteSnapshotCloneWithContext is an alternate form of the DeleteSnapshotClone method which supports a Context parameter -func (vpc *VpcV1) DeleteSnapshotCloneWithContext(ctx context.Context, deleteSnapshotCloneOptions *DeleteSnapshotCloneOptions) (response *core.DetailedResponse, err error) { - err = core.ValidateNotNil(deleteSnapshotCloneOptions, "deleteSnapshotCloneOptions cannot be nil") +// DeleteShareMountTargetWithContext is an alternate form of the DeleteShareMountTarget method which supports a Context parameter +func (vpc *VpcV1) DeleteShareMountTargetWithContext(ctx context.Context, deleteShareMountTargetOptions *DeleteShareMountTargetOptions) (result *ShareMountTarget, response *core.DetailedResponse, err error) { + err = core.ValidateNotNil(deleteShareMountTargetOptions, "deleteShareMountTargetOptions cannot be nil") if err != nil { return } - err = core.ValidateStruct(deleteSnapshotCloneOptions, "deleteSnapshotCloneOptions") + err = core.ValidateStruct(deleteShareMountTargetOptions, "deleteShareMountTargetOptions") if err != nil { return } pathParamsMap := map[string]string{ - "id": *deleteSnapshotCloneOptions.ID, - "zone_name": *deleteSnapshotCloneOptions.ZoneName, + "share_id": *deleteShareMountTargetOptions.ShareID, + "id": *deleteShareMountTargetOptions.ID, } builder := core.NewRequestBuilder(core.DELETE) builder = builder.WithContext(ctx) builder.EnableGzipCompression = vpc.GetEnableGzipCompression() - _, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/snapshots/{id}/clones/{zone_name}`, pathParamsMap) + _, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/shares/{share_id}/mount_targets/{id}`, pathParamsMap) if err != nil { return } - for headerName, headerValue := range deleteSnapshotCloneOptions.Headers { + for headerName, headerValue := range deleteShareMountTargetOptions.Headers { builder.AddHeader(headerName, headerValue) } - sdkHeaders := common.GetSdkHeaders("vpc", "V1", "DeleteSnapshotClone") + sdkHeaders := common.GetSdkHeaders("vpc", "V1", "DeleteShareMountTarget") 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)) @@ -15217,46 +15242,57 @@ func (vpc *VpcV1) DeleteSnapshotCloneWithContext(ctx context.Context, deleteSnap return } - response, err = vpc.Service.Request(request, nil) + 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, UnmarshalShareMountTarget) + if err != nil { + return + } + response.Result = result + } return } -// GetSnapshotClone : Retrieve a snapshot clone -// This request retrieves a single clone specified by the snapshot identifier and zone name in the URL. -func (vpc *VpcV1) GetSnapshotClone(getSnapshotCloneOptions *GetSnapshotCloneOptions) (result *SnapshotClone, response *core.DetailedResponse, err error) { - return vpc.GetSnapshotCloneWithContext(context.Background(), getSnapshotCloneOptions) +// GetShareMountTarget : Retrieve a share mount target +// This request retrieves a single share mount target specified by the identifier in the URL. +func (vpc *VpcV1) GetShareMountTarget(getShareMountTargetOptions *GetShareMountTargetOptions) (result *ShareMountTarget, response *core.DetailedResponse, err error) { + return vpc.GetShareMountTargetWithContext(context.Background(), getShareMountTargetOptions) } -// GetSnapshotCloneWithContext is an alternate form of the GetSnapshotClone method which supports a Context parameter -func (vpc *VpcV1) GetSnapshotCloneWithContext(ctx context.Context, getSnapshotCloneOptions *GetSnapshotCloneOptions) (result *SnapshotClone, response *core.DetailedResponse, err error) { - err = core.ValidateNotNil(getSnapshotCloneOptions, "getSnapshotCloneOptions cannot be nil") +// GetShareMountTargetWithContext is an alternate form of the GetShareMountTarget method which supports a Context parameter +func (vpc *VpcV1) GetShareMountTargetWithContext(ctx context.Context, getShareMountTargetOptions *GetShareMountTargetOptions) (result *ShareMountTarget, response *core.DetailedResponse, err error) { + err = core.ValidateNotNil(getShareMountTargetOptions, "getShareMountTargetOptions cannot be nil") if err != nil { return } - err = core.ValidateStruct(getSnapshotCloneOptions, "getSnapshotCloneOptions") + err = core.ValidateStruct(getShareMountTargetOptions, "getShareMountTargetOptions") if err != nil { return } pathParamsMap := map[string]string{ - "id": *getSnapshotCloneOptions.ID, - "zone_name": *getSnapshotCloneOptions.ZoneName, + "share_id": *getShareMountTargetOptions.ShareID, + "id": *getShareMountTargetOptions.ID, } builder := core.NewRequestBuilder(core.GET) builder = builder.WithContext(ctx) builder.EnableGzipCompression = vpc.GetEnableGzipCompression() - _, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/snapshots/{id}/clones/{zone_name}`, pathParamsMap) + _, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/shares/{share_id}/mount_targets/{id}`, pathParamsMap) if err != nil { return } - for headerName, headerValue := range getSnapshotCloneOptions.Headers { + for headerName, headerValue := range getShareMountTargetOptions.Headers { builder.AddHeader(headerName, headerValue) } - sdkHeaders := common.GetSdkHeaders("vpc", "V1", "GetSnapshotClone") + sdkHeaders := common.GetSdkHeaders("vpc", "V1", "GetShareMountTarget") for headerName, headerValue := range sdkHeaders { builder.AddHeader(headerName, headerValue) } @@ -15276,7 +15312,7 @@ func (vpc *VpcV1) GetSnapshotCloneWithContext(ctx context.Context, getSnapshotCl return } if rawResponse != nil { - err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalSnapshotClone) + err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalShareMountTarget) if err != nil { return } @@ -15286,50 +15322,57 @@ func (vpc *VpcV1) GetSnapshotCloneWithContext(ctx context.Context, getSnapshotCl return } -// CreateSnapshotClone : Create a clone for a snapshot -// This request creates a new clone for a snapshot in the specified zone. A request body is not required, and if -// provided, is ignored. If the snapshot already has a clone in the zone, it is returned. -func (vpc *VpcV1) CreateSnapshotClone(createSnapshotCloneOptions *CreateSnapshotCloneOptions) (result *SnapshotClone, response *core.DetailedResponse, err error) { - return vpc.CreateSnapshotCloneWithContext(context.Background(), createSnapshotCloneOptions) +// UpdateShareMountTarget : Update a share mount target +// This request updates a share mount target with the information provided in a share mount target patch object. The +// share mount target patch object is structured in the same way as a retrieved share mount target and needs to contain +// only the information to be updated. +func (vpc *VpcV1) UpdateShareMountTarget(updateShareMountTargetOptions *UpdateShareMountTargetOptions) (result *ShareMountTarget, response *core.DetailedResponse, err error) { + return vpc.UpdateShareMountTargetWithContext(context.Background(), updateShareMountTargetOptions) } -// CreateSnapshotCloneWithContext is an alternate form of the CreateSnapshotClone method which supports a Context parameter -func (vpc *VpcV1) CreateSnapshotCloneWithContext(ctx context.Context, createSnapshotCloneOptions *CreateSnapshotCloneOptions) (result *SnapshotClone, response *core.DetailedResponse, err error) { - err = core.ValidateNotNil(createSnapshotCloneOptions, "createSnapshotCloneOptions cannot be nil") +// UpdateShareMountTargetWithContext is an alternate form of the UpdateShareMountTarget method which supports a Context parameter +func (vpc *VpcV1) UpdateShareMountTargetWithContext(ctx context.Context, updateShareMountTargetOptions *UpdateShareMountTargetOptions) (result *ShareMountTarget, response *core.DetailedResponse, err error) { + err = core.ValidateNotNil(updateShareMountTargetOptions, "updateShareMountTargetOptions cannot be nil") if err != nil { return } - err = core.ValidateStruct(createSnapshotCloneOptions, "createSnapshotCloneOptions") + err = core.ValidateStruct(updateShareMountTargetOptions, "updateShareMountTargetOptions") if err != nil { return } pathParamsMap := map[string]string{ - "id": *createSnapshotCloneOptions.ID, - "zone_name": *createSnapshotCloneOptions.ZoneName, + "share_id": *updateShareMountTargetOptions.ShareID, + "id": *updateShareMountTargetOptions.ID, } - builder := core.NewRequestBuilder(core.PUT) + builder := core.NewRequestBuilder(core.PATCH) builder = builder.WithContext(ctx) builder.EnableGzipCompression = vpc.GetEnableGzipCompression() - _, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/snapshots/{id}/clones/{zone_name}`, pathParamsMap) + _, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/shares/{share_id}/mount_targets/{id}`, pathParamsMap) if err != nil { return } - for headerName, headerValue := range createSnapshotCloneOptions.Headers { + for headerName, headerValue := range updateShareMountTargetOptions.Headers { builder.AddHeader(headerName, headerValue) } - sdkHeaders := common.GetSdkHeaders("vpc", "V1", "CreateSnapshotClone") + sdkHeaders := common.GetSdkHeaders("vpc", "V1", "UpdateShareMountTarget") for headerName, headerValue := range sdkHeaders { builder.AddHeader(headerName, headerValue) } builder.AddHeader("Accept", "application/json") + builder.AddHeader("Content-Type", "application/merge-patch+json") builder.AddQuery("version", fmt.Sprint(*vpc.Version)) builder.AddQuery("generation", fmt.Sprint(*vpc.generation)) + _, err = builder.SetBodyContentJSON(updateShareMountTargetOptions.ShareMountTargetPatch) + if err != nil { + return + } + request, err := builder.Build() if err != nil { return @@ -15341,7 +15384,7 @@ func (vpc *VpcV1) CreateSnapshotCloneWithContext(ctx context.Context, createSnap return } if rawResponse != nil { - err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalSnapshotClone) + err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalShareMountTarget) if err != nil { return } @@ -15351,106 +15394,96 @@ func (vpc *VpcV1) CreateSnapshotCloneWithContext(ctx context.Context, createSnap return } -// ListShareProfiles : List all file share profiles -// This request lists all [file share profiles](https://cloud.ibm.com/docs/vpc?topic=vpc-file-storage-profiles) -// available in the region. A file share profile specifies the performance characteristics and pricing model for a file -// share. -func (vpc *VpcV1) ListShareProfiles(listShareProfilesOptions *ListShareProfilesOptions) (result *ShareProfileCollection, response *core.DetailedResponse, err error) { - return vpc.ListShareProfilesWithContext(context.Background(), listShareProfilesOptions) +// DeleteShareSource : Split the source file share from a replica share +// This request removes the replication relationship between a source share and the replica share specified by the +// identifier in the URL. The replication relationship cannot be removed if a source share or the replica share has a +// `lifecycle_state` of `updating`, or has a replication operation in progress. +// +// This operation cannot be reversed. +func (vpc *VpcV1) DeleteShareSource(deleteShareSourceOptions *DeleteShareSourceOptions) (response *core.DetailedResponse, err error) { + return vpc.DeleteShareSourceWithContext(context.Background(), deleteShareSourceOptions) } -// ListShareProfilesWithContext is an alternate form of the ListShareProfiles method which supports a Context parameter -func (vpc *VpcV1) ListShareProfilesWithContext(ctx context.Context, listShareProfilesOptions *ListShareProfilesOptions) (result *ShareProfileCollection, response *core.DetailedResponse, err error) { - err = core.ValidateStruct(listShareProfilesOptions, "listShareProfilesOptions") +// DeleteShareSourceWithContext is an alternate form of the DeleteShareSource method which supports a Context parameter +func (vpc *VpcV1) DeleteShareSourceWithContext(ctx context.Context, deleteShareSourceOptions *DeleteShareSourceOptions) (response *core.DetailedResponse, err error) { + err = core.ValidateNotNil(deleteShareSourceOptions, "deleteShareSourceOptions cannot be nil") + if err != nil { + return + } + err = core.ValidateStruct(deleteShareSourceOptions, "deleteShareSourceOptions") if err != nil { return } - builder := core.NewRequestBuilder(core.GET) + pathParamsMap := map[string]string{ + "share_id": *deleteShareSourceOptions.ShareID, + } + + builder := core.NewRequestBuilder(core.DELETE) builder = builder.WithContext(ctx) builder.EnableGzipCompression = vpc.GetEnableGzipCompression() - _, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/share/profiles`, nil) + _, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/shares/{share_id}/source`, pathParamsMap) if err != nil { return } - for headerName, headerValue := range listShareProfilesOptions.Headers { + for headerName, headerValue := range deleteShareSourceOptions.Headers { builder.AddHeader(headerName, headerValue) } - sdkHeaders := common.GetSdkHeaders("vpc", "V1", "ListShareProfiles") + sdkHeaders := common.GetSdkHeaders("vpc", "V1", "DeleteShareSource") 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 listShareProfilesOptions.Start != nil { - builder.AddQuery("start", fmt.Sprint(*listShareProfilesOptions.Start)) - } - if listShareProfilesOptions.Limit != nil { - builder.AddQuery("limit", fmt.Sprint(*listShareProfilesOptions.Limit)) - } - if listShareProfilesOptions.Sort != nil { - builder.AddQuery("sort", fmt.Sprint(*listShareProfilesOptions.Sort)) - } 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, UnmarshalShareProfileCollection) - if err != nil { - return - } - response.Result = result - } + response, err = vpc.Service.Request(request, nil) return } -// GetShareProfile : Retrieve a file share profile -// This request retrieves a single file share profile specified by the name in the URL. -func (vpc *VpcV1) GetShareProfile(getShareProfileOptions *GetShareProfileOptions) (result *ShareProfile, response *core.DetailedResponse, err error) { - return vpc.GetShareProfileWithContext(context.Background(), getShareProfileOptions) +// GetShareSource : Retrieve the source file share for a replica file share +// This request retrieves the source file share associated with the replica file share specified by the identifier in +// the URL. +func (vpc *VpcV1) GetShareSource(getShareSourceOptions *GetShareSourceOptions) (result *ShareReference, response *core.DetailedResponse, err error) { + return vpc.GetShareSourceWithContext(context.Background(), getShareSourceOptions) } -// GetShareProfileWithContext is an alternate form of the GetShareProfile method which supports a Context parameter -func (vpc *VpcV1) GetShareProfileWithContext(ctx context.Context, getShareProfileOptions *GetShareProfileOptions) (result *ShareProfile, response *core.DetailedResponse, err error) { - err = core.ValidateNotNil(getShareProfileOptions, "getShareProfileOptions cannot be nil") +// GetShareSourceWithContext is an alternate form of the GetShareSource method which supports a Context parameter +func (vpc *VpcV1) GetShareSourceWithContext(ctx context.Context, getShareSourceOptions *GetShareSourceOptions) (result *ShareReference, response *core.DetailedResponse, err error) { + err = core.ValidateNotNil(getShareSourceOptions, "getShareSourceOptions cannot be nil") if err != nil { return } - err = core.ValidateStruct(getShareProfileOptions, "getShareProfileOptions") + err = core.ValidateStruct(getShareSourceOptions, "getShareSourceOptions") if err != nil { return } pathParamsMap := map[string]string{ - "name": *getShareProfileOptions.Name, + "share_id": *getShareSourceOptions.ShareID, } builder := core.NewRequestBuilder(core.GET) builder = builder.WithContext(ctx) builder.EnableGzipCompression = vpc.GetEnableGzipCompression() - _, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/share/profiles/{name}`, pathParamsMap) + _, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/shares/{share_id}/source`, pathParamsMap) if err != nil { return } - for headerName, headerValue := range getShareProfileOptions.Headers { + for headerName, headerValue := range getShareSourceOptions.Headers { builder.AddHeader(headerName, headerValue) } - sdkHeaders := common.GetSdkHeaders("vpc", "V1", "GetShareProfile") + sdkHeaders := common.GetSdkHeaders("vpc", "V1", "GetShareSource") for headerName, headerValue := range sdkHeaders { builder.AddHeader(headerName, headerValue) } @@ -15470,7 +15503,7 @@ func (vpc *VpcV1) GetShareProfileWithContext(ctx context.Context, getShareProfil return } if rawResponse != nil { - err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalShareProfile) + err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalShareReference) if err != nil { return } @@ -15480,15 +15513,16 @@ func (vpc *VpcV1) GetShareProfileWithContext(ctx context.Context, getShareProfil return } -// ListShares : List all file shares -// This request lists all file shares in the region. -func (vpc *VpcV1) ListShares(listSharesOptions *ListSharesOptions) (result *ShareCollection, response *core.DetailedResponse, err error) { - return vpc.ListSharesWithContext(context.Background(), listSharesOptions) +// 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) } -// ListSharesWithContext is an alternate form of the ListShares method which supports a Context parameter -func (vpc *VpcV1) ListSharesWithContext(ctx context.Context, listSharesOptions *ListSharesOptions) (result *ShareCollection, response *core.DetailedResponse, err error) { - err = core.ValidateStruct(listSharesOptions, "listSharesOptions") +// 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 } @@ -15496,16 +15530,16 @@ func (vpc *VpcV1) ListSharesWithContext(ctx context.Context, listSharesOptions * builder := core.NewRequestBuilder(core.GET) builder = builder.WithContext(ctx) builder.EnableGzipCompression = vpc.GetEnableGzipCompression() - _, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/shares`, nil) + _, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/backup_policies`, nil) if err != nil { return } - for headerName, headerValue := range listSharesOptions.Headers { + for headerName, headerValue := range listBackupPoliciesOptions.Headers { builder.AddHeader(headerName, headerValue) } - sdkHeaders := common.GetSdkHeaders("vpc", "V1", "ListShares") + sdkHeaders := common.GetSdkHeaders("vpc", "V1", "ListBackupPolicies") for headerName, headerValue := range sdkHeaders { builder.AddHeader(headerName, headerValue) } @@ -15513,23 +15547,20 @@ func (vpc *VpcV1) ListSharesWithContext(ctx context.Context, listSharesOptions * builder.AddQuery("version", fmt.Sprint(*vpc.Version)) builder.AddQuery("generation", fmt.Sprint(*vpc.generation)) - if listSharesOptions.Start != nil { - builder.AddQuery("start", fmt.Sprint(*listSharesOptions.Start)) - } - if listSharesOptions.Limit != nil { - builder.AddQuery("limit", fmt.Sprint(*listSharesOptions.Limit)) + if listBackupPoliciesOptions.Start != nil { + builder.AddQuery("start", fmt.Sprint(*listBackupPoliciesOptions.Start)) } - if listSharesOptions.ResourceGroupID != nil { - builder.AddQuery("resource_group.id", fmt.Sprint(*listSharesOptions.ResourceGroupID)) + if listBackupPoliciesOptions.Limit != nil { + builder.AddQuery("limit", fmt.Sprint(*listBackupPoliciesOptions.Limit)) } - if listSharesOptions.Name != nil { - builder.AddQuery("name", fmt.Sprint(*listSharesOptions.Name)) + if listBackupPoliciesOptions.ResourceGroupID != nil { + builder.AddQuery("resource_group.id", fmt.Sprint(*listBackupPoliciesOptions.ResourceGroupID)) } - if listSharesOptions.Sort != nil { - builder.AddQuery("sort", fmt.Sprint(*listSharesOptions.Sort)) + if listBackupPoliciesOptions.Name != nil { + builder.AddQuery("name", fmt.Sprint(*listBackupPoliciesOptions.Name)) } - if listSharesOptions.ReplicationRole != nil { - builder.AddQuery("replication_role", fmt.Sprint(*listSharesOptions.ReplicationRole)) + if listBackupPoliciesOptions.Tag != nil { + builder.AddQuery("tag", fmt.Sprint(*listBackupPoliciesOptions.Tag)) } request, err := builder.Build() @@ -15543,7 +15574,7 @@ func (vpc *VpcV1) ListSharesWithContext(ctx context.Context, listSharesOptions * return } if rawResponse != nil { - err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalShareCollection) + err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalBackupPolicyCollection) if err != nil { return } @@ -15553,23 +15584,20 @@ func (vpc *VpcV1) ListSharesWithContext(ctx context.Context, listSharesOptions * return } -// CreateShare : Create a file share -// This request provisions new file shares from a share prototype object. The new file shares can be a standalone share, -// a replica share, or both a source and replica share. -// -// The prototype object is structured in the same way as a retrieved share, and contains the information necessary to -// provision the new file shares. -func (vpc *VpcV1) CreateShare(createShareOptions *CreateShareOptions) (result *Share, response *core.DetailedResponse, err error) { - return vpc.CreateShareWithContext(context.Background(), createShareOptions) +// 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 BackupPolicyIntf, response *core.DetailedResponse, err error) { + return vpc.CreateBackupPolicyWithContext(context.Background(), createBackupPolicyOptions) } -// CreateShareWithContext is an alternate form of the CreateShare method which supports a Context parameter -func (vpc *VpcV1) CreateShareWithContext(ctx context.Context, createShareOptions *CreateShareOptions) (result *Share, response *core.DetailedResponse, err error) { - err = core.ValidateNotNil(createShareOptions, "createShareOptions cannot be nil") +// CreateBackupPolicyWithContext is an alternate form of the CreateBackupPolicy method which supports a Context parameter +func (vpc *VpcV1) CreateBackupPolicyWithContext(ctx context.Context, createBackupPolicyOptions *CreateBackupPolicyOptions) (result BackupPolicyIntf, response *core.DetailedResponse, err error) { + err = core.ValidateNotNil(createBackupPolicyOptions, "createBackupPolicyOptions cannot be nil") if err != nil { return } - err = core.ValidateStruct(createShareOptions, "createShareOptions") + err = core.ValidateStruct(createBackupPolicyOptions, "createBackupPolicyOptions") if err != nil { return } @@ -15577,16 +15605,16 @@ func (vpc *VpcV1) CreateShareWithContext(ctx context.Context, createShareOptions builder := core.NewRequestBuilder(core.POST) builder = builder.WithContext(ctx) builder.EnableGzipCompression = vpc.GetEnableGzipCompression() - _, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/shares`, nil) + _, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/backup_policies`, nil) if err != nil { return } - for headerName, headerValue := range createShareOptions.Headers { + for headerName, headerValue := range createBackupPolicyOptions.Headers { builder.AddHeader(headerName, headerValue) } - sdkHeaders := common.GetSdkHeaders("vpc", "V1", "CreateShare") + sdkHeaders := common.GetSdkHeaders("vpc", "V1", "CreateBackupPolicy") for headerName, headerValue := range sdkHeaders { builder.AddHeader(headerName, headerValue) } @@ -15596,7 +15624,7 @@ func (vpc *VpcV1) CreateShareWithContext(ctx context.Context, createShareOptions builder.AddQuery("version", fmt.Sprint(*vpc.Version)) builder.AddQuery("generation", fmt.Sprint(*vpc.generation)) - _, err = builder.SetBodyContentJSON(createShareOptions.SharePrototype) + _, err = builder.SetBodyContentJSON(createBackupPolicyOptions.BackupPolicyPrototype) if err != nil { return } @@ -15612,7 +15640,7 @@ func (vpc *VpcV1) CreateShareWithContext(ctx context.Context, createShareOptions return } if rawResponse != nil { - err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalShare) + err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalBackupPolicy) if err != nil { return } @@ -15622,119 +15650,72 @@ func (vpc *VpcV1) CreateShareWithContext(ctx context.Context, createShareOptions return } -// DeleteShare : Delete a file share -// This request deletes a share. This operation cannot be reversed. A share cannot be deleted if it: -// - has share mount targets -// - has a `lifecycle_state` of `updating` -// - has a replication operation in progress -// -// If the request is accepted, the share `lifecycle_state` will be set to `deleting`. Once deletion processing -// completes, it will no longer be retrievable. -func (vpc *VpcV1) DeleteShare(deleteShareOptions *DeleteShareOptions) (result *Share, response *core.DetailedResponse, err error) { - return vpc.DeleteShareWithContext(context.Background(), deleteShareOptions) +// ListBackupPolicyJobs : List all jobs for a backup policy +// This request retrieves all jobs for a backup policy. A backup job represents the execution of a backup policy plan +// for a resource matching the policy's criteria. +func (vpc *VpcV1) ListBackupPolicyJobs(listBackupPolicyJobsOptions *ListBackupPolicyJobsOptions) (result *BackupPolicyJobCollection, response *core.DetailedResponse, err error) { + return vpc.ListBackupPolicyJobsWithContext(context.Background(), listBackupPolicyJobsOptions) } -// DeleteShareWithContext is an alternate form of the DeleteShare method which supports a Context parameter -func (vpc *VpcV1) DeleteShareWithContext(ctx context.Context, deleteShareOptions *DeleteShareOptions) (result *Share, response *core.DetailedResponse, err error) { - err = core.ValidateNotNil(deleteShareOptions, "deleteShareOptions cannot be nil") +// ListBackupPolicyJobsWithContext is an alternate form of the ListBackupPolicyJobs method which supports a Context parameter +func (vpc *VpcV1) ListBackupPolicyJobsWithContext(ctx context.Context, listBackupPolicyJobsOptions *ListBackupPolicyJobsOptions) (result *BackupPolicyJobCollection, response *core.DetailedResponse, err error) { + err = core.ValidateNotNil(listBackupPolicyJobsOptions, "listBackupPolicyJobsOptions cannot be nil") if err != nil { return } - err = core.ValidateStruct(deleteShareOptions, "deleteShareOptions") + err = core.ValidateStruct(listBackupPolicyJobsOptions, "listBackupPolicyJobsOptions") if err != nil { return } pathParamsMap := map[string]string{ - "id": *deleteShareOptions.ID, + "backup_policy_id": *listBackupPolicyJobsOptions.BackupPolicyID, } - builder := core.NewRequestBuilder(core.DELETE) + builder := core.NewRequestBuilder(core.GET) builder = builder.WithContext(ctx) builder.EnableGzipCompression = vpc.GetEnableGzipCompression() - _, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/shares/{id}`, pathParamsMap) + _, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/backup_policies/{backup_policy_id}/jobs`, pathParamsMap) if err != nil { return } - for headerName, headerValue := range deleteShareOptions.Headers { + for headerName, headerValue := range listBackupPolicyJobsOptions.Headers { builder.AddHeader(headerName, headerValue) } - sdkHeaders := common.GetSdkHeaders("vpc", "V1", "DeleteShare") + sdkHeaders := common.GetSdkHeaders("vpc", "V1", "ListBackupPolicyJobs") for headerName, headerValue := range sdkHeaders { builder.AddHeader(headerName, headerValue) } builder.AddHeader("Accept", "application/json") - if deleteShareOptions.IfMatch != nil { - builder.AddHeader("If-Match", fmt.Sprint(*deleteShareOptions.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 listBackupPolicyJobsOptions.Status != nil { + builder.AddQuery("status", fmt.Sprint(*listBackupPolicyJobsOptions.Status)) } - if rawResponse != nil { - err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalShare) - if err != nil { - return - } - response.Result = result + if listBackupPolicyJobsOptions.BackupPolicyPlanID != nil { + builder.AddQuery("backup_policy_plan.id", fmt.Sprint(*listBackupPolicyJobsOptions.BackupPolicyPlanID)) } - - return -} - -// GetShare : Retrieve a file share -// This request retrieves a single file share specified by the identifier in the URL. -func (vpc *VpcV1) GetShare(getShareOptions *GetShareOptions) (result *Share, response *core.DetailedResponse, err error) { - return vpc.GetShareWithContext(context.Background(), getShareOptions) -} - -// GetShareWithContext is an alternate form of the GetShare method which supports a Context parameter -func (vpc *VpcV1) GetShareWithContext(ctx context.Context, getShareOptions *GetShareOptions) (result *Share, response *core.DetailedResponse, err error) { - err = core.ValidateNotNil(getShareOptions, "getShareOptions cannot be nil") - if err != nil { - return + if listBackupPolicyJobsOptions.Start != nil { + builder.AddQuery("start", fmt.Sprint(*listBackupPolicyJobsOptions.Start)) } - err = core.ValidateStruct(getShareOptions, "getShareOptions") - if err != nil { - return + if listBackupPolicyJobsOptions.Limit != nil { + builder.AddQuery("limit", fmt.Sprint(*listBackupPolicyJobsOptions.Limit)) } - - pathParamsMap := map[string]string{ - "id": *getShareOptions.ID, + if listBackupPolicyJobsOptions.Sort != nil { + builder.AddQuery("sort", fmt.Sprint(*listBackupPolicyJobsOptions.Sort)) } - - builder := core.NewRequestBuilder(core.GET) - builder = builder.WithContext(ctx) - builder.EnableGzipCompression = vpc.GetEnableGzipCompression() - _, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/shares/{id}`, pathParamsMap) - if err != nil { - return + if listBackupPolicyJobsOptions.SourceID != nil { + builder.AddQuery("source.id", fmt.Sprint(*listBackupPolicyJobsOptions.SourceID)) } - - for headerName, headerValue := range getShareOptions.Headers { - builder.AddHeader(headerName, headerValue) + if listBackupPolicyJobsOptions.TargetSnapshotsID != nil { + builder.AddQuery("target_snapshots[].id", fmt.Sprint(*listBackupPolicyJobsOptions.TargetSnapshotsID)) } - - sdkHeaders := common.GetSdkHeaders("vpc", "V1", "GetShare") - for headerName, headerValue := range sdkHeaders { - builder.AddHeader(headerName, headerValue) + if listBackupPolicyJobsOptions.TargetSnapshotsCRN != nil { + builder.AddQuery("target_snapshots[].crn", fmt.Sprint(*listBackupPolicyJobsOptions.TargetSnapshotsCRN)) } - 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 { @@ -15747,7 +15728,7 @@ func (vpc *VpcV1) GetShareWithContext(ctx context.Context, getShareOptions *GetS return } if rawResponse != nil { - err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalShare) + err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalBackupPolicyJobCollection) if err != nil { return } @@ -15757,58 +15738,49 @@ func (vpc *VpcV1) GetShareWithContext(ctx context.Context, getShareOptions *GetS return } -// UpdateShare : Update a file share -// This request updates a share with the information in a provided share patch. The share patch object is structured in -// the same way as a retrieved share and contains only the information to be updated. -func (vpc *VpcV1) UpdateShare(updateShareOptions *UpdateShareOptions) (result *Share, response *core.DetailedResponse, err error) { - return vpc.UpdateShareWithContext(context.Background(), updateShareOptions) +// GetBackupPolicyJob : Retrieve a backup policy job +// This request retrieves a single backup policy job specified by the identifier in the URL. +func (vpc *VpcV1) GetBackupPolicyJob(getBackupPolicyJobOptions *GetBackupPolicyJobOptions) (result *BackupPolicyJob, response *core.DetailedResponse, err error) { + return vpc.GetBackupPolicyJobWithContext(context.Background(), getBackupPolicyJobOptions) } -// UpdateShareWithContext is an alternate form of the UpdateShare method which supports a Context parameter -func (vpc *VpcV1) UpdateShareWithContext(ctx context.Context, updateShareOptions *UpdateShareOptions) (result *Share, response *core.DetailedResponse, err error) { - err = core.ValidateNotNil(updateShareOptions, "updateShareOptions cannot be nil") +// GetBackupPolicyJobWithContext is an alternate form of the GetBackupPolicyJob method which supports a Context parameter +func (vpc *VpcV1) GetBackupPolicyJobWithContext(ctx context.Context, getBackupPolicyJobOptions *GetBackupPolicyJobOptions) (result *BackupPolicyJob, response *core.DetailedResponse, err error) { + err = core.ValidateNotNil(getBackupPolicyJobOptions, "getBackupPolicyJobOptions cannot be nil") if err != nil { return } - err = core.ValidateStruct(updateShareOptions, "updateShareOptions") + err = core.ValidateStruct(getBackupPolicyJobOptions, "getBackupPolicyJobOptions") if err != nil { return } pathParamsMap := map[string]string{ - "id": *updateShareOptions.ID, + "backup_policy_id": *getBackupPolicyJobOptions.BackupPolicyID, + "id": *getBackupPolicyJobOptions.ID, } - builder := core.NewRequestBuilder(core.PATCH) + builder := core.NewRequestBuilder(core.GET) builder = builder.WithContext(ctx) builder.EnableGzipCompression = vpc.GetEnableGzipCompression() - _, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/shares/{id}`, pathParamsMap) + _, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/backup_policies/{backup_policy_id}/jobs/{id}`, pathParamsMap) if err != nil { return } - for headerName, headerValue := range updateShareOptions.Headers { + for headerName, headerValue := range getBackupPolicyJobOptions.Headers { builder.AddHeader(headerName, headerValue) } - sdkHeaders := common.GetSdkHeaders("vpc", "V1", "UpdateShare") + sdkHeaders := common.GetSdkHeaders("vpc", "V1", "GetBackupPolicyJob") for headerName, headerValue := range sdkHeaders { builder.AddHeader(headerName, headerValue) } builder.AddHeader("Accept", "application/json") - builder.AddHeader("Content-Type", "application/merge-patch+json") - if updateShareOptions.IfMatch != nil { - builder.AddHeader("If-Match", fmt.Sprint(*updateShareOptions.IfMatch)) - } builder.AddQuery("version", fmt.Sprint(*vpc.Version)) builder.AddQuery("generation", fmt.Sprint(*vpc.generation)) - _, err = builder.SetBodyContentJSON(updateShareOptions.SharePatch) - if err != nil { - return - } - request, err := builder.Build() if err != nil { return @@ -15820,7 +15792,7 @@ func (vpc *VpcV1) UpdateShareWithContext(ctx context.Context, updateShareOptions return } if rawResponse != nil { - err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalShare) + err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalBackupPolicyJob) if err != nil { return } @@ -15830,128 +15802,150 @@ func (vpc *VpcV1) UpdateShareWithContext(ctx context.Context, updateShareOptions return } -// FailoverShare : Failover to replica file share -// This request triggers a failover to the replica file share specified by the identifier in the URL. The failover -// cannot be started if a source share or the replica share has a `lifecycle_state` of `updating`, or has a replication -// operation in progress. -// -// If `fallback_policy` is specified as `split`, and the request is accepted but the failover operation cannot be -// performed, a split will be triggered. -func (vpc *VpcV1) FailoverShare(failoverShareOptions *FailoverShareOptions) (response *core.DetailedResponse, err error) { - return vpc.FailoverShareWithContext(context.Background(), failoverShareOptions) +// 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) } -// FailoverShareWithContext is an alternate form of the FailoverShare method which supports a Context parameter -func (vpc *VpcV1) FailoverShareWithContext(ctx context.Context, failoverShareOptions *FailoverShareOptions) (response *core.DetailedResponse, err error) { - err = core.ValidateNotNil(failoverShareOptions, "failoverShareOptions cannot be nil") +// 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(failoverShareOptions, "failoverShareOptions") + err = core.ValidateStruct(listBackupPolicyPlansOptions, "listBackupPolicyPlansOptions") if err != nil { return } pathParamsMap := map[string]string{ - "share_id": *failoverShareOptions.ShareID, + "backup_policy_id": *listBackupPolicyPlansOptions.BackupPolicyID, } - builder := core.NewRequestBuilder(core.POST) + builder := core.NewRequestBuilder(core.GET) builder = builder.WithContext(ctx) builder.EnableGzipCompression = vpc.GetEnableGzipCompression() - _, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/shares/{share_id}/failover`, pathParamsMap) + _, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/backup_policies/{backup_policy_id}/plans`, pathParamsMap) if err != nil { return } - for headerName, headerValue := range failoverShareOptions.Headers { + for headerName, headerValue := range listBackupPolicyPlansOptions.Headers { builder.AddHeader(headerName, headerValue) } - sdkHeaders := common.GetSdkHeaders("vpc", "V1", "FailoverShare") + sdkHeaders := common.GetSdkHeaders("vpc", "V1", "ListBackupPolicyPlans") for headerName, headerValue := range sdkHeaders { builder.AddHeader(headerName, headerValue) } - builder.AddHeader("Content-Type", "application/json") + builder.AddHeader("Accept", "application/json") builder.AddQuery("version", fmt.Sprint(*vpc.Version)) builder.AddQuery("generation", fmt.Sprint(*vpc.generation)) - - body := make(map[string]interface{}) - if failoverShareOptions.FallbackPolicy != nil { - body["fallback_policy"] = failoverShareOptions.FallbackPolicy - } - if failoverShareOptions.Timeout != nil { - body["timeout"] = failoverShareOptions.Timeout + if listBackupPolicyPlansOptions.Name != nil { + builder.AddQuery("name", fmt.Sprint(*listBackupPolicyPlansOptions.Name)) } - _, err = builder.SetBodyContentJSON(body) + + request, err := builder.Build() if err != nil { return } - request, err := builder.Build() + var rawResponse map[string]json.RawMessage + response, err = vpc.Service.Request(request, &rawResponse) if err != nil { return } - - response, err = vpc.Service.Request(request, nil) + if rawResponse != nil { + err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalBackupPolicyPlanCollection) + if err != nil { + return + } + response.Result = result + } return } -// ListShareMountTargets : List all mount targets for a file share -// This request retrieves all share mount targets for a file share. A share mount target is a network endpoint at which -// a file share may be mounted. The file share can be mounted by clients in the same VPC and zone after creating share -// mount targets. +// 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. // -// The share mount targets will be sorted by their `created_at` property values, with newest targets first. -func (vpc *VpcV1) ListShareMountTargets(listShareMountTargetsOptions *ListShareMountTargetsOptions) (result *ShareMountTargetCollection, response *core.DetailedResponse, err error) { - return vpc.ListShareMountTargetsWithContext(context.Background(), listShareMountTargetsOptions) +// 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) } -// ListShareMountTargetsWithContext is an alternate form of the ListShareMountTargets method which supports a Context parameter -func (vpc *VpcV1) ListShareMountTargetsWithContext(ctx context.Context, listShareMountTargetsOptions *ListShareMountTargetsOptions) (result *ShareMountTargetCollection, response *core.DetailedResponse, err error) { - err = core.ValidateNotNil(listShareMountTargetsOptions, "listShareMountTargetsOptions cannot be nil") +// 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(listShareMountTargetsOptions, "listShareMountTargetsOptions") + err = core.ValidateStruct(createBackupPolicyPlanOptions, "createBackupPolicyPlanOptions") if err != nil { return } pathParamsMap := map[string]string{ - "share_id": *listShareMountTargetsOptions.ShareID, + "backup_policy_id": *createBackupPolicyPlanOptions.BackupPolicyID, } - builder := core.NewRequestBuilder(core.GET) + builder := core.NewRequestBuilder(core.POST) builder = builder.WithContext(ctx) builder.EnableGzipCompression = vpc.GetEnableGzipCompression() - _, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/shares/{share_id}/mount_targets`, pathParamsMap) + _, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/backup_policies/{backup_policy_id}/plans`, pathParamsMap) if err != nil { return } - for headerName, headerValue := range listShareMountTargetsOptions.Headers { + for headerName, headerValue := range createBackupPolicyPlanOptions.Headers { builder.AddHeader(headerName, headerValue) } - sdkHeaders := common.GetSdkHeaders("vpc", "V1", "ListShareMountTargets") + 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)) - if listShareMountTargetsOptions.Name != nil { - builder.AddQuery("name", fmt.Sprint(*listShareMountTargetsOptions.Name)) + + body := make(map[string]interface{}) + if createBackupPolicyPlanOptions.CronSpec != nil { + body["cron_spec"] = createBackupPolicyPlanOptions.CronSpec } - if listShareMountTargetsOptions.Start != nil { - builder.AddQuery("start", fmt.Sprint(*listShareMountTargetsOptions.Start)) + if createBackupPolicyPlanOptions.Active != nil { + body["active"] = createBackupPolicyPlanOptions.Active } - if listShareMountTargetsOptions.Limit != nil { - builder.AddQuery("limit", fmt.Sprint(*listShareMountTargetsOptions.Limit)) + if createBackupPolicyPlanOptions.AttachUserTags != nil { + body["attach_user_tags"] = createBackupPolicyPlanOptions.AttachUserTags + } + if createBackupPolicyPlanOptions.ClonePolicy != nil { + body["clone_policy"] = createBackupPolicyPlanOptions.ClonePolicy + } + 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 + } + if createBackupPolicyPlanOptions.RemoteRegionPolicies != nil { + body["remote_region_policies"] = createBackupPolicyPlanOptions.RemoteRegionPolicies + } + _, err = builder.SetBodyContentJSON(body) + if err != nil { + return } request, err := builder.Build() @@ -15965,7 +15959,7 @@ func (vpc *VpcV1) ListShareMountTargetsWithContext(ctx context.Context, listShar return } if rawResponse != nil { - err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalShareMountTargetCollection) + err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalBackupPolicyPlan) if err != nil { return } @@ -15975,57 +15969,57 @@ func (vpc *VpcV1) ListShareMountTargetsWithContext(ctx context.Context, listShar return } -// CreateShareMountTarget : Create a mount target for a file share -// This request creates a new share mount target from a share mount target prototype object. +// 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. // -// The prototype object is structured in the same way as a retrieved share mount target, and contains the information -// necessary to provision the new file share mount target. -func (vpc *VpcV1) CreateShareMountTarget(createShareMountTargetOptions *CreateShareMountTargetOptions) (result *ShareMountTarget, response *core.DetailedResponse, err error) { - return vpc.CreateShareMountTargetWithContext(context.Background(), createShareMountTargetOptions) +// 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) } -// CreateShareMountTargetWithContext is an alternate form of the CreateShareMountTarget method which supports a Context parameter -func (vpc *VpcV1) CreateShareMountTargetWithContext(ctx context.Context, createShareMountTargetOptions *CreateShareMountTargetOptions) (result *ShareMountTarget, response *core.DetailedResponse, err error) { - err = core.ValidateNotNil(createShareMountTargetOptions, "createShareMountTargetOptions cannot be nil") +// 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(createShareMountTargetOptions, "createShareMountTargetOptions") + err = core.ValidateStruct(deleteBackupPolicyPlanOptions, "deleteBackupPolicyPlanOptions") if err != nil { return } pathParamsMap := map[string]string{ - "share_id": *createShareMountTargetOptions.ShareID, + "backup_policy_id": *deleteBackupPolicyPlanOptions.BackupPolicyID, + "id": *deleteBackupPolicyPlanOptions.ID, } - builder := core.NewRequestBuilder(core.POST) + builder := core.NewRequestBuilder(core.DELETE) builder = builder.WithContext(ctx) builder.EnableGzipCompression = vpc.GetEnableGzipCompression() - _, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/shares/{share_id}/mount_targets`, pathParamsMap) + _, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/backup_policies/{backup_policy_id}/plans/{id}`, pathParamsMap) if err != nil { return } - for headerName, headerValue := range createShareMountTargetOptions.Headers { + for headerName, headerValue := range deleteBackupPolicyPlanOptions.Headers { builder.AddHeader(headerName, headerValue) } - sdkHeaders := common.GetSdkHeaders("vpc", "V1", "CreateShareMountTarget") + sdkHeaders := common.GetSdkHeaders("vpc", "V1", "DeleteBackupPolicyPlan") for headerName, headerValue := range sdkHeaders { builder.AddHeader(headerName, headerValue) } builder.AddHeader("Accept", "application/json") - builder.AddHeader("Content-Type", "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)) - _, err = builder.SetBodyContentJSON(createShareMountTargetOptions.ShareMountTargetPrototype) - if err != nil { - return - } - request, err := builder.Build() if err != nil { return @@ -16037,7 +16031,7 @@ func (vpc *VpcV1) CreateShareMountTargetWithContext(ctx context.Context, createS return } if rawResponse != nil { - err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalShareMountTarget) + err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalBackupPolicyPlan) if err != nil { return } @@ -16047,44 +16041,41 @@ func (vpc *VpcV1) CreateShareMountTargetWithContext(ctx context.Context, createS return } -// DeleteShareMountTarget : Delete a share mount target -// This request deletes a share mount target. This operation cannot be reversed. -// -// If the request is accepted, the share mount target `lifecycle_state` will be set to -// `deleting`. Once deletion processing completes, it will no longer be retrievable. -func (vpc *VpcV1) DeleteShareMountTarget(deleteShareMountTargetOptions *DeleteShareMountTargetOptions) (result *ShareMountTarget, response *core.DetailedResponse, err error) { - return vpc.DeleteShareMountTargetWithContext(context.Background(), deleteShareMountTargetOptions) +// 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) } -// DeleteShareMountTargetWithContext is an alternate form of the DeleteShareMountTarget method which supports a Context parameter -func (vpc *VpcV1) DeleteShareMountTargetWithContext(ctx context.Context, deleteShareMountTargetOptions *DeleteShareMountTargetOptions) (result *ShareMountTarget, response *core.DetailedResponse, err error) { - err = core.ValidateNotNil(deleteShareMountTargetOptions, "deleteShareMountTargetOptions cannot be nil") +// 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(deleteShareMountTargetOptions, "deleteShareMountTargetOptions") + err = core.ValidateStruct(getBackupPolicyPlanOptions, "getBackupPolicyPlanOptions") if err != nil { return } pathParamsMap := map[string]string{ - "share_id": *deleteShareMountTargetOptions.ShareID, - "id": *deleteShareMountTargetOptions.ID, + "backup_policy_id": *getBackupPolicyPlanOptions.BackupPolicyID, + "id": *getBackupPolicyPlanOptions.ID, } - builder := core.NewRequestBuilder(core.DELETE) + builder := core.NewRequestBuilder(core.GET) builder = builder.WithContext(ctx) builder.EnableGzipCompression = vpc.GetEnableGzipCompression() - _, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/shares/{share_id}/mount_targets/{id}`, pathParamsMap) + _, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/backup_policies/{backup_policy_id}/plans/{id}`, pathParamsMap) if err != nil { return } - for headerName, headerValue := range deleteShareMountTargetOptions.Headers { + for headerName, headerValue := range getBackupPolicyPlanOptions.Headers { builder.AddHeader(headerName, headerValue) } - sdkHeaders := common.GetSdkHeaders("vpc", "V1", "DeleteShareMountTarget") + sdkHeaders := common.GetSdkHeaders("vpc", "V1", "GetBackupPolicyPlan") for headerName, headerValue := range sdkHeaders { builder.AddHeader(headerName, headerValue) } @@ -16104,7 +16095,7 @@ func (vpc *VpcV1) DeleteShareMountTargetWithContext(ctx context.Context, deleteS return } if rawResponse != nil { - err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalShareMountTarget) + err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalBackupPolicyPlan) if err != nil { return } @@ -16114,49 +16105,59 @@ func (vpc *VpcV1) DeleteShareMountTargetWithContext(ctx context.Context, deleteS return } -// GetShareMountTarget : Retrieve a share mount target -// This request retrieves a single share mount target specified by the identifier in the URL. -func (vpc *VpcV1) GetShareMountTarget(getShareMountTargetOptions *GetShareMountTargetOptions) (result *ShareMountTarget, response *core.DetailedResponse, err error) { - return vpc.GetShareMountTargetWithContext(context.Background(), getShareMountTargetOptions) +// 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) } -// GetShareMountTargetWithContext is an alternate form of the GetShareMountTarget method which supports a Context parameter -func (vpc *VpcV1) GetShareMountTargetWithContext(ctx context.Context, getShareMountTargetOptions *GetShareMountTargetOptions) (result *ShareMountTarget, response *core.DetailedResponse, err error) { - err = core.ValidateNotNil(getShareMountTargetOptions, "getShareMountTargetOptions cannot be nil") +// 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(getShareMountTargetOptions, "getShareMountTargetOptions") + err = core.ValidateStruct(updateBackupPolicyPlanOptions, "updateBackupPolicyPlanOptions") if err != nil { return } pathParamsMap := map[string]string{ - "share_id": *getShareMountTargetOptions.ShareID, - "id": *getShareMountTargetOptions.ID, + "backup_policy_id": *updateBackupPolicyPlanOptions.BackupPolicyID, + "id": *updateBackupPolicyPlanOptions.ID, } - builder := core.NewRequestBuilder(core.GET) + builder := core.NewRequestBuilder(core.PATCH) builder = builder.WithContext(ctx) builder.EnableGzipCompression = vpc.GetEnableGzipCompression() - _, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/shares/{share_id}/mount_targets/{id}`, pathParamsMap) + _, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/backup_policies/{backup_policy_id}/plans/{id}`, pathParamsMap) if err != nil { return } - for headerName, headerValue := range getShareMountTargetOptions.Headers { + for headerName, headerValue := range updateBackupPolicyPlanOptions.Headers { builder.AddHeader(headerName, headerValue) } - sdkHeaders := common.GetSdkHeaders("vpc", "V1", "GetShareMountTarget") + 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 @@ -16168,7 +16169,7 @@ func (vpc *VpcV1) GetShareMountTargetWithContext(ctx context.Context, getShareMo return } if rawResponse != nil { - err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalShareMountTarget) + err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalBackupPolicyPlan) if err != nil { return } @@ -16178,57 +16179,54 @@ func (vpc *VpcV1) GetShareMountTargetWithContext(ctx context.Context, getShareMo return } -// UpdateShareMountTarget : Update a share mount target -// This request updates a share mount target with the information provided in a share mount target patch object. The -// share mount target patch object is structured in the same way as a retrieved share mount target and needs to contain -// only the information to be updated. -func (vpc *VpcV1) UpdateShareMountTarget(updateShareMountTargetOptions *UpdateShareMountTargetOptions) (result *ShareMountTarget, response *core.DetailedResponse, err error) { - return vpc.UpdateShareMountTargetWithContext(context.Background(), updateShareMountTargetOptions) +// 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 BackupPolicyIntf, response *core.DetailedResponse, err error) { + return vpc.DeleteBackupPolicyWithContext(context.Background(), deleteBackupPolicyOptions) } -// UpdateShareMountTargetWithContext is an alternate form of the UpdateShareMountTarget method which supports a Context parameter -func (vpc *VpcV1) UpdateShareMountTargetWithContext(ctx context.Context, updateShareMountTargetOptions *UpdateShareMountTargetOptions) (result *ShareMountTarget, response *core.DetailedResponse, err error) { - err = core.ValidateNotNil(updateShareMountTargetOptions, "updateShareMountTargetOptions cannot be nil") +// DeleteBackupPolicyWithContext is an alternate form of the DeleteBackupPolicy method which supports a Context parameter +func (vpc *VpcV1) DeleteBackupPolicyWithContext(ctx context.Context, deleteBackupPolicyOptions *DeleteBackupPolicyOptions) (result BackupPolicyIntf, response *core.DetailedResponse, err error) { + err = core.ValidateNotNil(deleteBackupPolicyOptions, "deleteBackupPolicyOptions cannot be nil") if err != nil { return } - err = core.ValidateStruct(updateShareMountTargetOptions, "updateShareMountTargetOptions") + err = core.ValidateStruct(deleteBackupPolicyOptions, "deleteBackupPolicyOptions") if err != nil { return } pathParamsMap := map[string]string{ - "share_id": *updateShareMountTargetOptions.ShareID, - "id": *updateShareMountTargetOptions.ID, + "id": *deleteBackupPolicyOptions.ID, } - builder := core.NewRequestBuilder(core.PATCH) + builder := core.NewRequestBuilder(core.DELETE) builder = builder.WithContext(ctx) builder.EnableGzipCompression = vpc.GetEnableGzipCompression() - _, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/shares/{share_id}/mount_targets/{id}`, pathParamsMap) + _, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/backup_policies/{id}`, pathParamsMap) if err != nil { return } - for headerName, headerValue := range updateShareMountTargetOptions.Headers { + for headerName, headerValue := range deleteBackupPolicyOptions.Headers { builder.AddHeader(headerName, headerValue) } - sdkHeaders := common.GetSdkHeaders("vpc", "V1", "UpdateShareMountTarget") + sdkHeaders := common.GetSdkHeaders("vpc", "V1", "DeleteBackupPolicy") for headerName, headerValue := range sdkHeaders { builder.AddHeader(headerName, headerValue) } builder.AddHeader("Accept", "application/json") - builder.AddHeader("Content-Type", "application/merge-patch+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)) - _, err = builder.SetBodyContentJSON(updateShareMountTargetOptions.ShareMountTargetPatch) - if err != nil { - return - } - request, err := builder.Build() if err != nil { return @@ -16240,7 +16238,7 @@ func (vpc *VpcV1) UpdateShareMountTargetWithContext(ctx context.Context, updateS return } if rawResponse != nil { - err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalShareMountTarget) + err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalBackupPolicy) if err != nil { return } @@ -16250,47 +16248,44 @@ func (vpc *VpcV1) UpdateShareMountTargetWithContext(ctx context.Context, updateS return } -// DeleteShareSource : Split the source file share from a replica share -// This request removes the replication relationship between a source share and the replica share specified by the -// identifier in the URL. The replication relationship cannot be removed if a source share or the replica share has a -// `lifecycle_state` of `updating`, or has a replication operation in progress. -// -// This operation cannot be reversed. -func (vpc *VpcV1) DeleteShareSource(deleteShareSourceOptions *DeleteShareSourceOptions) (response *core.DetailedResponse, err error) { - return vpc.DeleteShareSourceWithContext(context.Background(), deleteShareSourceOptions) +// 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 BackupPolicyIntf, response *core.DetailedResponse, err error) { + return vpc.GetBackupPolicyWithContext(context.Background(), getBackupPolicyOptions) } -// DeleteShareSourceWithContext is an alternate form of the DeleteShareSource method which supports a Context parameter -func (vpc *VpcV1) DeleteShareSourceWithContext(ctx context.Context, deleteShareSourceOptions *DeleteShareSourceOptions) (response *core.DetailedResponse, err error) { - err = core.ValidateNotNil(deleteShareSourceOptions, "deleteShareSourceOptions cannot be nil") +// GetBackupPolicyWithContext is an alternate form of the GetBackupPolicy method which supports a Context parameter +func (vpc *VpcV1) GetBackupPolicyWithContext(ctx context.Context, getBackupPolicyOptions *GetBackupPolicyOptions) (result BackupPolicyIntf, response *core.DetailedResponse, err error) { + err = core.ValidateNotNil(getBackupPolicyOptions, "getBackupPolicyOptions cannot be nil") if err != nil { return } - err = core.ValidateStruct(deleteShareSourceOptions, "deleteShareSourceOptions") + err = core.ValidateStruct(getBackupPolicyOptions, "getBackupPolicyOptions") if err != nil { return } pathParamsMap := map[string]string{ - "share_id": *deleteShareSourceOptions.ShareID, + "id": *getBackupPolicyOptions.ID, } - builder := core.NewRequestBuilder(core.DELETE) + builder := core.NewRequestBuilder(core.GET) builder = builder.WithContext(ctx) builder.EnableGzipCompression = vpc.GetEnableGzipCompression() - _, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/shares/{share_id}/source`, pathParamsMap) + _, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/backup_policies/{id}`, pathParamsMap) if err != nil { return } - for headerName, headerValue := range deleteShareSourceOptions.Headers { + for headerName, headerValue := range getBackupPolicyOptions.Headers { builder.AddHeader(headerName, headerValue) } - sdkHeaders := common.GetSdkHeaders("vpc", "V1", "DeleteShareSource") + 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)) @@ -16300,54 +16295,74 @@ func (vpc *VpcV1) DeleteShareSourceWithContext(ctx context.Context, deleteShareS return } - response, err = vpc.Service.Request(request, nil) + 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 } -// GetShareSource : Retrieve the source file share for a replica file share -// This request retrieves the source file share associated with the replica file share specified by the identifier in -// the URL. -func (vpc *VpcV1) GetShareSource(getShareSourceOptions *GetShareSourceOptions) (result *ShareReference, response *core.DetailedResponse, err error) { - return vpc.GetShareSourceWithContext(context.Background(), getShareSourceOptions) +// 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 BackupPolicyIntf, response *core.DetailedResponse, err error) { + return vpc.UpdateBackupPolicyWithContext(context.Background(), updateBackupPolicyOptions) } -// GetShareSourceWithContext is an alternate form of the GetShareSource method which supports a Context parameter -func (vpc *VpcV1) GetShareSourceWithContext(ctx context.Context, getShareSourceOptions *GetShareSourceOptions) (result *ShareReference, response *core.DetailedResponse, err error) { - err = core.ValidateNotNil(getShareSourceOptions, "getShareSourceOptions cannot be nil") +// UpdateBackupPolicyWithContext is an alternate form of the UpdateBackupPolicy method which supports a Context parameter +func (vpc *VpcV1) UpdateBackupPolicyWithContext(ctx context.Context, updateBackupPolicyOptions *UpdateBackupPolicyOptions) (result BackupPolicyIntf, response *core.DetailedResponse, err error) { + err = core.ValidateNotNil(updateBackupPolicyOptions, "updateBackupPolicyOptions cannot be nil") if err != nil { return } - err = core.ValidateStruct(getShareSourceOptions, "getShareSourceOptions") + err = core.ValidateStruct(updateBackupPolicyOptions, "updateBackupPolicyOptions") if err != nil { return } pathParamsMap := map[string]string{ - "share_id": *getShareSourceOptions.ShareID, + "id": *updateBackupPolicyOptions.ID, } - builder := core.NewRequestBuilder(core.GET) + builder := core.NewRequestBuilder(core.PATCH) builder = builder.WithContext(ctx) builder.EnableGzipCompression = vpc.GetEnableGzipCompression() - _, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/shares/{share_id}/source`, pathParamsMap) + _, err = builder.ResolveRequestURL(vpc.Service.Options.URL, `/backup_policies/{id}`, pathParamsMap) if err != nil { return } - for headerName, headerValue := range getShareSourceOptions.Headers { + for headerName, headerValue := range updateBackupPolicyOptions.Headers { builder.AddHeader(headerName, headerValue) } - sdkHeaders := common.GetSdkHeaders("vpc", "V1", "GetShareSource") + 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 @@ -16359,7 +16374,7 @@ func (vpc *VpcV1) GetShareSourceWithContext(ctx context.Context, getShareSourceO return } if rawResponse != nil { - err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalShareReference) + err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalBackupPolicy) if err != nil { return } @@ -23549,7 +23564,8 @@ func (vpc *VpcV1) UpdateLoadBalancerListenerWithContext(ctx context.Context, upd } // ListLoadBalancerListenerPolicies : List all policies for a load balancer listener -// This request lists all policies for a load balancer listener. +// This request lists all policies for a load balancer listener. A policy consists of rules to match against each +// incoming request, and an action to apply to the request if a rule matches. func (vpc *VpcV1) ListLoadBalancerListenerPolicies(listLoadBalancerListenerPoliciesOptions *ListLoadBalancerListenerPoliciesOptions) (result *LoadBalancerListenerPolicyCollection, response *core.DetailedResponse, err error) { return vpc.ListLoadBalancerListenerPoliciesWithContext(context.Background(), listLoadBalancerListenerPoliciesOptions) } @@ -23613,7 +23629,9 @@ func (vpc *VpcV1) ListLoadBalancerListenerPoliciesWithContext(ctx context.Contex } // CreateLoadBalancerListenerPolicy : Create a policy for a load balancer listener -// Creates a new policy for a load balancer listener. +// This request creates a new policy from a load balancer listener policy object. The prototype object is structured in +// the same way as a retrieved policy, and contains the information necessary to create the new policy. For this request +// to succeed, the listener must have a `protocol` of `http` or `https`. func (vpc *VpcV1) CreateLoadBalancerListenerPolicy(createLoadBalancerListenerPolicyOptions *CreateLoadBalancerListenerPolicyOptions) (result *LoadBalancerListenerPolicy, response *core.DetailedResponse, err error) { return vpc.CreateLoadBalancerListenerPolicyWithContext(context.Background(), createLoadBalancerListenerPolicyOptions) } @@ -23817,7 +23835,8 @@ func (vpc *VpcV1) GetLoadBalancerListenerPolicyWithContext(ctx context.Context, } // UpdateLoadBalancerListenerPolicy : Update a load balancer listener policy -// Updates a policy from a policy patch. +// This request updates a load balancer listener policy with the information in a provided policy patch. The policy +// patch object is structured in the same way as a retrieved policy and contains only the information to be updated. func (vpc *VpcV1) UpdateLoadBalancerListenerPolicy(updateLoadBalancerListenerPolicyOptions *UpdateLoadBalancerListenerPolicyOptions) (result *LoadBalancerListenerPolicy, response *core.DetailedResponse, err error) { return vpc.UpdateLoadBalancerListenerPolicyWithContext(context.Background(), updateLoadBalancerListenerPolicyOptions) } @@ -27482,17 +27501,80 @@ func UnmarshalBackupPolicyPlanClonePolicyPrototype(m map[string]json.RawMessage, // BackupPolicyPlanCollection : BackupPolicyPlanCollection struct type BackupPolicyPlanCollection struct { + // A link to the first page of resources. + First *BackupPolicyPlanCollectionFirst `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 *BackupPolicyPlanCollectionNext `json:"next,omitempty"` + // Collection of backup policy plans. Plans []BackupPolicyPlan `json:"plans" validate:"required"` + + // The total number of resources across all pages. + TotalCount *int64 `json:"total_count" 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, "first", &obj.First, UnmarshalBackupPolicyPlanCollectionFirst) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "limit", &obj.Limit) + if err != nil { + return + } + err = core.UnmarshalModel(m, "next", &obj.Next, UnmarshalBackupPolicyPlanCollectionNext) + if err != nil { + return + } err = core.UnmarshalModel(m, "plans", &obj.Plans, UnmarshalBackupPolicyPlan) 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 +} + +// BackupPolicyPlanCollectionFirst : A link to the first page of resources. +type BackupPolicyPlanCollectionFirst struct { + // The URL for a page of resources. + Href *string `json:"href" validate:"required"` +} + +// UnmarshalBackupPolicyPlanCollectionFirst unmarshals an instance of BackupPolicyPlanCollectionFirst from the specified map of raw messages. +func UnmarshalBackupPolicyPlanCollectionFirst(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(BackupPolicyPlanCollectionFirst) + err = core.UnmarshalPrimitive(m, "href", &obj.Href) + if err != nil { + return + } + reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) + return +} + +// BackupPolicyPlanCollectionNext : A link to the next page of resources. This property is present for all pages except the last page. +type BackupPolicyPlanCollectionNext struct { + // The URL for a page of resources. + Href *string `json:"href" validate:"required"` +} + +// UnmarshalBackupPolicyPlanCollectionNext unmarshals an instance of BackupPolicyPlanCollectionNext from the specified map of raw messages. +func UnmarshalBackupPolicyPlanCollectionNext(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(BackupPolicyPlanCollectionNext) + err = core.UnmarshalPrimitive(m, "href", &obj.Href) + if err != nil { + return + } reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) return } @@ -33930,7 +34012,8 @@ type CreateLoadBalancerListenerPolicyOptions struct { // unexpected property value was encountered. Action *string `json:"action" validate:"required"` - // Priority of the policy. Lower value indicates higher priority. + // Priority of the policy. The priority is unique across all policies for this load balancer listener. Lower value + // indicates higher priority. Priority *int64 `json:"priority" validate:"required"` // The name for this policy. The name must not be used by another policy for the load balancer listener. If @@ -33943,7 +34026,7 @@ type CreateLoadBalancerListenerPolicyOptions struct { // - If `action` is `forward`, specify a `LoadBalancerPoolIdentity`. // - If `action` is `redirect`, specify a `LoadBalancerListenerPolicyRedirectURLPrototype`. // - If `action` is `https_redirect`, specify a - // `LoadBalancerListenerPolicyHTTPSRedirectPrototype`. + // `LoadBalancerListenerPolicyHTTPSRedirectPrototype`. Target LoadBalancerListenerPolicyTargetPrototypeIntf `json:"target,omitempty"` // Allows users to set headers on API requests @@ -34389,7 +34472,9 @@ type CreateLoadBalancerPoolOptions struct { // Supported by load balancers in the `application` family (otherwise always `disabled`). ProxyProtocol *string `json:"proxy_protocol,omitempty"` - // The session persistence of this pool. + // The session persistence of this pool. If unspecified, session persistence will be + // disabled, and traffic will be distributed across backend server members of the + // pool. SessionPersistence *LoadBalancerPoolSessionPersistencePrototype `json:"session_persistence,omitempty"` // Allows users to set headers on API requests @@ -42334,13 +42419,14 @@ type FlowLogCollector struct { StorageBucket *LegacyCloudObjectStorageBucketReference `json:"storage_bucket" validate:"required"` // The target this collector is collecting flow logs for. + // // - If the target is an instance network attachment, flow logs will be collected // for that instance network attachment. // - If the target is an instance network interface, flow logs will be collected // for that instance network interface. // - If the target is a virtual network interface, flow logs will be collected for the - // the virtual network interface's `target` resource if the resource is: - // - an instance network attachment + // virtual network interface's `target` resource if the resource is an instance network + // attachment, unless the target resource is itself the target of a flow log collector. // - If the target is a virtual server instance, flow logs will be collected // for all network attachments or network interfaces on that instance. // - If the target is a subnet, flow logs will be collected @@ -42348,6 +42434,7 @@ type FlowLogCollector struct { // attached to that subnet. // - If the target is a VPC, flow logs will be collected for all instance network // interfaces and virtual network interfaces attached to all subnets within that VPC. + // // If the target is an instance, subnet, or VPC, flow logs will not be collected // for any instance network attachments or instance network interfaces within the target // that are themselves the target of a more specific flow log collector. @@ -42552,23 +42639,24 @@ func (flowLogCollectorPatch *FlowLogCollectorPatch) AsPatch() (_patch map[string } // FlowLogCollectorTarget : The target this collector is collecting flow logs for. +// // - If the target is an instance network attachment, flow logs will be collected // for that instance network attachment. // - If the target is an instance network interface, flow logs will be collected // for that instance network interface. // - If the target is a virtual network interface, flow logs will be collected for the -// the virtual network interface's `target` resource if the resource is: -// - an instance network attachment +// virtual network interface's `target` resource if the resource is an instance network +// attachment, unless the target resource is itself the target of a flow log collector. // - If the target is a virtual server instance, flow logs will be collected // for all network attachments or network interfaces on that instance. // - If the target is a subnet, flow logs will be collected // for all instance network interfaces and virtual network interfaces // attached to that subnet. // - If the target is a VPC, flow logs will be collected for all instance network -// interfaces and virtual network interfaces attached to all subnets within that VPC. If the target is an instance, +// interfaces and virtual network interfaces attached to all subnets within that VPC. // -// subnet, or VPC, flow logs will not be collected for any instance network attachments or instance network interfaces -// within the target that are themselves the target of a more specific flow log collector. +// If the target is an instance, subnet, or VPC, flow logs will not be collected for any instance network attachments or +// instance network interfaces within the target that are themselves the target of a more specific flow log collector. // Models which "extend" this model: // - FlowLogCollectorTargetNetworkInterfaceReferenceTargetContext // - FlowLogCollectorTargetInstanceReference @@ -48794,6 +48882,16 @@ type InstanceGroup struct { // The template used to create new instances for this group. InstanceTemplate *InstanceTemplateReference `json:"instance_template" validate:"required"` + // The reasons for the current `lifecycle_state` (if any). + // + // The enumerated reason code values for this property will expand in the future. When processing this property, check + // for and log unknown values. Optionally halt processing and surface the error, or bypass the resource on which the + // unexpected reason code was encountered. + LifecycleReasons []InstanceGroupLifecycleReason `json:"lifecycle_reasons" validate:"required"` + + // The lifecycle state of the instance group. + LifecycleState *string `json:"lifecycle_state" validate:"required"` + // If present, the load balancer pool this instance group manages. A pool member will // be created for each instance created by this group. LoadBalancerPool *LoadBalancerPoolReference `json:"load_balancer_pool,omitempty"` @@ -48827,6 +48925,18 @@ type InstanceGroup struct { VPC *VPCReference `json:"vpc" validate:"required"` } +// Constants associated with the InstanceGroup.LifecycleState property. +// The lifecycle state of the instance group. +const ( + InstanceGroupLifecycleStateDeletingConst = "deleting" + InstanceGroupLifecycleStateFailedConst = "failed" + InstanceGroupLifecycleStatePendingConst = "pending" + InstanceGroupLifecycleStateStableConst = "stable" + InstanceGroupLifecycleStateSuspendedConst = "suspended" + InstanceGroupLifecycleStateUpdatingConst = "updating" + InstanceGroupLifecycleStateWaitingConst = "waiting" +) + // Constants associated with the InstanceGroup.Status property. // The status of the instance group // - `deleting`: Group is being deleted @@ -48868,6 +48978,14 @@ func UnmarshalInstanceGroup(m map[string]json.RawMessage, result interface{}) (e if err != nil { return } + err = core.UnmarshalModel(m, "lifecycle_reasons", &obj.LifecycleReasons, UnmarshalInstanceGroupLifecycleReason) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "lifecycle_state", &obj.LifecycleState) + if err != nil { + return + } err = core.UnmarshalModel(m, "load_balancer_pool", &obj.LoadBalancerPool, UnmarshalLoadBalancerPoolReference) if err != nil { return @@ -49000,6 +49118,43 @@ func UnmarshalInstanceGroupCollectionNext(m map[string]json.RawMessage, result i return } +// InstanceGroupLifecycleReason : InstanceGroupLifecycleReason struct +type InstanceGroupLifecycleReason struct { + // A snake case string succinctly identifying the reason for this lifecycle state. + Code *string `json:"code" validate:"required"` + + // An explanation of the reason for this lifecycle state. + Message *string `json:"message" validate:"required"` + + // Link to documentation about the reason for this lifecycle state. + MoreInfo *string `json:"more_info,omitempty"` +} + +// Constants associated with the InstanceGroupLifecycleReason.Code property. +// A snake case string succinctly identifying the reason for this lifecycle state. +const ( + InstanceGroupLifecycleReasonCodeResourceSuspendedByProviderConst = "resource_suspended_by_provider" +) + +// UnmarshalInstanceGroupLifecycleReason unmarshals an instance of InstanceGroupLifecycleReason from the specified map of raw messages. +func UnmarshalInstanceGroupLifecycleReason(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(InstanceGroupLifecycleReason) + err = core.UnmarshalPrimitive(m, "code", &obj.Code) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "message", &obj.Message) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "more_info", &obj.MoreInfo) + if err != nil { + return + } + reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) + return +} + // InstanceGroupManager : InstanceGroupManager struct // Models which "extend" this model: // - InstanceGroupManagerAutoScale @@ -53448,11 +53603,9 @@ func UnmarshalInstanceReservationAffinity(m map[string]json.RawMessage, result i // InstanceReservationAffinityPatch : InstanceReservationAffinityPatch struct type InstanceReservationAffinityPatch struct { - // The reservation affinity policy for this virtual server instance. - // - // The enumerated values for this property are expected to expand in the future. When processing this property, check - // for and log unknown values. Optionally halt processing and surface the error, or bypass the resource on which the - // unexpected property value was encountered. + // The reservation affinity policy to use for this virtual server instance: + // - `disabled`: Reservations will not be used + // - `manual`: Reservations in `pool` are available for use. Policy *string `json:"policy,omitempty"` // The pool of reservations available for use by this virtual server instance, replacing the existing pool of @@ -53467,11 +53620,9 @@ type InstanceReservationAffinityPatch struct { } // Constants associated with the InstanceReservationAffinityPatch.Policy property. -// The reservation affinity policy for this virtual server instance. -// -// The enumerated values for this property are expected to expand in the future. When processing this property, check -// for and log unknown values. Optionally halt processing and surface the error, or bypass the resource on which the -// unexpected property value was encountered. +// The reservation affinity policy to use for this virtual server instance: +// - `disabled`: Reservations will not be used +// - `manual`: Reservations in `pool` are available for use. const ( InstanceReservationAffinityPatchPolicyDisabledConst = "disabled" InstanceReservationAffinityPatchPolicyManualConst = "manual" @@ -58393,6 +58544,9 @@ type ListVolumesOptions struct { // Filters the collection to resources with a `zone.name` property matching the exact specified name. ZoneName *string `json:"zone.name,omitempty"` + // Filters the collection to resources with an item in the `tags` property matching the exact specified tag. + Tag *string `json:"tag,omitempty"` + // Allows users to set headers on API requests Headers map[string]string } @@ -58465,6 +58619,12 @@ func (_options *ListVolumesOptions) SetZoneName(zoneName string) *ListVolumesOpt return _options } +// SetTag : Allow user to set Tag +func (_options *ListVolumesOptions) SetTag(tag string) *ListVolumesOptions { + _options.Tag = core.StringPtr(tag) + return _options +} + // SetHeaders : Allow user to set Headers func (options *ListVolumesOptions) SetHeaders(param map[string]string) *ListVolumesOptions { options.Headers = param @@ -60221,7 +60381,8 @@ type LoadBalancerListenerPolicy struct { // listener. Name *string `json:"name" validate:"required"` - // Priority of the policy. Lower value indicates higher priority. + // Priority of the policy. The priority is unique across all policies for this load balancer listener. Lower value + // indicates higher priority. Priority *int64 `json:"priority" validate:"required"` // The provisioning status of this policy @@ -60332,13 +60493,14 @@ type LoadBalancerListenerPolicyPatch struct { // The name for this policy. The name must not be used by another policy for the load balancer listener. Name *string `json:"name,omitempty"` - // Priority of the policy. Lower value indicates higher priority. + // Priority of the policy. The priority is unique across all policies for this load balancer listener. Lower value + // indicates higher priority. Priority *int64 `json:"priority,omitempty"` // - If `action` is `forward`, specify a `LoadBalancerPoolIdentity`. // - If `action` is `redirect`, specify a `LoadBalancerListenerPolicyRedirectURLPatch`. // - If `action` is `https_redirect`, specify a - // `LoadBalancerListenerPolicyHTTPSRedirectPatch`. + // `LoadBalancerListenerPolicyHTTPSRedirectPatch`. Target LoadBalancerListenerPolicyTargetPatchIntf `json:"target,omitempty"` } @@ -60384,7 +60546,8 @@ type LoadBalancerListenerPolicyPrototype struct { // unspecified, the name will be a hyphenated list of randomly-selected words. Name *string `json:"name,omitempty"` - // Priority of the policy. Lower value indicates higher priority. + // Priority of the policy. The priority is unique across all policies for this load balancer listener. Lower value + // indicates higher priority. Priority *int64 `json:"priority" validate:"required"` // The rule prototype objects for this policy. @@ -60393,7 +60556,7 @@ type LoadBalancerListenerPolicyPrototype struct { // - If `action` is `forward`, specify a `LoadBalancerPoolIdentity`. // - If `action` is `redirect`, specify a `LoadBalancerListenerPolicyRedirectURLPrototype`. // - If `action` is `https_redirect`, specify a - // `LoadBalancerListenerPolicyHTTPSRedirectPrototype`. + // `LoadBalancerListenerPolicyHTTPSRedirectPrototype`. Target LoadBalancerListenerPolicyTargetPrototypeIntf `json:"target,omitempty"` } @@ -60927,10 +61090,9 @@ func UnmarshalLoadBalancerListenerPolicyTarget(m map[string]json.RawMessage, res } // LoadBalancerListenerPolicyTargetPatch : - If `action` is `forward`, specify a `LoadBalancerPoolIdentity`. -// - If `action` is `redirect`, specify a `LoadBalancerListenerPolicyRedirectURLPatch`. -// - If `action` is `https_redirect`, specify a -// `LoadBalancerListenerPolicyHTTPSRedirectPatch`. -// +// - If `action` is `redirect`, specify a `LoadBalancerListenerPolicyRedirectURLPatch`. +// - If `action` is `https_redirect`, specify a +// `LoadBalancerListenerPolicyHTTPSRedirectPatch`. // Models which "extend" this model: // - LoadBalancerListenerPolicyTargetPatchLoadBalancerPoolIdentity // - LoadBalancerListenerPolicyTargetPatchLoadBalancerListenerPolicyRedirectURLPatch @@ -60995,10 +61157,9 @@ func UnmarshalLoadBalancerListenerPolicyTargetPatch(m map[string]json.RawMessage } // LoadBalancerListenerPolicyTargetPrototype : - If `action` is `forward`, specify a `LoadBalancerPoolIdentity`. -// - If `action` is `redirect`, specify a `LoadBalancerListenerPolicyRedirectURLPrototype`. -// - If `action` is `https_redirect`, specify a -// `LoadBalancerListenerPolicyHTTPSRedirectPrototype`. -// +// - If `action` is `redirect`, specify a `LoadBalancerListenerPolicyRedirectURLPrototype`. +// - If `action` is `https_redirect`, specify a +// `LoadBalancerListenerPolicyHTTPSRedirectPrototype`. // Models which "extend" this model: // - LoadBalancerListenerPolicyTargetPrototypeLoadBalancerPoolIdentity // - LoadBalancerListenerPolicyTargetPrototypeLoadBalancerListenerPolicyRedirectURLPrototype @@ -61472,11 +61633,6 @@ type LoadBalancerPool struct { ProxyProtocol *string `json:"proxy_protocol" validate:"required"` // The session persistence of this pool. - // - // The enumerated values for this property are expected to expand in the future. When - // processing this property, check for and log unknown values. Optionally halt - // processing and surface the error, or bypass the pool on which the unexpected - // property value was encountered. SessionPersistence *LoadBalancerPoolSessionPersistence `json:"session_persistence,omitempty"` } @@ -62424,7 +62580,9 @@ type LoadBalancerPoolPrototype struct { // Supported by load balancers in the `application` family (otherwise always `disabled`). ProxyProtocol *string `json:"proxy_protocol,omitempty"` - // The session persistence of this pool. + // The session persistence of this pool. If unspecified, session persistence will be + // disabled, and traffic will be distributed across backend server members of the + // pool. SessionPersistence *LoadBalancerPoolSessionPersistencePrototype `json:"session_persistence,omitempty"` } @@ -62571,12 +62729,20 @@ type LoadBalancerPoolSessionPersistence struct { // The session persistence type. The `http_cookie` and `app_cookie` types are applicable only to the `http` and `https` // protocols. + // + // The enumerated values for this property are expected to expand in the future. When processing this property, check + // for and log unknown values. Optionally halt processing and surface the error, or bypass the pool on which the + // unexpected property value was encountered. Type *string `json:"type" validate:"required"` } // Constants associated with the LoadBalancerPoolSessionPersistence.Type property. // The session persistence type. The `http_cookie` and `app_cookie` types are applicable only to the `http` and `https` // protocols. +// +// The enumerated values for this property are expected to expand in the future. When processing this property, check +// for and log unknown values. Optionally halt processing and surface the error, or bypass the pool on which the +// unexpected property value was encountered. const ( LoadBalancerPoolSessionPersistenceTypeAppCookieConst = "app_cookie" LoadBalancerPoolSessionPersistenceTypeHTTPCookieConst = "http_cookie" @@ -62745,6 +62911,10 @@ func UnmarshalLoadBalancerPrivateIpsItem(m map[string]json.RawMessage, result in // LoadBalancerProfile : LoadBalancerProfile struct type LoadBalancerProfile struct { // The product family this load balancer profile belongs to. + // + // 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 load balancer profile on which the + // unexpected property value was encountered. Family *string `json:"family" validate:"required"` // The URL for this load balancer profile. @@ -62765,6 +62935,17 @@ type LoadBalancerProfile struct { UDPSupported LoadBalancerProfileUDPSupportedIntf `json:"udp_supported" validate:"required"` } +// Constants associated with the LoadBalancerProfile.Family property. +// The product family this load balancer profile belongs to. +// +// 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 load balancer profile on which the +// unexpected property value was encountered. +const ( + LoadBalancerProfileFamilyApplicationConst = "application" + LoadBalancerProfileFamilyNetworkConst = "network" +) + // UnmarshalLoadBalancerProfile unmarshals an instance of LoadBalancerProfile from the specified map of raw messages. func UnmarshalLoadBalancerProfile(m map[string]json.RawMessage, result interface{}) (err error) { obj := new(LoadBalancerProfile) @@ -63005,6 +63186,10 @@ func UnmarshalLoadBalancerProfileLoggingSupported(m map[string]json.RawMessage, // LoadBalancerProfileReference : LoadBalancerProfileReference struct type LoadBalancerProfileReference struct { // The product family this load balancer profile belongs to. + // + // 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 load balancer profile on which the + // unexpected property value was encountered. Family *string `json:"family" validate:"required"` // The URL for this load balancer profile. @@ -63014,6 +63199,17 @@ type LoadBalancerProfileReference struct { Name *string `json:"name" validate:"required"` } +// Constants associated with the LoadBalancerProfileReference.Family property. +// The product family this load balancer profile belongs to. +// +// 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 load balancer profile on which the +// unexpected property value was encountered. +const ( + LoadBalancerProfileReferenceFamilyApplicationConst = "application" + LoadBalancerProfileReferenceFamilyNetworkConst = "network" +) + // UnmarshalLoadBalancerProfileReference unmarshals an instance of LoadBalancerProfileReference from the specified map of raw messages. func UnmarshalLoadBalancerProfileReference(m map[string]json.RawMessage, result interface{}) (err error) { obj := new(LoadBalancerProfileReference) @@ -70861,7 +71057,7 @@ type Share struct { // The key used to encrypt this file share. // - // This property will be present if `encryption_type` is `user_managed`. + // This property will be present if `encryption` is `user_managed`. EncryptionKey *EncryptionKeyReference `json:"encryption_key,omitempty"` // The URL for this file share. @@ -72044,7 +72240,8 @@ type SharePatch struct { // The maximum input/output operations per second (IOPS) for the file share. The value must be in the range supported // by the share's size. // - // For this property to be changed, the share `lifecycle_state` must be `stable`. + // For this property to be changed, the share `lifecycle_state` must be `stable` and + // `replication_role` must not be `replica`. Iops *int64 `json:"iops,omitempty"` // The name for this share. The name must not be used by another share in the region. @@ -72065,7 +72262,8 @@ type SharePatch struct { // The size of the file share rounded up to the next gigabyte. The value must not be less than the share's current // size, and must not exceed the maximum supported by the share's profile and IOPS. // - // For this property to be changed, the share `lifecycle_state` must be `stable`. + // For this property to be changed, the share `lifecycle_state` must be `stable` and + // `replication_role` must not be `replica`. Size *int64 `json:"size,omitempty"` // Tags for this resource. @@ -73338,7 +73536,7 @@ type SnapshotConsistencyGroup struct { // The member snapshots that are data-consistent with respect to captured time. (may be // [deleted](https://cloud.ibm.com/apidocs/vpc#deleted-resources)). - Snapshots []SnapshotConsistencyGroupSnapshotsItem `json:"snapshots" validate:"required"` + Snapshots []SnapshotReference `json:"snapshots" validate:"required"` } // Constants associated with the SnapshotConsistencyGroup.LifecycleState property. @@ -73406,7 +73604,7 @@ func UnmarshalSnapshotConsistencyGroup(m map[string]json.RawMessage, result inte if err != nil { return } - err = core.UnmarshalModel(m, "snapshots", &obj.Snapshots, UnmarshalSnapshotConsistencyGroupSnapshotsItem) + err = core.UnmarshalModel(m, "snapshots", &obj.Snapshots, UnmarshalSnapshotReference) if err != nil { return } @@ -73560,7 +73758,7 @@ type SnapshotConsistencyGroupPrototype struct { // The data-consistent member snapshots to create. All snapshots must specify a // `source_volume` attached to the same virtual server instance. - Snapshots []SnapshotConsistencyGroupPrototypeSnapshotsItem `json:"snapshots,omitempty"` + Snapshots []SnapshotPrototypeSnapshotConsistencyGroupContext `json:"snapshots,omitempty"` } func (*SnapshotConsistencyGroupPrototype) isaSnapshotConsistencyGroupPrototype() bool { @@ -73586,89 +73784,7 @@ func UnmarshalSnapshotConsistencyGroupPrototype(m map[string]json.RawMessage, re if err != nil { return } - err = core.UnmarshalModel(m, "snapshots", &obj.Snapshots, UnmarshalSnapshotConsistencyGroupPrototypeSnapshotsItem) - if err != nil { - return - } - reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) - return -} - -// SnapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshotsSnapshotsItem : SnapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshotsSnapshotsItem struct -type SnapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshotsSnapshotsItem struct { - // The name for this snapshot. The name must not be used by another snapshot in the region. If unspecified, the name - // will be a hyphenated list of randomly-selected words. - Name *string `json:"name,omitempty"` - - // The volume to create this snapshot from. - SourceVolume VolumeIdentityIntf `json:"source_volume" validate:"required"` - - // The [user tags](https://cloud.ibm.com/apidocs/tagging#types-of-tags) associated with this snapshot. - UserTags []string `json:"user_tags,omitempty"` -} - -// NewSnapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshotsSnapshotsItem : Instantiate SnapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshotsSnapshotsItem (Generic Model Constructor) -func (*VpcV1) NewSnapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshotsSnapshotsItem(sourceVolume VolumeIdentityIntf) (_model *SnapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshotsSnapshotsItem, err error) { - _model = &SnapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshotsSnapshotsItem{ - SourceVolume: sourceVolume, - } - err = core.ValidateStruct(_model, "required parameters") - return -} - -// UnmarshalSnapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshotsSnapshotsItem unmarshals an instance of SnapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshotsSnapshotsItem from the specified map of raw messages. -func UnmarshalSnapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshotsSnapshotsItem(m map[string]json.RawMessage, result interface{}) (err error) { - obj := new(SnapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshotsSnapshotsItem) - err = core.UnmarshalPrimitive(m, "name", &obj.Name) - if err != nil { - return - } - err = core.UnmarshalModel(m, "source_volume", &obj.SourceVolume, UnmarshalVolumeIdentity) - if err != nil { - return - } - err = core.UnmarshalPrimitive(m, "user_tags", &obj.UserTags) - if err != nil { - return - } - reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) - return -} - -// SnapshotConsistencyGroupPrototypeSnapshotsItem : SnapshotConsistencyGroupPrototypeSnapshotsItem struct -type SnapshotConsistencyGroupPrototypeSnapshotsItem struct { - // The name for this snapshot. The name must not be used by another snapshot in the region. If unspecified, the name - // will be a hyphenated list of randomly-selected words. - Name *string `json:"name,omitempty"` - - // The volume to create this snapshot from. - SourceVolume VolumeIdentityIntf `json:"source_volume" validate:"required"` - - // The [user tags](https://cloud.ibm.com/apidocs/tagging#types-of-tags) associated with this snapshot. - UserTags []string `json:"user_tags,omitempty"` -} - -// NewSnapshotConsistencyGroupPrototypeSnapshotsItem : Instantiate SnapshotConsistencyGroupPrototypeSnapshotsItem (Generic Model Constructor) -func (*VpcV1) NewSnapshotConsistencyGroupPrototypeSnapshotsItem(sourceVolume VolumeIdentityIntf) (_model *SnapshotConsistencyGroupPrototypeSnapshotsItem, err error) { - _model = &SnapshotConsistencyGroupPrototypeSnapshotsItem{ - SourceVolume: sourceVolume, - } - err = core.ValidateStruct(_model, "required parameters") - return -} - -// UnmarshalSnapshotConsistencyGroupPrototypeSnapshotsItem unmarshals an instance of SnapshotConsistencyGroupPrototypeSnapshotsItem from the specified map of raw messages. -func UnmarshalSnapshotConsistencyGroupPrototypeSnapshotsItem(m map[string]json.RawMessage, result interface{}) (err error) { - obj := new(SnapshotConsistencyGroupPrototypeSnapshotsItem) - err = core.UnmarshalPrimitive(m, "name", &obj.Name) - if err != nil { - return - } - err = core.UnmarshalModel(m, "source_volume", &obj.SourceVolume, UnmarshalVolumeIdentity) - if err != nil { - return - } - err = core.UnmarshalPrimitive(m, "user_tags", &obj.UserTags) + err = core.UnmarshalModel(m, "snapshots", &obj.Snapshots, UnmarshalSnapshotPrototypeSnapshotConsistencyGroupContext) if err != nil { return } @@ -73754,73 +73870,6 @@ func UnmarshalSnapshotConsistencyGroupReferenceDeleted(m map[string]json.RawMess return } -// SnapshotConsistencyGroupSnapshotsItem : SnapshotConsistencyGroupSnapshotsItem struct -type SnapshotConsistencyGroupSnapshotsItem struct { - // The CRN of this snapshot. - CRN *string `json:"crn" validate:"required"` - - // If present, this property indicates the referenced resource has been deleted, and provides - // some supplementary information. - Deleted *SnapshotReferenceDeleted `json:"deleted,omitempty"` - - // The URL for this snapshot. - Href *string `json:"href" validate:"required"` - - // The unique identifier for this snapshot. - ID *string `json:"id" validate:"required"` - - // The name for this snapshot. The name is unique across all snapshots in the region. - Name *string `json:"name" validate:"required"` - - // If present, this property indicates that the resource associated with this reference - // is remote and therefore may not be directly retrievable. - Remote *SnapshotRemote `json:"remote,omitempty"` - - // The resource type. - ResourceType *string `json:"resource_type" validate:"required"` -} - -// Constants associated with the SnapshotConsistencyGroupSnapshotsItem.ResourceType property. -// The resource type. -const ( - SnapshotConsistencyGroupSnapshotsItemResourceTypeSnapshotConst = "snapshot" -) - -// UnmarshalSnapshotConsistencyGroupSnapshotsItem unmarshals an instance of SnapshotConsistencyGroupSnapshotsItem from the specified map of raw messages. -func UnmarshalSnapshotConsistencyGroupSnapshotsItem(m map[string]json.RawMessage, result interface{}) (err error) { - obj := new(SnapshotConsistencyGroupSnapshotsItem) - err = core.UnmarshalPrimitive(m, "crn", &obj.CRN) - if err != nil { - return - } - err = core.UnmarshalModel(m, "deleted", &obj.Deleted, UnmarshalSnapshotReferenceDeleted) - if err != nil { - return - } - err = core.UnmarshalPrimitive(m, "href", &obj.Href) - if err != nil { - return - } - err = core.UnmarshalPrimitive(m, "id", &obj.ID) - if err != nil { - return - } - err = core.UnmarshalPrimitive(m, "name", &obj.Name) - if err != nil { - return - } - err = core.UnmarshalModel(m, "remote", &obj.Remote, UnmarshalSnapshotRemote) - if err != nil { - return - } - err = core.UnmarshalPrimitive(m, "resource_type", &obj.ResourceType) - if err != nil { - return - } - reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) - return -} - // SnapshotCopiesItem : SnapshotCopiesItem struct type SnapshotCopiesItem struct { // The CRN for the copied snapshot. @@ -74046,6 +74095,47 @@ func UnmarshalSnapshotPrototype(m map[string]json.RawMessage, result interface{} return } +// SnapshotPrototypeSnapshotConsistencyGroupContext : SnapshotPrototypeSnapshotConsistencyGroupContext struct +type SnapshotPrototypeSnapshotConsistencyGroupContext struct { + // The name for this snapshot. The name must not be used by another snapshot in the region. If unspecified, the name + // will be a hyphenated list of randomly-selected words. + Name *string `json:"name,omitempty"` + + // The volume to create this snapshot from. + SourceVolume VolumeIdentityIntf `json:"source_volume" validate:"required"` + + // The [user tags](https://cloud.ibm.com/apidocs/tagging#types-of-tags) associated with this snapshot. + UserTags []string `json:"user_tags,omitempty"` +} + +// NewSnapshotPrototypeSnapshotConsistencyGroupContext : Instantiate SnapshotPrototypeSnapshotConsistencyGroupContext (Generic Model Constructor) +func (*VpcV1) NewSnapshotPrototypeSnapshotConsistencyGroupContext(sourceVolume VolumeIdentityIntf) (_model *SnapshotPrototypeSnapshotConsistencyGroupContext, err error) { + _model = &SnapshotPrototypeSnapshotConsistencyGroupContext{ + SourceVolume: sourceVolume, + } + err = core.ValidateStruct(_model, "required parameters") + return +} + +// UnmarshalSnapshotPrototypeSnapshotConsistencyGroupContext unmarshals an instance of SnapshotPrototypeSnapshotConsistencyGroupContext from the specified map of raw messages. +func UnmarshalSnapshotPrototypeSnapshotConsistencyGroupContext(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(SnapshotPrototypeSnapshotConsistencyGroupContext) + err = core.UnmarshalPrimitive(m, "name", &obj.Name) + if err != nil { + return + } + err = core.UnmarshalModel(m, "source_volume", &obj.SourceVolume, UnmarshalVolumeIdentity) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "user_tags", &obj.UserTags) + if err != nil { + return + } + reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) + return +} + // SnapshotReference : SnapshotReference struct type SnapshotReference struct { // The CRN of this snapshot. @@ -78093,6 +78183,22 @@ type VpcdnsResolutionBinding struct { // The endpoint gateways may be remote and therefore may not be directly retrievable. EndpointGateways []EndpointGatewayReferenceRemote `json:"endpoint_gateways" validate:"required"` + // The reasons for the current `health_state` (if any). + // + // The enumerated reason code values for this property will expand in the future. When processing this property, check + // for and log unknown values. Optionally halt processing and surface the error, or bypass the resource on which the + // unexpected reason code was encountered. + HealthReasons []VpcdnsResolutionBindingHealthReason `json:"health_reasons" validate:"required"` + + // The health of this resource. + // - `ok`: No abnormal behavior detected + // - `degraded`: Experiencing compromised performance, capacity, or connectivity + // - `faulted`: Completely unreachable, inoperative, or otherwise entirely incapacitated + // - `inapplicable`: The health state does not apply because of the current lifecycle state. A resource with a + // lifecycle state of `failed` or `deleting` will have a health state of `inapplicable`. A `pending` resource may also + // have this state. + HealthState *string `json:"health_state" validate:"required"` + // The URL for this DNS resolution binding. Href *string `json:"href" validate:"required"` @@ -78114,6 +78220,21 @@ type VpcdnsResolutionBinding struct { VPC *VPCReferenceRemote `json:"vpc" validate:"required"` } +// Constants associated with the VpcdnsResolutionBinding.HealthState property. +// The health of this resource. +// - `ok`: No abnormal behavior detected +// - `degraded`: Experiencing compromised performance, capacity, or connectivity +// - `faulted`: Completely unreachable, inoperative, or otherwise entirely incapacitated +// - `inapplicable`: The health state does not apply because of the current lifecycle state. A resource with a lifecycle +// state of `failed` or `deleting` will have a health state of `inapplicable`. A `pending` resource may also have this +// state. +const ( + VpcdnsResolutionBindingHealthStateDegradedConst = "degraded" + VpcdnsResolutionBindingHealthStateFaultedConst = "faulted" + VpcdnsResolutionBindingHealthStateInapplicableConst = "inapplicable" + VpcdnsResolutionBindingHealthStateOkConst = "ok" +) + // Constants associated with the VpcdnsResolutionBinding.LifecycleState property. // The lifecycle state of the DNS resolution binding. const ( @@ -78143,6 +78264,14 @@ func UnmarshalVpcdnsResolutionBinding(m map[string]json.RawMessage, result inter if err != nil { return } + err = core.UnmarshalModel(m, "health_reasons", &obj.HealthReasons, UnmarshalVpcdnsResolutionBindingHealthReason) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "health_state", &obj.HealthState) + if err != nil { + return + } err = core.UnmarshalPrimitive(m, "href", &obj.Href) if err != nil { return @@ -78229,6 +78358,44 @@ func (resp *VpcdnsResolutionBindingCollection) GetNextStart() (*string, error) { return start, nil } +// VpcdnsResolutionBindingHealthReason : VpcdnsResolutionBindingHealthReason struct +type VpcdnsResolutionBindingHealthReason struct { + // A snake case string succinctly identifying the reason for this health state. + Code *string `json:"code" validate:"required"` + + // An explanation of the reason for this health state. + Message *string `json:"message" validate:"required"` + + // Link to documentation about the reason for this health state. + MoreInfo *string `json:"more_info,omitempty"` +} + +// Constants associated with the VpcdnsResolutionBindingHealthReason.Code property. +// A snake case string succinctly identifying the reason for this health state. +const ( + VpcdnsResolutionBindingHealthReasonCodeDisconnectedFromBoundVPCConst = "disconnected_from_bound_vpc" + VpcdnsResolutionBindingHealthReasonCodeInternalErrorConst = "internal_error" +) + +// UnmarshalVpcdnsResolutionBindingHealthReason unmarshals an instance of VpcdnsResolutionBindingHealthReason from the specified map of raw messages. +func UnmarshalVpcdnsResolutionBindingHealthReason(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(VpcdnsResolutionBindingHealthReason) + err = core.UnmarshalPrimitive(m, "code", &obj.Code) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "message", &obj.Message) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "more_info", &obj.MoreInfo) + if err != nil { + return + } + reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) + return +} + // VpcdnsResolutionBindingPatch : VpcdnsResolutionBindingPatch struct type VpcdnsResolutionBindingPatch struct { // The name for this DNS resolution binding. The name must not be used by another DNS resolution binding for the VPC. @@ -79232,7 +79399,7 @@ func UnmarshalVPNGatewayCollectionNext(m map[string]json.RawMessage, result inte // VPNGatewayConnection : VPNGatewayConnection struct // Models which "extend" this model: -// - VPNGatewayConnectionStaticRouteMode +// - VPNGatewayConnectionRouteMode // - VPNGatewayConnectionPolicyMode type VPNGatewayConnection struct { // If set to false, the VPN gateway connection is shut down. @@ -79355,84 +79522,24 @@ type VPNGatewayConnectionIntf interface { // UnmarshalVPNGatewayConnection unmarshals an instance of VPNGatewayConnection from the specified map of raw messages. func UnmarshalVPNGatewayConnection(m map[string]json.RawMessage, result interface{}) (err error) { - obj := new(VPNGatewayConnection) - err = core.UnmarshalPrimitive(m, "admin_state_up", &obj.AdminStateUp) - if err != nil { - return - } - err = core.UnmarshalPrimitive(m, "authentication_mode", &obj.AuthenticationMode) - if err != nil { - return - } - err = core.UnmarshalPrimitive(m, "created_at", &obj.CreatedAt) - if err != nil { - return - } - err = core.UnmarshalModel(m, "dead_peer_detection", &obj.DeadPeerDetection, UnmarshalVPNGatewayConnectionDpd) - 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.UnmarshalModel(m, "ike_policy", &obj.IkePolicy, UnmarshalIkePolicyReference) - if err != nil { - return - } - err = core.UnmarshalModel(m, "ipsec_policy", &obj.IpsecPolicy, UnmarshalIPsecPolicyReference) - if err != nil { - return - } - err = core.UnmarshalPrimitive(m, "mode", &obj.Mode) - if err != nil { - return - } - err = core.UnmarshalPrimitive(m, "name", &obj.Name) - if err != nil { - return - } - err = core.UnmarshalPrimitive(m, "peer_address", &obj.PeerAddress) - if err != nil { - return - } - err = core.UnmarshalPrimitive(m, "psk", &obj.Psk) - if err != nil { - return - } - err = core.UnmarshalPrimitive(m, "resource_type", &obj.ResourceType) - if err != nil { - return - } - err = core.UnmarshalPrimitive(m, "status", &obj.Status) - if err != nil { - return - } - err = core.UnmarshalModel(m, "status_reasons", &obj.StatusReasons, UnmarshalVPNGatewayConnectionStatusReason) - if err != nil { - return - } - err = core.UnmarshalPrimitive(m, "routing_protocol", &obj.RoutingProtocol) - if err != nil { - return - } - err = core.UnmarshalModel(m, "tunnels", &obj.Tunnels, UnmarshalVPNGatewayConnectionStaticRouteModeTunnel) + // Retrieve discriminator value to determine correct "subclass". + var discValue string + err = core.UnmarshalPrimitive(m, "mode", &discValue) if err != nil { + err = fmt.Errorf("error unmarshalling discriminator property 'mode': %s", err.Error()) return } - err = core.UnmarshalPrimitive(m, "local_cidrs", &obj.LocalCIDRs) - if err != nil { + if discValue == "" { + err = fmt.Errorf("required discriminator property 'mode' not found in JSON object") return } - err = core.UnmarshalPrimitive(m, "peer_cidrs", &obj.PeerCIDRs) - if err != nil { - return + if discValue == "policy" { + err = core.UnmarshalModel(m, "", result, UnmarshalVPNGatewayConnectionPolicyMode) + } else if discValue == "route" { + err = core.UnmarshalModel(m, "", result, UnmarshalVPNGatewayConnectionRouteMode) + } else { + err = fmt.Errorf("unrecognized value for discriminator property 'mode': %s", discValue) } - reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) return } @@ -79720,7 +79827,7 @@ func UnmarshalVPNGatewayConnectionIPsecPolicyPrototype(m map[string]json.RawMess // VPNGatewayConnectionLocalCIDRs : VPNGatewayConnectionLocalCIDRs struct type VPNGatewayConnectionLocalCIDRs struct { // The local CIDRs for this resource. - LocalCIDRs []string `json:"local_cidrs,omitempty"` + LocalCIDRs []string `json:"local_cidrs" validate:"required"` } // UnmarshalVPNGatewayConnectionLocalCIDRs unmarshals an instance of VPNGatewayConnectionLocalCIDRs from the specified map of raw messages. @@ -79821,7 +79928,7 @@ func (vpnGatewayConnectionPatch *VPNGatewayConnectionPatch) AsPatch() (_patch ma // VPNGatewayConnectionPeerCIDRs : VPNGatewayConnectionPeerCIDRs struct type VPNGatewayConnectionPeerCIDRs struct { // The peer CIDRs for this resource. - PeerCIDRs []string `json:"peer_cidrs,omitempty"` + PeerCIDRs []string `json:"peer_cidrs" validate:"required"` } // UnmarshalVPNGatewayConnectionPeerCIDRs unmarshals an instance of VPNGatewayConnectionPeerCIDRs from the specified map of raw messages. @@ -96126,7 +96233,13 @@ func UnmarshalInstanceTemplatePrototypeInstanceTemplateBySourceSnapshot(m map[st return } -// InstanceTemplatePrototypeInstanceTemplateBySourceTemplate : Create an instance template from an existing instance template. +// InstanceTemplatePrototypeInstanceTemplateBySourceTemplate : Create an instance template from an existing source instance template. +// +// The `primary_network_attachment` and `network_attachments` properties may only be specified if +// `primary_network_attachment` is specified in the source template. +// +// The `primary_network_interface` and `network_interfaces` properties may only be specified if +// `primary_network_interface` is specified in the source template. // This model "extends" InstanceTemplatePrototype type InstanceTemplatePrototypeInstanceTemplateBySourceTemplate struct { // The availability policy to use for this virtual server instance. @@ -103047,6 +103160,7 @@ func UnmarshalShareIdentityByID(m map[string]json.RawMessage, result interface{} // ShareMountTargetPrototypeShareMountTargetByAccessControlModeSecurityGroup : The virtual network interface for this share mount target. The virtual network interface must: // +// - be in the same `zone` as the share // - have `allow_ip_spoofing` set to `false` // - have `enable_infrastructure_nat` set to `true` // - not be in the same VPC as an existing mount target for this share @@ -104040,11 +104154,11 @@ type SnapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshots struct // The data-consistent member snapshots to create. All snapshots must specify a // `source_volume` attached to the same virtual server instance. - Snapshots []SnapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshotsSnapshotsItem `json:"snapshots" validate:"required"` + Snapshots []SnapshotPrototypeSnapshotConsistencyGroupContext `json:"snapshots" validate:"required"` } // NewSnapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshots : Instantiate SnapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshots (Generic Model Constructor) -func (*VpcV1) NewSnapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshots(snapshots []SnapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshotsSnapshotsItem) (_model *SnapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshots, err error) { +func (*VpcV1) NewSnapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshots(snapshots []SnapshotPrototypeSnapshotConsistencyGroupContext) (_model *SnapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshots, err error) { _model = &SnapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshots{ Snapshots: snapshots, } @@ -104071,7 +104185,7 @@ func UnmarshalSnapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapsho if err != nil { return } - err = core.UnmarshalModel(m, "snapshots", &obj.Snapshots, UnmarshalSnapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshotsSnapshotsItem) + err = core.UnmarshalModel(m, "snapshots", &obj.Snapshots, UnmarshalSnapshotPrototypeSnapshotConsistencyGroupContext) if err != nil { return } @@ -105817,9 +105931,11 @@ func UnmarshalVPNGatewayConnectionPrototypeVPNGatewayConnectionStaticRouteModePr return } -// VPNGatewayConnectionStaticRouteMode : VPNGatewayConnectionStaticRouteMode struct +// VPNGatewayConnectionRouteMode : VPNGatewayConnectionRouteMode struct +// Models which "extend" this model: +// - VPNGatewayConnectionRouteModeVPNGatewayConnectionStaticRouteMode // This model "extends" VPNGatewayConnection -type VPNGatewayConnectionStaticRouteMode struct { +type VPNGatewayConnectionRouteMode struct { // If set to false, the VPN gateway connection is shut down. AdminStateUp *bool `json:"admin_state_up" validate:"required"` @@ -105885,120 +106001,75 @@ type VPNGatewayConnectionStaticRouteMode struct { StatusReasons []VPNGatewayConnectionStatusReason `json:"status_reasons" validate:"required"` // Routing protocols are disabled for this VPN gateway connection. - RoutingProtocol *string `json:"routing_protocol" validate:"required"` + RoutingProtocol *string `json:"routing_protocol,omitempty"` // The VPN tunnel configuration for this VPN gateway connection (in static route mode). - Tunnels []VPNGatewayConnectionStaticRouteModeTunnel `json:"tunnels" validate:"required"` + Tunnels []VPNGatewayConnectionStaticRouteModeTunnel `json:"tunnels,omitempty"` } -// Constants associated with the VPNGatewayConnectionStaticRouteMode.AuthenticationMode property. +// Constants associated with the VPNGatewayConnectionRouteMode.AuthenticationMode property. // The authentication mode. Only `psk` is currently supported. const ( - VPNGatewayConnectionStaticRouteModeAuthenticationModePskConst = "psk" + VPNGatewayConnectionRouteModeAuthenticationModePskConst = "psk" ) -// Constants associated with the VPNGatewayConnectionStaticRouteMode.Mode property. +// Constants associated with the VPNGatewayConnectionRouteMode.Mode property. // The mode of the VPN gateway. const ( - VPNGatewayConnectionStaticRouteModeModePolicyConst = "policy" - VPNGatewayConnectionStaticRouteModeModeRouteConst = "route" + VPNGatewayConnectionRouteModeModePolicyConst = "policy" + VPNGatewayConnectionRouteModeModeRouteConst = "route" ) -// Constants associated with the VPNGatewayConnectionStaticRouteMode.ResourceType property. +// Constants associated with the VPNGatewayConnectionRouteMode.ResourceType property. // The resource type. const ( - VPNGatewayConnectionStaticRouteModeResourceTypeVPNGatewayConnectionConst = "vpn_gateway_connection" + VPNGatewayConnectionRouteModeResourceTypeVPNGatewayConnectionConst = "vpn_gateway_connection" ) -// Constants associated with the VPNGatewayConnectionStaticRouteMode.Status property. +// Constants associated with the VPNGatewayConnectionRouteMode.Status property. // The status of a VPN gateway connection. const ( - VPNGatewayConnectionStaticRouteModeStatusDownConst = "down" - VPNGatewayConnectionStaticRouteModeStatusUpConst = "up" + VPNGatewayConnectionRouteModeStatusDownConst = "down" + VPNGatewayConnectionRouteModeStatusUpConst = "up" ) -// Constants associated with the VPNGatewayConnectionStaticRouteMode.RoutingProtocol property. +// Constants associated with the VPNGatewayConnectionRouteMode.RoutingProtocol property. // Routing protocols are disabled for this VPN gateway connection. const ( - VPNGatewayConnectionStaticRouteModeRoutingProtocolNoneConst = "none" + VPNGatewayConnectionRouteModeRoutingProtocolNoneConst = "none" ) -func (*VPNGatewayConnectionStaticRouteMode) isaVPNGatewayConnection() bool { +func (*VPNGatewayConnectionRouteMode) isaVPNGatewayConnectionRouteMode() bool { return true } -// UnmarshalVPNGatewayConnectionStaticRouteMode unmarshals an instance of VPNGatewayConnectionStaticRouteMode from the specified map of raw messages. -func UnmarshalVPNGatewayConnectionStaticRouteMode(m map[string]json.RawMessage, result interface{}) (err error) { - obj := new(VPNGatewayConnectionStaticRouteMode) - err = core.UnmarshalPrimitive(m, "admin_state_up", &obj.AdminStateUp) - if err != nil { - return - } - err = core.UnmarshalPrimitive(m, "authentication_mode", &obj.AuthenticationMode) - if err != nil { - return - } - err = core.UnmarshalPrimitive(m, "created_at", &obj.CreatedAt) - if err != nil { - return - } - err = core.UnmarshalModel(m, "dead_peer_detection", &obj.DeadPeerDetection, UnmarshalVPNGatewayConnectionDpd) - 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.UnmarshalModel(m, "ike_policy", &obj.IkePolicy, UnmarshalIkePolicyReference) - if err != nil { - return - } - err = core.UnmarshalModel(m, "ipsec_policy", &obj.IpsecPolicy, UnmarshalIPsecPolicyReference) - if err != nil { - return - } - err = core.UnmarshalPrimitive(m, "mode", &obj.Mode) - if err != nil { - return - } - err = core.UnmarshalPrimitive(m, "name", &obj.Name) - if err != nil { - return - } - err = core.UnmarshalPrimitive(m, "peer_address", &obj.PeerAddress) - if err != nil { - return - } - err = core.UnmarshalPrimitive(m, "psk", &obj.Psk) - if err != nil { - return - } - err = core.UnmarshalPrimitive(m, "resource_type", &obj.ResourceType) - if err != nil { - return - } - err = core.UnmarshalPrimitive(m, "status", &obj.Status) - if err != nil { - return - } - err = core.UnmarshalModel(m, "status_reasons", &obj.StatusReasons, UnmarshalVPNGatewayConnectionStatusReason) +type VPNGatewayConnectionRouteModeIntf interface { + VPNGatewayConnectionIntf + isaVPNGatewayConnectionRouteMode() bool +} + +func (*VPNGatewayConnectionRouteMode) isaVPNGatewayConnection() bool { + return true +} + +// UnmarshalVPNGatewayConnectionRouteMode unmarshals an instance of VPNGatewayConnectionRouteMode from the specified map of raw messages. +func UnmarshalVPNGatewayConnectionRouteMode(m map[string]json.RawMessage, result interface{}) (err error) { + // Retrieve discriminator value to determine correct "subclass". + var discValue string + err = core.UnmarshalPrimitive(m, "routing_protocol", &discValue) if err != nil { + err = fmt.Errorf("error unmarshalling discriminator property 'routing_protocol': %s", err.Error()) return } - err = core.UnmarshalPrimitive(m, "routing_protocol", &obj.RoutingProtocol) - if err != nil { + if discValue == "" { + err = fmt.Errorf("required discriminator property 'routing_protocol' not found in JSON object") return } - err = core.UnmarshalModel(m, "tunnels", &obj.Tunnels, UnmarshalVPNGatewayConnectionStaticRouteModeTunnel) - if err != nil { - return + if discValue == "none" { + err = core.UnmarshalModel(m, "", result, UnmarshalVPNGatewayConnectionRouteModeVPNGatewayConnectionStaticRouteMode) + } else { + err = fmt.Errorf("unrecognized value for discriminator property 'routing_protocol': %s", discValue) } - reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) return } @@ -115072,6 +115143,195 @@ func UnmarshalShareMountTargetVirtualNetworkInterfacePrototypeVirtualNetworkInte return } +// VPNGatewayConnectionRouteModeVPNGatewayConnectionStaticRouteMode : VPNGatewayConnectionRouteModeVPNGatewayConnectionStaticRouteMode struct +// This model "extends" VPNGatewayConnectionRouteMode +type VPNGatewayConnectionRouteModeVPNGatewayConnectionStaticRouteMode struct { + // If set to false, the VPN gateway connection is shut down. + AdminStateUp *bool `json:"admin_state_up" validate:"required"` + + // The authentication mode. Only `psk` is currently supported. + AuthenticationMode *string `json:"authentication_mode" validate:"required"` + + // The date and time that this VPN gateway connection was created. + CreatedAt *strfmt.DateTime `json:"created_at" validate:"required"` + + DeadPeerDetection *VPNGatewayConnectionDpd `json:"dead_peer_detection" validate:"required"` + + // The VPN connection's canonical URL. + Href *string `json:"href" validate:"required"` + + // The unique identifier for this VPN gateway connection. + ID *string `json:"id" validate:"required"` + + // The IKE policy. If absent, [auto-negotiation is + // used](https://cloud.ibm.com/docs/vpc?topic=vpc-using-vpn&interface=ui#ike-auto-negotiation-phase-1). + IkePolicy *IkePolicyReference `json:"ike_policy,omitempty"` + + // The IPsec policy. If absent, [auto-negotiation is + // used](https://cloud.ibm.com/docs/vpc?topic=vpc-using-vpn&interface=ui#ipsec-auto-negotiation-phase-2). + IpsecPolicy *IPsecPolicyReference `json:"ipsec_policy,omitempty"` + + // The mode of the VPN gateway. + Mode *string `json:"mode" validate:"required"` + + // The name for this VPN gateway connection. The name is unique across all connections for the VPN gateway. + Name *string `json:"name" validate:"required"` + + // The IP address of the peer VPN gateway. + PeerAddress *string `json:"peer_address" validate:"required"` + + // The pre-shared key. + Psk *string `json:"psk" validate:"required"` + + // The resource type. + ResourceType *string `json:"resource_type" validate:"required"` + + // The status of a VPN gateway connection. + Status *string `json:"status" validate:"required"` + + // The reasons for the current VPN gateway connection status (if any): + // - `cannot_authenticate_connection`: Failed to authenticate a connection because of + // mismatched IKE ID and PSK (check IKE ID and PSK in peer VPN configuration) + // - `internal_error`: Internal error (contact IBM support) + // - `ike_policy_mismatch`: None of the proposed IKE crypto suites was acceptable (check + // the IKE policies on both sides of the VPN) + // - `ike_v1_id_local_remote_cidr_mismatch`: Invalid IKE ID or mismatched local CIDRs and + // remote CIDRs in IKE V1 (check the IKE ID or the local CIDRs and remote CIDRs in IKE + // V1 configuration) + // - `ike_v2_local_remote_cidr_mismatch`: Mismatched local CIDRs and remote CIDRs in IKE + // V2 (check the local CIDRs and remote CIDRs in IKE V2 configuration) + // - `ipsec_policy_mismatch`: None of the proposed IPsec crypto suites was acceptable + // (check the IPsec policies on both sides of the VPN) + // - `peer_not_responding`: No response from peer (check network ACL configuration, peer + // availability, and on-premise firewall configuration) + // + // The enumerated reason code values for this property will expand in the future. When processing this property, check + // for and log unknown values. Optionally halt processing and surface the error, or bypass the resource on which the + // unexpected reason code was encountered. + StatusReasons []VPNGatewayConnectionStatusReason `json:"status_reasons" validate:"required"` + + // Routing protocols are disabled for this VPN gateway connection. + RoutingProtocol *string `json:"routing_protocol" validate:"required"` + + // The VPN tunnel configuration for this VPN gateway connection (in static route mode). + Tunnels []VPNGatewayConnectionStaticRouteModeTunnel `json:"tunnels" validate:"required"` +} + +// Constants associated with the VPNGatewayConnectionRouteModeVPNGatewayConnectionStaticRouteMode.AuthenticationMode property. +// The authentication mode. Only `psk` is currently supported. +const ( + VPNGatewayConnectionRouteModeVPNGatewayConnectionStaticRouteModeAuthenticationModePskConst = "psk" +) + +// Constants associated with the VPNGatewayConnectionRouteModeVPNGatewayConnectionStaticRouteMode.Mode property. +// The mode of the VPN gateway. +const ( + VPNGatewayConnectionRouteModeVPNGatewayConnectionStaticRouteModeModePolicyConst = "policy" + VPNGatewayConnectionRouteModeVPNGatewayConnectionStaticRouteModeModeRouteConst = "route" +) + +// Constants associated with the VPNGatewayConnectionRouteModeVPNGatewayConnectionStaticRouteMode.ResourceType property. +// The resource type. +const ( + VPNGatewayConnectionRouteModeVPNGatewayConnectionStaticRouteModeResourceTypeVPNGatewayConnectionConst = "vpn_gateway_connection" +) + +// Constants associated with the VPNGatewayConnectionRouteModeVPNGatewayConnectionStaticRouteMode.Status property. +// The status of a VPN gateway connection. +const ( + VPNGatewayConnectionRouteModeVPNGatewayConnectionStaticRouteModeStatusDownConst = "down" + VPNGatewayConnectionRouteModeVPNGatewayConnectionStaticRouteModeStatusUpConst = "up" +) + +// Constants associated with the VPNGatewayConnectionRouteModeVPNGatewayConnectionStaticRouteMode.RoutingProtocol property. +// Routing protocols are disabled for this VPN gateway connection. +const ( + VPNGatewayConnectionRouteModeVPNGatewayConnectionStaticRouteModeRoutingProtocolNoneConst = "none" +) + +func (*VPNGatewayConnectionRouteModeVPNGatewayConnectionStaticRouteMode) isaVPNGatewayConnectionRouteMode() bool { + return true +} + +func (*VPNGatewayConnectionRouteModeVPNGatewayConnectionStaticRouteMode) isaVPNGatewayConnection() bool { + return true +} + +// UnmarshalVPNGatewayConnectionRouteModeVPNGatewayConnectionStaticRouteMode unmarshals an instance of VPNGatewayConnectionRouteModeVPNGatewayConnectionStaticRouteMode from the specified map of raw messages. +func UnmarshalVPNGatewayConnectionRouteModeVPNGatewayConnectionStaticRouteMode(m map[string]json.RawMessage, result interface{}) (err error) { + obj := new(VPNGatewayConnectionRouteModeVPNGatewayConnectionStaticRouteMode) + err = core.UnmarshalPrimitive(m, "admin_state_up", &obj.AdminStateUp) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "authentication_mode", &obj.AuthenticationMode) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "created_at", &obj.CreatedAt) + if err != nil { + return + } + err = core.UnmarshalModel(m, "dead_peer_detection", &obj.DeadPeerDetection, UnmarshalVPNGatewayConnectionDpd) + 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.UnmarshalModel(m, "ike_policy", &obj.IkePolicy, UnmarshalIkePolicyReference) + if err != nil { + return + } + err = core.UnmarshalModel(m, "ipsec_policy", &obj.IpsecPolicy, UnmarshalIPsecPolicyReference) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "mode", &obj.Mode) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "name", &obj.Name) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "peer_address", &obj.PeerAddress) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "psk", &obj.Psk) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "resource_type", &obj.ResourceType) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "status", &obj.Status) + if err != nil { + return + } + err = core.UnmarshalModel(m, "status_reasons", &obj.StatusReasons, UnmarshalVPNGatewayConnectionStatusReason) + if err != nil { + return + } + err = core.UnmarshalPrimitive(m, "routing_protocol", &obj.RoutingProtocol) + if err != nil { + return + } + err = core.UnmarshalModel(m, "tunnels", &obj.Tunnels, UnmarshalVPNGatewayConnectionStaticRouteModeTunnel) + if err != nil { + return + } + reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj)) + return +} + // VirtualNetworkInterfaceIPPrototypeReservedIPIdentityVirtualNetworkInterfaceIPsContextByHref : VirtualNetworkInterfaceIPPrototypeReservedIPIdentityVirtualNetworkInterfaceIPsContextByHref struct // This model "extends" VirtualNetworkInterfaceIPPrototypeReservedIPIdentityVirtualNetworkInterfaceIPsContext type VirtualNetworkInterfaceIPPrototypeReservedIPIdentityVirtualNetworkInterfaceIPsContextByHref struct { @@ -117576,176 +117836,6 @@ func (pager *DedicatedHostsPager) GetAll() (allItems []DedicatedHost, err error) return pager.GetAllWithContext(context.Background()) } -// BackupPoliciesPager can be used to simplify the use of the "ListBackupPolicies" method. -type BackupPoliciesPager struct { - hasNext bool - options *ListBackupPoliciesOptions - client *VpcV1 - pageContext struct { - next *string - } -} - -// NewBackupPoliciesPager returns a new BackupPoliciesPager instance. -func (vpc *VpcV1) NewBackupPoliciesPager(options *ListBackupPoliciesOptions) (pager *BackupPoliciesPager, err error) { - if options.Start != nil && *options.Start != "" { - err = fmt.Errorf("the 'options.Start' field should not be set") - return - } - - var optionsCopy ListBackupPoliciesOptions = *options - pager = &BackupPoliciesPager{ - hasNext: true, - options: &optionsCopy, - client: vpc, - } - return -} - -// HasNext returns true if there are potentially more results to be retrieved. -func (pager *BackupPoliciesPager) HasNext() bool { - return pager.hasNext -} - -// GetNextWithContext returns the next page of results using the specified Context. -func (pager *BackupPoliciesPager) GetNextWithContext(ctx context.Context) (page []BackupPolicyIntf, err error) { - if !pager.HasNext() { - return nil, fmt.Errorf("no more results available") - } - - pager.options.Start = pager.pageContext.next - - result, _, err := pager.client.ListBackupPoliciesWithContext(ctx, pager.options) - if err != nil { - return - } - - var next *string - if result.Next != nil { - var start *string - start, err = core.GetQueryParam(result.Next.Href, "start") - if err != nil { - err = fmt.Errorf("error retrieving 'start' query parameter from URL '%s': %s", *result.Next.Href, err.Error()) - return - } - next = start - } - pager.pageContext.next = next - pager.hasNext = (pager.pageContext.next != nil) - page = result.BackupPolicies - - return -} - -// GetAllWithContext returns all results by invoking GetNextWithContext() repeatedly -// until all pages of results have been retrieved. -func (pager *BackupPoliciesPager) GetAllWithContext(ctx context.Context) (allItems []BackupPolicyIntf, err error) { - for pager.HasNext() { - var nextPage []BackupPolicyIntf - nextPage, err = pager.GetNextWithContext(ctx) - if err != nil { - return - } - allItems = append(allItems, nextPage...) - } - return -} - -// GetNext invokes GetNextWithContext() using context.Background() as the Context parameter. -func (pager *BackupPoliciesPager) GetNext() (page []BackupPolicyIntf, err error) { - return pager.GetNextWithContext(context.Background()) -} - -// GetAll invokes GetAllWithContext() using context.Background() as the Context parameter. -func (pager *BackupPoliciesPager) GetAll() (allItems []BackupPolicyIntf, err error) { - return pager.GetAllWithContext(context.Background()) -} - -// BackupPolicyJobsPager can be used to simplify the use of the "ListBackupPolicyJobs" method. -type BackupPolicyJobsPager struct { - hasNext bool - options *ListBackupPolicyJobsOptions - client *VpcV1 - pageContext struct { - next *string - } -} - -// NewBackupPolicyJobsPager returns a new BackupPolicyJobsPager instance. -func (vpc *VpcV1) NewBackupPolicyJobsPager(options *ListBackupPolicyJobsOptions) (pager *BackupPolicyJobsPager, err error) { - if options.Start != nil && *options.Start != "" { - err = fmt.Errorf("the 'options.Start' field should not be set") - return - } - - var optionsCopy ListBackupPolicyJobsOptions = *options - pager = &BackupPolicyJobsPager{ - hasNext: true, - options: &optionsCopy, - client: vpc, - } - return -} - -// HasNext returns true if there are potentially more results to be retrieved. -func (pager *BackupPolicyJobsPager) HasNext() bool { - return pager.hasNext -} - -// GetNextWithContext returns the next page of results using the specified Context. -func (pager *BackupPolicyJobsPager) GetNextWithContext(ctx context.Context) (page []BackupPolicyJob, err error) { - if !pager.HasNext() { - return nil, fmt.Errorf("no more results available") - } - - pager.options.Start = pager.pageContext.next - - result, _, err := pager.client.ListBackupPolicyJobsWithContext(ctx, pager.options) - if err != nil { - return - } - - var next *string - if result.Next != nil { - var start *string - start, err = core.GetQueryParam(result.Next.Href, "start") - if err != nil { - err = fmt.Errorf("error retrieving 'start' query parameter from URL '%s': %s", *result.Next.Href, err.Error()) - return - } - next = start - } - pager.pageContext.next = next - pager.hasNext = (pager.pageContext.next != nil) - page = result.Jobs - - return -} - -// GetAllWithContext returns all results by invoking GetNextWithContext() repeatedly -// until all pages of results have been retrieved. -func (pager *BackupPolicyJobsPager) GetAllWithContext(ctx context.Context) (allItems []BackupPolicyJob, err error) { - for pager.HasNext() { - var nextPage []BackupPolicyJob - nextPage, err = pager.GetNextWithContext(ctx) - if err != nil { - return - } - allItems = append(allItems, nextPage...) - } - return -} - -// GetNext invokes GetNextWithContext() using context.Background() as the Context parameter. -func (pager *BackupPolicyJobsPager) GetNext() (page []BackupPolicyJob, err error) { - return pager.GetNextWithContext(context.Background()) -} - -// GetAll invokes GetAllWithContext() using context.Background() as the Context parameter. -func (pager *BackupPolicyJobsPager) GetAll() (allItems []BackupPolicyJob, err error) { - return pager.GetAllWithContext(context.Background()) -} - // PlacementGroupsPager can be used to simplify the use of the "ListPlacementGroups" method. type PlacementGroupsPager struct { hasNext bool @@ -118766,6 +118856,176 @@ func (pager *ShareMountTargetsPager) GetAll() (allItems []ShareMountTarget, err return pager.GetAllWithContext(context.Background()) } +// BackupPoliciesPager can be used to simplify the use of the "ListBackupPolicies" method. +type BackupPoliciesPager struct { + hasNext bool + options *ListBackupPoliciesOptions + client *VpcV1 + pageContext struct { + next *string + } +} + +// NewBackupPoliciesPager returns a new BackupPoliciesPager instance. +func (vpc *VpcV1) NewBackupPoliciesPager(options *ListBackupPoliciesOptions) (pager *BackupPoliciesPager, err error) { + if options.Start != nil && *options.Start != "" { + err = fmt.Errorf("the 'options.Start' field should not be set") + return + } + + var optionsCopy ListBackupPoliciesOptions = *options + pager = &BackupPoliciesPager{ + hasNext: true, + options: &optionsCopy, + client: vpc, + } + return +} + +// HasNext returns true if there are potentially more results to be retrieved. +func (pager *BackupPoliciesPager) HasNext() bool { + return pager.hasNext +} + +// GetNextWithContext returns the next page of results using the specified Context. +func (pager *BackupPoliciesPager) GetNextWithContext(ctx context.Context) (page []BackupPolicyIntf, err error) { + if !pager.HasNext() { + return nil, fmt.Errorf("no more results available") + } + + pager.options.Start = pager.pageContext.next + + result, _, err := pager.client.ListBackupPoliciesWithContext(ctx, pager.options) + if err != nil { + return + } + + var next *string + if result.Next != nil { + var start *string + start, err = core.GetQueryParam(result.Next.Href, "start") + if err != nil { + err = fmt.Errorf("error retrieving 'start' query parameter from URL '%s': %s", *result.Next.Href, err.Error()) + return + } + next = start + } + pager.pageContext.next = next + pager.hasNext = (pager.pageContext.next != nil) + page = result.BackupPolicies + + return +} + +// GetAllWithContext returns all results by invoking GetNextWithContext() repeatedly +// until all pages of results have been retrieved. +func (pager *BackupPoliciesPager) GetAllWithContext(ctx context.Context) (allItems []BackupPolicyIntf, err error) { + for pager.HasNext() { + var nextPage []BackupPolicyIntf + nextPage, err = pager.GetNextWithContext(ctx) + if err != nil { + return + } + allItems = append(allItems, nextPage...) + } + return +} + +// GetNext invokes GetNextWithContext() using context.Background() as the Context parameter. +func (pager *BackupPoliciesPager) GetNext() (page []BackupPolicyIntf, err error) { + return pager.GetNextWithContext(context.Background()) +} + +// GetAll invokes GetAllWithContext() using context.Background() as the Context parameter. +func (pager *BackupPoliciesPager) GetAll() (allItems []BackupPolicyIntf, err error) { + return pager.GetAllWithContext(context.Background()) +} + +// BackupPolicyJobsPager can be used to simplify the use of the "ListBackupPolicyJobs" method. +type BackupPolicyJobsPager struct { + hasNext bool + options *ListBackupPolicyJobsOptions + client *VpcV1 + pageContext struct { + next *string + } +} + +// NewBackupPolicyJobsPager returns a new BackupPolicyJobsPager instance. +func (vpc *VpcV1) NewBackupPolicyJobsPager(options *ListBackupPolicyJobsOptions) (pager *BackupPolicyJobsPager, err error) { + if options.Start != nil && *options.Start != "" { + err = fmt.Errorf("the 'options.Start' field should not be set") + return + } + + var optionsCopy ListBackupPolicyJobsOptions = *options + pager = &BackupPolicyJobsPager{ + hasNext: true, + options: &optionsCopy, + client: vpc, + } + return +} + +// HasNext returns true if there are potentially more results to be retrieved. +func (pager *BackupPolicyJobsPager) HasNext() bool { + return pager.hasNext +} + +// GetNextWithContext returns the next page of results using the specified Context. +func (pager *BackupPolicyJobsPager) GetNextWithContext(ctx context.Context) (page []BackupPolicyJob, err error) { + if !pager.HasNext() { + return nil, fmt.Errorf("no more results available") + } + + pager.options.Start = pager.pageContext.next + + result, _, err := pager.client.ListBackupPolicyJobsWithContext(ctx, pager.options) + if err != nil { + return + } + + var next *string + if result.Next != nil { + var start *string + start, err = core.GetQueryParam(result.Next.Href, "start") + if err != nil { + err = fmt.Errorf("error retrieving 'start' query parameter from URL '%s': %s", *result.Next.Href, err.Error()) + return + } + next = start + } + pager.pageContext.next = next + pager.hasNext = (pager.pageContext.next != nil) + page = result.Jobs + + return +} + +// GetAllWithContext returns all results by invoking GetNextWithContext() repeatedly +// until all pages of results have been retrieved. +func (pager *BackupPolicyJobsPager) GetAllWithContext(ctx context.Context) (allItems []BackupPolicyJob, err error) { + for pager.HasNext() { + var nextPage []BackupPolicyJob + nextPage, err = pager.GetNextWithContext(ctx) + if err != nil { + return + } + allItems = append(allItems, nextPage...) + } + return +} + +// GetNext invokes GetNextWithContext() using context.Background() as the Context parameter. +func (pager *BackupPolicyJobsPager) GetNext() (page []BackupPolicyJob, err error) { + return pager.GetNextWithContext(context.Background()) +} + +// GetAll invokes GetAllWithContext() using context.Background() as the Context parameter. +func (pager *BackupPolicyJobsPager) GetAll() (allItems []BackupPolicyJob, err error) { + return pager.GetAllWithContext(context.Background()) +} + // VirtualNetworkInterfacesPager can be used to simplify the use of the "ListVirtualNetworkInterfaces" method. type VirtualNetworkInterfacesPager struct { hasNext bool diff --git a/vpcv1/vpc_v1_examples_test.go b/vpcv1/vpc_v1_examples_test.go index 18833cf..d5ec686 100644 --- a/vpcv1/vpc_v1_examples_test.go +++ b/vpcv1/vpc_v1_examples_test.go @@ -3434,7 +3434,7 @@ var _ = Describe(`VpcV1 Examples Tests`, func() { volumeIdentityModel := &vpcv1.VolumeIdentityByID{ ID: &volumeID, } - snapshotConsistencyGroupPrototypeSnapshotsItem := &vpcv1.SnapshotConsistencyGroupPrototypeSnapshotsItem{ + snapshotConsistencyGroupPrototypeSnapshotsItem := &vpcv1.SnapshotPrototypeSnapshotConsistencyGroupContext{ Name: core.StringPtr("my-snapshot-1"), SourceVolume: volumeIdentityModel, // UserTags @@ -3444,7 +3444,7 @@ var _ = Describe(`VpcV1 Examples Tests`, func() { DeleteSnapshotsOnDelete: core.BoolPtr(true), Name: core.StringPtr(name), } - snapshotConsistencyGroupPrototype.Snapshots = []vpcv1.SnapshotConsistencyGroupPrototypeSnapshotsItem{*snapshotConsistencyGroupPrototypeSnapshotsItem} + snapshotConsistencyGroupPrototype.Snapshots = []vpcv1.SnapshotPrototypeSnapshotConsistencyGroupContext{*snapshotConsistencyGroupPrototypeSnapshotsItem} options := &vpcv1.CreateSnapshotConsistencyGroupOptions{ SnapshotConsistencyGroupPrototype: snapshotConsistencyGroupPrototype, diff --git a/vpcv1/vpc_v1_test.go b/vpcv1/vpc_v1_test.go index f177cbc..8d254b5 100644 --- a/vpcv1/vpc_v1_test.go +++ b/vpcv1/vpc_v1_test.go @@ -926,7 +926,7 @@ var _ = Describe(`VpcV1`, func() { 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.Header["If-Match"][0]).To(Equal(fmt.Sprintf("%v", "W/\"96d225c4-56bd-43d9-98fc-d7148e5c5028\""))) Expect(req.URL.Query()["version"]).To(Equal([]string{"testString"})) Expect(req.URL.Query()["generation"]).To(Equal([]string{fmt.Sprint(int64(2))})) res.WriteHeader(204) @@ -949,7 +949,7 @@ var _ = Describe(`VpcV1`, func() { // Construct an instance of the DeleteVPCOptions model deleteVPCOptionsModel := new(vpcv1.DeleteVPCOptions) deleteVPCOptionsModel.ID = core.StringPtr("testString") - deleteVPCOptionsModel.IfMatch = core.StringPtr(`W/"96d225c4-56bd-43d9-98fc-d7148e5c5028"`) + deleteVPCOptionsModel.IfMatch = core.StringPtr("W/\"96d225c4-56bd-43d9-98fc-d7148e5c5028\"") deleteVPCOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with valid options model (positive test) @@ -969,7 +969,7 @@ var _ = Describe(`VpcV1`, func() { // Construct an instance of the DeleteVPCOptions model deleteVPCOptionsModel := new(vpcv1.DeleteVPCOptions) deleteVPCOptionsModel.ID = core.StringPtr("testString") - deleteVPCOptionsModel.IfMatch = core.StringPtr(`W/"96d225c4-56bd-43d9-98fc-d7148e5c5028"`) + deleteVPCOptionsModel.IfMatch = core.StringPtr("W/\"96d225c4-56bd-43d9-98fc-d7148e5c5028\"") deleteVPCOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with empty URL (negative test) err := vpcService.SetServiceURL("") @@ -1227,7 +1227,7 @@ var _ = Describe(`VpcV1`, func() { Expect(req.URL.EscapedPath()).To(Equal(updateVPCPath)) 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.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") @@ -1279,7 +1279,7 @@ var _ = Describe(`VpcV1`, func() { updateVPCOptionsModel := new(vpcv1.UpdateVPCOptions) updateVPCOptionsModel.ID = core.StringPtr("testString") updateVPCOptionsModel.VPCPatch = vpcPatchModelAsPatch - updateVPCOptionsModel.IfMatch = core.StringPtr(`W/"96d225c4-56bd-43d9-98fc-d7148e5c5028"`) + updateVPCOptionsModel.IfMatch = core.StringPtr("W/\"96d225c4-56bd-43d9-98fc-d7148e5c5028\"") updateVPCOptionsModel.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.UpdateVPC(updateVPCOptionsModel) @@ -1328,7 +1328,7 @@ var _ = Describe(`VpcV1`, func() { 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.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 @@ -1385,7 +1385,7 @@ var _ = Describe(`VpcV1`, func() { updateVPCOptionsModel := new(vpcv1.UpdateVPCOptions) updateVPCOptionsModel.ID = core.StringPtr("testString") updateVPCOptionsModel.VPCPatch = vpcPatchModelAsPatch - updateVPCOptionsModel.IfMatch = core.StringPtr(`W/"96d225c4-56bd-43d9-98fc-d7148e5c5028"`) + updateVPCOptionsModel.IfMatch = core.StringPtr("W/\"96d225c4-56bd-43d9-98fc-d7148e5c5028\"") updateVPCOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with a Context to test a timeout error @@ -1439,7 +1439,7 @@ var _ = Describe(`VpcV1`, func() { 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.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 @@ -1498,7 +1498,7 @@ var _ = Describe(`VpcV1`, func() { updateVPCOptionsModel := new(vpcv1.UpdateVPCOptions) updateVPCOptionsModel.ID = core.StringPtr("testString") updateVPCOptionsModel.VPCPatch = vpcPatchModelAsPatch - updateVPCOptionsModel.IfMatch = core.StringPtr(`W/"96d225c4-56bd-43d9-98fc-d7148e5c5028"`) + updateVPCOptionsModel.IfMatch = core.StringPtr("W/\"96d225c4-56bd-43d9-98fc-d7148e5c5028\"") updateVPCOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with valid options model (positive test) @@ -1552,7 +1552,7 @@ var _ = Describe(`VpcV1`, func() { updateVPCOptionsModel := new(vpcv1.UpdateVPCOptions) updateVPCOptionsModel.ID = core.StringPtr("testString") updateVPCOptionsModel.VPCPatch = vpcPatchModelAsPatch - updateVPCOptionsModel.IfMatch = core.StringPtr(`W/"96d225c4-56bd-43d9-98fc-d7148e5c5028"`) + updateVPCOptionsModel.IfMatch = core.StringPtr("W/\"96d225c4-56bd-43d9-98fc-d7148e5c5028\"") updateVPCOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with empty URL (negative test) err := vpcService.SetServiceURL("") @@ -1627,7 +1627,7 @@ var _ = Describe(`VpcV1`, func() { updateVPCOptionsModel := new(vpcv1.UpdateVPCOptions) updateVPCOptionsModel.ID = core.StringPtr("testString") updateVPCOptionsModel.VPCPatch = vpcPatchModelAsPatch - updateVPCOptionsModel.IfMatch = core.StringPtr(`W/"96d225c4-56bd-43d9-98fc-d7148e5c5028"`) + updateVPCOptionsModel.IfMatch = core.StringPtr("W/\"96d225c4-56bd-43d9-98fc-d7148e5c5028\"") updateVPCOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation @@ -1937,7 +1937,7 @@ var _ = Describe(`VpcV1`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"accept_routes_from": [{"resource_type": "vpn_gateway"}], "advertise_routes_to": ["transit_gateway"], "created_at": "2019-01-01T12:00:00.000Z", "href": "https://us-south.iaas.cloud.ibm.com/v1/vpcs/982d72b7-db1b-4606-afb2-ed6bd4b0bed1/routing_tables/6885e83f-03b2-4603-8a86-db2a0f55c840", "id": "1a15dca5-7e33-45e1-b7c5-bc690e569531", "is_default": false, "lifecycle_state": "stable", "name": "milled-easy-equine-machines", "resource_type": "routing_table", "route_direct_link_ingress": true, "route_internet_ingress": true, "route_transit_gateway_ingress": true, "route_vpc_zone_ingress": false, "routes": [{"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/vpcs/8e454ead-0db7-48ac-9a8b-2698d8c470a7/routing_tables/6885e83f-03b2-4603-8a86-db2a0f55c840/routes/1a15dca5-7e33-45e1-b7c5-bc690e569531", "id": "1a15dca5-7e33-45e1-b7c5-bc690e569531", "name": "my-route-1"}], "subnets": [{"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "id": "7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "name": "my-subnet", "resource_type": "subnet"}]}`) + fmt.Fprintf(res, "%s", `{"accept_routes_from": [{"resource_type": "vpn_server"}], "advertise_routes_to": ["transit_gateway"], "created_at": "2019-01-01T12:00:00.000Z", "href": "https://us-south.iaas.cloud.ibm.com/v1/vpcs/982d72b7-db1b-4606-afb2-ed6bd4b0bed1/routing_tables/6885e83f-03b2-4603-8a86-db2a0f55c840", "id": "1a15dca5-7e33-45e1-b7c5-bc690e569531", "is_default": false, "lifecycle_state": "stable", "name": "milled-easy-equine-machines", "resource_type": "routing_table", "route_direct_link_ingress": true, "route_internet_ingress": true, "route_transit_gateway_ingress": true, "route_vpc_zone_ingress": false, "routes": [{"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/vpcs/8e454ead-0db7-48ac-9a8b-2698d8c470a7/routing_tables/6885e83f-03b2-4603-8a86-db2a0f55c840/routes/1a15dca5-7e33-45e1-b7c5-bc690e569531", "id": "1a15dca5-7e33-45e1-b7c5-bc690e569531", "name": "my-route-1"}], "subnets": [{"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "id": "7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "name": "my-subnet", "resource_type": "subnet"}]}`) })) }) It(`Invoke GetVPCDefaultRoutingTable successfully with retries`, func() { @@ -1994,7 +1994,7 @@ var _ = Describe(`VpcV1`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"accept_routes_from": [{"resource_type": "vpn_gateway"}], "advertise_routes_to": ["transit_gateway"], "created_at": "2019-01-01T12:00:00.000Z", "href": "https://us-south.iaas.cloud.ibm.com/v1/vpcs/982d72b7-db1b-4606-afb2-ed6bd4b0bed1/routing_tables/6885e83f-03b2-4603-8a86-db2a0f55c840", "id": "1a15dca5-7e33-45e1-b7c5-bc690e569531", "is_default": false, "lifecycle_state": "stable", "name": "milled-easy-equine-machines", "resource_type": "routing_table", "route_direct_link_ingress": true, "route_internet_ingress": true, "route_transit_gateway_ingress": true, "route_vpc_zone_ingress": false, "routes": [{"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/vpcs/8e454ead-0db7-48ac-9a8b-2698d8c470a7/routing_tables/6885e83f-03b2-4603-8a86-db2a0f55c840/routes/1a15dca5-7e33-45e1-b7c5-bc690e569531", "id": "1a15dca5-7e33-45e1-b7c5-bc690e569531", "name": "my-route-1"}], "subnets": [{"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "id": "7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "name": "my-subnet", "resource_type": "subnet"}]}`) + fmt.Fprintf(res, "%s", `{"accept_routes_from": [{"resource_type": "vpn_server"}], "advertise_routes_to": ["transit_gateway"], "created_at": "2019-01-01T12:00:00.000Z", "href": "https://us-south.iaas.cloud.ibm.com/v1/vpcs/982d72b7-db1b-4606-afb2-ed6bd4b0bed1/routing_tables/6885e83f-03b2-4603-8a86-db2a0f55c840", "id": "1a15dca5-7e33-45e1-b7c5-bc690e569531", "is_default": false, "lifecycle_state": "stable", "name": "milled-easy-equine-machines", "resource_type": "routing_table", "route_direct_link_ingress": true, "route_internet_ingress": true, "route_transit_gateway_ingress": true, "route_vpc_zone_ingress": false, "routes": [{"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/vpcs/8e454ead-0db7-48ac-9a8b-2698d8c470a7/routing_tables/6885e83f-03b2-4603-8a86-db2a0f55c840/routes/1a15dca5-7e33-45e1-b7c5-bc690e569531", "id": "1a15dca5-7e33-45e1-b7c5-bc690e569531", "name": "my-route-1"}], "subnets": [{"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "id": "7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "name": "my-subnet", "resource_type": "subnet"}]}`) })) }) It(`Invoke GetVPCDefaultRoutingTable successfully`, func() { @@ -3656,7 +3656,7 @@ var _ = Describe(`VpcV1`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"dns_resolution_bindings": [{"created_at": "2019-01-01T12:00:00.000Z", "endpoint_gateways": [{"crn": "crn:v1:bluemix:public:is:us-south:a/123456::endpoint-gateway:r134-d7cc5196-9864-48c4-82d8-3f30da41fcc5", "href": "https://us-south.iaas.cloud.ibm.com/v1/endpoint_gateways/r134-d7cc5196-9864-48c4-82d8-3f30da41fcc5", "id": "r134-d7cc5196-9864-48c4-82d8-3f30da41fcc5", "name": "my-endpoint-gateway", "remote": {"account": {"id": "aa2432b1fa4d4ace891e9b80fc104e34", "resource_type": "account"}, "region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "endpoint_gateway"}], "href": "https://us-south.iaas.cloud.ibm.com/v1/vpcs/r006-982d72b7-db1b-4606-afb2-ed6bd4b0bed1/dns_resolution_bindings/r006-8a524686-fcf6-4947-a59b-188c1ed78ad1", "id": "r006-8a524686-fcf6-4947-a59b-188c1ed78ad1", "lifecycle_state": "stable", "name": "my-dns-resolution-binding", "resource_type": "vpc_dns_resolution_binding", "vpc": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::vpc:4727d842-f94f-4a2d-824a-9bc9b02c523b", "href": "https://us-south.iaas.cloud.ibm.com/v1/vpcs/4727d842-f94f-4a2d-824a-9bc9b02c523b", "id": "4727d842-f94f-4a2d-824a-9bc9b02c523b", "name": "my-vpc", "remote": {"account": {"id": "aa2432b1fa4d4ace891e9b80fc104e34", "resource_type": "account"}, "region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "vpc"}}], "first": {"href": "https://us-south.iaas.cloud.ibm.com/v1/vpcs/r006-982d72b7-db1b-4606-afb2-ed6bd4b0bed1/dns_resolution_bindings?limit=20"}, "limit": 20, "next": {"href": "https://us-south.iaas.cloud.ibm.com/v1/vpcs/r006-982d72b7-db1b-4606-afb2-ed6bd4b0bed1/dns_resolution_bindings?start=9d5a91a3e2cbd233b5a5b33436855ed1&limit=20"}, "total_count": 132}`) + fmt.Fprintf(res, "%s", `{"dns_resolution_bindings": [{"created_at": "2019-01-01T12:00:00.000Z", "endpoint_gateways": [{"crn": "crn:v1:bluemix:public:is:us-south:a/123456::endpoint-gateway:r134-d7cc5196-9864-48c4-82d8-3f30da41fcc5", "href": "https://us-south.iaas.cloud.ibm.com/v1/endpoint_gateways/r134-d7cc5196-9864-48c4-82d8-3f30da41fcc5", "id": "r134-d7cc5196-9864-48c4-82d8-3f30da41fcc5", "name": "my-endpoint-gateway", "remote": {"account": {"id": "aa2432b1fa4d4ace891e9b80fc104e34", "resource_type": "account"}, "region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "endpoint_gateway"}], "health_reasons": [{"code": "disconnected_from_bound_vpc", "message": "The VPC specified in the DNS resolution binding has been disconnected.", "more_info": "https://cloud.ibm.com/docs/vpc?topic=vpc-troubleshoot-hub-spoke-1"}], "health_state": "ok", "href": "https://us-south.iaas.cloud.ibm.com/v1/vpcs/r006-982d72b7-db1b-4606-afb2-ed6bd4b0bed1/dns_resolution_bindings/r006-8a524686-fcf6-4947-a59b-188c1ed78ad1", "id": "r006-8a524686-fcf6-4947-a59b-188c1ed78ad1", "lifecycle_state": "stable", "name": "my-dns-resolution-binding", "resource_type": "vpc_dns_resolution_binding", "vpc": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::vpc:4727d842-f94f-4a2d-824a-9bc9b02c523b", "href": "https://us-south.iaas.cloud.ibm.com/v1/vpcs/4727d842-f94f-4a2d-824a-9bc9b02c523b", "id": "4727d842-f94f-4a2d-824a-9bc9b02c523b", "name": "my-vpc", "remote": {"account": {"id": "aa2432b1fa4d4ace891e9b80fc104e34", "resource_type": "account"}, "region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "vpc"}}], "first": {"href": "https://us-south.iaas.cloud.ibm.com/v1/vpcs/r006-982d72b7-db1b-4606-afb2-ed6bd4b0bed1/dns_resolution_bindings?limit=20"}, "limit": 20, "next": {"href": "https://us-south.iaas.cloud.ibm.com/v1/vpcs/r006-982d72b7-db1b-4606-afb2-ed6bd4b0bed1/dns_resolution_bindings?start=9d5a91a3e2cbd233b5a5b33436855ed1&limit=20"}, "total_count": 132}`) })) }) It(`Invoke ListVPCDnsResolutionBindings successfully with retries`, func() { @@ -3727,7 +3727,7 @@ var _ = Describe(`VpcV1`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"dns_resolution_bindings": [{"created_at": "2019-01-01T12:00:00.000Z", "endpoint_gateways": [{"crn": "crn:v1:bluemix:public:is:us-south:a/123456::endpoint-gateway:r134-d7cc5196-9864-48c4-82d8-3f30da41fcc5", "href": "https://us-south.iaas.cloud.ibm.com/v1/endpoint_gateways/r134-d7cc5196-9864-48c4-82d8-3f30da41fcc5", "id": "r134-d7cc5196-9864-48c4-82d8-3f30da41fcc5", "name": "my-endpoint-gateway", "remote": {"account": {"id": "aa2432b1fa4d4ace891e9b80fc104e34", "resource_type": "account"}, "region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "endpoint_gateway"}], "href": "https://us-south.iaas.cloud.ibm.com/v1/vpcs/r006-982d72b7-db1b-4606-afb2-ed6bd4b0bed1/dns_resolution_bindings/r006-8a524686-fcf6-4947-a59b-188c1ed78ad1", "id": "r006-8a524686-fcf6-4947-a59b-188c1ed78ad1", "lifecycle_state": "stable", "name": "my-dns-resolution-binding", "resource_type": "vpc_dns_resolution_binding", "vpc": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::vpc:4727d842-f94f-4a2d-824a-9bc9b02c523b", "href": "https://us-south.iaas.cloud.ibm.com/v1/vpcs/4727d842-f94f-4a2d-824a-9bc9b02c523b", "id": "4727d842-f94f-4a2d-824a-9bc9b02c523b", "name": "my-vpc", "remote": {"account": {"id": "aa2432b1fa4d4ace891e9b80fc104e34", "resource_type": "account"}, "region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "vpc"}}], "first": {"href": "https://us-south.iaas.cloud.ibm.com/v1/vpcs/r006-982d72b7-db1b-4606-afb2-ed6bd4b0bed1/dns_resolution_bindings?limit=20"}, "limit": 20, "next": {"href": "https://us-south.iaas.cloud.ibm.com/v1/vpcs/r006-982d72b7-db1b-4606-afb2-ed6bd4b0bed1/dns_resolution_bindings?start=9d5a91a3e2cbd233b5a5b33436855ed1&limit=20"}, "total_count": 132}`) + fmt.Fprintf(res, "%s", `{"dns_resolution_bindings": [{"created_at": "2019-01-01T12:00:00.000Z", "endpoint_gateways": [{"crn": "crn:v1:bluemix:public:is:us-south:a/123456::endpoint-gateway:r134-d7cc5196-9864-48c4-82d8-3f30da41fcc5", "href": "https://us-south.iaas.cloud.ibm.com/v1/endpoint_gateways/r134-d7cc5196-9864-48c4-82d8-3f30da41fcc5", "id": "r134-d7cc5196-9864-48c4-82d8-3f30da41fcc5", "name": "my-endpoint-gateway", "remote": {"account": {"id": "aa2432b1fa4d4ace891e9b80fc104e34", "resource_type": "account"}, "region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "endpoint_gateway"}], "health_reasons": [{"code": "disconnected_from_bound_vpc", "message": "The VPC specified in the DNS resolution binding has been disconnected.", "more_info": "https://cloud.ibm.com/docs/vpc?topic=vpc-troubleshoot-hub-spoke-1"}], "health_state": "ok", "href": "https://us-south.iaas.cloud.ibm.com/v1/vpcs/r006-982d72b7-db1b-4606-afb2-ed6bd4b0bed1/dns_resolution_bindings/r006-8a524686-fcf6-4947-a59b-188c1ed78ad1", "id": "r006-8a524686-fcf6-4947-a59b-188c1ed78ad1", "lifecycle_state": "stable", "name": "my-dns-resolution-binding", "resource_type": "vpc_dns_resolution_binding", "vpc": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::vpc:4727d842-f94f-4a2d-824a-9bc9b02c523b", "href": "https://us-south.iaas.cloud.ibm.com/v1/vpcs/4727d842-f94f-4a2d-824a-9bc9b02c523b", "id": "4727d842-f94f-4a2d-824a-9bc9b02c523b", "name": "my-vpc", "remote": {"account": {"id": "aa2432b1fa4d4ace891e9b80fc104e34", "resource_type": "account"}, "region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "vpc"}}], "first": {"href": "https://us-south.iaas.cloud.ibm.com/v1/vpcs/r006-982d72b7-db1b-4606-afb2-ed6bd4b0bed1/dns_resolution_bindings?limit=20"}, "limit": 20, "next": {"href": "https://us-south.iaas.cloud.ibm.com/v1/vpcs/r006-982d72b7-db1b-4606-afb2-ed6bd4b0bed1/dns_resolution_bindings?start=9d5a91a3e2cbd233b5a5b33436855ed1&limit=20"}, "total_count": 132}`) })) }) It(`Invoke ListVPCDnsResolutionBindings successfully`, func() { @@ -3890,9 +3890,9 @@ var _ = Describe(`VpcV1`, func() { res.WriteHeader(200) requestNumber++ if requestNumber == 1 { - fmt.Fprintf(res, "%s", `{"next":{"href":"https://myhost.com/somePath?start=1"},"total_count":2,"limit":1,"dns_resolution_bindings":[{"created_at":"2019-01-01T12:00:00.000Z","endpoint_gateways":[{"crn":"crn:v1:bluemix:public:is:us-south:a/123456::endpoint-gateway:r134-d7cc5196-9864-48c4-82d8-3f30da41fcc5","href":"https://us-south.iaas.cloud.ibm.com/v1/endpoint_gateways/r134-d7cc5196-9864-48c4-82d8-3f30da41fcc5","id":"r134-d7cc5196-9864-48c4-82d8-3f30da41fcc5","name":"my-endpoint-gateway","remote":{"account":{"id":"aa2432b1fa4d4ace891e9b80fc104e34","resource_type":"account"},"region":{"href":"https://us-south.iaas.cloud.ibm.com/v1/regions/us-south","name":"us-south"}},"resource_type":"endpoint_gateway"}],"href":"https://us-south.iaas.cloud.ibm.com/v1/vpcs/r006-982d72b7-db1b-4606-afb2-ed6bd4b0bed1/dns_resolution_bindings/r006-8a524686-fcf6-4947-a59b-188c1ed78ad1","id":"r006-8a524686-fcf6-4947-a59b-188c1ed78ad1","lifecycle_state":"stable","name":"my-dns-resolution-binding","resource_type":"vpc_dns_resolution_binding","vpc":{"crn":"crn:v1:bluemix:public:is:us-south:a/123456::vpc:4727d842-f94f-4a2d-824a-9bc9b02c523b","href":"https://us-south.iaas.cloud.ibm.com/v1/vpcs/4727d842-f94f-4a2d-824a-9bc9b02c523b","id":"4727d842-f94f-4a2d-824a-9bc9b02c523b","name":"my-vpc","remote":{"account":{"id":"aa2432b1fa4d4ace891e9b80fc104e34","resource_type":"account"},"region":{"href":"https://us-south.iaas.cloud.ibm.com/v1/regions/us-south","name":"us-south"}},"resource_type":"vpc"}}]}`) + fmt.Fprintf(res, "%s", `{"next":{"href":"https://myhost.com/somePath?start=1"},"total_count":2,"limit":1,"dns_resolution_bindings":[{"created_at":"2019-01-01T12:00:00.000Z","endpoint_gateways":[{"crn":"crn:v1:bluemix:public:is:us-south:a/123456::endpoint-gateway:r134-d7cc5196-9864-48c4-82d8-3f30da41fcc5","href":"https://us-south.iaas.cloud.ibm.com/v1/endpoint_gateways/r134-d7cc5196-9864-48c4-82d8-3f30da41fcc5","id":"r134-d7cc5196-9864-48c4-82d8-3f30da41fcc5","name":"my-endpoint-gateway","remote":{"account":{"id":"aa2432b1fa4d4ace891e9b80fc104e34","resource_type":"account"},"region":{"href":"https://us-south.iaas.cloud.ibm.com/v1/regions/us-south","name":"us-south"}},"resource_type":"endpoint_gateway"}],"health_reasons":[{"code":"disconnected_from_bound_vpc","message":"The VPC specified in the DNS resolution binding has been disconnected.","more_info":"https://cloud.ibm.com/docs/vpc?topic=vpc-troubleshoot-hub-spoke-1"}],"health_state":"ok","href":"https://us-south.iaas.cloud.ibm.com/v1/vpcs/r006-982d72b7-db1b-4606-afb2-ed6bd4b0bed1/dns_resolution_bindings/r006-8a524686-fcf6-4947-a59b-188c1ed78ad1","id":"r006-8a524686-fcf6-4947-a59b-188c1ed78ad1","lifecycle_state":"stable","name":"my-dns-resolution-binding","resource_type":"vpc_dns_resolution_binding","vpc":{"crn":"crn:v1:bluemix:public:is:us-south:a/123456::vpc:4727d842-f94f-4a2d-824a-9bc9b02c523b","href":"https://us-south.iaas.cloud.ibm.com/v1/vpcs/4727d842-f94f-4a2d-824a-9bc9b02c523b","id":"4727d842-f94f-4a2d-824a-9bc9b02c523b","name":"my-vpc","remote":{"account":{"id":"aa2432b1fa4d4ace891e9b80fc104e34","resource_type":"account"},"region":{"href":"https://us-south.iaas.cloud.ibm.com/v1/regions/us-south","name":"us-south"}},"resource_type":"vpc"}}]}`) } else if requestNumber == 2 { - fmt.Fprintf(res, "%s", `{"total_count":2,"limit":1,"dns_resolution_bindings":[{"created_at":"2019-01-01T12:00:00.000Z","endpoint_gateways":[{"crn":"crn:v1:bluemix:public:is:us-south:a/123456::endpoint-gateway:r134-d7cc5196-9864-48c4-82d8-3f30da41fcc5","href":"https://us-south.iaas.cloud.ibm.com/v1/endpoint_gateways/r134-d7cc5196-9864-48c4-82d8-3f30da41fcc5","id":"r134-d7cc5196-9864-48c4-82d8-3f30da41fcc5","name":"my-endpoint-gateway","remote":{"account":{"id":"aa2432b1fa4d4ace891e9b80fc104e34","resource_type":"account"},"region":{"href":"https://us-south.iaas.cloud.ibm.com/v1/regions/us-south","name":"us-south"}},"resource_type":"endpoint_gateway"}],"href":"https://us-south.iaas.cloud.ibm.com/v1/vpcs/r006-982d72b7-db1b-4606-afb2-ed6bd4b0bed1/dns_resolution_bindings/r006-8a524686-fcf6-4947-a59b-188c1ed78ad1","id":"r006-8a524686-fcf6-4947-a59b-188c1ed78ad1","lifecycle_state":"stable","name":"my-dns-resolution-binding","resource_type":"vpc_dns_resolution_binding","vpc":{"crn":"crn:v1:bluemix:public:is:us-south:a/123456::vpc:4727d842-f94f-4a2d-824a-9bc9b02c523b","href":"https://us-south.iaas.cloud.ibm.com/v1/vpcs/4727d842-f94f-4a2d-824a-9bc9b02c523b","id":"4727d842-f94f-4a2d-824a-9bc9b02c523b","name":"my-vpc","remote":{"account":{"id":"aa2432b1fa4d4ace891e9b80fc104e34","resource_type":"account"},"region":{"href":"https://us-south.iaas.cloud.ibm.com/v1/regions/us-south","name":"us-south"}},"resource_type":"vpc"}}]}`) + fmt.Fprintf(res, "%s", `{"total_count":2,"limit":1,"dns_resolution_bindings":[{"created_at":"2019-01-01T12:00:00.000Z","endpoint_gateways":[{"crn":"crn:v1:bluemix:public:is:us-south:a/123456::endpoint-gateway:r134-d7cc5196-9864-48c4-82d8-3f30da41fcc5","href":"https://us-south.iaas.cloud.ibm.com/v1/endpoint_gateways/r134-d7cc5196-9864-48c4-82d8-3f30da41fcc5","id":"r134-d7cc5196-9864-48c4-82d8-3f30da41fcc5","name":"my-endpoint-gateway","remote":{"account":{"id":"aa2432b1fa4d4ace891e9b80fc104e34","resource_type":"account"},"region":{"href":"https://us-south.iaas.cloud.ibm.com/v1/regions/us-south","name":"us-south"}},"resource_type":"endpoint_gateway"}],"health_reasons":[{"code":"disconnected_from_bound_vpc","message":"The VPC specified in the DNS resolution binding has been disconnected.","more_info":"https://cloud.ibm.com/docs/vpc?topic=vpc-troubleshoot-hub-spoke-1"}],"health_state":"ok","href":"https://us-south.iaas.cloud.ibm.com/v1/vpcs/r006-982d72b7-db1b-4606-afb2-ed6bd4b0bed1/dns_resolution_bindings/r006-8a524686-fcf6-4947-a59b-188c1ed78ad1","id":"r006-8a524686-fcf6-4947-a59b-188c1ed78ad1","lifecycle_state":"stable","name":"my-dns-resolution-binding","resource_type":"vpc_dns_resolution_binding","vpc":{"crn":"crn:v1:bluemix:public:is:us-south:a/123456::vpc:4727d842-f94f-4a2d-824a-9bc9b02c523b","href":"https://us-south.iaas.cloud.ibm.com/v1/vpcs/4727d842-f94f-4a2d-824a-9bc9b02c523b","id":"4727d842-f94f-4a2d-824a-9bc9b02c523b","name":"my-vpc","remote":{"account":{"id":"aa2432b1fa4d4ace891e9b80fc104e34","resource_type":"account"},"region":{"href":"https://us-south.iaas.cloud.ibm.com/v1/regions/us-south","name":"us-south"}},"resource_type":"vpc"}}]}`) } else { res.WriteHeader(400) } @@ -4051,7 +4051,7 @@ var _ = Describe(`VpcV1`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(201) - fmt.Fprintf(res, "%s", `{"created_at": "2019-01-01T12:00:00.000Z", "endpoint_gateways": [{"crn": "crn:v1:bluemix:public:is:us-south:a/123456::endpoint-gateway:r134-d7cc5196-9864-48c4-82d8-3f30da41fcc5", "href": "https://us-south.iaas.cloud.ibm.com/v1/endpoint_gateways/r134-d7cc5196-9864-48c4-82d8-3f30da41fcc5", "id": "r134-d7cc5196-9864-48c4-82d8-3f30da41fcc5", "name": "my-endpoint-gateway", "remote": {"account": {"id": "aa2432b1fa4d4ace891e9b80fc104e34", "resource_type": "account"}, "region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "endpoint_gateway"}], "href": "https://us-south.iaas.cloud.ibm.com/v1/vpcs/r006-982d72b7-db1b-4606-afb2-ed6bd4b0bed1/dns_resolution_bindings/r006-8a524686-fcf6-4947-a59b-188c1ed78ad1", "id": "r006-8a524686-fcf6-4947-a59b-188c1ed78ad1", "lifecycle_state": "stable", "name": "my-dns-resolution-binding", "resource_type": "vpc_dns_resolution_binding", "vpc": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::vpc:4727d842-f94f-4a2d-824a-9bc9b02c523b", "href": "https://us-south.iaas.cloud.ibm.com/v1/vpcs/4727d842-f94f-4a2d-824a-9bc9b02c523b", "id": "4727d842-f94f-4a2d-824a-9bc9b02c523b", "name": "my-vpc", "remote": {"account": {"id": "aa2432b1fa4d4ace891e9b80fc104e34", "resource_type": "account"}, "region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "vpc"}}`) + fmt.Fprintf(res, "%s", `{"created_at": "2019-01-01T12:00:00.000Z", "endpoint_gateways": [{"crn": "crn:v1:bluemix:public:is:us-south:a/123456::endpoint-gateway:r134-d7cc5196-9864-48c4-82d8-3f30da41fcc5", "href": "https://us-south.iaas.cloud.ibm.com/v1/endpoint_gateways/r134-d7cc5196-9864-48c4-82d8-3f30da41fcc5", "id": "r134-d7cc5196-9864-48c4-82d8-3f30da41fcc5", "name": "my-endpoint-gateway", "remote": {"account": {"id": "aa2432b1fa4d4ace891e9b80fc104e34", "resource_type": "account"}, "region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "endpoint_gateway"}], "health_reasons": [{"code": "disconnected_from_bound_vpc", "message": "The VPC specified in the DNS resolution binding has been disconnected.", "more_info": "https://cloud.ibm.com/docs/vpc?topic=vpc-troubleshoot-hub-spoke-1"}], "health_state": "ok", "href": "https://us-south.iaas.cloud.ibm.com/v1/vpcs/r006-982d72b7-db1b-4606-afb2-ed6bd4b0bed1/dns_resolution_bindings/r006-8a524686-fcf6-4947-a59b-188c1ed78ad1", "id": "r006-8a524686-fcf6-4947-a59b-188c1ed78ad1", "lifecycle_state": "stable", "name": "my-dns-resolution-binding", "resource_type": "vpc_dns_resolution_binding", "vpc": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::vpc:4727d842-f94f-4a2d-824a-9bc9b02c523b", "href": "https://us-south.iaas.cloud.ibm.com/v1/vpcs/4727d842-f94f-4a2d-824a-9bc9b02c523b", "id": "4727d842-f94f-4a2d-824a-9bc9b02c523b", "name": "my-vpc", "remote": {"account": {"id": "aa2432b1fa4d4ace891e9b80fc104e34", "resource_type": "account"}, "region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "vpc"}}`) })) }) It(`Invoke CreateVPCDnsResolutionBinding successfully with retries`, func() { @@ -4130,7 +4130,7 @@ var _ = Describe(`VpcV1`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(201) - fmt.Fprintf(res, "%s", `{"created_at": "2019-01-01T12:00:00.000Z", "endpoint_gateways": [{"crn": "crn:v1:bluemix:public:is:us-south:a/123456::endpoint-gateway:r134-d7cc5196-9864-48c4-82d8-3f30da41fcc5", "href": "https://us-south.iaas.cloud.ibm.com/v1/endpoint_gateways/r134-d7cc5196-9864-48c4-82d8-3f30da41fcc5", "id": "r134-d7cc5196-9864-48c4-82d8-3f30da41fcc5", "name": "my-endpoint-gateway", "remote": {"account": {"id": "aa2432b1fa4d4ace891e9b80fc104e34", "resource_type": "account"}, "region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "endpoint_gateway"}], "href": "https://us-south.iaas.cloud.ibm.com/v1/vpcs/r006-982d72b7-db1b-4606-afb2-ed6bd4b0bed1/dns_resolution_bindings/r006-8a524686-fcf6-4947-a59b-188c1ed78ad1", "id": "r006-8a524686-fcf6-4947-a59b-188c1ed78ad1", "lifecycle_state": "stable", "name": "my-dns-resolution-binding", "resource_type": "vpc_dns_resolution_binding", "vpc": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::vpc:4727d842-f94f-4a2d-824a-9bc9b02c523b", "href": "https://us-south.iaas.cloud.ibm.com/v1/vpcs/4727d842-f94f-4a2d-824a-9bc9b02c523b", "id": "4727d842-f94f-4a2d-824a-9bc9b02c523b", "name": "my-vpc", "remote": {"account": {"id": "aa2432b1fa4d4ace891e9b80fc104e34", "resource_type": "account"}, "region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "vpc"}}`) + fmt.Fprintf(res, "%s", `{"created_at": "2019-01-01T12:00:00.000Z", "endpoint_gateways": [{"crn": "crn:v1:bluemix:public:is:us-south:a/123456::endpoint-gateway:r134-d7cc5196-9864-48c4-82d8-3f30da41fcc5", "href": "https://us-south.iaas.cloud.ibm.com/v1/endpoint_gateways/r134-d7cc5196-9864-48c4-82d8-3f30da41fcc5", "id": "r134-d7cc5196-9864-48c4-82d8-3f30da41fcc5", "name": "my-endpoint-gateway", "remote": {"account": {"id": "aa2432b1fa4d4ace891e9b80fc104e34", "resource_type": "account"}, "region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "endpoint_gateway"}], "health_reasons": [{"code": "disconnected_from_bound_vpc", "message": "The VPC specified in the DNS resolution binding has been disconnected.", "more_info": "https://cloud.ibm.com/docs/vpc?topic=vpc-troubleshoot-hub-spoke-1"}], "health_state": "ok", "href": "https://us-south.iaas.cloud.ibm.com/v1/vpcs/r006-982d72b7-db1b-4606-afb2-ed6bd4b0bed1/dns_resolution_bindings/r006-8a524686-fcf6-4947-a59b-188c1ed78ad1", "id": "r006-8a524686-fcf6-4947-a59b-188c1ed78ad1", "lifecycle_state": "stable", "name": "my-dns-resolution-binding", "resource_type": "vpc_dns_resolution_binding", "vpc": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::vpc:4727d842-f94f-4a2d-824a-9bc9b02c523b", "href": "https://us-south.iaas.cloud.ibm.com/v1/vpcs/4727d842-f94f-4a2d-824a-9bc9b02c523b", "id": "4727d842-f94f-4a2d-824a-9bc9b02c523b", "name": "my-vpc", "remote": {"account": {"id": "aa2432b1fa4d4ace891e9b80fc104e34", "resource_type": "account"}, "region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "vpc"}}`) })) }) It(`Invoke CreateVPCDnsResolutionBinding successfully`, func() { @@ -4317,7 +4317,7 @@ var _ = Describe(`VpcV1`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(202) - fmt.Fprintf(res, "%s", `{"created_at": "2019-01-01T12:00:00.000Z", "endpoint_gateways": [{"crn": "crn:v1:bluemix:public:is:us-south:a/123456::endpoint-gateway:r134-d7cc5196-9864-48c4-82d8-3f30da41fcc5", "href": "https://us-south.iaas.cloud.ibm.com/v1/endpoint_gateways/r134-d7cc5196-9864-48c4-82d8-3f30da41fcc5", "id": "r134-d7cc5196-9864-48c4-82d8-3f30da41fcc5", "name": "my-endpoint-gateway", "remote": {"account": {"id": "aa2432b1fa4d4ace891e9b80fc104e34", "resource_type": "account"}, "region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "endpoint_gateway"}], "href": "https://us-south.iaas.cloud.ibm.com/v1/vpcs/r006-982d72b7-db1b-4606-afb2-ed6bd4b0bed1/dns_resolution_bindings/r006-8a524686-fcf6-4947-a59b-188c1ed78ad1", "id": "r006-8a524686-fcf6-4947-a59b-188c1ed78ad1", "lifecycle_state": "stable", "name": "my-dns-resolution-binding", "resource_type": "vpc_dns_resolution_binding", "vpc": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::vpc:4727d842-f94f-4a2d-824a-9bc9b02c523b", "href": "https://us-south.iaas.cloud.ibm.com/v1/vpcs/4727d842-f94f-4a2d-824a-9bc9b02c523b", "id": "4727d842-f94f-4a2d-824a-9bc9b02c523b", "name": "my-vpc", "remote": {"account": {"id": "aa2432b1fa4d4ace891e9b80fc104e34", "resource_type": "account"}, "region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "vpc"}}`) + fmt.Fprintf(res, "%s", `{"created_at": "2019-01-01T12:00:00.000Z", "endpoint_gateways": [{"crn": "crn:v1:bluemix:public:is:us-south:a/123456::endpoint-gateway:r134-d7cc5196-9864-48c4-82d8-3f30da41fcc5", "href": "https://us-south.iaas.cloud.ibm.com/v1/endpoint_gateways/r134-d7cc5196-9864-48c4-82d8-3f30da41fcc5", "id": "r134-d7cc5196-9864-48c4-82d8-3f30da41fcc5", "name": "my-endpoint-gateway", "remote": {"account": {"id": "aa2432b1fa4d4ace891e9b80fc104e34", "resource_type": "account"}, "region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "endpoint_gateway"}], "health_reasons": [{"code": "disconnected_from_bound_vpc", "message": "The VPC specified in the DNS resolution binding has been disconnected.", "more_info": "https://cloud.ibm.com/docs/vpc?topic=vpc-troubleshoot-hub-spoke-1"}], "health_state": "ok", "href": "https://us-south.iaas.cloud.ibm.com/v1/vpcs/r006-982d72b7-db1b-4606-afb2-ed6bd4b0bed1/dns_resolution_bindings/r006-8a524686-fcf6-4947-a59b-188c1ed78ad1", "id": "r006-8a524686-fcf6-4947-a59b-188c1ed78ad1", "lifecycle_state": "stable", "name": "my-dns-resolution-binding", "resource_type": "vpc_dns_resolution_binding", "vpc": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::vpc:4727d842-f94f-4a2d-824a-9bc9b02c523b", "href": "https://us-south.iaas.cloud.ibm.com/v1/vpcs/4727d842-f94f-4a2d-824a-9bc9b02c523b", "id": "4727d842-f94f-4a2d-824a-9bc9b02c523b", "name": "my-vpc", "remote": {"account": {"id": "aa2432b1fa4d4ace891e9b80fc104e34", "resource_type": "account"}, "region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "vpc"}}`) })) }) It(`Invoke DeleteVPCDnsResolutionBinding successfully with retries`, func() { @@ -4375,7 +4375,7 @@ var _ = Describe(`VpcV1`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(202) - fmt.Fprintf(res, "%s", `{"created_at": "2019-01-01T12:00:00.000Z", "endpoint_gateways": [{"crn": "crn:v1:bluemix:public:is:us-south:a/123456::endpoint-gateway:r134-d7cc5196-9864-48c4-82d8-3f30da41fcc5", "href": "https://us-south.iaas.cloud.ibm.com/v1/endpoint_gateways/r134-d7cc5196-9864-48c4-82d8-3f30da41fcc5", "id": "r134-d7cc5196-9864-48c4-82d8-3f30da41fcc5", "name": "my-endpoint-gateway", "remote": {"account": {"id": "aa2432b1fa4d4ace891e9b80fc104e34", "resource_type": "account"}, "region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "endpoint_gateway"}], "href": "https://us-south.iaas.cloud.ibm.com/v1/vpcs/r006-982d72b7-db1b-4606-afb2-ed6bd4b0bed1/dns_resolution_bindings/r006-8a524686-fcf6-4947-a59b-188c1ed78ad1", "id": "r006-8a524686-fcf6-4947-a59b-188c1ed78ad1", "lifecycle_state": "stable", "name": "my-dns-resolution-binding", "resource_type": "vpc_dns_resolution_binding", "vpc": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::vpc:4727d842-f94f-4a2d-824a-9bc9b02c523b", "href": "https://us-south.iaas.cloud.ibm.com/v1/vpcs/4727d842-f94f-4a2d-824a-9bc9b02c523b", "id": "4727d842-f94f-4a2d-824a-9bc9b02c523b", "name": "my-vpc", "remote": {"account": {"id": "aa2432b1fa4d4ace891e9b80fc104e34", "resource_type": "account"}, "region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "vpc"}}`) + fmt.Fprintf(res, "%s", `{"created_at": "2019-01-01T12:00:00.000Z", "endpoint_gateways": [{"crn": "crn:v1:bluemix:public:is:us-south:a/123456::endpoint-gateway:r134-d7cc5196-9864-48c4-82d8-3f30da41fcc5", "href": "https://us-south.iaas.cloud.ibm.com/v1/endpoint_gateways/r134-d7cc5196-9864-48c4-82d8-3f30da41fcc5", "id": "r134-d7cc5196-9864-48c4-82d8-3f30da41fcc5", "name": "my-endpoint-gateway", "remote": {"account": {"id": "aa2432b1fa4d4ace891e9b80fc104e34", "resource_type": "account"}, "region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "endpoint_gateway"}], "health_reasons": [{"code": "disconnected_from_bound_vpc", "message": "The VPC specified in the DNS resolution binding has been disconnected.", "more_info": "https://cloud.ibm.com/docs/vpc?topic=vpc-troubleshoot-hub-spoke-1"}], "health_state": "ok", "href": "https://us-south.iaas.cloud.ibm.com/v1/vpcs/r006-982d72b7-db1b-4606-afb2-ed6bd4b0bed1/dns_resolution_bindings/r006-8a524686-fcf6-4947-a59b-188c1ed78ad1", "id": "r006-8a524686-fcf6-4947-a59b-188c1ed78ad1", "lifecycle_state": "stable", "name": "my-dns-resolution-binding", "resource_type": "vpc_dns_resolution_binding", "vpc": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::vpc:4727d842-f94f-4a2d-824a-9bc9b02c523b", "href": "https://us-south.iaas.cloud.ibm.com/v1/vpcs/4727d842-f94f-4a2d-824a-9bc9b02c523b", "id": "4727d842-f94f-4a2d-824a-9bc9b02c523b", "name": "my-vpc", "remote": {"account": {"id": "aa2432b1fa4d4ace891e9b80fc104e34", "resource_type": "account"}, "region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "vpc"}}`) })) }) It(`Invoke DeleteVPCDnsResolutionBinding successfully`, func() { @@ -4547,7 +4547,7 @@ var _ = Describe(`VpcV1`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"created_at": "2019-01-01T12:00:00.000Z", "endpoint_gateways": [{"crn": "crn:v1:bluemix:public:is:us-south:a/123456::endpoint-gateway:r134-d7cc5196-9864-48c4-82d8-3f30da41fcc5", "href": "https://us-south.iaas.cloud.ibm.com/v1/endpoint_gateways/r134-d7cc5196-9864-48c4-82d8-3f30da41fcc5", "id": "r134-d7cc5196-9864-48c4-82d8-3f30da41fcc5", "name": "my-endpoint-gateway", "remote": {"account": {"id": "aa2432b1fa4d4ace891e9b80fc104e34", "resource_type": "account"}, "region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "endpoint_gateway"}], "href": "https://us-south.iaas.cloud.ibm.com/v1/vpcs/r006-982d72b7-db1b-4606-afb2-ed6bd4b0bed1/dns_resolution_bindings/r006-8a524686-fcf6-4947-a59b-188c1ed78ad1", "id": "r006-8a524686-fcf6-4947-a59b-188c1ed78ad1", "lifecycle_state": "stable", "name": "my-dns-resolution-binding", "resource_type": "vpc_dns_resolution_binding", "vpc": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::vpc:4727d842-f94f-4a2d-824a-9bc9b02c523b", "href": "https://us-south.iaas.cloud.ibm.com/v1/vpcs/4727d842-f94f-4a2d-824a-9bc9b02c523b", "id": "4727d842-f94f-4a2d-824a-9bc9b02c523b", "name": "my-vpc", "remote": {"account": {"id": "aa2432b1fa4d4ace891e9b80fc104e34", "resource_type": "account"}, "region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "vpc"}}`) + fmt.Fprintf(res, "%s", `{"created_at": "2019-01-01T12:00:00.000Z", "endpoint_gateways": [{"crn": "crn:v1:bluemix:public:is:us-south:a/123456::endpoint-gateway:r134-d7cc5196-9864-48c4-82d8-3f30da41fcc5", "href": "https://us-south.iaas.cloud.ibm.com/v1/endpoint_gateways/r134-d7cc5196-9864-48c4-82d8-3f30da41fcc5", "id": "r134-d7cc5196-9864-48c4-82d8-3f30da41fcc5", "name": "my-endpoint-gateway", "remote": {"account": {"id": "aa2432b1fa4d4ace891e9b80fc104e34", "resource_type": "account"}, "region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "endpoint_gateway"}], "health_reasons": [{"code": "disconnected_from_bound_vpc", "message": "The VPC specified in the DNS resolution binding has been disconnected.", "more_info": "https://cloud.ibm.com/docs/vpc?topic=vpc-troubleshoot-hub-spoke-1"}], "health_state": "ok", "href": "https://us-south.iaas.cloud.ibm.com/v1/vpcs/r006-982d72b7-db1b-4606-afb2-ed6bd4b0bed1/dns_resolution_bindings/r006-8a524686-fcf6-4947-a59b-188c1ed78ad1", "id": "r006-8a524686-fcf6-4947-a59b-188c1ed78ad1", "lifecycle_state": "stable", "name": "my-dns-resolution-binding", "resource_type": "vpc_dns_resolution_binding", "vpc": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::vpc:4727d842-f94f-4a2d-824a-9bc9b02c523b", "href": "https://us-south.iaas.cloud.ibm.com/v1/vpcs/4727d842-f94f-4a2d-824a-9bc9b02c523b", "id": "4727d842-f94f-4a2d-824a-9bc9b02c523b", "name": "my-vpc", "remote": {"account": {"id": "aa2432b1fa4d4ace891e9b80fc104e34", "resource_type": "account"}, "region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "vpc"}}`) })) }) It(`Invoke GetVPCDnsResolutionBinding successfully with retries`, func() { @@ -4605,7 +4605,7 @@ var _ = Describe(`VpcV1`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"created_at": "2019-01-01T12:00:00.000Z", "endpoint_gateways": [{"crn": "crn:v1:bluemix:public:is:us-south:a/123456::endpoint-gateway:r134-d7cc5196-9864-48c4-82d8-3f30da41fcc5", "href": "https://us-south.iaas.cloud.ibm.com/v1/endpoint_gateways/r134-d7cc5196-9864-48c4-82d8-3f30da41fcc5", "id": "r134-d7cc5196-9864-48c4-82d8-3f30da41fcc5", "name": "my-endpoint-gateway", "remote": {"account": {"id": "aa2432b1fa4d4ace891e9b80fc104e34", "resource_type": "account"}, "region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "endpoint_gateway"}], "href": "https://us-south.iaas.cloud.ibm.com/v1/vpcs/r006-982d72b7-db1b-4606-afb2-ed6bd4b0bed1/dns_resolution_bindings/r006-8a524686-fcf6-4947-a59b-188c1ed78ad1", "id": "r006-8a524686-fcf6-4947-a59b-188c1ed78ad1", "lifecycle_state": "stable", "name": "my-dns-resolution-binding", "resource_type": "vpc_dns_resolution_binding", "vpc": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::vpc:4727d842-f94f-4a2d-824a-9bc9b02c523b", "href": "https://us-south.iaas.cloud.ibm.com/v1/vpcs/4727d842-f94f-4a2d-824a-9bc9b02c523b", "id": "4727d842-f94f-4a2d-824a-9bc9b02c523b", "name": "my-vpc", "remote": {"account": {"id": "aa2432b1fa4d4ace891e9b80fc104e34", "resource_type": "account"}, "region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "vpc"}}`) + fmt.Fprintf(res, "%s", `{"created_at": "2019-01-01T12:00:00.000Z", "endpoint_gateways": [{"crn": "crn:v1:bluemix:public:is:us-south:a/123456::endpoint-gateway:r134-d7cc5196-9864-48c4-82d8-3f30da41fcc5", "href": "https://us-south.iaas.cloud.ibm.com/v1/endpoint_gateways/r134-d7cc5196-9864-48c4-82d8-3f30da41fcc5", "id": "r134-d7cc5196-9864-48c4-82d8-3f30da41fcc5", "name": "my-endpoint-gateway", "remote": {"account": {"id": "aa2432b1fa4d4ace891e9b80fc104e34", "resource_type": "account"}, "region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "endpoint_gateway"}], "health_reasons": [{"code": "disconnected_from_bound_vpc", "message": "The VPC specified in the DNS resolution binding has been disconnected.", "more_info": "https://cloud.ibm.com/docs/vpc?topic=vpc-troubleshoot-hub-spoke-1"}], "health_state": "ok", "href": "https://us-south.iaas.cloud.ibm.com/v1/vpcs/r006-982d72b7-db1b-4606-afb2-ed6bd4b0bed1/dns_resolution_bindings/r006-8a524686-fcf6-4947-a59b-188c1ed78ad1", "id": "r006-8a524686-fcf6-4947-a59b-188c1ed78ad1", "lifecycle_state": "stable", "name": "my-dns-resolution-binding", "resource_type": "vpc_dns_resolution_binding", "vpc": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::vpc:4727d842-f94f-4a2d-824a-9bc9b02c523b", "href": "https://us-south.iaas.cloud.ibm.com/v1/vpcs/4727d842-f94f-4a2d-824a-9bc9b02c523b", "id": "4727d842-f94f-4a2d-824a-9bc9b02c523b", "name": "my-vpc", "remote": {"account": {"id": "aa2432b1fa4d4ace891e9b80fc104e34", "resource_type": "account"}, "region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "vpc"}}`) })) }) It(`Invoke GetVPCDnsResolutionBinding successfully`, func() { @@ -4800,7 +4800,7 @@ var _ = Describe(`VpcV1`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"created_at": "2019-01-01T12:00:00.000Z", "endpoint_gateways": [{"crn": "crn:v1:bluemix:public:is:us-south:a/123456::endpoint-gateway:r134-d7cc5196-9864-48c4-82d8-3f30da41fcc5", "href": "https://us-south.iaas.cloud.ibm.com/v1/endpoint_gateways/r134-d7cc5196-9864-48c4-82d8-3f30da41fcc5", "id": "r134-d7cc5196-9864-48c4-82d8-3f30da41fcc5", "name": "my-endpoint-gateway", "remote": {"account": {"id": "aa2432b1fa4d4ace891e9b80fc104e34", "resource_type": "account"}, "region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "endpoint_gateway"}], "href": "https://us-south.iaas.cloud.ibm.com/v1/vpcs/r006-982d72b7-db1b-4606-afb2-ed6bd4b0bed1/dns_resolution_bindings/r006-8a524686-fcf6-4947-a59b-188c1ed78ad1", "id": "r006-8a524686-fcf6-4947-a59b-188c1ed78ad1", "lifecycle_state": "stable", "name": "my-dns-resolution-binding", "resource_type": "vpc_dns_resolution_binding", "vpc": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::vpc:4727d842-f94f-4a2d-824a-9bc9b02c523b", "href": "https://us-south.iaas.cloud.ibm.com/v1/vpcs/4727d842-f94f-4a2d-824a-9bc9b02c523b", "id": "4727d842-f94f-4a2d-824a-9bc9b02c523b", "name": "my-vpc", "remote": {"account": {"id": "aa2432b1fa4d4ace891e9b80fc104e34", "resource_type": "account"}, "region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "vpc"}}`) + fmt.Fprintf(res, "%s", `{"created_at": "2019-01-01T12:00:00.000Z", "endpoint_gateways": [{"crn": "crn:v1:bluemix:public:is:us-south:a/123456::endpoint-gateway:r134-d7cc5196-9864-48c4-82d8-3f30da41fcc5", "href": "https://us-south.iaas.cloud.ibm.com/v1/endpoint_gateways/r134-d7cc5196-9864-48c4-82d8-3f30da41fcc5", "id": "r134-d7cc5196-9864-48c4-82d8-3f30da41fcc5", "name": "my-endpoint-gateway", "remote": {"account": {"id": "aa2432b1fa4d4ace891e9b80fc104e34", "resource_type": "account"}, "region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "endpoint_gateway"}], "health_reasons": [{"code": "disconnected_from_bound_vpc", "message": "The VPC specified in the DNS resolution binding has been disconnected.", "more_info": "https://cloud.ibm.com/docs/vpc?topic=vpc-troubleshoot-hub-spoke-1"}], "health_state": "ok", "href": "https://us-south.iaas.cloud.ibm.com/v1/vpcs/r006-982d72b7-db1b-4606-afb2-ed6bd4b0bed1/dns_resolution_bindings/r006-8a524686-fcf6-4947-a59b-188c1ed78ad1", "id": "r006-8a524686-fcf6-4947-a59b-188c1ed78ad1", "lifecycle_state": "stable", "name": "my-dns-resolution-binding", "resource_type": "vpc_dns_resolution_binding", "vpc": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::vpc:4727d842-f94f-4a2d-824a-9bc9b02c523b", "href": "https://us-south.iaas.cloud.ibm.com/v1/vpcs/4727d842-f94f-4a2d-824a-9bc9b02c523b", "id": "4727d842-f94f-4a2d-824a-9bc9b02c523b", "name": "my-vpc", "remote": {"account": {"id": "aa2432b1fa4d4ace891e9b80fc104e34", "resource_type": "account"}, "region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "vpc"}}`) })) }) It(`Invoke UpdateVPCDnsResolutionBinding successfully with retries`, func() { @@ -4881,7 +4881,7 @@ var _ = Describe(`VpcV1`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"created_at": "2019-01-01T12:00:00.000Z", "endpoint_gateways": [{"crn": "crn:v1:bluemix:public:is:us-south:a/123456::endpoint-gateway:r134-d7cc5196-9864-48c4-82d8-3f30da41fcc5", "href": "https://us-south.iaas.cloud.ibm.com/v1/endpoint_gateways/r134-d7cc5196-9864-48c4-82d8-3f30da41fcc5", "id": "r134-d7cc5196-9864-48c4-82d8-3f30da41fcc5", "name": "my-endpoint-gateway", "remote": {"account": {"id": "aa2432b1fa4d4ace891e9b80fc104e34", "resource_type": "account"}, "region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "endpoint_gateway"}], "href": "https://us-south.iaas.cloud.ibm.com/v1/vpcs/r006-982d72b7-db1b-4606-afb2-ed6bd4b0bed1/dns_resolution_bindings/r006-8a524686-fcf6-4947-a59b-188c1ed78ad1", "id": "r006-8a524686-fcf6-4947-a59b-188c1ed78ad1", "lifecycle_state": "stable", "name": "my-dns-resolution-binding", "resource_type": "vpc_dns_resolution_binding", "vpc": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::vpc:4727d842-f94f-4a2d-824a-9bc9b02c523b", "href": "https://us-south.iaas.cloud.ibm.com/v1/vpcs/4727d842-f94f-4a2d-824a-9bc9b02c523b", "id": "4727d842-f94f-4a2d-824a-9bc9b02c523b", "name": "my-vpc", "remote": {"account": {"id": "aa2432b1fa4d4ace891e9b80fc104e34", "resource_type": "account"}, "region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "vpc"}}`) + fmt.Fprintf(res, "%s", `{"created_at": "2019-01-01T12:00:00.000Z", "endpoint_gateways": [{"crn": "crn:v1:bluemix:public:is:us-south:a/123456::endpoint-gateway:r134-d7cc5196-9864-48c4-82d8-3f30da41fcc5", "href": "https://us-south.iaas.cloud.ibm.com/v1/endpoint_gateways/r134-d7cc5196-9864-48c4-82d8-3f30da41fcc5", "id": "r134-d7cc5196-9864-48c4-82d8-3f30da41fcc5", "name": "my-endpoint-gateway", "remote": {"account": {"id": "aa2432b1fa4d4ace891e9b80fc104e34", "resource_type": "account"}, "region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "endpoint_gateway"}], "health_reasons": [{"code": "disconnected_from_bound_vpc", "message": "The VPC specified in the DNS resolution binding has been disconnected.", "more_info": "https://cloud.ibm.com/docs/vpc?topic=vpc-troubleshoot-hub-spoke-1"}], "health_state": "ok", "href": "https://us-south.iaas.cloud.ibm.com/v1/vpcs/r006-982d72b7-db1b-4606-afb2-ed6bd4b0bed1/dns_resolution_bindings/r006-8a524686-fcf6-4947-a59b-188c1ed78ad1", "id": "r006-8a524686-fcf6-4947-a59b-188c1ed78ad1", "lifecycle_state": "stable", "name": "my-dns-resolution-binding", "resource_type": "vpc_dns_resolution_binding", "vpc": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::vpc:4727d842-f94f-4a2d-824a-9bc9b02c523b", "href": "https://us-south.iaas.cloud.ibm.com/v1/vpcs/4727d842-f94f-4a2d-824a-9bc9b02c523b", "id": "4727d842-f94f-4a2d-824a-9bc9b02c523b", "name": "my-vpc", "remote": {"account": {"id": "aa2432b1fa4d4ace891e9b80fc104e34", "resource_type": "account"}, "region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "vpc"}}`) })) }) It(`Invoke UpdateVPCDnsResolutionBinding successfully`, func() { @@ -6405,7 +6405,7 @@ var _ = Describe(`VpcV1`, func() { // 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/vpcs/982d72b7-db1b-4606-afb2-ed6bd4b0bed1/routing_tables?limit=20"}, "limit": 20, "next": {"href": "https://us-south.iaas.cloud.ibm.com/v1/vpcs/982d72b7-db1b-4606-afb2-ed6bd4b0bed1/routing_tables?start=9d5a91a3e2cbd233b5a5b33436855ed1&limit=20"}, "routing_tables": [{"accept_routes_from": [{"resource_type": "vpn_gateway"}], "advertise_routes_to": ["transit_gateway"], "created_at": "2019-01-01T12:00:00.000Z", "href": "https://us-south.iaas.cloud.ibm.com/v1/vpcs/982d72b7-db1b-4606-afb2-ed6bd4b0bed1/routing_tables/6885e83f-03b2-4603-8a86-db2a0f55c840", "id": "1a15dca5-7e33-45e1-b7c5-bc690e569531", "is_default": false, "lifecycle_state": "stable", "name": "my-routing-table-1", "resource_type": "routing_table", "route_direct_link_ingress": true, "route_internet_ingress": true, "route_transit_gateway_ingress": true, "route_vpc_zone_ingress": false, "routes": [{"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/vpcs/8e454ead-0db7-48ac-9a8b-2698d8c470a7/routing_tables/6885e83f-03b2-4603-8a86-db2a0f55c840/routes/1a15dca5-7e33-45e1-b7c5-bc690e569531", "id": "1a15dca5-7e33-45e1-b7c5-bc690e569531", "name": "my-route-1"}], "subnets": [{"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "id": "7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "name": "my-subnet", "resource_type": "subnet"}]}], "total_count": 132}`) + fmt.Fprintf(res, "%s", `{"first": {"href": "https://us-south.iaas.cloud.ibm.com/v1/vpcs/982d72b7-db1b-4606-afb2-ed6bd4b0bed1/routing_tables?limit=20"}, "limit": 20, "next": {"href": "https://us-south.iaas.cloud.ibm.com/v1/vpcs/982d72b7-db1b-4606-afb2-ed6bd4b0bed1/routing_tables?start=9d5a91a3e2cbd233b5a5b33436855ed1&limit=20"}, "routing_tables": [{"accept_routes_from": [{"resource_type": "vpn_server"}], "advertise_routes_to": ["transit_gateway"], "created_at": "2019-01-01T12:00:00.000Z", "href": "https://us-south.iaas.cloud.ibm.com/v1/vpcs/982d72b7-db1b-4606-afb2-ed6bd4b0bed1/routing_tables/6885e83f-03b2-4603-8a86-db2a0f55c840", "id": "1a15dca5-7e33-45e1-b7c5-bc690e569531", "is_default": false, "lifecycle_state": "stable", "name": "my-routing-table-1", "resource_type": "routing_table", "route_direct_link_ingress": true, "route_internet_ingress": true, "route_transit_gateway_ingress": true, "route_vpc_zone_ingress": false, "routes": [{"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/vpcs/8e454ead-0db7-48ac-9a8b-2698d8c470a7/routing_tables/6885e83f-03b2-4603-8a86-db2a0f55c840/routes/1a15dca5-7e33-45e1-b7c5-bc690e569531", "id": "1a15dca5-7e33-45e1-b7c5-bc690e569531", "name": "my-route-1"}], "subnets": [{"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "id": "7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "name": "my-subnet", "resource_type": "subnet"}]}], "total_count": 132}`) })) }) It(`Invoke ListVPCRoutingTables successfully with retries`, func() { @@ -6468,7 +6468,7 @@ var _ = Describe(`VpcV1`, func() { // 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/vpcs/982d72b7-db1b-4606-afb2-ed6bd4b0bed1/routing_tables?limit=20"}, "limit": 20, "next": {"href": "https://us-south.iaas.cloud.ibm.com/v1/vpcs/982d72b7-db1b-4606-afb2-ed6bd4b0bed1/routing_tables?start=9d5a91a3e2cbd233b5a5b33436855ed1&limit=20"}, "routing_tables": [{"accept_routes_from": [{"resource_type": "vpn_gateway"}], "advertise_routes_to": ["transit_gateway"], "created_at": "2019-01-01T12:00:00.000Z", "href": "https://us-south.iaas.cloud.ibm.com/v1/vpcs/982d72b7-db1b-4606-afb2-ed6bd4b0bed1/routing_tables/6885e83f-03b2-4603-8a86-db2a0f55c840", "id": "1a15dca5-7e33-45e1-b7c5-bc690e569531", "is_default": false, "lifecycle_state": "stable", "name": "my-routing-table-1", "resource_type": "routing_table", "route_direct_link_ingress": true, "route_internet_ingress": true, "route_transit_gateway_ingress": true, "route_vpc_zone_ingress": false, "routes": [{"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/vpcs/8e454ead-0db7-48ac-9a8b-2698d8c470a7/routing_tables/6885e83f-03b2-4603-8a86-db2a0f55c840/routes/1a15dca5-7e33-45e1-b7c5-bc690e569531", "id": "1a15dca5-7e33-45e1-b7c5-bc690e569531", "name": "my-route-1"}], "subnets": [{"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "id": "7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "name": "my-subnet", "resource_type": "subnet"}]}], "total_count": 132}`) + fmt.Fprintf(res, "%s", `{"first": {"href": "https://us-south.iaas.cloud.ibm.com/v1/vpcs/982d72b7-db1b-4606-afb2-ed6bd4b0bed1/routing_tables?limit=20"}, "limit": 20, "next": {"href": "https://us-south.iaas.cloud.ibm.com/v1/vpcs/982d72b7-db1b-4606-afb2-ed6bd4b0bed1/routing_tables?start=9d5a91a3e2cbd233b5a5b33436855ed1&limit=20"}, "routing_tables": [{"accept_routes_from": [{"resource_type": "vpn_server"}], "advertise_routes_to": ["transit_gateway"], "created_at": "2019-01-01T12:00:00.000Z", "href": "https://us-south.iaas.cloud.ibm.com/v1/vpcs/982d72b7-db1b-4606-afb2-ed6bd4b0bed1/routing_tables/6885e83f-03b2-4603-8a86-db2a0f55c840", "id": "1a15dca5-7e33-45e1-b7c5-bc690e569531", "is_default": false, "lifecycle_state": "stable", "name": "my-routing-table-1", "resource_type": "routing_table", "route_direct_link_ingress": true, "route_internet_ingress": true, "route_transit_gateway_ingress": true, "route_vpc_zone_ingress": false, "routes": [{"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/vpcs/8e454ead-0db7-48ac-9a8b-2698d8c470a7/routing_tables/6885e83f-03b2-4603-8a86-db2a0f55c840/routes/1a15dca5-7e33-45e1-b7c5-bc690e569531", "id": "1a15dca5-7e33-45e1-b7c5-bc690e569531", "name": "my-route-1"}], "subnets": [{"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "id": "7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "name": "my-subnet", "resource_type": "subnet"}]}], "total_count": 132}`) })) }) It(`Invoke ListVPCRoutingTables successfully`, func() { @@ -6619,9 +6619,9 @@ var _ = Describe(`VpcV1`, func() { res.WriteHeader(200) requestNumber++ if requestNumber == 1 { - fmt.Fprintf(res, "%s", `{"next":{"href":"https://myhost.com/somePath?start=1"},"routing_tables":[{"accept_routes_from":[{"resource_type":"vpn_gateway"}],"advertise_routes_to":["transit_gateway"],"created_at":"2019-01-01T12:00:00.000Z","href":"https://us-south.iaas.cloud.ibm.com/v1/vpcs/982d72b7-db1b-4606-afb2-ed6bd4b0bed1/routing_tables/6885e83f-03b2-4603-8a86-db2a0f55c840","id":"1a15dca5-7e33-45e1-b7c5-bc690e569531","is_default":false,"lifecycle_state":"stable","name":"my-routing-table-1","resource_type":"routing_table","route_direct_link_ingress":true,"route_internet_ingress":true,"route_transit_gateway_ingress":true,"route_vpc_zone_ingress":false,"routes":[{"deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/vpcs/8e454ead-0db7-48ac-9a8b-2698d8c470a7/routing_tables/6885e83f-03b2-4603-8a86-db2a0f55c840/routes/1a15dca5-7e33-45e1-b7c5-bc690e569531","id":"1a15dca5-7e33-45e1-b7c5-bc690e569531","name":"my-route-1"}],"subnets":[{"crn":"crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e","deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e","id":"7ec86020-1c6e-4889-b3f0-a15f2e50f87e","name":"my-subnet","resource_type":"subnet"}]}],"total_count":2,"limit":1}`) + fmt.Fprintf(res, "%s", `{"next":{"href":"https://myhost.com/somePath?start=1"},"routing_tables":[{"accept_routes_from":[{"resource_type":"vpn_server"}],"advertise_routes_to":["transit_gateway"],"created_at":"2019-01-01T12:00:00.000Z","href":"https://us-south.iaas.cloud.ibm.com/v1/vpcs/982d72b7-db1b-4606-afb2-ed6bd4b0bed1/routing_tables/6885e83f-03b2-4603-8a86-db2a0f55c840","id":"1a15dca5-7e33-45e1-b7c5-bc690e569531","is_default":false,"lifecycle_state":"stable","name":"my-routing-table-1","resource_type":"routing_table","route_direct_link_ingress":true,"route_internet_ingress":true,"route_transit_gateway_ingress":true,"route_vpc_zone_ingress":false,"routes":[{"deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/vpcs/8e454ead-0db7-48ac-9a8b-2698d8c470a7/routing_tables/6885e83f-03b2-4603-8a86-db2a0f55c840/routes/1a15dca5-7e33-45e1-b7c5-bc690e569531","id":"1a15dca5-7e33-45e1-b7c5-bc690e569531","name":"my-route-1"}],"subnets":[{"crn":"crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e","deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e","id":"7ec86020-1c6e-4889-b3f0-a15f2e50f87e","name":"my-subnet","resource_type":"subnet"}]}],"total_count":2,"limit":1}`) } else if requestNumber == 2 { - fmt.Fprintf(res, "%s", `{"routing_tables":[{"accept_routes_from":[{"resource_type":"vpn_gateway"}],"advertise_routes_to":["transit_gateway"],"created_at":"2019-01-01T12:00:00.000Z","href":"https://us-south.iaas.cloud.ibm.com/v1/vpcs/982d72b7-db1b-4606-afb2-ed6bd4b0bed1/routing_tables/6885e83f-03b2-4603-8a86-db2a0f55c840","id":"1a15dca5-7e33-45e1-b7c5-bc690e569531","is_default":false,"lifecycle_state":"stable","name":"my-routing-table-1","resource_type":"routing_table","route_direct_link_ingress":true,"route_internet_ingress":true,"route_transit_gateway_ingress":true,"route_vpc_zone_ingress":false,"routes":[{"deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/vpcs/8e454ead-0db7-48ac-9a8b-2698d8c470a7/routing_tables/6885e83f-03b2-4603-8a86-db2a0f55c840/routes/1a15dca5-7e33-45e1-b7c5-bc690e569531","id":"1a15dca5-7e33-45e1-b7c5-bc690e569531","name":"my-route-1"}],"subnets":[{"crn":"crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e","deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e","id":"7ec86020-1c6e-4889-b3f0-a15f2e50f87e","name":"my-subnet","resource_type":"subnet"}]}],"total_count":2,"limit":1}`) + fmt.Fprintf(res, "%s", `{"routing_tables":[{"accept_routes_from":[{"resource_type":"vpn_server"}],"advertise_routes_to":["transit_gateway"],"created_at":"2019-01-01T12:00:00.000Z","href":"https://us-south.iaas.cloud.ibm.com/v1/vpcs/982d72b7-db1b-4606-afb2-ed6bd4b0bed1/routing_tables/6885e83f-03b2-4603-8a86-db2a0f55c840","id":"1a15dca5-7e33-45e1-b7c5-bc690e569531","is_default":false,"lifecycle_state":"stable","name":"my-routing-table-1","resource_type":"routing_table","route_direct_link_ingress":true,"route_internet_ingress":true,"route_transit_gateway_ingress":true,"route_vpc_zone_ingress":false,"routes":[{"deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/vpcs/8e454ead-0db7-48ac-9a8b-2698d8c470a7/routing_tables/6885e83f-03b2-4603-8a86-db2a0f55c840/routes/1a15dca5-7e33-45e1-b7c5-bc690e569531","id":"1a15dca5-7e33-45e1-b7c5-bc690e569531","name":"my-route-1"}],"subnets":[{"crn":"crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e","deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e","id":"7ec86020-1c6e-4889-b3f0-a15f2e50f87e","name":"my-subnet","resource_type":"subnet"}]}],"total_count":2,"limit":1}`) } else { res.WriteHeader(400) } @@ -6796,7 +6796,7 @@ var _ = Describe(`VpcV1`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(201) - fmt.Fprintf(res, "%s", `{"accept_routes_from": [{"resource_type": "vpn_gateway"}], "advertise_routes_to": ["transit_gateway"], "created_at": "2019-01-01T12:00:00.000Z", "href": "https://us-south.iaas.cloud.ibm.com/v1/vpcs/982d72b7-db1b-4606-afb2-ed6bd4b0bed1/routing_tables/6885e83f-03b2-4603-8a86-db2a0f55c840", "id": "1a15dca5-7e33-45e1-b7c5-bc690e569531", "is_default": false, "lifecycle_state": "stable", "name": "my-routing-table-1", "resource_type": "routing_table", "route_direct_link_ingress": true, "route_internet_ingress": true, "route_transit_gateway_ingress": true, "route_vpc_zone_ingress": false, "routes": [{"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/vpcs/8e454ead-0db7-48ac-9a8b-2698d8c470a7/routing_tables/6885e83f-03b2-4603-8a86-db2a0f55c840/routes/1a15dca5-7e33-45e1-b7c5-bc690e569531", "id": "1a15dca5-7e33-45e1-b7c5-bc690e569531", "name": "my-route-1"}], "subnets": [{"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "id": "7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "name": "my-subnet", "resource_type": "subnet"}]}`) + fmt.Fprintf(res, "%s", `{"accept_routes_from": [{"resource_type": "vpn_server"}], "advertise_routes_to": ["transit_gateway"], "created_at": "2019-01-01T12:00:00.000Z", "href": "https://us-south.iaas.cloud.ibm.com/v1/vpcs/982d72b7-db1b-4606-afb2-ed6bd4b0bed1/routing_tables/6885e83f-03b2-4603-8a86-db2a0f55c840", "id": "1a15dca5-7e33-45e1-b7c5-bc690e569531", "is_default": false, "lifecycle_state": "stable", "name": "my-routing-table-1", "resource_type": "routing_table", "route_direct_link_ingress": true, "route_internet_ingress": true, "route_transit_gateway_ingress": true, "route_vpc_zone_ingress": false, "routes": [{"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/vpcs/8e454ead-0db7-48ac-9a8b-2698d8c470a7/routing_tables/6885e83f-03b2-4603-8a86-db2a0f55c840/routes/1a15dca5-7e33-45e1-b7c5-bc690e569531", "id": "1a15dca5-7e33-45e1-b7c5-bc690e569531", "name": "my-route-1"}], "subnets": [{"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "id": "7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "name": "my-subnet", "resource_type": "subnet"}]}`) })) }) It(`Invoke CreateVPCRoutingTable successfully with retries`, func() { @@ -6899,7 +6899,7 @@ var _ = Describe(`VpcV1`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(201) - fmt.Fprintf(res, "%s", `{"accept_routes_from": [{"resource_type": "vpn_gateway"}], "advertise_routes_to": ["transit_gateway"], "created_at": "2019-01-01T12:00:00.000Z", "href": "https://us-south.iaas.cloud.ibm.com/v1/vpcs/982d72b7-db1b-4606-afb2-ed6bd4b0bed1/routing_tables/6885e83f-03b2-4603-8a86-db2a0f55c840", "id": "1a15dca5-7e33-45e1-b7c5-bc690e569531", "is_default": false, "lifecycle_state": "stable", "name": "my-routing-table-1", "resource_type": "routing_table", "route_direct_link_ingress": true, "route_internet_ingress": true, "route_transit_gateway_ingress": true, "route_vpc_zone_ingress": false, "routes": [{"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/vpcs/8e454ead-0db7-48ac-9a8b-2698d8c470a7/routing_tables/6885e83f-03b2-4603-8a86-db2a0f55c840/routes/1a15dca5-7e33-45e1-b7c5-bc690e569531", "id": "1a15dca5-7e33-45e1-b7c5-bc690e569531", "name": "my-route-1"}], "subnets": [{"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "id": "7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "name": "my-subnet", "resource_type": "subnet"}]}`) + fmt.Fprintf(res, "%s", `{"accept_routes_from": [{"resource_type": "vpn_server"}], "advertise_routes_to": ["transit_gateway"], "created_at": "2019-01-01T12:00:00.000Z", "href": "https://us-south.iaas.cloud.ibm.com/v1/vpcs/982d72b7-db1b-4606-afb2-ed6bd4b0bed1/routing_tables/6885e83f-03b2-4603-8a86-db2a0f55c840", "id": "1a15dca5-7e33-45e1-b7c5-bc690e569531", "is_default": false, "lifecycle_state": "stable", "name": "my-routing-table-1", "resource_type": "routing_table", "route_direct_link_ingress": true, "route_internet_ingress": true, "route_transit_gateway_ingress": true, "route_vpc_zone_ingress": false, "routes": [{"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/vpcs/8e454ead-0db7-48ac-9a8b-2698d8c470a7/routing_tables/6885e83f-03b2-4603-8a86-db2a0f55c840/routes/1a15dca5-7e33-45e1-b7c5-bc690e569531", "id": "1a15dca5-7e33-45e1-b7c5-bc690e569531", "name": "my-route-1"}], "subnets": [{"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "id": "7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "name": "my-subnet", "resource_type": "subnet"}]}`) })) }) It(`Invoke CreateVPCRoutingTable successfully`, func() { @@ -7101,7 +7101,7 @@ var _ = Describe(`VpcV1`, func() { 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.Header["If-Match"][0]).To(Equal(fmt.Sprintf("%v", "W/\"96d225c4-56bd-43d9-98fc-d7148e5c5028\""))) Expect(req.URL.Query()["version"]).To(Equal([]string{"testString"})) Expect(req.URL.Query()["generation"]).To(Equal([]string{fmt.Sprint(int64(2))})) res.WriteHeader(204) @@ -7125,7 +7125,7 @@ var _ = Describe(`VpcV1`, func() { deleteVPCRoutingTableOptionsModel := new(vpcv1.DeleteVPCRoutingTableOptions) deleteVPCRoutingTableOptionsModel.VPCID = core.StringPtr("testString") deleteVPCRoutingTableOptionsModel.ID = core.StringPtr("testString") - deleteVPCRoutingTableOptionsModel.IfMatch = core.StringPtr(`W/"96d225c4-56bd-43d9-98fc-d7148e5c5028"`) + deleteVPCRoutingTableOptionsModel.IfMatch = core.StringPtr("W/\"96d225c4-56bd-43d9-98fc-d7148e5c5028\"") deleteVPCRoutingTableOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with valid options model (positive test) @@ -7146,7 +7146,7 @@ var _ = Describe(`VpcV1`, func() { deleteVPCRoutingTableOptionsModel := new(vpcv1.DeleteVPCRoutingTableOptions) deleteVPCRoutingTableOptionsModel.VPCID = core.StringPtr("testString") deleteVPCRoutingTableOptionsModel.ID = core.StringPtr("testString") - deleteVPCRoutingTableOptionsModel.IfMatch = core.StringPtr(`W/"96d225c4-56bd-43d9-98fc-d7148e5c5028"`) + deleteVPCRoutingTableOptionsModel.IfMatch = core.StringPtr("W/\"96d225c4-56bd-43d9-98fc-d7148e5c5028\"") deleteVPCRoutingTableOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with empty URL (negative test) err := vpcService.SetServiceURL("") @@ -7237,7 +7237,7 @@ var _ = Describe(`VpcV1`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"accept_routes_from": [{"resource_type": "vpn_gateway"}], "advertise_routes_to": ["transit_gateway"], "created_at": "2019-01-01T12:00:00.000Z", "href": "https://us-south.iaas.cloud.ibm.com/v1/vpcs/982d72b7-db1b-4606-afb2-ed6bd4b0bed1/routing_tables/6885e83f-03b2-4603-8a86-db2a0f55c840", "id": "1a15dca5-7e33-45e1-b7c5-bc690e569531", "is_default": false, "lifecycle_state": "stable", "name": "my-routing-table-1", "resource_type": "routing_table", "route_direct_link_ingress": true, "route_internet_ingress": true, "route_transit_gateway_ingress": true, "route_vpc_zone_ingress": false, "routes": [{"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/vpcs/8e454ead-0db7-48ac-9a8b-2698d8c470a7/routing_tables/6885e83f-03b2-4603-8a86-db2a0f55c840/routes/1a15dca5-7e33-45e1-b7c5-bc690e569531", "id": "1a15dca5-7e33-45e1-b7c5-bc690e569531", "name": "my-route-1"}], "subnets": [{"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "id": "7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "name": "my-subnet", "resource_type": "subnet"}]}`) + fmt.Fprintf(res, "%s", `{"accept_routes_from": [{"resource_type": "vpn_server"}], "advertise_routes_to": ["transit_gateway"], "created_at": "2019-01-01T12:00:00.000Z", "href": "https://us-south.iaas.cloud.ibm.com/v1/vpcs/982d72b7-db1b-4606-afb2-ed6bd4b0bed1/routing_tables/6885e83f-03b2-4603-8a86-db2a0f55c840", "id": "1a15dca5-7e33-45e1-b7c5-bc690e569531", "is_default": false, "lifecycle_state": "stable", "name": "my-routing-table-1", "resource_type": "routing_table", "route_direct_link_ingress": true, "route_internet_ingress": true, "route_transit_gateway_ingress": true, "route_vpc_zone_ingress": false, "routes": [{"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/vpcs/8e454ead-0db7-48ac-9a8b-2698d8c470a7/routing_tables/6885e83f-03b2-4603-8a86-db2a0f55c840/routes/1a15dca5-7e33-45e1-b7c5-bc690e569531", "id": "1a15dca5-7e33-45e1-b7c5-bc690e569531", "name": "my-route-1"}], "subnets": [{"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "id": "7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "name": "my-subnet", "resource_type": "subnet"}]}`) })) }) It(`Invoke GetVPCRoutingTable successfully with retries`, func() { @@ -7295,7 +7295,7 @@ var _ = Describe(`VpcV1`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"accept_routes_from": [{"resource_type": "vpn_gateway"}], "advertise_routes_to": ["transit_gateway"], "created_at": "2019-01-01T12:00:00.000Z", "href": "https://us-south.iaas.cloud.ibm.com/v1/vpcs/982d72b7-db1b-4606-afb2-ed6bd4b0bed1/routing_tables/6885e83f-03b2-4603-8a86-db2a0f55c840", "id": "1a15dca5-7e33-45e1-b7c5-bc690e569531", "is_default": false, "lifecycle_state": "stable", "name": "my-routing-table-1", "resource_type": "routing_table", "route_direct_link_ingress": true, "route_internet_ingress": true, "route_transit_gateway_ingress": true, "route_vpc_zone_ingress": false, "routes": [{"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/vpcs/8e454ead-0db7-48ac-9a8b-2698d8c470a7/routing_tables/6885e83f-03b2-4603-8a86-db2a0f55c840/routes/1a15dca5-7e33-45e1-b7c5-bc690e569531", "id": "1a15dca5-7e33-45e1-b7c5-bc690e569531", "name": "my-route-1"}], "subnets": [{"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "id": "7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "name": "my-subnet", "resource_type": "subnet"}]}`) + fmt.Fprintf(res, "%s", `{"accept_routes_from": [{"resource_type": "vpn_server"}], "advertise_routes_to": ["transit_gateway"], "created_at": "2019-01-01T12:00:00.000Z", "href": "https://us-south.iaas.cloud.ibm.com/v1/vpcs/982d72b7-db1b-4606-afb2-ed6bd4b0bed1/routing_tables/6885e83f-03b2-4603-8a86-db2a0f55c840", "id": "1a15dca5-7e33-45e1-b7c5-bc690e569531", "is_default": false, "lifecycle_state": "stable", "name": "my-routing-table-1", "resource_type": "routing_table", "route_direct_link_ingress": true, "route_internet_ingress": true, "route_transit_gateway_ingress": true, "route_vpc_zone_ingress": false, "routes": [{"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/vpcs/8e454ead-0db7-48ac-9a8b-2698d8c470a7/routing_tables/6885e83f-03b2-4603-8a86-db2a0f55c840/routes/1a15dca5-7e33-45e1-b7c5-bc690e569531", "id": "1a15dca5-7e33-45e1-b7c5-bc690e569531", "name": "my-route-1"}], "subnets": [{"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "id": "7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "name": "my-subnet", "resource_type": "subnet"}]}`) })) }) It(`Invoke GetVPCRoutingTable successfully`, func() { @@ -7409,7 +7409,7 @@ var _ = Describe(`VpcV1`, func() { Expect(req.URL.EscapedPath()).To(Equal(updateVPCRoutingTablePath)) 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.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") @@ -7447,7 +7447,7 @@ var _ = Describe(`VpcV1`, func() { updateVPCRoutingTableOptionsModel.VPCID = core.StringPtr("testString") updateVPCRoutingTableOptionsModel.ID = core.StringPtr("testString") updateVPCRoutingTableOptionsModel.RoutingTablePatch = routingTablePatchModelAsPatch - updateVPCRoutingTableOptionsModel.IfMatch = core.StringPtr(`W/"96d225c4-56bd-43d9-98fc-d7148e5c5028"`) + updateVPCRoutingTableOptionsModel.IfMatch = core.StringPtr("W/\"96d225c4-56bd-43d9-98fc-d7148e5c5028\"") updateVPCRoutingTableOptionsModel.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.UpdateVPCRoutingTable(updateVPCRoutingTableOptionsModel) @@ -7496,7 +7496,7 @@ var _ = Describe(`VpcV1`, func() { 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.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 @@ -7505,7 +7505,7 @@ var _ = Describe(`VpcV1`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"accept_routes_from": [{"resource_type": "vpn_gateway"}], "advertise_routes_to": ["transit_gateway"], "created_at": "2019-01-01T12:00:00.000Z", "href": "https://us-south.iaas.cloud.ibm.com/v1/vpcs/982d72b7-db1b-4606-afb2-ed6bd4b0bed1/routing_tables/6885e83f-03b2-4603-8a86-db2a0f55c840", "id": "1a15dca5-7e33-45e1-b7c5-bc690e569531", "is_default": false, "lifecycle_state": "stable", "name": "my-routing-table-1", "resource_type": "routing_table", "route_direct_link_ingress": true, "route_internet_ingress": true, "route_transit_gateway_ingress": true, "route_vpc_zone_ingress": false, "routes": [{"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/vpcs/8e454ead-0db7-48ac-9a8b-2698d8c470a7/routing_tables/6885e83f-03b2-4603-8a86-db2a0f55c840/routes/1a15dca5-7e33-45e1-b7c5-bc690e569531", "id": "1a15dca5-7e33-45e1-b7c5-bc690e569531", "name": "my-route-1"}], "subnets": [{"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "id": "7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "name": "my-subnet", "resource_type": "subnet"}]}`) + fmt.Fprintf(res, "%s", `{"accept_routes_from": [{"resource_type": "vpn_server"}], "advertise_routes_to": ["transit_gateway"], "created_at": "2019-01-01T12:00:00.000Z", "href": "https://us-south.iaas.cloud.ibm.com/v1/vpcs/982d72b7-db1b-4606-afb2-ed6bd4b0bed1/routing_tables/6885e83f-03b2-4603-8a86-db2a0f55c840", "id": "1a15dca5-7e33-45e1-b7c5-bc690e569531", "is_default": false, "lifecycle_state": "stable", "name": "my-routing-table-1", "resource_type": "routing_table", "route_direct_link_ingress": true, "route_internet_ingress": true, "route_transit_gateway_ingress": true, "route_vpc_zone_ingress": false, "routes": [{"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/vpcs/8e454ead-0db7-48ac-9a8b-2698d8c470a7/routing_tables/6885e83f-03b2-4603-8a86-db2a0f55c840/routes/1a15dca5-7e33-45e1-b7c5-bc690e569531", "id": "1a15dca5-7e33-45e1-b7c5-bc690e569531", "name": "my-route-1"}], "subnets": [{"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "id": "7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "name": "my-subnet", "resource_type": "subnet"}]}`) })) }) It(`Invoke UpdateVPCRoutingTable successfully with retries`, func() { @@ -7539,7 +7539,7 @@ var _ = Describe(`VpcV1`, func() { updateVPCRoutingTableOptionsModel.VPCID = core.StringPtr("testString") updateVPCRoutingTableOptionsModel.ID = core.StringPtr("testString") updateVPCRoutingTableOptionsModel.RoutingTablePatch = routingTablePatchModelAsPatch - updateVPCRoutingTableOptionsModel.IfMatch = core.StringPtr(`W/"96d225c4-56bd-43d9-98fc-d7148e5c5028"`) + updateVPCRoutingTableOptionsModel.IfMatch = core.StringPtr("W/\"96d225c4-56bd-43d9-98fc-d7148e5c5028\"") updateVPCRoutingTableOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with a Context to test a timeout error @@ -7593,13 +7593,13 @@ var _ = Describe(`VpcV1`, func() { 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.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", `{"accept_routes_from": [{"resource_type": "vpn_gateway"}], "advertise_routes_to": ["transit_gateway"], "created_at": "2019-01-01T12:00:00.000Z", "href": "https://us-south.iaas.cloud.ibm.com/v1/vpcs/982d72b7-db1b-4606-afb2-ed6bd4b0bed1/routing_tables/6885e83f-03b2-4603-8a86-db2a0f55c840", "id": "1a15dca5-7e33-45e1-b7c5-bc690e569531", "is_default": false, "lifecycle_state": "stable", "name": "my-routing-table-1", "resource_type": "routing_table", "route_direct_link_ingress": true, "route_internet_ingress": true, "route_transit_gateway_ingress": true, "route_vpc_zone_ingress": false, "routes": [{"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/vpcs/8e454ead-0db7-48ac-9a8b-2698d8c470a7/routing_tables/6885e83f-03b2-4603-8a86-db2a0f55c840/routes/1a15dca5-7e33-45e1-b7c5-bc690e569531", "id": "1a15dca5-7e33-45e1-b7c5-bc690e569531", "name": "my-route-1"}], "subnets": [{"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "id": "7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "name": "my-subnet", "resource_type": "subnet"}]}`) + fmt.Fprintf(res, "%s", `{"accept_routes_from": [{"resource_type": "vpn_server"}], "advertise_routes_to": ["transit_gateway"], "created_at": "2019-01-01T12:00:00.000Z", "href": "https://us-south.iaas.cloud.ibm.com/v1/vpcs/982d72b7-db1b-4606-afb2-ed6bd4b0bed1/routing_tables/6885e83f-03b2-4603-8a86-db2a0f55c840", "id": "1a15dca5-7e33-45e1-b7c5-bc690e569531", "is_default": false, "lifecycle_state": "stable", "name": "my-routing-table-1", "resource_type": "routing_table", "route_direct_link_ingress": true, "route_internet_ingress": true, "route_transit_gateway_ingress": true, "route_vpc_zone_ingress": false, "routes": [{"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/vpcs/8e454ead-0db7-48ac-9a8b-2698d8c470a7/routing_tables/6885e83f-03b2-4603-8a86-db2a0f55c840/routes/1a15dca5-7e33-45e1-b7c5-bc690e569531", "id": "1a15dca5-7e33-45e1-b7c5-bc690e569531", "name": "my-route-1"}], "subnets": [{"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "id": "7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "name": "my-subnet", "resource_type": "subnet"}]}`) })) }) It(`Invoke UpdateVPCRoutingTable successfully`, func() { @@ -7638,7 +7638,7 @@ var _ = Describe(`VpcV1`, func() { updateVPCRoutingTableOptionsModel.VPCID = core.StringPtr("testString") updateVPCRoutingTableOptionsModel.ID = core.StringPtr("testString") updateVPCRoutingTableOptionsModel.RoutingTablePatch = routingTablePatchModelAsPatch - updateVPCRoutingTableOptionsModel.IfMatch = core.StringPtr(`W/"96d225c4-56bd-43d9-98fc-d7148e5c5028"`) + updateVPCRoutingTableOptionsModel.IfMatch = core.StringPtr("W/\"96d225c4-56bd-43d9-98fc-d7148e5c5028\"") updateVPCRoutingTableOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with valid options model (positive test) @@ -7678,7 +7678,7 @@ var _ = Describe(`VpcV1`, func() { updateVPCRoutingTableOptionsModel.VPCID = core.StringPtr("testString") updateVPCRoutingTableOptionsModel.ID = core.StringPtr("testString") updateVPCRoutingTableOptionsModel.RoutingTablePatch = routingTablePatchModelAsPatch - updateVPCRoutingTableOptionsModel.IfMatch = core.StringPtr(`W/"96d225c4-56bd-43d9-98fc-d7148e5c5028"`) + updateVPCRoutingTableOptionsModel.IfMatch = core.StringPtr("W/\"96d225c4-56bd-43d9-98fc-d7148e5c5028\"") updateVPCRoutingTableOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with empty URL (negative test) err := vpcService.SetServiceURL("") @@ -7739,7 +7739,7 @@ var _ = Describe(`VpcV1`, func() { updateVPCRoutingTableOptionsModel.VPCID = core.StringPtr("testString") updateVPCRoutingTableOptionsModel.ID = core.StringPtr("testString") updateVPCRoutingTableOptionsModel.RoutingTablePatch = routingTablePatchModelAsPatch - updateVPCRoutingTableOptionsModel.IfMatch = core.StringPtr(`W/"96d225c4-56bd-43d9-98fc-d7148e5c5028"`) + updateVPCRoutingTableOptionsModel.IfMatch = core.StringPtr("W/\"96d225c4-56bd-43d9-98fc-d7148e5c5028\"") updateVPCRoutingTableOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation @@ -11750,7 +11750,7 @@ var _ = Describe(`VpcV1`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"accept_routes_from": [{"resource_type": "vpn_gateway"}], "advertise_routes_to": ["transit_gateway"], "created_at": "2019-01-01T12:00:00.000Z", "href": "https://us-south.iaas.cloud.ibm.com/v1/vpcs/982d72b7-db1b-4606-afb2-ed6bd4b0bed1/routing_tables/6885e83f-03b2-4603-8a86-db2a0f55c840", "id": "1a15dca5-7e33-45e1-b7c5-bc690e569531", "is_default": false, "lifecycle_state": "stable", "name": "my-routing-table-1", "resource_type": "routing_table", "route_direct_link_ingress": true, "route_internet_ingress": true, "route_transit_gateway_ingress": true, "route_vpc_zone_ingress": false, "routes": [{"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/vpcs/8e454ead-0db7-48ac-9a8b-2698d8c470a7/routing_tables/6885e83f-03b2-4603-8a86-db2a0f55c840/routes/1a15dca5-7e33-45e1-b7c5-bc690e569531", "id": "1a15dca5-7e33-45e1-b7c5-bc690e569531", "name": "my-route-1"}], "subnets": [{"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "id": "7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "name": "my-subnet", "resource_type": "subnet"}]}`) + fmt.Fprintf(res, "%s", `{"accept_routes_from": [{"resource_type": "vpn_server"}], "advertise_routes_to": ["transit_gateway"], "created_at": "2019-01-01T12:00:00.000Z", "href": "https://us-south.iaas.cloud.ibm.com/v1/vpcs/982d72b7-db1b-4606-afb2-ed6bd4b0bed1/routing_tables/6885e83f-03b2-4603-8a86-db2a0f55c840", "id": "1a15dca5-7e33-45e1-b7c5-bc690e569531", "is_default": false, "lifecycle_state": "stable", "name": "my-routing-table-1", "resource_type": "routing_table", "route_direct_link_ingress": true, "route_internet_ingress": true, "route_transit_gateway_ingress": true, "route_vpc_zone_ingress": false, "routes": [{"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/vpcs/8e454ead-0db7-48ac-9a8b-2698d8c470a7/routing_tables/6885e83f-03b2-4603-8a86-db2a0f55c840/routes/1a15dca5-7e33-45e1-b7c5-bc690e569531", "id": "1a15dca5-7e33-45e1-b7c5-bc690e569531", "name": "my-route-1"}], "subnets": [{"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "id": "7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "name": "my-subnet", "resource_type": "subnet"}]}`) })) }) It(`Invoke GetSubnetRoutingTable successfully with retries`, func() { @@ -11807,7 +11807,7 @@ var _ = Describe(`VpcV1`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"accept_routes_from": [{"resource_type": "vpn_gateway"}], "advertise_routes_to": ["transit_gateway"], "created_at": "2019-01-01T12:00:00.000Z", "href": "https://us-south.iaas.cloud.ibm.com/v1/vpcs/982d72b7-db1b-4606-afb2-ed6bd4b0bed1/routing_tables/6885e83f-03b2-4603-8a86-db2a0f55c840", "id": "1a15dca5-7e33-45e1-b7c5-bc690e569531", "is_default": false, "lifecycle_state": "stable", "name": "my-routing-table-1", "resource_type": "routing_table", "route_direct_link_ingress": true, "route_internet_ingress": true, "route_transit_gateway_ingress": true, "route_vpc_zone_ingress": false, "routes": [{"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/vpcs/8e454ead-0db7-48ac-9a8b-2698d8c470a7/routing_tables/6885e83f-03b2-4603-8a86-db2a0f55c840/routes/1a15dca5-7e33-45e1-b7c5-bc690e569531", "id": "1a15dca5-7e33-45e1-b7c5-bc690e569531", "name": "my-route-1"}], "subnets": [{"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "id": "7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "name": "my-subnet", "resource_type": "subnet"}]}`) + fmt.Fprintf(res, "%s", `{"accept_routes_from": [{"resource_type": "vpn_server"}], "advertise_routes_to": ["transit_gateway"], "created_at": "2019-01-01T12:00:00.000Z", "href": "https://us-south.iaas.cloud.ibm.com/v1/vpcs/982d72b7-db1b-4606-afb2-ed6bd4b0bed1/routing_tables/6885e83f-03b2-4603-8a86-db2a0f55c840", "id": "1a15dca5-7e33-45e1-b7c5-bc690e569531", "is_default": false, "lifecycle_state": "stable", "name": "my-routing-table-1", "resource_type": "routing_table", "route_direct_link_ingress": true, "route_internet_ingress": true, "route_transit_gateway_ingress": true, "route_vpc_zone_ingress": false, "routes": [{"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/vpcs/8e454ead-0db7-48ac-9a8b-2698d8c470a7/routing_tables/6885e83f-03b2-4603-8a86-db2a0f55c840/routes/1a15dca5-7e33-45e1-b7c5-bc690e569531", "id": "1a15dca5-7e33-45e1-b7c5-bc690e569531", "name": "my-route-1"}], "subnets": [{"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "id": "7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "name": "my-subnet", "resource_type": "subnet"}]}`) })) }) It(`Invoke GetSubnetRoutingTable successfully`, func() { @@ -11996,7 +11996,7 @@ var _ = Describe(`VpcV1`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(201) - fmt.Fprintf(res, "%s", `{"accept_routes_from": [{"resource_type": "vpn_gateway"}], "advertise_routes_to": ["transit_gateway"], "created_at": "2019-01-01T12:00:00.000Z", "href": "https://us-south.iaas.cloud.ibm.com/v1/vpcs/982d72b7-db1b-4606-afb2-ed6bd4b0bed1/routing_tables/6885e83f-03b2-4603-8a86-db2a0f55c840", "id": "1a15dca5-7e33-45e1-b7c5-bc690e569531", "is_default": false, "lifecycle_state": "stable", "name": "my-routing-table-1", "resource_type": "routing_table", "route_direct_link_ingress": true, "route_internet_ingress": true, "route_transit_gateway_ingress": true, "route_vpc_zone_ingress": false, "routes": [{"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/vpcs/8e454ead-0db7-48ac-9a8b-2698d8c470a7/routing_tables/6885e83f-03b2-4603-8a86-db2a0f55c840/routes/1a15dca5-7e33-45e1-b7c5-bc690e569531", "id": "1a15dca5-7e33-45e1-b7c5-bc690e569531", "name": "my-route-1"}], "subnets": [{"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "id": "7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "name": "my-subnet", "resource_type": "subnet"}]}`) + fmt.Fprintf(res, "%s", `{"accept_routes_from": [{"resource_type": "vpn_server"}], "advertise_routes_to": ["transit_gateway"], "created_at": "2019-01-01T12:00:00.000Z", "href": "https://us-south.iaas.cloud.ibm.com/v1/vpcs/982d72b7-db1b-4606-afb2-ed6bd4b0bed1/routing_tables/6885e83f-03b2-4603-8a86-db2a0f55c840", "id": "1a15dca5-7e33-45e1-b7c5-bc690e569531", "is_default": false, "lifecycle_state": "stable", "name": "my-routing-table-1", "resource_type": "routing_table", "route_direct_link_ingress": true, "route_internet_ingress": true, "route_transit_gateway_ingress": true, "route_vpc_zone_ingress": false, "routes": [{"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/vpcs/8e454ead-0db7-48ac-9a8b-2698d8c470a7/routing_tables/6885e83f-03b2-4603-8a86-db2a0f55c840/routes/1a15dca5-7e33-45e1-b7c5-bc690e569531", "id": "1a15dca5-7e33-45e1-b7c5-bc690e569531", "name": "my-route-1"}], "subnets": [{"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "id": "7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "name": "my-subnet", "resource_type": "subnet"}]}`) })) }) It(`Invoke ReplaceSubnetRoutingTable successfully with retries`, func() { @@ -12074,7 +12074,7 @@ var _ = Describe(`VpcV1`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(201) - fmt.Fprintf(res, "%s", `{"accept_routes_from": [{"resource_type": "vpn_gateway"}], "advertise_routes_to": ["transit_gateway"], "created_at": "2019-01-01T12:00:00.000Z", "href": "https://us-south.iaas.cloud.ibm.com/v1/vpcs/982d72b7-db1b-4606-afb2-ed6bd4b0bed1/routing_tables/6885e83f-03b2-4603-8a86-db2a0f55c840", "id": "1a15dca5-7e33-45e1-b7c5-bc690e569531", "is_default": false, "lifecycle_state": "stable", "name": "my-routing-table-1", "resource_type": "routing_table", "route_direct_link_ingress": true, "route_internet_ingress": true, "route_transit_gateway_ingress": true, "route_vpc_zone_ingress": false, "routes": [{"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/vpcs/8e454ead-0db7-48ac-9a8b-2698d8c470a7/routing_tables/6885e83f-03b2-4603-8a86-db2a0f55c840/routes/1a15dca5-7e33-45e1-b7c5-bc690e569531", "id": "1a15dca5-7e33-45e1-b7c5-bc690e569531", "name": "my-route-1"}], "subnets": [{"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "id": "7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "name": "my-subnet", "resource_type": "subnet"}]}`) + fmt.Fprintf(res, "%s", `{"accept_routes_from": [{"resource_type": "vpn_server"}], "advertise_routes_to": ["transit_gateway"], "created_at": "2019-01-01T12:00:00.000Z", "href": "https://us-south.iaas.cloud.ibm.com/v1/vpcs/982d72b7-db1b-4606-afb2-ed6bd4b0bed1/routing_tables/6885e83f-03b2-4603-8a86-db2a0f55c840", "id": "1a15dca5-7e33-45e1-b7c5-bc690e569531", "is_default": false, "lifecycle_state": "stable", "name": "my-routing-table-1", "resource_type": "routing_table", "route_direct_link_ingress": true, "route_internet_ingress": true, "route_transit_gateway_ingress": true, "route_vpc_zone_ingress": false, "routes": [{"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/vpcs/8e454ead-0db7-48ac-9a8b-2698d8c470a7/routing_tables/6885e83f-03b2-4603-8a86-db2a0f55c840/routes/1a15dca5-7e33-45e1-b7c5-bc690e569531", "id": "1a15dca5-7e33-45e1-b7c5-bc690e569531", "name": "my-route-1"}], "subnets": [{"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "id": "7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "name": "my-subnet", "resource_type": "subnet"}]}`) })) }) It(`Invoke ReplaceSubnetRoutingTable successfully`, func() { @@ -21483,7 +21483,7 @@ var _ = Describe(`VpcV1`, func() { 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.Header["If-Match"][0]).To(Equal(fmt.Sprintf("%v", "W/\"96d225c4-56bd-43d9-98fc-d7148e5c5028\""))) Expect(req.URL.Query()["version"]).To(Equal([]string{"testString"})) Expect(req.URL.Query()["generation"]).To(Equal([]string{fmt.Sprint(int64(2))})) res.WriteHeader(204) @@ -21506,7 +21506,7 @@ var _ = Describe(`VpcV1`, func() { // Construct an instance of the DeleteInstanceOptions model deleteInstanceOptionsModel := new(vpcv1.DeleteInstanceOptions) deleteInstanceOptionsModel.ID = core.StringPtr("testString") - deleteInstanceOptionsModel.IfMatch = core.StringPtr(`W/"96d225c4-56bd-43d9-98fc-d7148e5c5028"`) + deleteInstanceOptionsModel.IfMatch = core.StringPtr("W/\"96d225c4-56bd-43d9-98fc-d7148e5c5028\"") deleteInstanceOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with valid options model (positive test) @@ -21526,7 +21526,7 @@ var _ = Describe(`VpcV1`, func() { // Construct an instance of the DeleteInstanceOptions model deleteInstanceOptionsModel := new(vpcv1.DeleteInstanceOptions) deleteInstanceOptionsModel.ID = core.StringPtr("testString") - deleteInstanceOptionsModel.IfMatch = core.StringPtr(`W/"96d225c4-56bd-43d9-98fc-d7148e5c5028"`) + deleteInstanceOptionsModel.IfMatch = core.StringPtr("W/\"96d225c4-56bd-43d9-98fc-d7148e5c5028\"") deleteInstanceOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with empty URL (negative test) err := vpcService.SetServiceURL("") @@ -21784,7 +21784,7 @@ var _ = Describe(`VpcV1`, func() { Expect(req.URL.EscapedPath()).To(Equal(updateInstancePath)) 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.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") @@ -21844,7 +21844,7 @@ var _ = Describe(`VpcV1`, func() { updateInstanceOptionsModel := new(vpcv1.UpdateInstanceOptions) updateInstanceOptionsModel.ID = core.StringPtr("testString") updateInstanceOptionsModel.InstancePatch = instancePatchModelAsPatch - updateInstanceOptionsModel.IfMatch = core.StringPtr(`W/"96d225c4-56bd-43d9-98fc-d7148e5c5028"`) + updateInstanceOptionsModel.IfMatch = core.StringPtr("W/\"96d225c4-56bd-43d9-98fc-d7148e5c5028\"") updateInstanceOptionsModel.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.UpdateInstance(updateInstanceOptionsModel) @@ -21893,7 +21893,7 @@ var _ = Describe(`VpcV1`, func() { 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.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 @@ -21958,7 +21958,7 @@ var _ = Describe(`VpcV1`, func() { updateInstanceOptionsModel := new(vpcv1.UpdateInstanceOptions) updateInstanceOptionsModel.ID = core.StringPtr("testString") updateInstanceOptionsModel.InstancePatch = instancePatchModelAsPatch - updateInstanceOptionsModel.IfMatch = core.StringPtr(`W/"96d225c4-56bd-43d9-98fc-d7148e5c5028"`) + updateInstanceOptionsModel.IfMatch = core.StringPtr("W/\"96d225c4-56bd-43d9-98fc-d7148e5c5028\"") updateInstanceOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with a Context to test a timeout error @@ -22012,7 +22012,7 @@ var _ = Describe(`VpcV1`, func() { 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.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 @@ -22079,7 +22079,7 @@ var _ = Describe(`VpcV1`, func() { updateInstanceOptionsModel := new(vpcv1.UpdateInstanceOptions) updateInstanceOptionsModel.ID = core.StringPtr("testString") updateInstanceOptionsModel.InstancePatch = instancePatchModelAsPatch - updateInstanceOptionsModel.IfMatch = core.StringPtr(`W/"96d225c4-56bd-43d9-98fc-d7148e5c5028"`) + updateInstanceOptionsModel.IfMatch = core.StringPtr("W/\"96d225c4-56bd-43d9-98fc-d7148e5c5028\"") updateInstanceOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with valid options model (positive test) @@ -22141,7 +22141,7 @@ var _ = Describe(`VpcV1`, func() { updateInstanceOptionsModel := new(vpcv1.UpdateInstanceOptions) updateInstanceOptionsModel.ID = core.StringPtr("testString") updateInstanceOptionsModel.InstancePatch = instancePatchModelAsPatch - updateInstanceOptionsModel.IfMatch = core.StringPtr(`W/"96d225c4-56bd-43d9-98fc-d7148e5c5028"`) + updateInstanceOptionsModel.IfMatch = core.StringPtr("W/\"96d225c4-56bd-43d9-98fc-d7148e5c5028\"") updateInstanceOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with empty URL (negative test) err := vpcService.SetServiceURL("") @@ -22224,7 +22224,7 @@ var _ = Describe(`VpcV1`, func() { updateInstanceOptionsModel := new(vpcv1.UpdateInstanceOptions) updateInstanceOptionsModel.ID = core.StringPtr("testString") updateInstanceOptionsModel.InstancePatch = instancePatchModelAsPatch - updateInstanceOptionsModel.IfMatch = core.StringPtr(`W/"96d225c4-56bd-43d9-98fc-d7148e5c5028"`) + updateInstanceOptionsModel.IfMatch = core.StringPtr("W/\"96d225c4-56bd-43d9-98fc-d7148e5c5028\"") updateInstanceOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation @@ -28770,7 +28770,7 @@ var _ = Describe(`VpcV1`, func() { // 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/instance_groups?limit=20"}, "instance_groups": [{"application_port": 22, "created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::instance-group:1e09281b-f177-46fb-baf1-bc152b2e391a", "href": "https://us-south.iaas.cloud.ibm.com/v1/instance_groups/1e09281b-f177-46fb-baf1-bc152b2e391a", "id": "1e09281b-f177-46fb-baf1-bc152b2e391a", "instance_template": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::instance-template:1e09281b-f177-46fb-baf1-bc152b2e391a", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/instance/templates/1e09281b-f177-46fb-baf1-bc152b2e391a", "id": "a6b1a881-2ce8-41a3-80fc-36316a73f803", "name": "my-instance-template"}, "load_balancer_pool": {"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/load_balancers/dd754295-e9e0-4c9d-bf6c-58fbc59e5727/pools/70294e14-4e61-11e8-bcf4-0242ac110004", "id": "70294e14-4e61-11e8-bcf4-0242ac110004", "name": "my-load-balancer-pool"}, "managers": [{"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/instance_groups/1e09281b-f177-46fb-baf1-bc152b2e391a/managers/dd754295-e9e0-4c9d-bf6c-58fbc59e5727", "id": "1e09281b-f177-46fb-baf1-bc152b2e391a", "name": "my-instance-group-manager"}], "membership_count": 10, "name": "my-instance-group", "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "status": "deleting", "subnets": [{"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "id": "7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "name": "my-subnet", "resource_type": "subnet"}], "updated_at": "2019-01-01T12:00:00.000Z", "vpc": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::vpc:4727d842-f94f-4a2d-824a-9bc9b02c523b", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/vpcs/4727d842-f94f-4a2d-824a-9bc9b02c523b", "id": "4727d842-f94f-4a2d-824a-9bc9b02c523b", "name": "my-vpc", "resource_type": "vpc"}}], "limit": 20, "next": {"href": "https://us-south.iaas.cloud.ibm.com/v1/instance_groups?start=9d5a91a3e2cbd233b5a5b33436855ed1&limit=20"}, "total_count": 132}`) + fmt.Fprintf(res, "%s", `{"first": {"href": "https://us-south.iaas.cloud.ibm.com/v1/instance_groups?limit=20"}, "instance_groups": [{"application_port": 22, "created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::instance-group:1e09281b-f177-46fb-baf1-bc152b2e391a", "href": "https://us-south.iaas.cloud.ibm.com/v1/instance_groups/1e09281b-f177-46fb-baf1-bc152b2e391a", "id": "1e09281b-f177-46fb-baf1-bc152b2e391a", "instance_template": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::instance-template:1e09281b-f177-46fb-baf1-bc152b2e391a", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/instance/templates/1e09281b-f177-46fb-baf1-bc152b2e391a", "id": "a6b1a881-2ce8-41a3-80fc-36316a73f803", "name": "my-instance-template"}, "lifecycle_reasons": [{"code": "resource_suspended_by_provider", "message": "The resource has been suspended. Contact IBM support with the CRN for next steps.", "more_info": "https://cloud.ibm.com/apidocs/vpc#resource-suspension"}], "lifecycle_state": "stable", "load_balancer_pool": {"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/load_balancers/dd754295-e9e0-4c9d-bf6c-58fbc59e5727/pools/70294e14-4e61-11e8-bcf4-0242ac110004", "id": "70294e14-4e61-11e8-bcf4-0242ac110004", "name": "my-load-balancer-pool"}, "managers": [{"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/instance_groups/1e09281b-f177-46fb-baf1-bc152b2e391a/managers/dd754295-e9e0-4c9d-bf6c-58fbc59e5727", "id": "1e09281b-f177-46fb-baf1-bc152b2e391a", "name": "my-instance-group-manager"}], "membership_count": 10, "name": "my-instance-group", "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "status": "deleting", "subnets": [{"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "id": "7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "name": "my-subnet", "resource_type": "subnet"}], "updated_at": "2019-01-01T12:00:00.000Z", "vpc": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::vpc:4727d842-f94f-4a2d-824a-9bc9b02c523b", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/vpcs/4727d842-f94f-4a2d-824a-9bc9b02c523b", "id": "4727d842-f94f-4a2d-824a-9bc9b02c523b", "name": "my-vpc", "resource_type": "vpc"}}], "limit": 20, "next": {"href": "https://us-south.iaas.cloud.ibm.com/v1/instance_groups?start=9d5a91a3e2cbd233b5a5b33436855ed1&limit=20"}, "total_count": 132}`) })) }) It(`Invoke ListInstanceGroups successfully with retries`, func() { @@ -28830,7 +28830,7 @@ var _ = Describe(`VpcV1`, func() { // 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/instance_groups?limit=20"}, "instance_groups": [{"application_port": 22, "created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::instance-group:1e09281b-f177-46fb-baf1-bc152b2e391a", "href": "https://us-south.iaas.cloud.ibm.com/v1/instance_groups/1e09281b-f177-46fb-baf1-bc152b2e391a", "id": "1e09281b-f177-46fb-baf1-bc152b2e391a", "instance_template": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::instance-template:1e09281b-f177-46fb-baf1-bc152b2e391a", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/instance/templates/1e09281b-f177-46fb-baf1-bc152b2e391a", "id": "a6b1a881-2ce8-41a3-80fc-36316a73f803", "name": "my-instance-template"}, "load_balancer_pool": {"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/load_balancers/dd754295-e9e0-4c9d-bf6c-58fbc59e5727/pools/70294e14-4e61-11e8-bcf4-0242ac110004", "id": "70294e14-4e61-11e8-bcf4-0242ac110004", "name": "my-load-balancer-pool"}, "managers": [{"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/instance_groups/1e09281b-f177-46fb-baf1-bc152b2e391a/managers/dd754295-e9e0-4c9d-bf6c-58fbc59e5727", "id": "1e09281b-f177-46fb-baf1-bc152b2e391a", "name": "my-instance-group-manager"}], "membership_count": 10, "name": "my-instance-group", "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "status": "deleting", "subnets": [{"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "id": "7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "name": "my-subnet", "resource_type": "subnet"}], "updated_at": "2019-01-01T12:00:00.000Z", "vpc": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::vpc:4727d842-f94f-4a2d-824a-9bc9b02c523b", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/vpcs/4727d842-f94f-4a2d-824a-9bc9b02c523b", "id": "4727d842-f94f-4a2d-824a-9bc9b02c523b", "name": "my-vpc", "resource_type": "vpc"}}], "limit": 20, "next": {"href": "https://us-south.iaas.cloud.ibm.com/v1/instance_groups?start=9d5a91a3e2cbd233b5a5b33436855ed1&limit=20"}, "total_count": 132}`) + fmt.Fprintf(res, "%s", `{"first": {"href": "https://us-south.iaas.cloud.ibm.com/v1/instance_groups?limit=20"}, "instance_groups": [{"application_port": 22, "created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::instance-group:1e09281b-f177-46fb-baf1-bc152b2e391a", "href": "https://us-south.iaas.cloud.ibm.com/v1/instance_groups/1e09281b-f177-46fb-baf1-bc152b2e391a", "id": "1e09281b-f177-46fb-baf1-bc152b2e391a", "instance_template": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::instance-template:1e09281b-f177-46fb-baf1-bc152b2e391a", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/instance/templates/1e09281b-f177-46fb-baf1-bc152b2e391a", "id": "a6b1a881-2ce8-41a3-80fc-36316a73f803", "name": "my-instance-template"}, "lifecycle_reasons": [{"code": "resource_suspended_by_provider", "message": "The resource has been suspended. Contact IBM support with the CRN for next steps.", "more_info": "https://cloud.ibm.com/apidocs/vpc#resource-suspension"}], "lifecycle_state": "stable", "load_balancer_pool": {"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/load_balancers/dd754295-e9e0-4c9d-bf6c-58fbc59e5727/pools/70294e14-4e61-11e8-bcf4-0242ac110004", "id": "70294e14-4e61-11e8-bcf4-0242ac110004", "name": "my-load-balancer-pool"}, "managers": [{"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/instance_groups/1e09281b-f177-46fb-baf1-bc152b2e391a/managers/dd754295-e9e0-4c9d-bf6c-58fbc59e5727", "id": "1e09281b-f177-46fb-baf1-bc152b2e391a", "name": "my-instance-group-manager"}], "membership_count": 10, "name": "my-instance-group", "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "status": "deleting", "subnets": [{"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "id": "7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "name": "my-subnet", "resource_type": "subnet"}], "updated_at": "2019-01-01T12:00:00.000Z", "vpc": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::vpc:4727d842-f94f-4a2d-824a-9bc9b02c523b", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/vpcs/4727d842-f94f-4a2d-824a-9bc9b02c523b", "id": "4727d842-f94f-4a2d-824a-9bc9b02c523b", "name": "my-vpc", "resource_type": "vpc"}}], "limit": 20, "next": {"href": "https://us-south.iaas.cloud.ibm.com/v1/instance_groups?start=9d5a91a3e2cbd233b5a5b33436855ed1&limit=20"}, "total_count": 132}`) })) }) It(`Invoke ListInstanceGroups successfully`, func() { @@ -28968,9 +28968,9 @@ var _ = Describe(`VpcV1`, func() { res.WriteHeader(200) requestNumber++ if requestNumber == 1 { - fmt.Fprintf(res, "%s", `{"next":{"href":"https://myhost.com/somePath?start=1"},"total_count":2,"limit":1,"instance_groups":[{"application_port":22,"created_at":"2019-01-01T12:00:00.000Z","crn":"crn:v1:bluemix:public:is:us-south-1:a/123456::instance-group:1e09281b-f177-46fb-baf1-bc152b2e391a","href":"https://us-south.iaas.cloud.ibm.com/v1/instance_groups/1e09281b-f177-46fb-baf1-bc152b2e391a","id":"1e09281b-f177-46fb-baf1-bc152b2e391a","instance_template":{"crn":"crn:v1:bluemix:public:is:us-south-1:a/123456::instance-template:1e09281b-f177-46fb-baf1-bc152b2e391a","deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/instance/templates/1e09281b-f177-46fb-baf1-bc152b2e391a","id":"a6b1a881-2ce8-41a3-80fc-36316a73f803","name":"my-instance-template"},"load_balancer_pool":{"deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/load_balancers/dd754295-e9e0-4c9d-bf6c-58fbc59e5727/pools/70294e14-4e61-11e8-bcf4-0242ac110004","id":"70294e14-4e61-11e8-bcf4-0242ac110004","name":"my-load-balancer-pool"},"managers":[{"deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/instance_groups/1e09281b-f177-46fb-baf1-bc152b2e391a/managers/dd754295-e9e0-4c9d-bf6c-58fbc59e5727","id":"1e09281b-f177-46fb-baf1-bc152b2e391a","name":"my-instance-group-manager"}],"membership_count":10,"name":"my-instance-group","resource_group":{"href":"https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345","id":"fee82deba12e4c0fb69c3b09d1f12345","name":"my-resource-group"},"status":"deleting","subnets":[{"crn":"crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e","deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e","id":"7ec86020-1c6e-4889-b3f0-a15f2e50f87e","name":"my-subnet","resource_type":"subnet"}],"updated_at":"2019-01-01T12:00:00.000Z","vpc":{"crn":"crn:v1:bluemix:public:is:us-south:a/123456::vpc:4727d842-f94f-4a2d-824a-9bc9b02c523b","deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/vpcs/4727d842-f94f-4a2d-824a-9bc9b02c523b","id":"4727d842-f94f-4a2d-824a-9bc9b02c523b","name":"my-vpc","resource_type":"vpc"}}]}`) + fmt.Fprintf(res, "%s", `{"next":{"href":"https://myhost.com/somePath?start=1"},"total_count":2,"limit":1,"instance_groups":[{"application_port":22,"created_at":"2019-01-01T12:00:00.000Z","crn":"crn:v1:bluemix:public:is:us-south-1:a/123456::instance-group:1e09281b-f177-46fb-baf1-bc152b2e391a","href":"https://us-south.iaas.cloud.ibm.com/v1/instance_groups/1e09281b-f177-46fb-baf1-bc152b2e391a","id":"1e09281b-f177-46fb-baf1-bc152b2e391a","instance_template":{"crn":"crn:v1:bluemix:public:is:us-south-1:a/123456::instance-template:1e09281b-f177-46fb-baf1-bc152b2e391a","deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/instance/templates/1e09281b-f177-46fb-baf1-bc152b2e391a","id":"a6b1a881-2ce8-41a3-80fc-36316a73f803","name":"my-instance-template"},"lifecycle_reasons":[{"code":"resource_suspended_by_provider","message":"The resource has been suspended. Contact IBM support with the CRN for next steps.","more_info":"https://cloud.ibm.com/apidocs/vpc#resource-suspension"}],"lifecycle_state":"stable","load_balancer_pool":{"deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/load_balancers/dd754295-e9e0-4c9d-bf6c-58fbc59e5727/pools/70294e14-4e61-11e8-bcf4-0242ac110004","id":"70294e14-4e61-11e8-bcf4-0242ac110004","name":"my-load-balancer-pool"},"managers":[{"deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/instance_groups/1e09281b-f177-46fb-baf1-bc152b2e391a/managers/dd754295-e9e0-4c9d-bf6c-58fbc59e5727","id":"1e09281b-f177-46fb-baf1-bc152b2e391a","name":"my-instance-group-manager"}],"membership_count":10,"name":"my-instance-group","resource_group":{"href":"https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345","id":"fee82deba12e4c0fb69c3b09d1f12345","name":"my-resource-group"},"status":"deleting","subnets":[{"crn":"crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e","deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e","id":"7ec86020-1c6e-4889-b3f0-a15f2e50f87e","name":"my-subnet","resource_type":"subnet"}],"updated_at":"2019-01-01T12:00:00.000Z","vpc":{"crn":"crn:v1:bluemix:public:is:us-south:a/123456::vpc:4727d842-f94f-4a2d-824a-9bc9b02c523b","deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/vpcs/4727d842-f94f-4a2d-824a-9bc9b02c523b","id":"4727d842-f94f-4a2d-824a-9bc9b02c523b","name":"my-vpc","resource_type":"vpc"}}]}`) } else if requestNumber == 2 { - fmt.Fprintf(res, "%s", `{"total_count":2,"limit":1,"instance_groups":[{"application_port":22,"created_at":"2019-01-01T12:00:00.000Z","crn":"crn:v1:bluemix:public:is:us-south-1:a/123456::instance-group:1e09281b-f177-46fb-baf1-bc152b2e391a","href":"https://us-south.iaas.cloud.ibm.com/v1/instance_groups/1e09281b-f177-46fb-baf1-bc152b2e391a","id":"1e09281b-f177-46fb-baf1-bc152b2e391a","instance_template":{"crn":"crn:v1:bluemix:public:is:us-south-1:a/123456::instance-template:1e09281b-f177-46fb-baf1-bc152b2e391a","deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/instance/templates/1e09281b-f177-46fb-baf1-bc152b2e391a","id":"a6b1a881-2ce8-41a3-80fc-36316a73f803","name":"my-instance-template"},"load_balancer_pool":{"deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/load_balancers/dd754295-e9e0-4c9d-bf6c-58fbc59e5727/pools/70294e14-4e61-11e8-bcf4-0242ac110004","id":"70294e14-4e61-11e8-bcf4-0242ac110004","name":"my-load-balancer-pool"},"managers":[{"deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/instance_groups/1e09281b-f177-46fb-baf1-bc152b2e391a/managers/dd754295-e9e0-4c9d-bf6c-58fbc59e5727","id":"1e09281b-f177-46fb-baf1-bc152b2e391a","name":"my-instance-group-manager"}],"membership_count":10,"name":"my-instance-group","resource_group":{"href":"https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345","id":"fee82deba12e4c0fb69c3b09d1f12345","name":"my-resource-group"},"status":"deleting","subnets":[{"crn":"crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e","deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e","id":"7ec86020-1c6e-4889-b3f0-a15f2e50f87e","name":"my-subnet","resource_type":"subnet"}],"updated_at":"2019-01-01T12:00:00.000Z","vpc":{"crn":"crn:v1:bluemix:public:is:us-south:a/123456::vpc:4727d842-f94f-4a2d-824a-9bc9b02c523b","deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/vpcs/4727d842-f94f-4a2d-824a-9bc9b02c523b","id":"4727d842-f94f-4a2d-824a-9bc9b02c523b","name":"my-vpc","resource_type":"vpc"}}]}`) + fmt.Fprintf(res, "%s", `{"total_count":2,"limit":1,"instance_groups":[{"application_port":22,"created_at":"2019-01-01T12:00:00.000Z","crn":"crn:v1:bluemix:public:is:us-south-1:a/123456::instance-group:1e09281b-f177-46fb-baf1-bc152b2e391a","href":"https://us-south.iaas.cloud.ibm.com/v1/instance_groups/1e09281b-f177-46fb-baf1-bc152b2e391a","id":"1e09281b-f177-46fb-baf1-bc152b2e391a","instance_template":{"crn":"crn:v1:bluemix:public:is:us-south-1:a/123456::instance-template:1e09281b-f177-46fb-baf1-bc152b2e391a","deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/instance/templates/1e09281b-f177-46fb-baf1-bc152b2e391a","id":"a6b1a881-2ce8-41a3-80fc-36316a73f803","name":"my-instance-template"},"lifecycle_reasons":[{"code":"resource_suspended_by_provider","message":"The resource has been suspended. Contact IBM support with the CRN for next steps.","more_info":"https://cloud.ibm.com/apidocs/vpc#resource-suspension"}],"lifecycle_state":"stable","load_balancer_pool":{"deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/load_balancers/dd754295-e9e0-4c9d-bf6c-58fbc59e5727/pools/70294e14-4e61-11e8-bcf4-0242ac110004","id":"70294e14-4e61-11e8-bcf4-0242ac110004","name":"my-load-balancer-pool"},"managers":[{"deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/instance_groups/1e09281b-f177-46fb-baf1-bc152b2e391a/managers/dd754295-e9e0-4c9d-bf6c-58fbc59e5727","id":"1e09281b-f177-46fb-baf1-bc152b2e391a","name":"my-instance-group-manager"}],"membership_count":10,"name":"my-instance-group","resource_group":{"href":"https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345","id":"fee82deba12e4c0fb69c3b09d1f12345","name":"my-resource-group"},"status":"deleting","subnets":[{"crn":"crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e","deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e","id":"7ec86020-1c6e-4889-b3f0-a15f2e50f87e","name":"my-subnet","resource_type":"subnet"}],"updated_at":"2019-01-01T12:00:00.000Z","vpc":{"crn":"crn:v1:bluemix:public:is:us-south:a/123456::vpc:4727d842-f94f-4a2d-824a-9bc9b02c523b","deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/vpcs/4727d842-f94f-4a2d-824a-9bc9b02c523b","id":"4727d842-f94f-4a2d-824a-9bc9b02c523b","name":"my-vpc","resource_type":"vpc"}}]}`) } else { res.WriteHeader(400) } @@ -29138,7 +29138,7 @@ var _ = Describe(`VpcV1`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(201) - fmt.Fprintf(res, "%s", `{"application_port": 22, "created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::instance-group:1e09281b-f177-46fb-baf1-bc152b2e391a", "href": "https://us-south.iaas.cloud.ibm.com/v1/instance_groups/1e09281b-f177-46fb-baf1-bc152b2e391a", "id": "1e09281b-f177-46fb-baf1-bc152b2e391a", "instance_template": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::instance-template:1e09281b-f177-46fb-baf1-bc152b2e391a", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/instance/templates/1e09281b-f177-46fb-baf1-bc152b2e391a", "id": "a6b1a881-2ce8-41a3-80fc-36316a73f803", "name": "my-instance-template"}, "load_balancer_pool": {"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/load_balancers/dd754295-e9e0-4c9d-bf6c-58fbc59e5727/pools/70294e14-4e61-11e8-bcf4-0242ac110004", "id": "70294e14-4e61-11e8-bcf4-0242ac110004", "name": "my-load-balancer-pool"}, "managers": [{"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/instance_groups/1e09281b-f177-46fb-baf1-bc152b2e391a/managers/dd754295-e9e0-4c9d-bf6c-58fbc59e5727", "id": "1e09281b-f177-46fb-baf1-bc152b2e391a", "name": "my-instance-group-manager"}], "membership_count": 10, "name": "my-instance-group", "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "status": "deleting", "subnets": [{"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "id": "7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "name": "my-subnet", "resource_type": "subnet"}], "updated_at": "2019-01-01T12:00:00.000Z", "vpc": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::vpc:4727d842-f94f-4a2d-824a-9bc9b02c523b", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/vpcs/4727d842-f94f-4a2d-824a-9bc9b02c523b", "id": "4727d842-f94f-4a2d-824a-9bc9b02c523b", "name": "my-vpc", "resource_type": "vpc"}}`) + fmt.Fprintf(res, "%s", `{"application_port": 22, "created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::instance-group:1e09281b-f177-46fb-baf1-bc152b2e391a", "href": "https://us-south.iaas.cloud.ibm.com/v1/instance_groups/1e09281b-f177-46fb-baf1-bc152b2e391a", "id": "1e09281b-f177-46fb-baf1-bc152b2e391a", "instance_template": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::instance-template:1e09281b-f177-46fb-baf1-bc152b2e391a", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/instance/templates/1e09281b-f177-46fb-baf1-bc152b2e391a", "id": "a6b1a881-2ce8-41a3-80fc-36316a73f803", "name": "my-instance-template"}, "lifecycle_reasons": [{"code": "resource_suspended_by_provider", "message": "The resource has been suspended. Contact IBM support with the CRN for next steps.", "more_info": "https://cloud.ibm.com/apidocs/vpc#resource-suspension"}], "lifecycle_state": "stable", "load_balancer_pool": {"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/load_balancers/dd754295-e9e0-4c9d-bf6c-58fbc59e5727/pools/70294e14-4e61-11e8-bcf4-0242ac110004", "id": "70294e14-4e61-11e8-bcf4-0242ac110004", "name": "my-load-balancer-pool"}, "managers": [{"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/instance_groups/1e09281b-f177-46fb-baf1-bc152b2e391a/managers/dd754295-e9e0-4c9d-bf6c-58fbc59e5727", "id": "1e09281b-f177-46fb-baf1-bc152b2e391a", "name": "my-instance-group-manager"}], "membership_count": 10, "name": "my-instance-group", "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "status": "deleting", "subnets": [{"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "id": "7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "name": "my-subnet", "resource_type": "subnet"}], "updated_at": "2019-01-01T12:00:00.000Z", "vpc": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::vpc:4727d842-f94f-4a2d-824a-9bc9b02c523b", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/vpcs/4727d842-f94f-4a2d-824a-9bc9b02c523b", "id": "4727d842-f94f-4a2d-824a-9bc9b02c523b", "name": "my-vpc", "resource_type": "vpc"}}`) })) }) It(`Invoke CreateInstanceGroup successfully with retries`, func() { @@ -29238,7 +29238,7 @@ var _ = Describe(`VpcV1`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(201) - fmt.Fprintf(res, "%s", `{"application_port": 22, "created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::instance-group:1e09281b-f177-46fb-baf1-bc152b2e391a", "href": "https://us-south.iaas.cloud.ibm.com/v1/instance_groups/1e09281b-f177-46fb-baf1-bc152b2e391a", "id": "1e09281b-f177-46fb-baf1-bc152b2e391a", "instance_template": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::instance-template:1e09281b-f177-46fb-baf1-bc152b2e391a", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/instance/templates/1e09281b-f177-46fb-baf1-bc152b2e391a", "id": "a6b1a881-2ce8-41a3-80fc-36316a73f803", "name": "my-instance-template"}, "load_balancer_pool": {"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/load_balancers/dd754295-e9e0-4c9d-bf6c-58fbc59e5727/pools/70294e14-4e61-11e8-bcf4-0242ac110004", "id": "70294e14-4e61-11e8-bcf4-0242ac110004", "name": "my-load-balancer-pool"}, "managers": [{"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/instance_groups/1e09281b-f177-46fb-baf1-bc152b2e391a/managers/dd754295-e9e0-4c9d-bf6c-58fbc59e5727", "id": "1e09281b-f177-46fb-baf1-bc152b2e391a", "name": "my-instance-group-manager"}], "membership_count": 10, "name": "my-instance-group", "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "status": "deleting", "subnets": [{"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "id": "7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "name": "my-subnet", "resource_type": "subnet"}], "updated_at": "2019-01-01T12:00:00.000Z", "vpc": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::vpc:4727d842-f94f-4a2d-824a-9bc9b02c523b", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/vpcs/4727d842-f94f-4a2d-824a-9bc9b02c523b", "id": "4727d842-f94f-4a2d-824a-9bc9b02c523b", "name": "my-vpc", "resource_type": "vpc"}}`) + fmt.Fprintf(res, "%s", `{"application_port": 22, "created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::instance-group:1e09281b-f177-46fb-baf1-bc152b2e391a", "href": "https://us-south.iaas.cloud.ibm.com/v1/instance_groups/1e09281b-f177-46fb-baf1-bc152b2e391a", "id": "1e09281b-f177-46fb-baf1-bc152b2e391a", "instance_template": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::instance-template:1e09281b-f177-46fb-baf1-bc152b2e391a", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/instance/templates/1e09281b-f177-46fb-baf1-bc152b2e391a", "id": "a6b1a881-2ce8-41a3-80fc-36316a73f803", "name": "my-instance-template"}, "lifecycle_reasons": [{"code": "resource_suspended_by_provider", "message": "The resource has been suspended. Contact IBM support with the CRN for next steps.", "more_info": "https://cloud.ibm.com/apidocs/vpc#resource-suspension"}], "lifecycle_state": "stable", "load_balancer_pool": {"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/load_balancers/dd754295-e9e0-4c9d-bf6c-58fbc59e5727/pools/70294e14-4e61-11e8-bcf4-0242ac110004", "id": "70294e14-4e61-11e8-bcf4-0242ac110004", "name": "my-load-balancer-pool"}, "managers": [{"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/instance_groups/1e09281b-f177-46fb-baf1-bc152b2e391a/managers/dd754295-e9e0-4c9d-bf6c-58fbc59e5727", "id": "1e09281b-f177-46fb-baf1-bc152b2e391a", "name": "my-instance-group-manager"}], "membership_count": 10, "name": "my-instance-group", "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "status": "deleting", "subnets": [{"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "id": "7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "name": "my-subnet", "resource_type": "subnet"}], "updated_at": "2019-01-01T12:00:00.000Z", "vpc": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::vpc:4727d842-f94f-4a2d-824a-9bc9b02c523b", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/vpcs/4727d842-f94f-4a2d-824a-9bc9b02c523b", "id": "4727d842-f94f-4a2d-824a-9bc9b02c523b", "name": "my-vpc", "resource_type": "vpc"}}`) })) }) It(`Invoke CreateInstanceGroup successfully`, func() { @@ -29560,7 +29560,7 @@ var _ = Describe(`VpcV1`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"application_port": 22, "created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::instance-group:1e09281b-f177-46fb-baf1-bc152b2e391a", "href": "https://us-south.iaas.cloud.ibm.com/v1/instance_groups/1e09281b-f177-46fb-baf1-bc152b2e391a", "id": "1e09281b-f177-46fb-baf1-bc152b2e391a", "instance_template": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::instance-template:1e09281b-f177-46fb-baf1-bc152b2e391a", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/instance/templates/1e09281b-f177-46fb-baf1-bc152b2e391a", "id": "a6b1a881-2ce8-41a3-80fc-36316a73f803", "name": "my-instance-template"}, "load_balancer_pool": {"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/load_balancers/dd754295-e9e0-4c9d-bf6c-58fbc59e5727/pools/70294e14-4e61-11e8-bcf4-0242ac110004", "id": "70294e14-4e61-11e8-bcf4-0242ac110004", "name": "my-load-balancer-pool"}, "managers": [{"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/instance_groups/1e09281b-f177-46fb-baf1-bc152b2e391a/managers/dd754295-e9e0-4c9d-bf6c-58fbc59e5727", "id": "1e09281b-f177-46fb-baf1-bc152b2e391a", "name": "my-instance-group-manager"}], "membership_count": 10, "name": "my-instance-group", "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "status": "deleting", "subnets": [{"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "id": "7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "name": "my-subnet", "resource_type": "subnet"}], "updated_at": "2019-01-01T12:00:00.000Z", "vpc": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::vpc:4727d842-f94f-4a2d-824a-9bc9b02c523b", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/vpcs/4727d842-f94f-4a2d-824a-9bc9b02c523b", "id": "4727d842-f94f-4a2d-824a-9bc9b02c523b", "name": "my-vpc", "resource_type": "vpc"}}`) + fmt.Fprintf(res, "%s", `{"application_port": 22, "created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::instance-group:1e09281b-f177-46fb-baf1-bc152b2e391a", "href": "https://us-south.iaas.cloud.ibm.com/v1/instance_groups/1e09281b-f177-46fb-baf1-bc152b2e391a", "id": "1e09281b-f177-46fb-baf1-bc152b2e391a", "instance_template": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::instance-template:1e09281b-f177-46fb-baf1-bc152b2e391a", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/instance/templates/1e09281b-f177-46fb-baf1-bc152b2e391a", "id": "a6b1a881-2ce8-41a3-80fc-36316a73f803", "name": "my-instance-template"}, "lifecycle_reasons": [{"code": "resource_suspended_by_provider", "message": "The resource has been suspended. Contact IBM support with the CRN for next steps.", "more_info": "https://cloud.ibm.com/apidocs/vpc#resource-suspension"}], "lifecycle_state": "stable", "load_balancer_pool": {"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/load_balancers/dd754295-e9e0-4c9d-bf6c-58fbc59e5727/pools/70294e14-4e61-11e8-bcf4-0242ac110004", "id": "70294e14-4e61-11e8-bcf4-0242ac110004", "name": "my-load-balancer-pool"}, "managers": [{"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/instance_groups/1e09281b-f177-46fb-baf1-bc152b2e391a/managers/dd754295-e9e0-4c9d-bf6c-58fbc59e5727", "id": "1e09281b-f177-46fb-baf1-bc152b2e391a", "name": "my-instance-group-manager"}], "membership_count": 10, "name": "my-instance-group", "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "status": "deleting", "subnets": [{"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "id": "7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "name": "my-subnet", "resource_type": "subnet"}], "updated_at": "2019-01-01T12:00:00.000Z", "vpc": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::vpc:4727d842-f94f-4a2d-824a-9bc9b02c523b", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/vpcs/4727d842-f94f-4a2d-824a-9bc9b02c523b", "id": "4727d842-f94f-4a2d-824a-9bc9b02c523b", "name": "my-vpc", "resource_type": "vpc"}}`) })) }) It(`Invoke GetInstanceGroup successfully with retries`, func() { @@ -29617,7 +29617,7 @@ var _ = Describe(`VpcV1`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"application_port": 22, "created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::instance-group:1e09281b-f177-46fb-baf1-bc152b2e391a", "href": "https://us-south.iaas.cloud.ibm.com/v1/instance_groups/1e09281b-f177-46fb-baf1-bc152b2e391a", "id": "1e09281b-f177-46fb-baf1-bc152b2e391a", "instance_template": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::instance-template:1e09281b-f177-46fb-baf1-bc152b2e391a", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/instance/templates/1e09281b-f177-46fb-baf1-bc152b2e391a", "id": "a6b1a881-2ce8-41a3-80fc-36316a73f803", "name": "my-instance-template"}, "load_balancer_pool": {"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/load_balancers/dd754295-e9e0-4c9d-bf6c-58fbc59e5727/pools/70294e14-4e61-11e8-bcf4-0242ac110004", "id": "70294e14-4e61-11e8-bcf4-0242ac110004", "name": "my-load-balancer-pool"}, "managers": [{"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/instance_groups/1e09281b-f177-46fb-baf1-bc152b2e391a/managers/dd754295-e9e0-4c9d-bf6c-58fbc59e5727", "id": "1e09281b-f177-46fb-baf1-bc152b2e391a", "name": "my-instance-group-manager"}], "membership_count": 10, "name": "my-instance-group", "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "status": "deleting", "subnets": [{"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "id": "7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "name": "my-subnet", "resource_type": "subnet"}], "updated_at": "2019-01-01T12:00:00.000Z", "vpc": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::vpc:4727d842-f94f-4a2d-824a-9bc9b02c523b", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/vpcs/4727d842-f94f-4a2d-824a-9bc9b02c523b", "id": "4727d842-f94f-4a2d-824a-9bc9b02c523b", "name": "my-vpc", "resource_type": "vpc"}}`) + fmt.Fprintf(res, "%s", `{"application_port": 22, "created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::instance-group:1e09281b-f177-46fb-baf1-bc152b2e391a", "href": "https://us-south.iaas.cloud.ibm.com/v1/instance_groups/1e09281b-f177-46fb-baf1-bc152b2e391a", "id": "1e09281b-f177-46fb-baf1-bc152b2e391a", "instance_template": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::instance-template:1e09281b-f177-46fb-baf1-bc152b2e391a", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/instance/templates/1e09281b-f177-46fb-baf1-bc152b2e391a", "id": "a6b1a881-2ce8-41a3-80fc-36316a73f803", "name": "my-instance-template"}, "lifecycle_reasons": [{"code": "resource_suspended_by_provider", "message": "The resource has been suspended. Contact IBM support with the CRN for next steps.", "more_info": "https://cloud.ibm.com/apidocs/vpc#resource-suspension"}], "lifecycle_state": "stable", "load_balancer_pool": {"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/load_balancers/dd754295-e9e0-4c9d-bf6c-58fbc59e5727/pools/70294e14-4e61-11e8-bcf4-0242ac110004", "id": "70294e14-4e61-11e8-bcf4-0242ac110004", "name": "my-load-balancer-pool"}, "managers": [{"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/instance_groups/1e09281b-f177-46fb-baf1-bc152b2e391a/managers/dd754295-e9e0-4c9d-bf6c-58fbc59e5727", "id": "1e09281b-f177-46fb-baf1-bc152b2e391a", "name": "my-instance-group-manager"}], "membership_count": 10, "name": "my-instance-group", "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "status": "deleting", "subnets": [{"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "id": "7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "name": "my-subnet", "resource_type": "subnet"}], "updated_at": "2019-01-01T12:00:00.000Z", "vpc": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::vpc:4727d842-f94f-4a2d-824a-9bc9b02c523b", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/vpcs/4727d842-f94f-4a2d-824a-9bc9b02c523b", "id": "4727d842-f94f-4a2d-824a-9bc9b02c523b", "name": "my-vpc", "resource_type": "vpc"}}`) })) }) It(`Invoke GetInstanceGroup successfully`, func() { @@ -29830,7 +29830,7 @@ var _ = Describe(`VpcV1`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"application_port": 22, "created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::instance-group:1e09281b-f177-46fb-baf1-bc152b2e391a", "href": "https://us-south.iaas.cloud.ibm.com/v1/instance_groups/1e09281b-f177-46fb-baf1-bc152b2e391a", "id": "1e09281b-f177-46fb-baf1-bc152b2e391a", "instance_template": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::instance-template:1e09281b-f177-46fb-baf1-bc152b2e391a", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/instance/templates/1e09281b-f177-46fb-baf1-bc152b2e391a", "id": "a6b1a881-2ce8-41a3-80fc-36316a73f803", "name": "my-instance-template"}, "load_balancer_pool": {"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/load_balancers/dd754295-e9e0-4c9d-bf6c-58fbc59e5727/pools/70294e14-4e61-11e8-bcf4-0242ac110004", "id": "70294e14-4e61-11e8-bcf4-0242ac110004", "name": "my-load-balancer-pool"}, "managers": [{"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/instance_groups/1e09281b-f177-46fb-baf1-bc152b2e391a/managers/dd754295-e9e0-4c9d-bf6c-58fbc59e5727", "id": "1e09281b-f177-46fb-baf1-bc152b2e391a", "name": "my-instance-group-manager"}], "membership_count": 10, "name": "my-instance-group", "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "status": "deleting", "subnets": [{"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "id": "7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "name": "my-subnet", "resource_type": "subnet"}], "updated_at": "2019-01-01T12:00:00.000Z", "vpc": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::vpc:4727d842-f94f-4a2d-824a-9bc9b02c523b", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/vpcs/4727d842-f94f-4a2d-824a-9bc9b02c523b", "id": "4727d842-f94f-4a2d-824a-9bc9b02c523b", "name": "my-vpc", "resource_type": "vpc"}}`) + fmt.Fprintf(res, "%s", `{"application_port": 22, "created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::instance-group:1e09281b-f177-46fb-baf1-bc152b2e391a", "href": "https://us-south.iaas.cloud.ibm.com/v1/instance_groups/1e09281b-f177-46fb-baf1-bc152b2e391a", "id": "1e09281b-f177-46fb-baf1-bc152b2e391a", "instance_template": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::instance-template:1e09281b-f177-46fb-baf1-bc152b2e391a", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/instance/templates/1e09281b-f177-46fb-baf1-bc152b2e391a", "id": "a6b1a881-2ce8-41a3-80fc-36316a73f803", "name": "my-instance-template"}, "lifecycle_reasons": [{"code": "resource_suspended_by_provider", "message": "The resource has been suspended. Contact IBM support with the CRN for next steps.", "more_info": "https://cloud.ibm.com/apidocs/vpc#resource-suspension"}], "lifecycle_state": "stable", "load_balancer_pool": {"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/load_balancers/dd754295-e9e0-4c9d-bf6c-58fbc59e5727/pools/70294e14-4e61-11e8-bcf4-0242ac110004", "id": "70294e14-4e61-11e8-bcf4-0242ac110004", "name": "my-load-balancer-pool"}, "managers": [{"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/instance_groups/1e09281b-f177-46fb-baf1-bc152b2e391a/managers/dd754295-e9e0-4c9d-bf6c-58fbc59e5727", "id": "1e09281b-f177-46fb-baf1-bc152b2e391a", "name": "my-instance-group-manager"}], "membership_count": 10, "name": "my-instance-group", "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "status": "deleting", "subnets": [{"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "id": "7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "name": "my-subnet", "resource_type": "subnet"}], "updated_at": "2019-01-01T12:00:00.000Z", "vpc": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::vpc:4727d842-f94f-4a2d-824a-9bc9b02c523b", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/vpcs/4727d842-f94f-4a2d-824a-9bc9b02c523b", "id": "4727d842-f94f-4a2d-824a-9bc9b02c523b", "name": "my-vpc", "resource_type": "vpc"}}`) })) }) It(`Invoke UpdateInstanceGroup successfully with retries`, func() { @@ -29932,7 +29932,7 @@ var _ = Describe(`VpcV1`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"application_port": 22, "created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::instance-group:1e09281b-f177-46fb-baf1-bc152b2e391a", "href": "https://us-south.iaas.cloud.ibm.com/v1/instance_groups/1e09281b-f177-46fb-baf1-bc152b2e391a", "id": "1e09281b-f177-46fb-baf1-bc152b2e391a", "instance_template": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::instance-template:1e09281b-f177-46fb-baf1-bc152b2e391a", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/instance/templates/1e09281b-f177-46fb-baf1-bc152b2e391a", "id": "a6b1a881-2ce8-41a3-80fc-36316a73f803", "name": "my-instance-template"}, "load_balancer_pool": {"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/load_balancers/dd754295-e9e0-4c9d-bf6c-58fbc59e5727/pools/70294e14-4e61-11e8-bcf4-0242ac110004", "id": "70294e14-4e61-11e8-bcf4-0242ac110004", "name": "my-load-balancer-pool"}, "managers": [{"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/instance_groups/1e09281b-f177-46fb-baf1-bc152b2e391a/managers/dd754295-e9e0-4c9d-bf6c-58fbc59e5727", "id": "1e09281b-f177-46fb-baf1-bc152b2e391a", "name": "my-instance-group-manager"}], "membership_count": 10, "name": "my-instance-group", "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "status": "deleting", "subnets": [{"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "id": "7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "name": "my-subnet", "resource_type": "subnet"}], "updated_at": "2019-01-01T12:00:00.000Z", "vpc": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::vpc:4727d842-f94f-4a2d-824a-9bc9b02c523b", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/vpcs/4727d842-f94f-4a2d-824a-9bc9b02c523b", "id": "4727d842-f94f-4a2d-824a-9bc9b02c523b", "name": "my-vpc", "resource_type": "vpc"}}`) + fmt.Fprintf(res, "%s", `{"application_port": 22, "created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::instance-group:1e09281b-f177-46fb-baf1-bc152b2e391a", "href": "https://us-south.iaas.cloud.ibm.com/v1/instance_groups/1e09281b-f177-46fb-baf1-bc152b2e391a", "id": "1e09281b-f177-46fb-baf1-bc152b2e391a", "instance_template": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::instance-template:1e09281b-f177-46fb-baf1-bc152b2e391a", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/instance/templates/1e09281b-f177-46fb-baf1-bc152b2e391a", "id": "a6b1a881-2ce8-41a3-80fc-36316a73f803", "name": "my-instance-template"}, "lifecycle_reasons": [{"code": "resource_suspended_by_provider", "message": "The resource has been suspended. Contact IBM support with the CRN for next steps.", "more_info": "https://cloud.ibm.com/apidocs/vpc#resource-suspension"}], "lifecycle_state": "stable", "load_balancer_pool": {"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/load_balancers/dd754295-e9e0-4c9d-bf6c-58fbc59e5727/pools/70294e14-4e61-11e8-bcf4-0242ac110004", "id": "70294e14-4e61-11e8-bcf4-0242ac110004", "name": "my-load-balancer-pool"}, "managers": [{"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/instance_groups/1e09281b-f177-46fb-baf1-bc152b2e391a/managers/dd754295-e9e0-4c9d-bf6c-58fbc59e5727", "id": "1e09281b-f177-46fb-baf1-bc152b2e391a", "name": "my-instance-group-manager"}], "membership_count": 10, "name": "my-instance-group", "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "status": "deleting", "subnets": [{"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "id": "7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "name": "my-subnet", "resource_type": "subnet"}], "updated_at": "2019-01-01T12:00:00.000Z", "vpc": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::vpc:4727d842-f94f-4a2d-824a-9bc9b02c523b", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/vpcs/4727d842-f94f-4a2d-824a-9bc9b02c523b", "id": "4727d842-f94f-4a2d-824a-9bc9b02c523b", "name": "my-vpc", "resource_type": "vpc"}}`) })) }) It(`Invoke UpdateInstanceGroup successfully`, func() { @@ -40670,30 +40670,27 @@ var _ = Describe(`VpcV1`, func() { }) }) }) - Describe(`ListBackupPolicies(listBackupPoliciesOptions *ListBackupPoliciesOptions) - Operation response error`, func() { + Describe(`ListPlacementGroups(listPlacementGroupsOptions *ListPlacementGroupsOptions) - Operation response error`, func() { version := "testString" - listBackupPoliciesPath := "/backup_policies" + 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(listBackupPoliciesPath)) + 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(10))})) - 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 ListBackupPolicies with error: Operation response processing error`, func() { + It(`Invoke ListPlacementGroups with error: Operation response processing error`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -40702,23 +40699,20 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the ListBackupPoliciesOptions model - listBackupPoliciesOptionsModel := new(vpcv1.ListBackupPoliciesOptions) - listBackupPoliciesOptionsModel.Start = core.StringPtr("testString") - listBackupPoliciesOptionsModel.Limit = core.Int64Ptr(int64(10)) - 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"} + // Construct an instance of the ListPlacementGroupsOptions model + listPlacementGroupsOptionsModel := new(vpcv1.ListPlacementGroupsOptions) + listPlacementGroupsOptionsModel.Start = core.StringPtr("testString") + listPlacementGroupsOptionsModel.Limit = core.Int64Ptr(int64(10)) + 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.ListBackupPolicies(listBackupPoliciesOptionsModel) + 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.ListBackupPolicies(listBackupPoliciesOptionsModel) + result, response, operationErr = vpcService.ListPlacementGroups(listPlacementGroupsOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).To(BeNil()) @@ -40728,35 +40722,32 @@ var _ = Describe(`VpcV1`, func() { }) }) }) - Describe(`ListBackupPolicies(listBackupPoliciesOptions *ListBackupPoliciesOptions)`, func() { + Describe(`ListPlacementGroups(listPlacementGroupsOptions *ListPlacementGroupsOptions)`, func() { version := "testString" - listBackupPoliciesPath := "/backup_policies" + 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(listBackupPoliciesPath)) + 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(10))})) - 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", `{"backup_policies": [{"created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south:a/123456::backup-policy:r134-076191ba-49c2-4763-94fd-c70de73ee2e6", "health_reasons": [{"code": "missing_service_authorization_policies", "message": "One or more accounts are missing service authorization policies", "more_info": "https://cloud.ibm.com/docs/vpc?topic=vpc-backup-service-about&interface=ui"}], "health_state": "ok", "href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6", "id": "r134-076191ba-49c2-4763-94fd-c70de73ee2e6", "last_job_completed_at": "2019-01-01T12:00:00.000Z", "lifecycle_state": "stable", "match_user_tags": ["MatchUserTags"], "name": "my-backup-policy", "plans": [{"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6/plans/r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "id": "r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "name": "my-policy-plan", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "backup_policy_plan"}], "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "resource_type": "backup_policy", "scope": {"crn": "crn:v1:bluemix:public:enterprise::a/123456::enterprise:ebc2b430240943458b9e91e1432cfcce", "id": "fee82deba12e4c0fb69c3b09d1f12345", "resource_type": "enterprise"}, "included_content": ["data_volumes"], "match_resource_type": "instance"}], "first": {"href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies?limit=20"}, "limit": 20, "next": {"href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies?start=9d5a91a3e2cbd233b5a5b33436855ed1&limit=20"}, "total_count": 132}`) + 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 ListBackupPolicies successfully with retries`, func() { + It(`Invoke ListPlacementGroups successfully with retries`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -40766,25 +40757,22 @@ var _ = Describe(`VpcV1`, func() { Expect(vpcService).ToNot(BeNil()) vpcService.EnableRetries(0, 0) - // Construct an instance of the ListBackupPoliciesOptions model - listBackupPoliciesOptionsModel := new(vpcv1.ListBackupPoliciesOptions) - listBackupPoliciesOptionsModel.Start = core.StringPtr("testString") - listBackupPoliciesOptionsModel.Limit = core.Int64Ptr(int64(10)) - 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"} + // Construct an instance of the ListPlacementGroupsOptions model + listPlacementGroupsOptionsModel := new(vpcv1.ListPlacementGroupsOptions) + listPlacementGroupsOptionsModel.Start = core.StringPtr("testString") + listPlacementGroupsOptionsModel.Limit = core.Int64Ptr(int64(10)) + 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.ListBackupPoliciesWithContext(ctx, listBackupPoliciesOptionsModel) + _, _, 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.ListBackupPolicies(listBackupPoliciesOptionsModel) + result, response, operationErr := vpcService.ListPlacementGroups(listPlacementGroupsOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) @@ -40792,7 +40780,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.ListBackupPoliciesWithContext(ctx, listBackupPoliciesOptionsModel) + _, _, operationErr = vpcService.ListPlacementGroupsWithContext(ctx, listPlacementGroupsOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) }) @@ -40806,23 +40794,20 @@ var _ = Describe(`VpcV1`, func() { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(listBackupPoliciesPath)) + 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(10))})) - 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", `{"backup_policies": [{"created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south:a/123456::backup-policy:r134-076191ba-49c2-4763-94fd-c70de73ee2e6", "health_reasons": [{"code": "missing_service_authorization_policies", "message": "One or more accounts are missing service authorization policies", "more_info": "https://cloud.ibm.com/docs/vpc?topic=vpc-backup-service-about&interface=ui"}], "health_state": "ok", "href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6", "id": "r134-076191ba-49c2-4763-94fd-c70de73ee2e6", "last_job_completed_at": "2019-01-01T12:00:00.000Z", "lifecycle_state": "stable", "match_user_tags": ["MatchUserTags"], "name": "my-backup-policy", "plans": [{"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6/plans/r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "id": "r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "name": "my-policy-plan", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "backup_policy_plan"}], "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "resource_type": "backup_policy", "scope": {"crn": "crn:v1:bluemix:public:enterprise::a/123456::enterprise:ebc2b430240943458b9e91e1432cfcce", "id": "fee82deba12e4c0fb69c3b09d1f12345", "resource_type": "enterprise"}, "included_content": ["data_volumes"], "match_resource_type": "instance"}], "first": {"href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies?limit=20"}, "limit": 20, "next": {"href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies?start=9d5a91a3e2cbd233b5a5b33436855ed1&limit=20"}, "total_count": 132}`) + 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 ListBackupPolicies successfully`, func() { + It(`Invoke ListPlacementGroups successfully`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -40832,28 +40817,25 @@ var _ = Describe(`VpcV1`, func() { Expect(vpcService).ToNot(BeNil()) // Invoke operation with nil options model (negative test) - result, response, operationErr := vpcService.ListBackupPolicies(nil) + result, response, operationErr := vpcService.ListPlacementGroups(nil) Expect(operationErr).NotTo(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) - // Construct an instance of the ListBackupPoliciesOptions model - listBackupPoliciesOptionsModel := new(vpcv1.ListBackupPoliciesOptions) - listBackupPoliciesOptionsModel.Start = core.StringPtr("testString") - listBackupPoliciesOptionsModel.Limit = core.Int64Ptr(int64(10)) - 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"} + // Construct an instance of the ListPlacementGroupsOptions model + listPlacementGroupsOptionsModel := new(vpcv1.ListPlacementGroupsOptions) + listPlacementGroupsOptionsModel.Start = core.StringPtr("testString") + listPlacementGroupsOptionsModel.Limit = core.Int64Ptr(int64(10)) + listPlacementGroupsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with valid options model (positive test) - result, response, operationErr = vpcService.ListBackupPolicies(listBackupPoliciesOptionsModel) + result, response, operationErr = vpcService.ListPlacementGroups(listPlacementGroupsOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) }) - It(`Invoke ListBackupPolicies with error: Operation request error`, func() { + It(`Invoke ListPlacementGroups with error: Operation request error`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -40862,18 +40844,15 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the ListBackupPoliciesOptions model - listBackupPoliciesOptionsModel := new(vpcv1.ListBackupPoliciesOptions) - listBackupPoliciesOptionsModel.Start = core.StringPtr("testString") - listBackupPoliciesOptionsModel.Limit = core.Int64Ptr(int64(10)) - 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"} + // Construct an instance of the ListPlacementGroupsOptions model + listPlacementGroupsOptionsModel := new(vpcv1.ListPlacementGroupsOptions) + listPlacementGroupsOptionsModel.Start = core.StringPtr("testString") + listPlacementGroupsOptionsModel.Limit = core.Int64Ptr(int64(10)) + 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.ListBackupPolicies(listBackupPoliciesOptionsModel) + result, response, operationErr := vpcService.ListPlacementGroups(listPlacementGroupsOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING)) Expect(response).To(BeNil()) @@ -40892,7 +40871,7 @@ var _ = Describe(`VpcV1`, func() { res.WriteHeader(200) })) }) - It(`Invoke ListBackupPolicies successfully`, func() { + It(`Invoke ListPlacementGroups successfully`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -40901,17 +40880,14 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the ListBackupPoliciesOptions model - listBackupPoliciesOptionsModel := new(vpcv1.ListBackupPoliciesOptions) - listBackupPoliciesOptionsModel.Start = core.StringPtr("testString") - listBackupPoliciesOptionsModel.Limit = core.Int64Ptr(int64(10)) - 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"} + // Construct an instance of the ListPlacementGroupsOptions model + listPlacementGroupsOptionsModel := new(vpcv1.ListPlacementGroupsOptions) + listPlacementGroupsOptionsModel.Start = core.StringPtr("testString") + listPlacementGroupsOptionsModel.Limit = core.Int64Ptr(int64(10)) + listPlacementGroupsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation - result, response, operationErr := vpcService.ListBackupPolicies(listBackupPoliciesOptionsModel) + result, response, operationErr := vpcService.ListPlacementGroups(listPlacementGroupsOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) @@ -40924,8 +40900,8 @@ var _ = Describe(`VpcV1`, func() { }) Context(`Test pagination helper method on response`, func() { It(`Invoke GetNextStart successfully`, func() { - responseObject := new(vpcv1.BackupPolicyCollection) - nextObject := new(vpcv1.BackupPolicyCollectionNext) + responseObject := new(vpcv1.PlacementGroupCollection) + nextObject := new(vpcv1.PlacementGroupCollectionNext) nextObject.Href = core.StringPtr("ibm.com?start=abc-123") responseObject.Next = nextObject @@ -40934,15 +40910,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.BackupPolicyCollection) + 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.BackupPolicyCollection) - nextObject := new(vpcv1.BackupPolicyCollectionNext) + responseObject := new(vpcv1.PlacementGroupCollection) + nextObject := new(vpcv1.PlacementGroupCollectionNext) nextObject.Href = core.StringPtr("ibm.com") responseObject.Next = nextObject @@ -40958,7 +40934,7 @@ var _ = Describe(`VpcV1`, func() { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(listBackupPoliciesPath)) + Expect(req.URL.EscapedPath()).To(Equal(listPlacementGroupsPath)) Expect(req.Method).To(Equal("GET")) // Set mock response @@ -40966,15 +40942,15 @@ var _ = Describe(`VpcV1`, func() { res.WriteHeader(200) requestNumber++ if requestNumber == 1 { - fmt.Fprintf(res, "%s", `{"next":{"href":"https://myhost.com/somePath?start=1"},"backup_policies":[{"created_at":"2019-01-01T12:00:00.000Z","crn":"crn:v1:bluemix:public:is:us-south:a/123456::backup-policy:r134-076191ba-49c2-4763-94fd-c70de73ee2e6","health_reasons":[{"code":"missing_service_authorization_policies","message":"One or more accounts are missing service authorization policies","more_info":"https://cloud.ibm.com/docs/vpc?topic=vpc-backup-service-about&interface=ui"}],"health_state":"ok","href":"https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6","id":"r134-076191ba-49c2-4763-94fd-c70de73ee2e6","last_job_completed_at":"2019-01-01T12:00:00.000Z","lifecycle_state":"stable","match_user_tags":["MatchUserTags"],"name":"my-backup-policy","plans":[{"deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6/plans/r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178","id":"r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178","name":"my-policy-plan","remote":{"region":{"href":"https://us-south.iaas.cloud.ibm.com/v1/regions/us-south","name":"us-south"}},"resource_type":"backup_policy_plan"}],"resource_group":{"href":"https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345","id":"fee82deba12e4c0fb69c3b09d1f12345","name":"my-resource-group"},"resource_type":"backup_policy","scope":{"crn":"crn:v1:bluemix:public:enterprise::a/123456::enterprise:ebc2b430240943458b9e91e1432cfcce","id":"fee82deba12e4c0fb69c3b09d1f12345","resource_type":"enterprise"},"included_content":["data_volumes"],"match_resource_type":"instance"}],"total_count":2,"limit":1}`) + fmt.Fprintf(res, "%s", `{"next":{"href":"https://myhost.com/somePath?start=1"},"total_count":2,"limit":1,"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"}]}`) } else if requestNumber == 2 { - fmt.Fprintf(res, "%s", `{"backup_policies":[{"created_at":"2019-01-01T12:00:00.000Z","crn":"crn:v1:bluemix:public:is:us-south:a/123456::backup-policy:r134-076191ba-49c2-4763-94fd-c70de73ee2e6","health_reasons":[{"code":"missing_service_authorization_policies","message":"One or more accounts are missing service authorization policies","more_info":"https://cloud.ibm.com/docs/vpc?topic=vpc-backup-service-about&interface=ui"}],"health_state":"ok","href":"https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6","id":"r134-076191ba-49c2-4763-94fd-c70de73ee2e6","last_job_completed_at":"2019-01-01T12:00:00.000Z","lifecycle_state":"stable","match_user_tags":["MatchUserTags"],"name":"my-backup-policy","plans":[{"deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6/plans/r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178","id":"r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178","name":"my-policy-plan","remote":{"region":{"href":"https://us-south.iaas.cloud.ibm.com/v1/regions/us-south","name":"us-south"}},"resource_type":"backup_policy_plan"}],"resource_group":{"href":"https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345","id":"fee82deba12e4c0fb69c3b09d1f12345","name":"my-resource-group"},"resource_type":"backup_policy","scope":{"crn":"crn:v1:bluemix:public:enterprise::a/123456::enterprise:ebc2b430240943458b9e91e1432cfcce","id":"fee82deba12e4c0fb69c3b09d1f12345","resource_type":"enterprise"},"included_content":["data_volumes"],"match_resource_type":"instance"}],"total_count":2,"limit":1}`) + fmt.Fprintf(res, "%s", `{"total_count":2,"limit":1,"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"}]}`) } else { res.WriteHeader(400) } })) }) - It(`Use BackupPoliciesPager.GetNext successfully`, func() { + It(`Use PlacementGroupsPager.GetNext successfully`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -40983,18 +40959,15 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - listBackupPoliciesOptionsModel := &vpcv1.ListBackupPoliciesOptions{ - Limit: core.Int64Ptr(int64(10)), - ResourceGroupID: core.StringPtr("testString"), - Name: core.StringPtr("testString"), - Tag: core.StringPtr("testString"), + listPlacementGroupsOptionsModel := &vpcv1.ListPlacementGroupsOptions{ + Limit: core.Int64Ptr(int64(10)), } - pager, err := vpcService.NewBackupPoliciesPager(listBackupPoliciesOptionsModel) + pager, err := vpcService.NewPlacementGroupsPager(listPlacementGroupsOptionsModel) Expect(err).To(BeNil()) Expect(pager).ToNot(BeNil()) - var allResults []vpcv1.BackupPolicyIntf + var allResults []vpcv1.PlacementGroup for pager.HasNext() { nextPage, err := pager.GetNext() Expect(err).To(BeNil()) @@ -41003,7 +40976,7 @@ var _ = Describe(`VpcV1`, func() { } Expect(len(allResults)).To(Equal(2)) }) - It(`Use BackupPoliciesPager.GetAll successfully`, func() { + It(`Use PlacementGroupsPager.GetAll successfully`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -41012,14 +40985,11 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - listBackupPoliciesOptionsModel := &vpcv1.ListBackupPoliciesOptions{ - Limit: core.Int64Ptr(int64(10)), - ResourceGroupID: core.StringPtr("testString"), - Name: core.StringPtr("testString"), - Tag: core.StringPtr("testString"), + listPlacementGroupsOptionsModel := &vpcv1.ListPlacementGroupsOptions{ + Limit: core.Int64Ptr(int64(10)), } - pager, err := vpcService.NewBackupPoliciesPager(listBackupPoliciesOptionsModel) + pager, err := vpcService.NewPlacementGroupsPager(listPlacementGroupsOptionsModel) Expect(err).To(BeNil()) Expect(pager).ToNot(BeNil()) @@ -41030,16 +41000,16 @@ var _ = Describe(`VpcV1`, func() { }) }) }) - Describe(`CreateBackupPolicy(createBackupPolicyOptions *CreateBackupPolicyOptions) - Operation response error`, func() { + Describe(`CreatePlacementGroup(createPlacementGroupOptions *CreatePlacementGroupOptions) - Operation response error`, func() { version := "testString" - createBackupPolicyPath := "/backup_policies" + 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(createBackupPolicyPath)) + 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))})) @@ -41048,7 +41018,7 @@ var _ = Describe(`VpcV1`, func() { fmt.Fprint(res, `} this is not valid json {`) })) }) - It(`Invoke CreateBackupPolicy with error: Operation response processing error`, func() { + It(`Invoke CreatePlacementGroup with error: Operation response processing error`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -41057,75 +41027,25 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the ZoneIdentityByName model - zoneIdentityModel := new(vpcv1.ZoneIdentityByName) - zoneIdentityModel.Name = core.StringPtr("us-south-1") - - // Construct an instance of the BackupPolicyPlanClonePolicyPrototype model - backupPolicyPlanClonePolicyPrototypeModel := new(vpcv1.BackupPolicyPlanClonePolicyPrototype) - backupPolicyPlanClonePolicyPrototypeModel.MaxSnapshots = core.Int64Ptr(int64(5)) - backupPolicyPlanClonePolicyPrototypeModel.Zones = []vpcv1.ZoneIdentityIntf{zoneIdentityModel} - - // 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 EncryptionKeyIdentityByCRN model - encryptionKeyIdentityModel := new(vpcv1.EncryptionKeyIdentityByCRN) - encryptionKeyIdentityModel.CRN = core.StringPtr("crn:v1:bluemix:public:kms:us-south:a/123456:e4a29d1a-2ef0-42a6-8fd2-350deb1c647e:key:5437653b-c4b1-447f-9646-b2a2a4cd6179") - - // Construct an instance of the RegionIdentityByName model - regionIdentityModel := new(vpcv1.RegionIdentityByName) - regionIdentityModel.Name = core.StringPtr("us-south") - - // Construct an instance of the BackupPolicyPlanRemoteRegionPolicyPrototype model - backupPolicyPlanRemoteRegionPolicyPrototypeModel := new(vpcv1.BackupPolicyPlanRemoteRegionPolicyPrototype) - backupPolicyPlanRemoteRegionPolicyPrototypeModel.DeleteOverCount = core.Int64Ptr(int64(5)) - backupPolicyPlanRemoteRegionPolicyPrototypeModel.EncryptionKey = encryptionKeyIdentityModel - backupPolicyPlanRemoteRegionPolicyPrototypeModel.Region = regionIdentityModel - - // Construct an instance of the BackupPolicyPlanPrototype model - backupPolicyPlanPrototypeModel := new(vpcv1.BackupPolicyPlanPrototype) - backupPolicyPlanPrototypeModel.Active = core.BoolPtr(true) - backupPolicyPlanPrototypeModel.AttachUserTags = []string{"my-daily-backup-plan"} - backupPolicyPlanPrototypeModel.ClonePolicy = backupPolicyPlanClonePolicyPrototypeModel - backupPolicyPlanPrototypeModel.CopyUserTags = core.BoolPtr(true) - backupPolicyPlanPrototypeModel.CronSpec = core.StringPtr("30 */2 * * 1-5") - backupPolicyPlanPrototypeModel.DeletionTrigger = backupPolicyPlanDeletionTriggerPrototypeModel - backupPolicyPlanPrototypeModel.Name = core.StringPtr("my-policy-plan") - backupPolicyPlanPrototypeModel.RemoteRegionPolicies = []vpcv1.BackupPolicyPlanRemoteRegionPolicyPrototype{*backupPolicyPlanRemoteRegionPolicyPrototypeModel} - // Construct an instance of the ResourceGroupIdentityByID model resourceGroupIdentityModel := new(vpcv1.ResourceGroupIdentityByID) resourceGroupIdentityModel.ID = core.StringPtr("fee82deba12e4c0fb69c3b09d1f12345") - // Construct an instance of the BackupPolicyScopePrototypeEnterpriseIdentityEnterpriseIdentityByCRN model - backupPolicyScopePrototypeModel := new(vpcv1.BackupPolicyScopePrototypeEnterpriseIdentityEnterpriseIdentityByCRN) - backupPolicyScopePrototypeModel.CRN = core.StringPtr("crn:v1:bluemix:public:enterprise::a/123456::enterprise:ebc2b430240943458b9e91e1432cfcce") - - // Construct an instance of the BackupPolicyPrototypeBackupPolicyMatchResourceTypeVolumePrototype model - backupPolicyPrototypeModel := new(vpcv1.BackupPolicyPrototypeBackupPolicyMatchResourceTypeVolumePrototype) - backupPolicyPrototypeModel.MatchUserTags = []string{"my-daily-backup-policy"} - backupPolicyPrototypeModel.Name = core.StringPtr("my-backup-policy") - backupPolicyPrototypeModel.Plans = []vpcv1.BackupPolicyPlanPrototype{*backupPolicyPlanPrototypeModel} - backupPolicyPrototypeModel.ResourceGroup = resourceGroupIdentityModel - backupPolicyPrototypeModel.Scope = backupPolicyScopePrototypeModel - backupPolicyPrototypeModel.MatchResourceType = core.StringPtr("volume") - - // Construct an instance of the CreateBackupPolicyOptions model - createBackupPolicyOptionsModel := new(vpcv1.CreateBackupPolicyOptions) - createBackupPolicyOptionsModel.BackupPolicyPrototype = backupPolicyPrototypeModel - createBackupPolicyOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // 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.CreateBackupPolicy(createBackupPolicyOptionsModel) + 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.CreateBackupPolicy(createBackupPolicyOptionsModel) + result, response, operationErr = vpcService.CreatePlacementGroup(createPlacementGroupOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).To(BeNil()) @@ -41135,16 +41055,16 @@ var _ = Describe(`VpcV1`, func() { }) }) }) - Describe(`CreateBackupPolicy(createBackupPolicyOptions *CreateBackupPolicyOptions)`, func() { + Describe(`CreatePlacementGroup(createPlacementGroupOptions *CreatePlacementGroupOptions)`, func() { version := "testString" - createBackupPolicyPath := "/backup_policies" + 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(createBackupPolicyPath)) + Expect(req.URL.EscapedPath()).To(Equal(createPlacementGroupPath)) Expect(req.Method).To(Equal("POST")) // For gzip-disabled operation, verify Content-Encoding is not set. @@ -41171,10 +41091,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::backup-policy:r134-076191ba-49c2-4763-94fd-c70de73ee2e6", "health_reasons": [{"code": "missing_service_authorization_policies", "message": "One or more accounts are missing service authorization policies", "more_info": "https://cloud.ibm.com/docs/vpc?topic=vpc-backup-service-about&interface=ui"}], "health_state": "ok", "href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6", "id": "r134-076191ba-49c2-4763-94fd-c70de73ee2e6", "last_job_completed_at": "2019-01-01T12:00:00.000Z", "lifecycle_state": "stable", "match_user_tags": ["MatchUserTags"], "name": "my-backup-policy", "plans": [{"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6/plans/r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "id": "r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "name": "my-policy-plan", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "backup_policy_plan"}], "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "resource_type": "backup_policy", "scope": {"crn": "crn:v1:bluemix:public:enterprise::a/123456::enterprise:ebc2b430240943458b9e91e1432cfcce", "id": "fee82deba12e4c0fb69c3b09d1f12345", "resource_type": "enterprise"}, "included_content": ["data_volumes"], "match_resource_type": "instance"}`) + 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 CreateBackupPolicy successfully with retries`, func() { + It(`Invoke CreatePlacementGroup successfully with retries`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -41184,77 +41104,27 @@ var _ = Describe(`VpcV1`, func() { Expect(vpcService).ToNot(BeNil()) vpcService.EnableRetries(0, 0) - // Construct an instance of the ZoneIdentityByName model - zoneIdentityModel := new(vpcv1.ZoneIdentityByName) - zoneIdentityModel.Name = core.StringPtr("us-south-1") - - // Construct an instance of the BackupPolicyPlanClonePolicyPrototype model - backupPolicyPlanClonePolicyPrototypeModel := new(vpcv1.BackupPolicyPlanClonePolicyPrototype) - backupPolicyPlanClonePolicyPrototypeModel.MaxSnapshots = core.Int64Ptr(int64(5)) - backupPolicyPlanClonePolicyPrototypeModel.Zones = []vpcv1.ZoneIdentityIntf{zoneIdentityModel} - - // 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 EncryptionKeyIdentityByCRN model - encryptionKeyIdentityModel := new(vpcv1.EncryptionKeyIdentityByCRN) - encryptionKeyIdentityModel.CRN = core.StringPtr("crn:v1:bluemix:public:kms:us-south:a/123456:e4a29d1a-2ef0-42a6-8fd2-350deb1c647e:key:5437653b-c4b1-447f-9646-b2a2a4cd6179") - - // Construct an instance of the RegionIdentityByName model - regionIdentityModel := new(vpcv1.RegionIdentityByName) - regionIdentityModel.Name = core.StringPtr("us-south") - - // Construct an instance of the BackupPolicyPlanRemoteRegionPolicyPrototype model - backupPolicyPlanRemoteRegionPolicyPrototypeModel := new(vpcv1.BackupPolicyPlanRemoteRegionPolicyPrototype) - backupPolicyPlanRemoteRegionPolicyPrototypeModel.DeleteOverCount = core.Int64Ptr(int64(5)) - backupPolicyPlanRemoteRegionPolicyPrototypeModel.EncryptionKey = encryptionKeyIdentityModel - backupPolicyPlanRemoteRegionPolicyPrototypeModel.Region = regionIdentityModel - - // Construct an instance of the BackupPolicyPlanPrototype model - backupPolicyPlanPrototypeModel := new(vpcv1.BackupPolicyPlanPrototype) - backupPolicyPlanPrototypeModel.Active = core.BoolPtr(true) - backupPolicyPlanPrototypeModel.AttachUserTags = []string{"my-daily-backup-plan"} - backupPolicyPlanPrototypeModel.ClonePolicy = backupPolicyPlanClonePolicyPrototypeModel - backupPolicyPlanPrototypeModel.CopyUserTags = core.BoolPtr(true) - backupPolicyPlanPrototypeModel.CronSpec = core.StringPtr("30 */2 * * 1-5") - backupPolicyPlanPrototypeModel.DeletionTrigger = backupPolicyPlanDeletionTriggerPrototypeModel - backupPolicyPlanPrototypeModel.Name = core.StringPtr("my-policy-plan") - backupPolicyPlanPrototypeModel.RemoteRegionPolicies = []vpcv1.BackupPolicyPlanRemoteRegionPolicyPrototype{*backupPolicyPlanRemoteRegionPolicyPrototypeModel} - // Construct an instance of the ResourceGroupIdentityByID model resourceGroupIdentityModel := new(vpcv1.ResourceGroupIdentityByID) resourceGroupIdentityModel.ID = core.StringPtr("fee82deba12e4c0fb69c3b09d1f12345") - // Construct an instance of the BackupPolicyScopePrototypeEnterpriseIdentityEnterpriseIdentityByCRN model - backupPolicyScopePrototypeModel := new(vpcv1.BackupPolicyScopePrototypeEnterpriseIdentityEnterpriseIdentityByCRN) - backupPolicyScopePrototypeModel.CRN = core.StringPtr("crn:v1:bluemix:public:enterprise::a/123456::enterprise:ebc2b430240943458b9e91e1432cfcce") - - // Construct an instance of the BackupPolicyPrototypeBackupPolicyMatchResourceTypeVolumePrototype model - backupPolicyPrototypeModel := new(vpcv1.BackupPolicyPrototypeBackupPolicyMatchResourceTypeVolumePrototype) - backupPolicyPrototypeModel.MatchUserTags = []string{"my-daily-backup-policy"} - backupPolicyPrototypeModel.Name = core.StringPtr("my-backup-policy") - backupPolicyPrototypeModel.Plans = []vpcv1.BackupPolicyPlanPrototype{*backupPolicyPlanPrototypeModel} - backupPolicyPrototypeModel.ResourceGroup = resourceGroupIdentityModel - backupPolicyPrototypeModel.Scope = backupPolicyScopePrototypeModel - backupPolicyPrototypeModel.MatchResourceType = core.StringPtr("volume") - - // Construct an instance of the CreateBackupPolicyOptions model - createBackupPolicyOptionsModel := new(vpcv1.CreateBackupPolicyOptions) - createBackupPolicyOptionsModel.BackupPolicyPrototype = backupPolicyPrototypeModel - createBackupPolicyOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // 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.CreateBackupPolicyWithContext(ctx, createBackupPolicyOptionsModel) + _, _, 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.CreateBackupPolicy(createBackupPolicyOptionsModel) + result, response, operationErr := vpcService.CreatePlacementGroup(createPlacementGroupOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) @@ -41262,7 +41132,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.CreateBackupPolicyWithContext(ctx, createBackupPolicyOptionsModel) + _, _, operationErr = vpcService.CreatePlacementGroupWithContext(ctx, createPlacementGroupOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) }) @@ -41276,7 +41146,7 @@ var _ = Describe(`VpcV1`, func() { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(createBackupPolicyPath)) + Expect(req.URL.EscapedPath()).To(Equal(createPlacementGroupPath)) Expect(req.Method).To(Equal("POST")) // For gzip-disabled operation, verify Content-Encoding is not set. @@ -41300,10 +41170,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::backup-policy:r134-076191ba-49c2-4763-94fd-c70de73ee2e6", "health_reasons": [{"code": "missing_service_authorization_policies", "message": "One or more accounts are missing service authorization policies", "more_info": "https://cloud.ibm.com/docs/vpc?topic=vpc-backup-service-about&interface=ui"}], "health_state": "ok", "href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6", "id": "r134-076191ba-49c2-4763-94fd-c70de73ee2e6", "last_job_completed_at": "2019-01-01T12:00:00.000Z", "lifecycle_state": "stable", "match_user_tags": ["MatchUserTags"], "name": "my-backup-policy", "plans": [{"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6/plans/r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "id": "r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "name": "my-policy-plan", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "backup_policy_plan"}], "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "resource_type": "backup_policy", "scope": {"crn": "crn:v1:bluemix:public:enterprise::a/123456::enterprise:ebc2b430240943458b9e91e1432cfcce", "id": "fee82deba12e4c0fb69c3b09d1f12345", "resource_type": "enterprise"}, "included_content": ["data_volumes"], "match_resource_type": "instance"}`) + 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 CreateBackupPolicy successfully`, func() { + It(`Invoke CreatePlacementGroup successfully`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -41313,80 +41183,30 @@ var _ = Describe(`VpcV1`, func() { Expect(vpcService).ToNot(BeNil()) // Invoke operation with nil options model (negative test) - result, response, operationErr := vpcService.CreateBackupPolicy(nil) + result, response, operationErr := vpcService.CreatePlacementGroup(nil) Expect(operationErr).NotTo(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) - // Construct an instance of the ZoneIdentityByName model - zoneIdentityModel := new(vpcv1.ZoneIdentityByName) - zoneIdentityModel.Name = core.StringPtr("us-south-1") - - // Construct an instance of the BackupPolicyPlanClonePolicyPrototype model - backupPolicyPlanClonePolicyPrototypeModel := new(vpcv1.BackupPolicyPlanClonePolicyPrototype) - backupPolicyPlanClonePolicyPrototypeModel.MaxSnapshots = core.Int64Ptr(int64(5)) - backupPolicyPlanClonePolicyPrototypeModel.Zones = []vpcv1.ZoneIdentityIntf{zoneIdentityModel} - - // 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 EncryptionKeyIdentityByCRN model - encryptionKeyIdentityModel := new(vpcv1.EncryptionKeyIdentityByCRN) - encryptionKeyIdentityModel.CRN = core.StringPtr("crn:v1:bluemix:public:kms:us-south:a/123456:e4a29d1a-2ef0-42a6-8fd2-350deb1c647e:key:5437653b-c4b1-447f-9646-b2a2a4cd6179") - - // Construct an instance of the RegionIdentityByName model - regionIdentityModel := new(vpcv1.RegionIdentityByName) - regionIdentityModel.Name = core.StringPtr("us-south") - - // Construct an instance of the BackupPolicyPlanRemoteRegionPolicyPrototype model - backupPolicyPlanRemoteRegionPolicyPrototypeModel := new(vpcv1.BackupPolicyPlanRemoteRegionPolicyPrototype) - backupPolicyPlanRemoteRegionPolicyPrototypeModel.DeleteOverCount = core.Int64Ptr(int64(5)) - backupPolicyPlanRemoteRegionPolicyPrototypeModel.EncryptionKey = encryptionKeyIdentityModel - backupPolicyPlanRemoteRegionPolicyPrototypeModel.Region = regionIdentityModel - - // Construct an instance of the BackupPolicyPlanPrototype model - backupPolicyPlanPrototypeModel := new(vpcv1.BackupPolicyPlanPrototype) - backupPolicyPlanPrototypeModel.Active = core.BoolPtr(true) - backupPolicyPlanPrototypeModel.AttachUserTags = []string{"my-daily-backup-plan"} - backupPolicyPlanPrototypeModel.ClonePolicy = backupPolicyPlanClonePolicyPrototypeModel - backupPolicyPlanPrototypeModel.CopyUserTags = core.BoolPtr(true) - backupPolicyPlanPrototypeModel.CronSpec = core.StringPtr("30 */2 * * 1-5") - backupPolicyPlanPrototypeModel.DeletionTrigger = backupPolicyPlanDeletionTriggerPrototypeModel - backupPolicyPlanPrototypeModel.Name = core.StringPtr("my-policy-plan") - backupPolicyPlanPrototypeModel.RemoteRegionPolicies = []vpcv1.BackupPolicyPlanRemoteRegionPolicyPrototype{*backupPolicyPlanRemoteRegionPolicyPrototypeModel} - // Construct an instance of the ResourceGroupIdentityByID model resourceGroupIdentityModel := new(vpcv1.ResourceGroupIdentityByID) resourceGroupIdentityModel.ID = core.StringPtr("fee82deba12e4c0fb69c3b09d1f12345") - // Construct an instance of the BackupPolicyScopePrototypeEnterpriseIdentityEnterpriseIdentityByCRN model - backupPolicyScopePrototypeModel := new(vpcv1.BackupPolicyScopePrototypeEnterpriseIdentityEnterpriseIdentityByCRN) - backupPolicyScopePrototypeModel.CRN = core.StringPtr("crn:v1:bluemix:public:enterprise::a/123456::enterprise:ebc2b430240943458b9e91e1432cfcce") - - // Construct an instance of the BackupPolicyPrototypeBackupPolicyMatchResourceTypeVolumePrototype model - backupPolicyPrototypeModel := new(vpcv1.BackupPolicyPrototypeBackupPolicyMatchResourceTypeVolumePrototype) - backupPolicyPrototypeModel.MatchUserTags = []string{"my-daily-backup-policy"} - backupPolicyPrototypeModel.Name = core.StringPtr("my-backup-policy") - backupPolicyPrototypeModel.Plans = []vpcv1.BackupPolicyPlanPrototype{*backupPolicyPlanPrototypeModel} - backupPolicyPrototypeModel.ResourceGroup = resourceGroupIdentityModel - backupPolicyPrototypeModel.Scope = backupPolicyScopePrototypeModel - backupPolicyPrototypeModel.MatchResourceType = core.StringPtr("volume") - - // Construct an instance of the CreateBackupPolicyOptions model - createBackupPolicyOptionsModel := new(vpcv1.CreateBackupPolicyOptions) - createBackupPolicyOptionsModel.BackupPolicyPrototype = backupPolicyPrototypeModel - createBackupPolicyOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // 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.CreateBackupPolicy(createBackupPolicyOptionsModel) + result, response, operationErr = vpcService.CreatePlacementGroup(createPlacementGroupOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) }) - It(`Invoke CreateBackupPolicy with error: Operation validation and request error`, func() { + It(`Invoke CreatePlacementGroup with error: Operation validation and request error`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -41395,78 +41215,28 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the ZoneIdentityByName model - zoneIdentityModel := new(vpcv1.ZoneIdentityByName) - zoneIdentityModel.Name = core.StringPtr("us-south-1") - - // Construct an instance of the BackupPolicyPlanClonePolicyPrototype model - backupPolicyPlanClonePolicyPrototypeModel := new(vpcv1.BackupPolicyPlanClonePolicyPrototype) - backupPolicyPlanClonePolicyPrototypeModel.MaxSnapshots = core.Int64Ptr(int64(5)) - backupPolicyPlanClonePolicyPrototypeModel.Zones = []vpcv1.ZoneIdentityIntf{zoneIdentityModel} - - // 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 EncryptionKeyIdentityByCRN model - encryptionKeyIdentityModel := new(vpcv1.EncryptionKeyIdentityByCRN) - encryptionKeyIdentityModel.CRN = core.StringPtr("crn:v1:bluemix:public:kms:us-south:a/123456:e4a29d1a-2ef0-42a6-8fd2-350deb1c647e:key:5437653b-c4b1-447f-9646-b2a2a4cd6179") - - // Construct an instance of the RegionIdentityByName model - regionIdentityModel := new(vpcv1.RegionIdentityByName) - regionIdentityModel.Name = core.StringPtr("us-south") - - // Construct an instance of the BackupPolicyPlanRemoteRegionPolicyPrototype model - backupPolicyPlanRemoteRegionPolicyPrototypeModel := new(vpcv1.BackupPolicyPlanRemoteRegionPolicyPrototype) - backupPolicyPlanRemoteRegionPolicyPrototypeModel.DeleteOverCount = core.Int64Ptr(int64(5)) - backupPolicyPlanRemoteRegionPolicyPrototypeModel.EncryptionKey = encryptionKeyIdentityModel - backupPolicyPlanRemoteRegionPolicyPrototypeModel.Region = regionIdentityModel - - // Construct an instance of the BackupPolicyPlanPrototype model - backupPolicyPlanPrototypeModel := new(vpcv1.BackupPolicyPlanPrototype) - backupPolicyPlanPrototypeModel.Active = core.BoolPtr(true) - backupPolicyPlanPrototypeModel.AttachUserTags = []string{"my-daily-backup-plan"} - backupPolicyPlanPrototypeModel.ClonePolicy = backupPolicyPlanClonePolicyPrototypeModel - backupPolicyPlanPrototypeModel.CopyUserTags = core.BoolPtr(true) - backupPolicyPlanPrototypeModel.CronSpec = core.StringPtr("30 */2 * * 1-5") - backupPolicyPlanPrototypeModel.DeletionTrigger = backupPolicyPlanDeletionTriggerPrototypeModel - backupPolicyPlanPrototypeModel.Name = core.StringPtr("my-policy-plan") - backupPolicyPlanPrototypeModel.RemoteRegionPolicies = []vpcv1.BackupPolicyPlanRemoteRegionPolicyPrototype{*backupPolicyPlanRemoteRegionPolicyPrototypeModel} - // Construct an instance of the ResourceGroupIdentityByID model resourceGroupIdentityModel := new(vpcv1.ResourceGroupIdentityByID) resourceGroupIdentityModel.ID = core.StringPtr("fee82deba12e4c0fb69c3b09d1f12345") - // Construct an instance of the BackupPolicyScopePrototypeEnterpriseIdentityEnterpriseIdentityByCRN model - backupPolicyScopePrototypeModel := new(vpcv1.BackupPolicyScopePrototypeEnterpriseIdentityEnterpriseIdentityByCRN) - backupPolicyScopePrototypeModel.CRN = core.StringPtr("crn:v1:bluemix:public:enterprise::a/123456::enterprise:ebc2b430240943458b9e91e1432cfcce") - - // Construct an instance of the BackupPolicyPrototypeBackupPolicyMatchResourceTypeVolumePrototype model - backupPolicyPrototypeModel := new(vpcv1.BackupPolicyPrototypeBackupPolicyMatchResourceTypeVolumePrototype) - backupPolicyPrototypeModel.MatchUserTags = []string{"my-daily-backup-policy"} - backupPolicyPrototypeModel.Name = core.StringPtr("my-backup-policy") - backupPolicyPrototypeModel.Plans = []vpcv1.BackupPolicyPlanPrototype{*backupPolicyPlanPrototypeModel} - backupPolicyPrototypeModel.ResourceGroup = resourceGroupIdentityModel - backupPolicyPrototypeModel.Scope = backupPolicyScopePrototypeModel - backupPolicyPrototypeModel.MatchResourceType = core.StringPtr("volume") - - // Construct an instance of the CreateBackupPolicyOptions model - createBackupPolicyOptionsModel := new(vpcv1.CreateBackupPolicyOptions) - createBackupPolicyOptionsModel.BackupPolicyPrototype = backupPolicyPrototypeModel - createBackupPolicyOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // 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.CreateBackupPolicy(createBackupPolicyOptionsModel) + 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 CreateBackupPolicyOptions model with no property values - createBackupPolicyOptionsModelNew := new(vpcv1.CreateBackupPolicyOptions) + // 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.CreateBackupPolicy(createBackupPolicyOptionsModelNew) + result, response, operationErr = vpcService.CreatePlacementGroup(createPlacementGroupOptionsModelNew) Expect(operationErr).ToNot(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) @@ -41484,7 +41254,7 @@ var _ = Describe(`VpcV1`, func() { res.WriteHeader(201) })) }) - It(`Invoke CreateBackupPolicy successfully`, func() { + It(`Invoke CreatePlacementGroup successfully`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -41493,69 +41263,19 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the ZoneIdentityByName model - zoneIdentityModel := new(vpcv1.ZoneIdentityByName) - zoneIdentityModel.Name = core.StringPtr("us-south-1") - - // Construct an instance of the BackupPolicyPlanClonePolicyPrototype model - backupPolicyPlanClonePolicyPrototypeModel := new(vpcv1.BackupPolicyPlanClonePolicyPrototype) - backupPolicyPlanClonePolicyPrototypeModel.MaxSnapshots = core.Int64Ptr(int64(5)) - backupPolicyPlanClonePolicyPrototypeModel.Zones = []vpcv1.ZoneIdentityIntf{zoneIdentityModel} - - // 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 EncryptionKeyIdentityByCRN model - encryptionKeyIdentityModel := new(vpcv1.EncryptionKeyIdentityByCRN) - encryptionKeyIdentityModel.CRN = core.StringPtr("crn:v1:bluemix:public:kms:us-south:a/123456:e4a29d1a-2ef0-42a6-8fd2-350deb1c647e:key:5437653b-c4b1-447f-9646-b2a2a4cd6179") - - // Construct an instance of the RegionIdentityByName model - regionIdentityModel := new(vpcv1.RegionIdentityByName) - regionIdentityModel.Name = core.StringPtr("us-south") - - // Construct an instance of the BackupPolicyPlanRemoteRegionPolicyPrototype model - backupPolicyPlanRemoteRegionPolicyPrototypeModel := new(vpcv1.BackupPolicyPlanRemoteRegionPolicyPrototype) - backupPolicyPlanRemoteRegionPolicyPrototypeModel.DeleteOverCount = core.Int64Ptr(int64(5)) - backupPolicyPlanRemoteRegionPolicyPrototypeModel.EncryptionKey = encryptionKeyIdentityModel - backupPolicyPlanRemoteRegionPolicyPrototypeModel.Region = regionIdentityModel - - // Construct an instance of the BackupPolicyPlanPrototype model - backupPolicyPlanPrototypeModel := new(vpcv1.BackupPolicyPlanPrototype) - backupPolicyPlanPrototypeModel.Active = core.BoolPtr(true) - backupPolicyPlanPrototypeModel.AttachUserTags = []string{"my-daily-backup-plan"} - backupPolicyPlanPrototypeModel.ClonePolicy = backupPolicyPlanClonePolicyPrototypeModel - backupPolicyPlanPrototypeModel.CopyUserTags = core.BoolPtr(true) - backupPolicyPlanPrototypeModel.CronSpec = core.StringPtr("30 */2 * * 1-5") - backupPolicyPlanPrototypeModel.DeletionTrigger = backupPolicyPlanDeletionTriggerPrototypeModel - backupPolicyPlanPrototypeModel.Name = core.StringPtr("my-policy-plan") - backupPolicyPlanPrototypeModel.RemoteRegionPolicies = []vpcv1.BackupPolicyPlanRemoteRegionPolicyPrototype{*backupPolicyPlanRemoteRegionPolicyPrototypeModel} - // Construct an instance of the ResourceGroupIdentityByID model resourceGroupIdentityModel := new(vpcv1.ResourceGroupIdentityByID) resourceGroupIdentityModel.ID = core.StringPtr("fee82deba12e4c0fb69c3b09d1f12345") - // Construct an instance of the BackupPolicyScopePrototypeEnterpriseIdentityEnterpriseIdentityByCRN model - backupPolicyScopePrototypeModel := new(vpcv1.BackupPolicyScopePrototypeEnterpriseIdentityEnterpriseIdentityByCRN) - backupPolicyScopePrototypeModel.CRN = core.StringPtr("crn:v1:bluemix:public:enterprise::a/123456::enterprise:ebc2b430240943458b9e91e1432cfcce") - - // Construct an instance of the BackupPolicyPrototypeBackupPolicyMatchResourceTypeVolumePrototype model - backupPolicyPrototypeModel := new(vpcv1.BackupPolicyPrototypeBackupPolicyMatchResourceTypeVolumePrototype) - backupPolicyPrototypeModel.MatchUserTags = []string{"my-daily-backup-policy"} - backupPolicyPrototypeModel.Name = core.StringPtr("my-backup-policy") - backupPolicyPrototypeModel.Plans = []vpcv1.BackupPolicyPlanPrototype{*backupPolicyPlanPrototypeModel} - backupPolicyPrototypeModel.ResourceGroup = resourceGroupIdentityModel - backupPolicyPrototypeModel.Scope = backupPolicyScopePrototypeModel - backupPolicyPrototypeModel.MatchResourceType = core.StringPtr("volume") - - // Construct an instance of the CreateBackupPolicyOptions model - createBackupPolicyOptionsModel := new(vpcv1.CreateBackupPolicyOptions) - createBackupPolicyOptionsModel.BackupPolicyPrototype = backupPolicyPrototypeModel - createBackupPolicyOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // 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.CreateBackupPolicy(createBackupPolicyOptionsModel) + result, response, operationErr := vpcService.CreatePlacementGroup(createPlacementGroupOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) @@ -41567,33 +41287,98 @@ var _ = Describe(`VpcV1`, func() { }) }) }) - Describe(`ListBackupPolicyJobs(listBackupPolicyJobsOptions *ListBackupPolicyJobsOptions) - Operation response error`, func() { + Describe(`DeletePlacementGroup(deletePlacementGroupOptions *DeletePlacementGroupOptions)`, func() { version := "testString" - listBackupPolicyJobsPath := "/backup_policies/testString/jobs" + 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(listBackupPolicyJobsPath)) + 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))})) - Expect(req.URL.Query()["status"]).To(Equal([]string{"failed"})) - Expect(req.URL.Query()["backup_policy_plan.id"]).To(Equal([]string{"testString"})) - Expect(req.URL.Query()["start"]).To(Equal([]string{"testString"})) - Expect(req.URL.Query()["limit"]).To(Equal([]string{fmt.Sprint(int64(10))})) - Expect(req.URL.Query()["sort"]).To(Equal([]string{"name"})) - Expect(req.URL.Query()["source.id"]).To(Equal([]string{"testString"})) - Expect(req.URL.Query()["target_snapshots[].id"]).To(Equal([]string{"testString"})) - Expect(req.URL.Query()["target_snapshots[].crn"]).To(Equal([]string{"crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263"})) res.Header().Set("Content-type", "application/json") res.WriteHeader(200) fmt.Fprint(res, `} this is not valid json {`) })) }) - It(`Invoke ListBackupPolicyJobs with error: Operation response processing error`, func() { + It(`Invoke GetPlacementGroup with error: Operation response processing error`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -41602,27 +41387,19 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the ListBackupPolicyJobsOptions model - listBackupPolicyJobsOptionsModel := new(vpcv1.ListBackupPolicyJobsOptions) - listBackupPolicyJobsOptionsModel.BackupPolicyID = core.StringPtr("testString") - listBackupPolicyJobsOptionsModel.Status = core.StringPtr("failed") - listBackupPolicyJobsOptionsModel.BackupPolicyPlanID = core.StringPtr("testString") - listBackupPolicyJobsOptionsModel.Start = core.StringPtr("testString") - listBackupPolicyJobsOptionsModel.Limit = core.Int64Ptr(int64(10)) - listBackupPolicyJobsOptionsModel.Sort = core.StringPtr("name") - listBackupPolicyJobsOptionsModel.SourceID = core.StringPtr("testString") - listBackupPolicyJobsOptionsModel.TargetSnapshotsID = core.StringPtr("testString") - listBackupPolicyJobsOptionsModel.TargetSnapshotsCRN = core.StringPtr("crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263") - listBackupPolicyJobsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // 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.ListBackupPolicyJobs(listBackupPolicyJobsOptionsModel) + 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.ListBackupPolicyJobs(listBackupPolicyJobsOptionsModel) + result, response, operationErr = vpcService.GetPlacementGroup(getPlacementGroupOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).To(BeNil()) @@ -41632,38 +41409,30 @@ var _ = Describe(`VpcV1`, func() { }) }) }) - Describe(`ListBackupPolicyJobs(listBackupPolicyJobsOptions *ListBackupPolicyJobsOptions)`, func() { + Describe(`GetPlacementGroup(getPlacementGroupOptions *GetPlacementGroupOptions)`, func() { version := "testString" - listBackupPolicyJobsPath := "/backup_policies/testString/jobs" + 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(listBackupPolicyJobsPath)) + 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))})) - Expect(req.URL.Query()["status"]).To(Equal([]string{"failed"})) - Expect(req.URL.Query()["backup_policy_plan.id"]).To(Equal([]string{"testString"})) - Expect(req.URL.Query()["start"]).To(Equal([]string{"testString"})) - Expect(req.URL.Query()["limit"]).To(Equal([]string{fmt.Sprint(int64(10))})) - Expect(req.URL.Query()["sort"]).To(Equal([]string{"name"})) - Expect(req.URL.Query()["source.id"]).To(Equal([]string{"testString"})) - Expect(req.URL.Query()["target_snapshots[].id"]).To(Equal([]string{"testString"})) - Expect(req.URL.Query()["target_snapshots[].crn"]).To(Equal([]string{"crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263"})) // Sleep a short time to support a timeout test time.Sleep(100 * time.Millisecond) // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"first": {"href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies/7241e2a8-601f-11ea-8503-000c29475bed/jobs?limit=20"}, "jobs": [{"auto_delete": true, "auto_delete_after": 90, "backup_policy_plan": {"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6/plans/r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "id": "r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "name": "my-policy-plan", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "backup_policy_plan"}, "completed_at": "2019-01-01T12:00:00.000Z", "created_at": "2019-01-01T12:00:00.000Z", "href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies/0fe9e5d8-0a4d-4818-96ec-e99708644a58/jobs/4cf9171a-0043-4434-8727-15b53dbc374c", "id": "4cf9171a-0043-4434-8727-15b53dbc374c", "job_type": "creation", "resource_type": "backup_policy_job", "source": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::volume:1a6b7274-678d-4dfb-8981-c71dd9d4daa5", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/volumes/1a6b7274-678d-4dfb-8981-c71dd9d4daa5", "id": "1a6b7274-678d-4dfb-8981-c71dd9d4daa5", "name": "my-volume", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "volume"}, "status": "failed", "status_reasons": [{"code": "source_volume_busy", "message": "Message", "more_info": "https://cloud.ibm.com/docs/vpc?topic=vpc-troubleshooting-backup-for-vpc"}], "target_snapshots": [{"crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "id": "r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "name": "my-snapshot", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "snapshot"}]}], "limit": 20, "next": {"href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies/7241e2a8-601f-11ea-8503-000c29475bed/jobss?start=9d5a91a3e2cbd233b5a5b33436855ed1&limit=20"}, "total_count": 132}`) + 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 ListBackupPolicyJobs successfully with retries`, func() { + It(`Invoke GetPlacementGroup successfully with retries`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -41673,29 +41442,21 @@ var _ = Describe(`VpcV1`, func() { Expect(vpcService).ToNot(BeNil()) vpcService.EnableRetries(0, 0) - // Construct an instance of the ListBackupPolicyJobsOptions model - listBackupPolicyJobsOptionsModel := new(vpcv1.ListBackupPolicyJobsOptions) - listBackupPolicyJobsOptionsModel.BackupPolicyID = core.StringPtr("testString") - listBackupPolicyJobsOptionsModel.Status = core.StringPtr("failed") - listBackupPolicyJobsOptionsModel.BackupPolicyPlanID = core.StringPtr("testString") - listBackupPolicyJobsOptionsModel.Start = core.StringPtr("testString") - listBackupPolicyJobsOptionsModel.Limit = core.Int64Ptr(int64(10)) - listBackupPolicyJobsOptionsModel.Sort = core.StringPtr("name") - listBackupPolicyJobsOptionsModel.SourceID = core.StringPtr("testString") - listBackupPolicyJobsOptionsModel.TargetSnapshotsID = core.StringPtr("testString") - listBackupPolicyJobsOptionsModel.TargetSnapshotsCRN = core.StringPtr("crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263") - listBackupPolicyJobsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // 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.ListBackupPolicyJobsWithContext(ctx, listBackupPolicyJobsOptionsModel) + _, _, 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.ListBackupPolicyJobs(listBackupPolicyJobsOptionsModel) + result, response, operationErr := vpcService.GetPlacementGroup(getPlacementGroupOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) @@ -41703,7 +41464,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.ListBackupPolicyJobsWithContext(ctx, listBackupPolicyJobsOptionsModel) + _, _, operationErr = vpcService.GetPlacementGroupWithContext(ctx, getPlacementGroupOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) }) @@ -41717,26 +41478,18 @@ var _ = Describe(`VpcV1`, func() { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(listBackupPolicyJobsPath)) + 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))})) - Expect(req.URL.Query()["status"]).To(Equal([]string{"failed"})) - Expect(req.URL.Query()["backup_policy_plan.id"]).To(Equal([]string{"testString"})) - Expect(req.URL.Query()["start"]).To(Equal([]string{"testString"})) - Expect(req.URL.Query()["limit"]).To(Equal([]string{fmt.Sprint(int64(10))})) - Expect(req.URL.Query()["sort"]).To(Equal([]string{"name"})) - Expect(req.URL.Query()["source.id"]).To(Equal([]string{"testString"})) - Expect(req.URL.Query()["target_snapshots[].id"]).To(Equal([]string{"testString"})) - Expect(req.URL.Query()["target_snapshots[].crn"]).To(Equal([]string{"crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263"})) // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"first": {"href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies/7241e2a8-601f-11ea-8503-000c29475bed/jobs?limit=20"}, "jobs": [{"auto_delete": true, "auto_delete_after": 90, "backup_policy_plan": {"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6/plans/r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "id": "r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "name": "my-policy-plan", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "backup_policy_plan"}, "completed_at": "2019-01-01T12:00:00.000Z", "created_at": "2019-01-01T12:00:00.000Z", "href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies/0fe9e5d8-0a4d-4818-96ec-e99708644a58/jobs/4cf9171a-0043-4434-8727-15b53dbc374c", "id": "4cf9171a-0043-4434-8727-15b53dbc374c", "job_type": "creation", "resource_type": "backup_policy_job", "source": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::volume:1a6b7274-678d-4dfb-8981-c71dd9d4daa5", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/volumes/1a6b7274-678d-4dfb-8981-c71dd9d4daa5", "id": "1a6b7274-678d-4dfb-8981-c71dd9d4daa5", "name": "my-volume", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "volume"}, "status": "failed", "status_reasons": [{"code": "source_volume_busy", "message": "Message", "more_info": "https://cloud.ibm.com/docs/vpc?topic=vpc-troubleshooting-backup-for-vpc"}], "target_snapshots": [{"crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "id": "r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "name": "my-snapshot", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "snapshot"}]}], "limit": 20, "next": {"href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies/7241e2a8-601f-11ea-8503-000c29475bed/jobss?start=9d5a91a3e2cbd233b5a5b33436855ed1&limit=20"}, "total_count": 132}`) + 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 ListBackupPolicyJobs successfully`, func() { + It(`Invoke GetPlacementGroup successfully`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -41746,32 +41499,24 @@ var _ = Describe(`VpcV1`, func() { Expect(vpcService).ToNot(BeNil()) // Invoke operation with nil options model (negative test) - result, response, operationErr := vpcService.ListBackupPolicyJobs(nil) + result, response, operationErr := vpcService.GetPlacementGroup(nil) Expect(operationErr).NotTo(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) - // Construct an instance of the ListBackupPolicyJobsOptions model - listBackupPolicyJobsOptionsModel := new(vpcv1.ListBackupPolicyJobsOptions) - listBackupPolicyJobsOptionsModel.BackupPolicyID = core.StringPtr("testString") - listBackupPolicyJobsOptionsModel.Status = core.StringPtr("failed") - listBackupPolicyJobsOptionsModel.BackupPolicyPlanID = core.StringPtr("testString") - listBackupPolicyJobsOptionsModel.Start = core.StringPtr("testString") - listBackupPolicyJobsOptionsModel.Limit = core.Int64Ptr(int64(10)) - listBackupPolicyJobsOptionsModel.Sort = core.StringPtr("name") - listBackupPolicyJobsOptionsModel.SourceID = core.StringPtr("testString") - listBackupPolicyJobsOptionsModel.TargetSnapshotsID = core.StringPtr("testString") - listBackupPolicyJobsOptionsModel.TargetSnapshotsCRN = core.StringPtr("crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263") - listBackupPolicyJobsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // 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.ListBackupPolicyJobs(listBackupPolicyJobsOptionsModel) + result, response, operationErr = vpcService.GetPlacementGroup(getPlacementGroupOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) }) - It(`Invoke ListBackupPolicyJobs with error: Operation validation and request error`, func() { + It(`Invoke GetPlacementGroup with error: Operation validation and request error`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -41780,30 +41525,22 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the ListBackupPolicyJobsOptions model - listBackupPolicyJobsOptionsModel := new(vpcv1.ListBackupPolicyJobsOptions) - listBackupPolicyJobsOptionsModel.BackupPolicyID = core.StringPtr("testString") - listBackupPolicyJobsOptionsModel.Status = core.StringPtr("failed") - listBackupPolicyJobsOptionsModel.BackupPolicyPlanID = core.StringPtr("testString") - listBackupPolicyJobsOptionsModel.Start = core.StringPtr("testString") - listBackupPolicyJobsOptionsModel.Limit = core.Int64Ptr(int64(10)) - listBackupPolicyJobsOptionsModel.Sort = core.StringPtr("name") - listBackupPolicyJobsOptionsModel.SourceID = core.StringPtr("testString") - listBackupPolicyJobsOptionsModel.TargetSnapshotsID = core.StringPtr("testString") - listBackupPolicyJobsOptionsModel.TargetSnapshotsCRN = core.StringPtr("crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263") - listBackupPolicyJobsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // 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.ListBackupPolicyJobs(listBackupPolicyJobsOptionsModel) + 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 ListBackupPolicyJobsOptions model with no property values - listBackupPolicyJobsOptionsModelNew := new(vpcv1.ListBackupPolicyJobsOptions) + // 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.ListBackupPolicyJobs(listBackupPolicyJobsOptionsModelNew) + result, response, operationErr = vpcService.GetPlacementGroup(getPlacementGroupOptionsModelNew) Expect(operationErr).ToNot(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) @@ -41821,7 +41558,7 @@ var _ = Describe(`VpcV1`, func() { res.WriteHeader(200) })) }) - It(`Invoke ListBackupPolicyJobs successfully`, func() { + It(`Invoke GetPlacementGroup successfully`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -41830,21 +41567,13 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the ListBackupPolicyJobsOptions model - listBackupPolicyJobsOptionsModel := new(vpcv1.ListBackupPolicyJobsOptions) - listBackupPolicyJobsOptionsModel.BackupPolicyID = core.StringPtr("testString") - listBackupPolicyJobsOptionsModel.Status = core.StringPtr("failed") - listBackupPolicyJobsOptionsModel.BackupPolicyPlanID = core.StringPtr("testString") - listBackupPolicyJobsOptionsModel.Start = core.StringPtr("testString") - listBackupPolicyJobsOptionsModel.Limit = core.Int64Ptr(int64(10)) - listBackupPolicyJobsOptionsModel.Sort = core.StringPtr("name") - listBackupPolicyJobsOptionsModel.SourceID = core.StringPtr("testString") - listBackupPolicyJobsOptionsModel.TargetSnapshotsID = core.StringPtr("testString") - listBackupPolicyJobsOptionsModel.TargetSnapshotsCRN = core.StringPtr("crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263") - listBackupPolicyJobsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // 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.ListBackupPolicyJobs(listBackupPolicyJobsOptionsModel) + result, response, operationErr := vpcService.GetPlacementGroup(getPlacementGroupOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) @@ -41855,133 +41584,18 @@ var _ = Describe(`VpcV1`, func() { testServer.Close() }) }) - Context(`Test pagination helper method on response`, func() { - It(`Invoke GetNextStart successfully`, func() { - responseObject := new(vpcv1.BackupPolicyJobCollection) - nextObject := new(vpcv1.BackupPolicyJobCollectionNext) - 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.BackupPolicyJobCollection) - - 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.BackupPolicyJobCollection) - nextObject := new(vpcv1.BackupPolicyJobCollectionNext) - nextObject.Href = core.StringPtr("ibm.com") - responseObject.Next = nextObject - - value, err := responseObject.GetNextStart() - Expect(err).To(BeNil()) - Expect(value).To(BeNil()) - }) - }) - Context(`Using mock server endpoint - paginated response`, func() { - BeforeEach(func() { - var requestNumber int = 0 - testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { - defer GinkgoRecover() - - // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(listBackupPolicyJobsPath)) - Expect(req.Method).To(Equal("GET")) - - // Set mock response - res.Header().Set("Content-type", "application/json") - res.WriteHeader(200) - requestNumber++ - if requestNumber == 1 { - fmt.Fprintf(res, "%s", `{"next":{"href":"https://myhost.com/somePath?start=1"},"total_count":2,"jobs":[{"auto_delete":true,"auto_delete_after":90,"backup_policy_plan":{"deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6/plans/r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178","id":"r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178","name":"my-policy-plan","remote":{"region":{"href":"https://us-south.iaas.cloud.ibm.com/v1/regions/us-south","name":"us-south"}},"resource_type":"backup_policy_plan"},"completed_at":"2019-01-01T12:00:00.000Z","created_at":"2019-01-01T12:00:00.000Z","href":"https://us-south.iaas.cloud.ibm.com/v1/backup_policies/0fe9e5d8-0a4d-4818-96ec-e99708644a58/jobs/4cf9171a-0043-4434-8727-15b53dbc374c","id":"4cf9171a-0043-4434-8727-15b53dbc374c","job_type":"creation","resource_type":"backup_policy_job","source":{"crn":"crn:v1:bluemix:public:is:us-south-1:a/123456::volume:1a6b7274-678d-4dfb-8981-c71dd9d4daa5","deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/volumes/1a6b7274-678d-4dfb-8981-c71dd9d4daa5","id":"1a6b7274-678d-4dfb-8981-c71dd9d4daa5","name":"my-volume","remote":{"region":{"href":"https://us-south.iaas.cloud.ibm.com/v1/regions/us-south","name":"us-south"}},"resource_type":"volume"},"status":"failed","status_reasons":[{"code":"source_volume_busy","message":"Message","more_info":"https://cloud.ibm.com/docs/vpc?topic=vpc-troubleshooting-backup-for-vpc"}],"target_snapshots":[{"crn":"crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263","deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263","id":"r134-f6bfa329-0e36-433f-a3bb-0df632e79263","name":"my-snapshot","remote":{"region":{"href":"https://us-south.iaas.cloud.ibm.com/v1/regions/us-south","name":"us-south"}},"resource_type":"snapshot"}]}],"limit":1}`) - } else if requestNumber == 2 { - fmt.Fprintf(res, "%s", `{"total_count":2,"jobs":[{"auto_delete":true,"auto_delete_after":90,"backup_policy_plan":{"deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6/plans/r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178","id":"r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178","name":"my-policy-plan","remote":{"region":{"href":"https://us-south.iaas.cloud.ibm.com/v1/regions/us-south","name":"us-south"}},"resource_type":"backup_policy_plan"},"completed_at":"2019-01-01T12:00:00.000Z","created_at":"2019-01-01T12:00:00.000Z","href":"https://us-south.iaas.cloud.ibm.com/v1/backup_policies/0fe9e5d8-0a4d-4818-96ec-e99708644a58/jobs/4cf9171a-0043-4434-8727-15b53dbc374c","id":"4cf9171a-0043-4434-8727-15b53dbc374c","job_type":"creation","resource_type":"backup_policy_job","source":{"crn":"crn:v1:bluemix:public:is:us-south-1:a/123456::volume:1a6b7274-678d-4dfb-8981-c71dd9d4daa5","deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/volumes/1a6b7274-678d-4dfb-8981-c71dd9d4daa5","id":"1a6b7274-678d-4dfb-8981-c71dd9d4daa5","name":"my-volume","remote":{"region":{"href":"https://us-south.iaas.cloud.ibm.com/v1/regions/us-south","name":"us-south"}},"resource_type":"volume"},"status":"failed","status_reasons":[{"code":"source_volume_busy","message":"Message","more_info":"https://cloud.ibm.com/docs/vpc?topic=vpc-troubleshooting-backup-for-vpc"}],"target_snapshots":[{"crn":"crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263","deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263","id":"r134-f6bfa329-0e36-433f-a3bb-0df632e79263","name":"my-snapshot","remote":{"region":{"href":"https://us-south.iaas.cloud.ibm.com/v1/regions/us-south","name":"us-south"}},"resource_type":"snapshot"}]}],"limit":1}`) - } else { - res.WriteHeader(400) - } - })) - }) - It(`Use BackupPolicyJobsPager.GetNext successfully`, func() { - vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ - URL: testServer.URL, - Authenticator: &core.NoAuthAuthenticator{}, - Version: core.StringPtr(version), - }) - Expect(serviceErr).To(BeNil()) - Expect(vpcService).ToNot(BeNil()) - - listBackupPolicyJobsOptionsModel := &vpcv1.ListBackupPolicyJobsOptions{ - BackupPolicyID: core.StringPtr("testString"), - Status: core.StringPtr("failed"), - BackupPolicyPlanID: core.StringPtr("testString"), - Limit: core.Int64Ptr(int64(10)), - Sort: core.StringPtr("name"), - SourceID: core.StringPtr("testString"), - TargetSnapshotsID: core.StringPtr("testString"), - TargetSnapshotsCRN: core.StringPtr("crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263"), - } - - pager, err := vpcService.NewBackupPolicyJobsPager(listBackupPolicyJobsOptionsModel) - Expect(err).To(BeNil()) - Expect(pager).ToNot(BeNil()) - - var allResults []vpcv1.BackupPolicyJob - for pager.HasNext() { - nextPage, err := pager.GetNext() - Expect(err).To(BeNil()) - Expect(nextPage).ToNot(BeNil()) - allResults = append(allResults, nextPage...) - } - Expect(len(allResults)).To(Equal(2)) - }) - It(`Use BackupPolicyJobsPager.GetAll successfully`, func() { - vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ - URL: testServer.URL, - Authenticator: &core.NoAuthAuthenticator{}, - Version: core.StringPtr(version), - }) - Expect(serviceErr).To(BeNil()) - Expect(vpcService).ToNot(BeNil()) - - listBackupPolicyJobsOptionsModel := &vpcv1.ListBackupPolicyJobsOptions{ - BackupPolicyID: core.StringPtr("testString"), - Status: core.StringPtr("failed"), - BackupPolicyPlanID: core.StringPtr("testString"), - Limit: core.Int64Ptr(int64(10)), - Sort: core.StringPtr("name"), - SourceID: core.StringPtr("testString"), - TargetSnapshotsID: core.StringPtr("testString"), - TargetSnapshotsCRN: core.StringPtr("crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263"), - } - - pager, err := vpcService.NewBackupPolicyJobsPager(listBackupPolicyJobsOptionsModel) - Expect(err).To(BeNil()) - Expect(pager).ToNot(BeNil()) - - allResults, err := pager.GetAll() - Expect(err).To(BeNil()) - Expect(allResults).ToNot(BeNil()) - Expect(len(allResults)).To(Equal(2)) - }) - }) }) - Describe(`GetBackupPolicyJob(getBackupPolicyJobOptions *GetBackupPolicyJobOptions) - Operation response error`, func() { + Describe(`UpdatePlacementGroup(updatePlacementGroupOptions *UpdatePlacementGroupOptions) - Operation response error`, func() { version := "testString" - getBackupPolicyJobPath := "/backup_policies/testString/jobs/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(getBackupPolicyJobPath)) - Expect(req.Method).To(Equal("GET")) + 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") @@ -41989,7 +41603,7 @@ var _ = Describe(`VpcV1`, func() { fmt.Fprint(res, `} this is not valid json {`) })) }) - It(`Invoke GetBackupPolicyJob with error: Operation response processing error`, func() { + It(`Invoke UpdatePlacementGroup with error: Operation response processing error`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -41998,20 +41612,26 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the GetBackupPolicyJobOptions model - getBackupPolicyJobOptionsModel := new(vpcv1.GetBackupPolicyJobOptions) - getBackupPolicyJobOptionsModel.BackupPolicyID = core.StringPtr("testString") - getBackupPolicyJobOptionsModel.ID = core.StringPtr("testString") - getBackupPolicyJobOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // 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.GetBackupPolicyJob(getBackupPolicyJobOptionsModel) + 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.GetBackupPolicyJob(getBackupPolicyJobOptionsModel) + result, response, operationErr = vpcService.UpdatePlacementGroup(updatePlacementGroupOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).To(BeNil()) @@ -42021,17 +41641,33 @@ var _ = Describe(`VpcV1`, func() { }) }) }) - Describe(`GetBackupPolicyJob(getBackupPolicyJobOptions *GetBackupPolicyJobOptions)`, func() { + Describe(`UpdatePlacementGroup(updatePlacementGroupOptions *UpdatePlacementGroupOptions)`, func() { version := "testString" - getBackupPolicyJobPath := "/backup_policies/testString/jobs/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(getBackupPolicyJobPath)) - Expect(req.Method).To(Equal("GET")) + 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()) + + // 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))})) @@ -42041,10 +41677,10 @@ var _ = Describe(`VpcV1`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"auto_delete": true, "auto_delete_after": 90, "backup_policy_plan": {"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6/plans/r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "id": "r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "name": "my-policy-plan", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "backup_policy_plan"}, "completed_at": "2019-01-01T12:00:00.000Z", "created_at": "2019-01-01T12:00:00.000Z", "href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies/0fe9e5d8-0a4d-4818-96ec-e99708644a58/jobs/4cf9171a-0043-4434-8727-15b53dbc374c", "id": "4cf9171a-0043-4434-8727-15b53dbc374c", "job_type": "creation", "resource_type": "backup_policy_job", "source": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::volume:1a6b7274-678d-4dfb-8981-c71dd9d4daa5", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/volumes/1a6b7274-678d-4dfb-8981-c71dd9d4daa5", "id": "1a6b7274-678d-4dfb-8981-c71dd9d4daa5", "name": "my-volume", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "volume"}, "status": "failed", "status_reasons": [{"code": "source_volume_busy", "message": "Message", "more_info": "https://cloud.ibm.com/docs/vpc?topic=vpc-troubleshooting-backup-for-vpc"}], "target_snapshots": [{"crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "id": "r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "name": "my-snapshot", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "snapshot"}]}`) + 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 GetBackupPolicyJob successfully with retries`, func() { + It(`Invoke UpdatePlacementGroup successfully with retries`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -42054,22 +41690,28 @@ var _ = Describe(`VpcV1`, func() { Expect(vpcService).ToNot(BeNil()) vpcService.EnableRetries(0, 0) - // Construct an instance of the GetBackupPolicyJobOptions model - getBackupPolicyJobOptionsModel := new(vpcv1.GetBackupPolicyJobOptions) - getBackupPolicyJobOptionsModel.BackupPolicyID = core.StringPtr("testString") - getBackupPolicyJobOptionsModel.ID = core.StringPtr("testString") - getBackupPolicyJobOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // 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"} // Invoke operation with a Context to test a timeout error ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond) defer cancelFunc() - _, _, operationErr := vpcService.GetBackupPolicyJobWithContext(ctx, getBackupPolicyJobOptionsModel) + _, _, operationErr := vpcService.UpdatePlacementGroupWithContext(ctx, updatePlacementGroupOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) // Disable retries and test again vpcService.DisableRetries() - result, response, operationErr := vpcService.GetBackupPolicyJob(getBackupPolicyJobOptionsModel) + result, response, operationErr := vpcService.UpdatePlacementGroup(updatePlacementGroupOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) @@ -42077,7 +41719,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.GetBackupPolicyJobWithContext(ctx, getBackupPolicyJobOptionsModel) + _, _, operationErr = vpcService.UpdatePlacementGroupWithContext(ctx, updatePlacementGroupOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) }) @@ -42091,18 +41733,34 @@ var _ = Describe(`VpcV1`, func() { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(getBackupPolicyJobPath)) - Expect(req.Method).To(Equal("GET")) + 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()) + + // 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(200) - fmt.Fprintf(res, "%s", `{"auto_delete": true, "auto_delete_after": 90, "backup_policy_plan": {"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6/plans/r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "id": "r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "name": "my-policy-plan", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "backup_policy_plan"}, "completed_at": "2019-01-01T12:00:00.000Z", "created_at": "2019-01-01T12:00:00.000Z", "href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies/0fe9e5d8-0a4d-4818-96ec-e99708644a58/jobs/4cf9171a-0043-4434-8727-15b53dbc374c", "id": "4cf9171a-0043-4434-8727-15b53dbc374c", "job_type": "creation", "resource_type": "backup_policy_job", "source": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::volume:1a6b7274-678d-4dfb-8981-c71dd9d4daa5", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/volumes/1a6b7274-678d-4dfb-8981-c71dd9d4daa5", "id": "1a6b7274-678d-4dfb-8981-c71dd9d4daa5", "name": "my-volume", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "volume"}, "status": "failed", "status_reasons": [{"code": "source_volume_busy", "message": "Message", "more_info": "https://cloud.ibm.com/docs/vpc?topic=vpc-troubleshooting-backup-for-vpc"}], "target_snapshots": [{"crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "id": "r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "name": "my-snapshot", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "snapshot"}]}`) + 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 GetBackupPolicyJob successfully`, func() { + It(`Invoke UpdatePlacementGroup successfully`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -42112,25 +41770,31 @@ var _ = Describe(`VpcV1`, func() { Expect(vpcService).ToNot(BeNil()) // Invoke operation with nil options model (negative test) - result, response, operationErr := vpcService.GetBackupPolicyJob(nil) + result, response, operationErr := vpcService.UpdatePlacementGroup(nil) Expect(operationErr).NotTo(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) - // Construct an instance of the GetBackupPolicyJobOptions model - getBackupPolicyJobOptionsModel := new(vpcv1.GetBackupPolicyJobOptions) - getBackupPolicyJobOptionsModel.BackupPolicyID = core.StringPtr("testString") - getBackupPolicyJobOptionsModel.ID = core.StringPtr("testString") - getBackupPolicyJobOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // 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"} // Invoke operation with valid options model (positive test) - result, response, operationErr = vpcService.GetBackupPolicyJob(getBackupPolicyJobOptionsModel) + result, response, operationErr = vpcService.UpdatePlacementGroup(updatePlacementGroupOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) }) - It(`Invoke GetBackupPolicyJob with error: Operation validation and request error`, func() { + It(`Invoke UpdatePlacementGroup with error: Operation validation and request error`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -42139,23 +41803,29 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the GetBackupPolicyJobOptions model - getBackupPolicyJobOptionsModel := new(vpcv1.GetBackupPolicyJobOptions) - getBackupPolicyJobOptionsModel.BackupPolicyID = core.StringPtr("testString") - getBackupPolicyJobOptionsModel.ID = core.StringPtr("testString") - getBackupPolicyJobOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // 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"} // Invoke operation with empty URL (negative test) err := vpcService.SetServiceURL("") Expect(err).To(BeNil()) - result, response, operationErr := vpcService.GetBackupPolicyJob(getBackupPolicyJobOptionsModel) + result, response, operationErr := vpcService.UpdatePlacementGroup(updatePlacementGroupOptionsModel) 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 GetBackupPolicyJobOptions model with no property values - getBackupPolicyJobOptionsModelNew := new(vpcv1.GetBackupPolicyJobOptions) + // Construct a second instance of the UpdatePlacementGroupOptions model with no property values + updatePlacementGroupOptionsModelNew := new(vpcv1.UpdatePlacementGroupOptions) // Invoke operation with invalid model (negative test) - result, response, operationErr = vpcService.GetBackupPolicyJob(getBackupPolicyJobOptionsModelNew) + result, response, operationErr = vpcService.UpdatePlacementGroup(updatePlacementGroupOptionsModelNew) Expect(operationErr).ToNot(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) @@ -42173,7 +41843,7 @@ var _ = Describe(`VpcV1`, func() { res.WriteHeader(200) })) }) - It(`Invoke GetBackupPolicyJob successfully`, func() { + It(`Invoke UpdatePlacementGroup successfully`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -42182,14 +41852,20 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the GetBackupPolicyJobOptions model - getBackupPolicyJobOptionsModel := new(vpcv1.GetBackupPolicyJobOptions) - getBackupPolicyJobOptionsModel.BackupPolicyID = core.StringPtr("testString") - getBackupPolicyJobOptionsModel.ID = core.StringPtr("testString") - getBackupPolicyJobOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} - + // 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"} + // Invoke operation - result, response, operationErr := vpcService.GetBackupPolicyJob(getBackupPolicyJobOptionsModel) + result, response, operationErr := vpcService.UpdatePlacementGroup(updatePlacementGroupOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) @@ -42201,26 +41877,27 @@ var _ = Describe(`VpcV1`, func() { }) }) }) - Describe(`ListBackupPolicyPlans(listBackupPolicyPlansOptions *ListBackupPolicyPlansOptions) - Operation response error`, func() { + Describe(`ListBareMetalServerProfiles(listBareMetalServerProfilesOptions *ListBareMetalServerProfilesOptions) - Operation response error`, func() { version := "testString" - listBackupPolicyPlansPath := "/backup_policies/testString/plans" + listBareMetalServerProfilesPath := "/bare_metal_server/profiles" 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(listBackupPolicyPlansPath)) + Expect(req.URL.EscapedPath()).To(Equal(listBareMetalServerProfilesPath)) 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"})) + Expect(req.URL.Query()["start"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["limit"]).To(Equal([]string{fmt.Sprint(int64(10))})) res.Header().Set("Content-type", "application/json") res.WriteHeader(200) fmt.Fprint(res, `} this is not valid json {`) })) }) - It(`Invoke ListBackupPolicyPlans with error: Operation response processing error`, func() { + It(`Invoke ListBareMetalServerProfiles with error: Operation response processing error`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -42229,20 +41906,20 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // 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"} + // Construct an instance of the ListBareMetalServerProfilesOptions model + listBareMetalServerProfilesOptionsModel := new(vpcv1.ListBareMetalServerProfilesOptions) + listBareMetalServerProfilesOptionsModel.Start = core.StringPtr("testString") + listBareMetalServerProfilesOptionsModel.Limit = core.Int64Ptr(int64(10)) + listBareMetalServerProfilesOptionsModel.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.ListBackupPolicyPlans(listBackupPolicyPlansOptionsModel) + result, response, operationErr := vpcService.ListBareMetalServerProfiles(listBareMetalServerProfilesOptionsModel) 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.ListBackupPolicyPlans(listBackupPolicyPlansOptionsModel) + result, response, operationErr = vpcService.ListBareMetalServerProfiles(listBareMetalServerProfilesOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).To(BeNil()) @@ -42252,31 +41929,32 @@ var _ = Describe(`VpcV1`, func() { }) }) }) - Describe(`ListBackupPolicyPlans(listBackupPolicyPlansOptions *ListBackupPolicyPlansOptions)`, func() { + Describe(`ListBareMetalServerProfiles(listBareMetalServerProfilesOptions *ListBareMetalServerProfilesOptions)`, func() { version := "testString" - listBackupPolicyPlansPath := "/backup_policies/testString/plans" + listBareMetalServerProfilesPath := "/bare_metal_server/profiles" 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(listBackupPolicyPlansPath)) + Expect(req.URL.EscapedPath()).To(Equal(listBareMetalServerProfilesPath)) 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"})) + Expect(req.URL.Query()["start"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["limit"]).To(Equal([]string{fmt.Sprint(int64(10))})) // 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", `{"plans": [{"active": true, "attach_user_tags": ["AttachUserTags"], "clone_policy": {"max_snapshots": 1, "zones": [{"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south/zones/us-south-1", "name": "us-south-1"}]}, "copy_user_tags": true, "created_at": "2019-01-01T12:00:00.000Z", "cron_spec": "30 */2 * * 1-5", "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", "remote_region_policies": [{"delete_over_count": 1, "encryption_key": {"crn": "crn:v1:bluemix:public:kms:us-south:a/123456:e4a29d1a-2ef0-42a6-8fd2-350deb1c647e:key:5437653b-c4b1-447f-9646-b2a2a4cd6179"}, "region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}], "resource_type": "backup_policy_plan"}]}`) + fmt.Fprintf(res, "%s", `{"first": {"href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/profiles?limit=20"}, "limit": 20, "next": {"href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/profiles?start=9d5a91a3e2cbd233b5a5b33436855ed1&limit=20"}, "profiles": [{"bandwidth": {"type": "fixed", "value": 20000}, "console_types": {"type": "enum", "values": ["serial"]}, "cpu_architecture": {"default": "amd64", "type": "fixed", "value": "amd64"}, "cpu_core_count": {"type": "fixed", "value": 80}, "cpu_socket_count": {"type": "fixed", "value": 4}, "disks": [{"quantity": {"type": "fixed", "value": 4}, "size": {"type": "fixed", "value": 100}, "supported_interface_types": {"default": "fcp", "type": "enum", "values": ["fcp"]}}], "family": "balanced", "href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/profiles/bx2-metal-192x768", "memory": {"type": "fixed", "value": 16}, "name": "bx2-metal-192x768", "network_attachment_count": {"max": 128, "min": 1, "type": "range"}, "network_interface_count": {"max": 128, "min": 1, "type": "range"}, "os_architecture": {"default": "amd64", "type": "enum", "values": ["amd64"]}, "resource_type": "bare_metal_server_profile", "supported_trusted_platform_module_modes": {"type": "enum", "values": ["disabled"]}, "virtual_network_interfaces_supported": {"type": "fixed", "value": false}}], "total_count": 132}`) })) }) - It(`Invoke ListBackupPolicyPlans successfully with retries`, func() { + It(`Invoke ListBareMetalServerProfiles successfully with retries`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -42286,22 +41964,22 @@ var _ = Describe(`VpcV1`, func() { Expect(vpcService).ToNot(BeNil()) vpcService.EnableRetries(0, 0) - // 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"} + // Construct an instance of the ListBareMetalServerProfilesOptions model + listBareMetalServerProfilesOptionsModel := new(vpcv1.ListBareMetalServerProfilesOptions) + listBareMetalServerProfilesOptionsModel.Start = core.StringPtr("testString") + listBareMetalServerProfilesOptionsModel.Limit = core.Int64Ptr(int64(10)) + listBareMetalServerProfilesOptionsModel.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.ListBackupPolicyPlansWithContext(ctx, listBackupPolicyPlansOptionsModel) + _, _, operationErr := vpcService.ListBareMetalServerProfilesWithContext(ctx, listBareMetalServerProfilesOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) // Disable retries and test again vpcService.DisableRetries() - result, response, operationErr := vpcService.ListBackupPolicyPlans(listBackupPolicyPlansOptionsModel) + result, response, operationErr := vpcService.ListBareMetalServerProfiles(listBareMetalServerProfilesOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) @@ -42309,7 +41987,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.ListBackupPolicyPlansWithContext(ctx, listBackupPolicyPlansOptionsModel) + _, _, operationErr = vpcService.ListBareMetalServerProfilesWithContext(ctx, listBareMetalServerProfilesOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) }) @@ -42323,19 +42001,20 @@ var _ = Describe(`VpcV1`, func() { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(listBackupPolicyPlansPath)) + Expect(req.URL.EscapedPath()).To(Equal(listBareMetalServerProfilesPath)) 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"})) + Expect(req.URL.Query()["start"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["limit"]).To(Equal([]string{fmt.Sprint(int64(10))})) // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"plans": [{"active": true, "attach_user_tags": ["AttachUserTags"], "clone_policy": {"max_snapshots": 1, "zones": [{"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south/zones/us-south-1", "name": "us-south-1"}]}, "copy_user_tags": true, "created_at": "2019-01-01T12:00:00.000Z", "cron_spec": "30 */2 * * 1-5", "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", "remote_region_policies": [{"delete_over_count": 1, "encryption_key": {"crn": "crn:v1:bluemix:public:kms:us-south:a/123456:e4a29d1a-2ef0-42a6-8fd2-350deb1c647e:key:5437653b-c4b1-447f-9646-b2a2a4cd6179"}, "region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}], "resource_type": "backup_policy_plan"}]}`) + fmt.Fprintf(res, "%s", `{"first": {"href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/profiles?limit=20"}, "limit": 20, "next": {"href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/profiles?start=9d5a91a3e2cbd233b5a5b33436855ed1&limit=20"}, "profiles": [{"bandwidth": {"type": "fixed", "value": 20000}, "console_types": {"type": "enum", "values": ["serial"]}, "cpu_architecture": {"default": "amd64", "type": "fixed", "value": "amd64"}, "cpu_core_count": {"type": "fixed", "value": 80}, "cpu_socket_count": {"type": "fixed", "value": 4}, "disks": [{"quantity": {"type": "fixed", "value": 4}, "size": {"type": "fixed", "value": 100}, "supported_interface_types": {"default": "fcp", "type": "enum", "values": ["fcp"]}}], "family": "balanced", "href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/profiles/bx2-metal-192x768", "memory": {"type": "fixed", "value": 16}, "name": "bx2-metal-192x768", "network_attachment_count": {"max": 128, "min": 1, "type": "range"}, "network_interface_count": {"max": 128, "min": 1, "type": "range"}, "os_architecture": {"default": "amd64", "type": "enum", "values": ["amd64"]}, "resource_type": "bare_metal_server_profile", "supported_trusted_platform_module_modes": {"type": "enum", "values": ["disabled"]}, "virtual_network_interfaces_supported": {"type": "fixed", "value": false}}], "total_count": 132}`) })) }) - It(`Invoke ListBackupPolicyPlans successfully`, func() { + It(`Invoke ListBareMetalServerProfiles successfully`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -42345,25 +42024,25 @@ var _ = Describe(`VpcV1`, func() { Expect(vpcService).ToNot(BeNil()) // Invoke operation with nil options model (negative test) - result, response, operationErr := vpcService.ListBackupPolicyPlans(nil) + result, response, operationErr := vpcService.ListBareMetalServerProfiles(nil) Expect(operationErr).NotTo(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) - // 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"} + // Construct an instance of the ListBareMetalServerProfilesOptions model + listBareMetalServerProfilesOptionsModel := new(vpcv1.ListBareMetalServerProfilesOptions) + listBareMetalServerProfilesOptionsModel.Start = core.StringPtr("testString") + listBareMetalServerProfilesOptionsModel.Limit = core.Int64Ptr(int64(10)) + listBareMetalServerProfilesOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with valid options model (positive test) - result, response, operationErr = vpcService.ListBackupPolicyPlans(listBackupPolicyPlansOptionsModel) + result, response, operationErr = vpcService.ListBareMetalServerProfiles(listBareMetalServerProfilesOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) }) - It(`Invoke ListBackupPolicyPlans with error: Operation validation and request error`, func() { + It(`Invoke ListBareMetalServerProfiles with error: Operation request error`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -42372,26 +42051,19 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // 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"} + // Construct an instance of the ListBareMetalServerProfilesOptions model + listBareMetalServerProfilesOptionsModel := new(vpcv1.ListBareMetalServerProfilesOptions) + listBareMetalServerProfilesOptionsModel.Start = core.StringPtr("testString") + listBareMetalServerProfilesOptionsModel.Limit = core.Int64Ptr(int64(10)) + listBareMetalServerProfilesOptionsModel.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.ListBackupPolicyPlans(listBackupPolicyPlansOptionsModel) + result, response, operationErr := vpcService.ListBareMetalServerProfiles(listBareMetalServerProfilesOptionsModel) 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 ListBackupPolicyPlansOptions model with no property values - listBackupPolicyPlansOptionsModelNew := new(vpcv1.ListBackupPolicyPlansOptions) - // Invoke operation with invalid model (negative test) - result, response, operationErr = vpcService.ListBackupPolicyPlans(listBackupPolicyPlansOptionsModelNew) - Expect(operationErr).ToNot(BeNil()) - Expect(response).To(BeNil()) - Expect(result).To(BeNil()) }) AfterEach(func() { testServer.Close() @@ -42406,7 +42078,7 @@ var _ = Describe(`VpcV1`, func() { res.WriteHeader(200) })) }) - It(`Invoke ListBackupPolicyPlans successfully`, func() { + It(`Invoke ListBareMetalServerProfiles successfully`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -42415,14 +42087,14 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // 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"} + // Construct an instance of the ListBareMetalServerProfilesOptions model + listBareMetalServerProfilesOptionsModel := new(vpcv1.ListBareMetalServerProfilesOptions) + listBareMetalServerProfilesOptionsModel.Start = core.StringPtr("testString") + listBareMetalServerProfilesOptionsModel.Limit = core.Int64Ptr(int64(10)) + listBareMetalServerProfilesOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation - result, response, operationErr := vpcService.ListBackupPolicyPlans(listBackupPolicyPlansOptionsModel) + result, response, operationErr := vpcService.ListBareMetalServerProfiles(listBareMetalServerProfilesOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) @@ -42433,26 +42105,59 @@ var _ = Describe(`VpcV1`, func() { testServer.Close() }) }) - }) - Describe(`CreateBackupPolicyPlan(createBackupPolicyPlanOptions *CreateBackupPolicyPlanOptions) - Operation response error`, func() { - version := "testString" - createBackupPolicyPlanPath := "/backup_policies/testString/plans" - Context(`Using mock server endpoint with invalid JSON response`, func() { + Context(`Test pagination helper method on response`, func() { + It(`Invoke GetNextStart successfully`, func() { + responseObject := new(vpcv1.BareMetalServerProfileCollection) + nextObject := new(vpcv1.BareMetalServerProfileCollectionNext) + 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.BareMetalServerProfileCollection) + + 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.BareMetalServerProfileCollection) + nextObject := new(vpcv1.BareMetalServerProfileCollectionNext) + nextObject.Href = core.StringPtr("ibm.com") + responseObject.Next = nextObject + + value, err := responseObject.GetNextStart() + Expect(err).To(BeNil()) + Expect(value).To(BeNil()) + }) + }) + Context(`Using mock server endpoint - paginated response`, func() { BeforeEach(func() { + var requestNumber int = 0 testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(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))})) + Expect(req.URL.EscapedPath()).To(Equal(listBareMetalServerProfilesPath)) + Expect(req.Method).To(Equal("GET")) + + // Set mock response res.Header().Set("Content-type", "application/json") - res.WriteHeader(201) - fmt.Fprint(res, `} this is not valid json {`) + res.WriteHeader(200) + requestNumber++ + if requestNumber == 1 { + fmt.Fprintf(res, "%s", `{"next":{"href":"https://myhost.com/somePath?start=1"},"total_count":2,"limit":1,"profiles":[{"bandwidth":{"type":"fixed","value":20000},"console_types":{"type":"enum","values":["serial"]},"cpu_architecture":{"default":"amd64","type":"fixed","value":"amd64"},"cpu_core_count":{"type":"fixed","value":80},"cpu_socket_count":{"type":"fixed","value":4},"disks":[{"quantity":{"type":"fixed","value":4},"size":{"type":"fixed","value":100},"supported_interface_types":{"default":"fcp","type":"enum","values":["fcp"]}}],"family":"balanced","href":"https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/profiles/bx2-metal-192x768","memory":{"type":"fixed","value":16},"name":"bx2-metal-192x768","network_attachment_count":{"max":128,"min":1,"type":"range"},"network_interface_count":{"max":128,"min":1,"type":"range"},"os_architecture":{"default":"amd64","type":"enum","values":["amd64"]},"resource_type":"bare_metal_server_profile","supported_trusted_platform_module_modes":{"type":"enum","values":["disabled"]},"virtual_network_interfaces_supported":{"type":"fixed","value":false}}]}`) + } else if requestNumber == 2 { + fmt.Fprintf(res, "%s", `{"total_count":2,"limit":1,"profiles":[{"bandwidth":{"type":"fixed","value":20000},"console_types":{"type":"enum","values":["serial"]},"cpu_architecture":{"default":"amd64","type":"fixed","value":"amd64"},"cpu_core_count":{"type":"fixed","value":80},"cpu_socket_count":{"type":"fixed","value":4},"disks":[{"quantity":{"type":"fixed","value":4},"size":{"type":"fixed","value":100},"supported_interface_types":{"default":"fcp","type":"enum","values":["fcp"]}}],"family":"balanced","href":"https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/profiles/bx2-metal-192x768","memory":{"type":"fixed","value":16},"name":"bx2-metal-192x768","network_attachment_count":{"max":128,"min":1,"type":"range"},"network_interface_count":{"max":128,"min":1,"type":"range"},"os_architecture":{"default":"amd64","type":"enum","values":["amd64"]},"resource_type":"bare_metal_server_profile","supported_trusted_platform_module_modes":{"type":"enum","values":["disabled"]},"virtual_network_interfaces_supported":{"type":"fixed","value":false}}]}`) + } else { + res.WriteHeader(400) + } })) }) - It(`Invoke CreateBackupPolicyPlan with error: Operation response processing error`, func() { + It(`Use BareMetalServerProfilesPager.GetNext successfully`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -42461,55 +42166,87 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the ZoneIdentityByName model - zoneIdentityModel := new(vpcv1.ZoneIdentityByName) - zoneIdentityModel.Name = core.StringPtr("us-south-1") + listBareMetalServerProfilesOptionsModel := &vpcv1.ListBareMetalServerProfilesOptions{ + Limit: core.Int64Ptr(int64(10)), + } - // Construct an instance of the BackupPolicyPlanClonePolicyPrototype model - backupPolicyPlanClonePolicyPrototypeModel := new(vpcv1.BackupPolicyPlanClonePolicyPrototype) - backupPolicyPlanClonePolicyPrototypeModel.MaxSnapshots = core.Int64Ptr(int64(5)) - backupPolicyPlanClonePolicyPrototypeModel.Zones = []vpcv1.ZoneIdentityIntf{zoneIdentityModel} + pager, err := vpcService.NewBareMetalServerProfilesPager(listBareMetalServerProfilesOptionsModel) + Expect(err).To(BeNil()) + Expect(pager).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)) + var allResults []vpcv1.BareMetalServerProfile + for pager.HasNext() { + nextPage, err := pager.GetNext() + Expect(err).To(BeNil()) + Expect(nextPage).ToNot(BeNil()) + allResults = append(allResults, nextPage...) + } + Expect(len(allResults)).To(Equal(2)) + }) + It(`Use BareMetalServerProfilesPager.GetAll successfully`, func() { + vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + Version: core.StringPtr(version), + }) + Expect(serviceErr).To(BeNil()) + Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the EncryptionKeyIdentityByCRN model - encryptionKeyIdentityModel := new(vpcv1.EncryptionKeyIdentityByCRN) - encryptionKeyIdentityModel.CRN = core.StringPtr("crn:v1:bluemix:public:kms:us-south:a/123456:e4a29d1a-2ef0-42a6-8fd2-350deb1c647e:key:5437653b-c4b1-447f-9646-b2a2a4cd6179") + listBareMetalServerProfilesOptionsModel := &vpcv1.ListBareMetalServerProfilesOptions{ + Limit: core.Int64Ptr(int64(10)), + } - // Construct an instance of the RegionIdentityByName model - regionIdentityModel := new(vpcv1.RegionIdentityByName) - regionIdentityModel.Name = core.StringPtr("us-south") + pager, err := vpcService.NewBareMetalServerProfilesPager(listBareMetalServerProfilesOptionsModel) + Expect(err).To(BeNil()) + Expect(pager).ToNot(BeNil()) - // Construct an instance of the BackupPolicyPlanRemoteRegionPolicyPrototype model - backupPolicyPlanRemoteRegionPolicyPrototypeModel := new(vpcv1.BackupPolicyPlanRemoteRegionPolicyPrototype) - backupPolicyPlanRemoteRegionPolicyPrototypeModel.DeleteOverCount = core.Int64Ptr(int64(5)) - backupPolicyPlanRemoteRegionPolicyPrototypeModel.EncryptionKey = encryptionKeyIdentityModel - backupPolicyPlanRemoteRegionPolicyPrototypeModel.Region = regionIdentityModel + allResults, err := pager.GetAll() + Expect(err).To(BeNil()) + Expect(allResults).ToNot(BeNil()) + Expect(len(allResults)).To(Equal(2)) + }) + }) + }) + Describe(`GetBareMetalServerProfile(getBareMetalServerProfileOptions *GetBareMetalServerProfileOptions) - Operation response error`, func() { + version := "testString" + getBareMetalServerProfilePath := "/bare_metal_server/profiles/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() - // Construct an instance of the CreateBackupPolicyPlanOptions model - createBackupPolicyPlanOptionsModel := new(vpcv1.CreateBackupPolicyPlanOptions) - createBackupPolicyPlanOptionsModel.BackupPolicyID = core.StringPtr("testString") - createBackupPolicyPlanOptionsModel.CronSpec = core.StringPtr("30 */2 * * 1-5") - createBackupPolicyPlanOptionsModel.Active = core.BoolPtr(true) - createBackupPolicyPlanOptionsModel.AttachUserTags = []string{"my-daily-backup-plan"} - createBackupPolicyPlanOptionsModel.ClonePolicy = backupPolicyPlanClonePolicyPrototypeModel - createBackupPolicyPlanOptionsModel.CopyUserTags = core.BoolPtr(true) - createBackupPolicyPlanOptionsModel.DeletionTrigger = backupPolicyPlanDeletionTriggerPrototypeModel - createBackupPolicyPlanOptionsModel.Name = core.StringPtr("my-policy-plan") - createBackupPolicyPlanOptionsModel.RemoteRegionPolicies = []vpcv1.BackupPolicyPlanRemoteRegionPolicyPrototype{*backupPolicyPlanRemoteRegionPolicyPrototypeModel} - createBackupPolicyPlanOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Verify the contents of the request + Expect(req.URL.EscapedPath()).To(Equal(getBareMetalServerProfilePath)) + 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 GetBareMetalServerProfile 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 GetBareMetalServerProfileOptions model + getBareMetalServerProfileOptionsModel := new(vpcv1.GetBareMetalServerProfileOptions) + getBareMetalServerProfileOptionsModel.Name = core.StringPtr("testString") + getBareMetalServerProfileOptionsModel.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.CreateBackupPolicyPlan(createBackupPolicyPlanOptionsModel) + result, response, operationErr := vpcService.GetBareMetalServerProfile(getBareMetalServerProfileOptionsModel) 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.CreateBackupPolicyPlan(createBackupPolicyPlanOptionsModel) + result, response, operationErr = vpcService.GetBareMetalServerProfile(getBareMetalServerProfileOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).To(BeNil()) @@ -42519,33 +42256,17 @@ var _ = Describe(`VpcV1`, func() { }) }) }) - Describe(`CreateBackupPolicyPlan(createBackupPolicyPlanOptions *CreateBackupPolicyPlanOptions)`, func() { + Describe(`GetBareMetalServerProfile(getBareMetalServerProfileOptions *GetBareMetalServerProfileOptions)`, func() { version := "testString" - createBackupPolicyPlanPath := "/backup_policies/testString/plans" + getBareMetalServerProfilePath := "/bare_metal_server/profiles/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(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.EscapedPath()).To(Equal(getBareMetalServerProfilePath)) + 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))})) @@ -42554,11 +42275,11 @@ var _ = Describe(`VpcV1`, func() { // Set mock response res.Header().Set("Content-type", "application/json") - res.WriteHeader(201) - fmt.Fprintf(res, "%s", `{"active": true, "attach_user_tags": ["AttachUserTags"], "clone_policy": {"max_snapshots": 1, "zones": [{"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south/zones/us-south-1", "name": "us-south-1"}]}, "copy_user_tags": true, "created_at": "2019-01-01T12:00:00.000Z", "cron_spec": "30 */2 * * 1-5", "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", "remote_region_policies": [{"delete_over_count": 1, "encryption_key": {"crn": "crn:v1:bluemix:public:kms:us-south:a/123456:e4a29d1a-2ef0-42a6-8fd2-350deb1c647e:key:5437653b-c4b1-447f-9646-b2a2a4cd6179"}, "region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}], "resource_type": "backup_policy_plan"}`) + res.WriteHeader(200) + fmt.Fprintf(res, "%s", `{"bandwidth": {"type": "fixed", "value": 20000}, "console_types": {"type": "enum", "values": ["serial"]}, "cpu_architecture": {"default": "amd64", "type": "fixed", "value": "amd64"}, "cpu_core_count": {"type": "fixed", "value": 80}, "cpu_socket_count": {"type": "fixed", "value": 4}, "disks": [{"quantity": {"type": "fixed", "value": 4}, "size": {"type": "fixed", "value": 100}, "supported_interface_types": {"default": "fcp", "type": "enum", "values": ["fcp"]}}], "family": "balanced", "href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/profiles/bx2-metal-192x768", "memory": {"type": "fixed", "value": 16}, "name": "bx2-metal-192x768", "network_attachment_count": {"max": 128, "min": 1, "type": "range"}, "network_interface_count": {"max": 128, "min": 1, "type": "range"}, "os_architecture": {"default": "amd64", "type": "enum", "values": ["amd64"]}, "resource_type": "bare_metal_server_profile", "supported_trusted_platform_module_modes": {"type": "enum", "values": ["disabled"]}, "virtual_network_interfaces_supported": {"type": "fixed", "value": false}}`) })) }) - It(`Invoke CreateBackupPolicyPlan successfully with retries`, func() { + It(`Invoke GetBareMetalServerProfile successfully with retries`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -42568,57 +42289,21 @@ var _ = Describe(`VpcV1`, func() { Expect(vpcService).ToNot(BeNil()) vpcService.EnableRetries(0, 0) - // Construct an instance of the ZoneIdentityByName model - zoneIdentityModel := new(vpcv1.ZoneIdentityByName) - zoneIdentityModel.Name = core.StringPtr("us-south-1") - - // Construct an instance of the BackupPolicyPlanClonePolicyPrototype model - backupPolicyPlanClonePolicyPrototypeModel := new(vpcv1.BackupPolicyPlanClonePolicyPrototype) - backupPolicyPlanClonePolicyPrototypeModel.MaxSnapshots = core.Int64Ptr(int64(5)) - backupPolicyPlanClonePolicyPrototypeModel.Zones = []vpcv1.ZoneIdentityIntf{zoneIdentityModel} - - // 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 EncryptionKeyIdentityByCRN model - encryptionKeyIdentityModel := new(vpcv1.EncryptionKeyIdentityByCRN) - encryptionKeyIdentityModel.CRN = core.StringPtr("crn:v1:bluemix:public:kms:us-south:a/123456:e4a29d1a-2ef0-42a6-8fd2-350deb1c647e:key:5437653b-c4b1-447f-9646-b2a2a4cd6179") - - // Construct an instance of the RegionIdentityByName model - regionIdentityModel := new(vpcv1.RegionIdentityByName) - regionIdentityModel.Name = core.StringPtr("us-south") - - // Construct an instance of the BackupPolicyPlanRemoteRegionPolicyPrototype model - backupPolicyPlanRemoteRegionPolicyPrototypeModel := new(vpcv1.BackupPolicyPlanRemoteRegionPolicyPrototype) - backupPolicyPlanRemoteRegionPolicyPrototypeModel.DeleteOverCount = core.Int64Ptr(int64(5)) - backupPolicyPlanRemoteRegionPolicyPrototypeModel.EncryptionKey = encryptionKeyIdentityModel - backupPolicyPlanRemoteRegionPolicyPrototypeModel.Region = regionIdentityModel - - // Construct an instance of the CreateBackupPolicyPlanOptions model - createBackupPolicyPlanOptionsModel := new(vpcv1.CreateBackupPolicyPlanOptions) - createBackupPolicyPlanOptionsModel.BackupPolicyID = core.StringPtr("testString") - createBackupPolicyPlanOptionsModel.CronSpec = core.StringPtr("30 */2 * * 1-5") - createBackupPolicyPlanOptionsModel.Active = core.BoolPtr(true) - createBackupPolicyPlanOptionsModel.AttachUserTags = []string{"my-daily-backup-plan"} - createBackupPolicyPlanOptionsModel.ClonePolicy = backupPolicyPlanClonePolicyPrototypeModel - createBackupPolicyPlanOptionsModel.CopyUserTags = core.BoolPtr(true) - createBackupPolicyPlanOptionsModel.DeletionTrigger = backupPolicyPlanDeletionTriggerPrototypeModel - createBackupPolicyPlanOptionsModel.Name = core.StringPtr("my-policy-plan") - createBackupPolicyPlanOptionsModel.RemoteRegionPolicies = []vpcv1.BackupPolicyPlanRemoteRegionPolicyPrototype{*backupPolicyPlanRemoteRegionPolicyPrototypeModel} - createBackupPolicyPlanOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the GetBareMetalServerProfileOptions model + getBareMetalServerProfileOptionsModel := new(vpcv1.GetBareMetalServerProfileOptions) + getBareMetalServerProfileOptionsModel.Name = core.StringPtr("testString") + getBareMetalServerProfileOptionsModel.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) + _, _, operationErr := vpcService.GetBareMetalServerProfileWithContext(ctx, getBareMetalServerProfileOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) // Disable retries and test again vpcService.DisableRetries() - result, response, operationErr := vpcService.CreateBackupPolicyPlan(createBackupPolicyPlanOptionsModel) + result, response, operationErr := vpcService.GetBareMetalServerProfile(getBareMetalServerProfileOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) @@ -42626,7 +42311,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.CreateBackupPolicyPlanWithContext(ctx, createBackupPolicyPlanOptionsModel) + _, _, operationErr = vpcService.GetBareMetalServerProfileWithContext(ctx, getBareMetalServerProfileOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) }) @@ -42640,34 +42325,18 @@ var _ = Describe(`VpcV1`, func() { 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.EscapedPath()).To(Equal(getBareMetalServerProfilePath)) + 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(201) - fmt.Fprintf(res, "%s", `{"active": true, "attach_user_tags": ["AttachUserTags"], "clone_policy": {"max_snapshots": 1, "zones": [{"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south/zones/us-south-1", "name": "us-south-1"}]}, "copy_user_tags": true, "created_at": "2019-01-01T12:00:00.000Z", "cron_spec": "30 */2 * * 1-5", "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", "remote_region_policies": [{"delete_over_count": 1, "encryption_key": {"crn": "crn:v1:bluemix:public:kms:us-south:a/123456:e4a29d1a-2ef0-42a6-8fd2-350deb1c647e:key:5437653b-c4b1-447f-9646-b2a2a4cd6179"}, "region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}], "resource_type": "backup_policy_plan"}`) + res.WriteHeader(200) + fmt.Fprintf(res, "%s", `{"bandwidth": {"type": "fixed", "value": 20000}, "console_types": {"type": "enum", "values": ["serial"]}, "cpu_architecture": {"default": "amd64", "type": "fixed", "value": "amd64"}, "cpu_core_count": {"type": "fixed", "value": 80}, "cpu_socket_count": {"type": "fixed", "value": 4}, "disks": [{"quantity": {"type": "fixed", "value": 4}, "size": {"type": "fixed", "value": 100}, "supported_interface_types": {"default": "fcp", "type": "enum", "values": ["fcp"]}}], "family": "balanced", "href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/profiles/bx2-metal-192x768", "memory": {"type": "fixed", "value": 16}, "name": "bx2-metal-192x768", "network_attachment_count": {"max": 128, "min": 1, "type": "range"}, "network_interface_count": {"max": 128, "min": 1, "type": "range"}, "os_architecture": {"default": "amd64", "type": "enum", "values": ["amd64"]}, "resource_type": "bare_metal_server_profile", "supported_trusted_platform_module_modes": {"type": "enum", "values": ["disabled"]}, "virtual_network_interfaces_supported": {"type": "fixed", "value": false}}`) })) }) - It(`Invoke CreateBackupPolicyPlan successfully`, func() { + It(`Invoke GetBareMetalServerProfile successfully`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -42677,60 +42346,24 @@ var _ = Describe(`VpcV1`, func() { Expect(vpcService).ToNot(BeNil()) // Invoke operation with nil options model (negative test) - result, response, operationErr := vpcService.CreateBackupPolicyPlan(nil) + result, response, operationErr := vpcService.GetBareMetalServerProfile(nil) Expect(operationErr).NotTo(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) - // Construct an instance of the ZoneIdentityByName model - zoneIdentityModel := new(vpcv1.ZoneIdentityByName) - zoneIdentityModel.Name = core.StringPtr("us-south-1") - - // Construct an instance of the BackupPolicyPlanClonePolicyPrototype model - backupPolicyPlanClonePolicyPrototypeModel := new(vpcv1.BackupPolicyPlanClonePolicyPrototype) - backupPolicyPlanClonePolicyPrototypeModel.MaxSnapshots = core.Int64Ptr(int64(5)) - backupPolicyPlanClonePolicyPrototypeModel.Zones = []vpcv1.ZoneIdentityIntf{zoneIdentityModel} - - // 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 EncryptionKeyIdentityByCRN model - encryptionKeyIdentityModel := new(vpcv1.EncryptionKeyIdentityByCRN) - encryptionKeyIdentityModel.CRN = core.StringPtr("crn:v1:bluemix:public:kms:us-south:a/123456:e4a29d1a-2ef0-42a6-8fd2-350deb1c647e:key:5437653b-c4b1-447f-9646-b2a2a4cd6179") - - // Construct an instance of the RegionIdentityByName model - regionIdentityModel := new(vpcv1.RegionIdentityByName) - regionIdentityModel.Name = core.StringPtr("us-south") - - // Construct an instance of the BackupPolicyPlanRemoteRegionPolicyPrototype model - backupPolicyPlanRemoteRegionPolicyPrototypeModel := new(vpcv1.BackupPolicyPlanRemoteRegionPolicyPrototype) - backupPolicyPlanRemoteRegionPolicyPrototypeModel.DeleteOverCount = core.Int64Ptr(int64(5)) - backupPolicyPlanRemoteRegionPolicyPrototypeModel.EncryptionKey = encryptionKeyIdentityModel - backupPolicyPlanRemoteRegionPolicyPrototypeModel.Region = regionIdentityModel - - // Construct an instance of the CreateBackupPolicyPlanOptions model - createBackupPolicyPlanOptionsModel := new(vpcv1.CreateBackupPolicyPlanOptions) - createBackupPolicyPlanOptionsModel.BackupPolicyID = core.StringPtr("testString") - createBackupPolicyPlanOptionsModel.CronSpec = core.StringPtr("30 */2 * * 1-5") - createBackupPolicyPlanOptionsModel.Active = core.BoolPtr(true) - createBackupPolicyPlanOptionsModel.AttachUserTags = []string{"my-daily-backup-plan"} - createBackupPolicyPlanOptionsModel.ClonePolicy = backupPolicyPlanClonePolicyPrototypeModel - createBackupPolicyPlanOptionsModel.CopyUserTags = core.BoolPtr(true) - createBackupPolicyPlanOptionsModel.DeletionTrigger = backupPolicyPlanDeletionTriggerPrototypeModel - createBackupPolicyPlanOptionsModel.Name = core.StringPtr("my-policy-plan") - createBackupPolicyPlanOptionsModel.RemoteRegionPolicies = []vpcv1.BackupPolicyPlanRemoteRegionPolicyPrototype{*backupPolicyPlanRemoteRegionPolicyPrototypeModel} - createBackupPolicyPlanOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the GetBareMetalServerProfileOptions model + getBareMetalServerProfileOptionsModel := new(vpcv1.GetBareMetalServerProfileOptions) + getBareMetalServerProfileOptionsModel.Name = core.StringPtr("testString") + getBareMetalServerProfileOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with valid options model (positive test) - result, response, operationErr = vpcService.CreateBackupPolicyPlan(createBackupPolicyPlanOptionsModel) + result, response, operationErr = vpcService.GetBareMetalServerProfile(getBareMetalServerProfileOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) }) - It(`Invoke CreateBackupPolicyPlan with error: Operation validation and request error`, func() { + It(`Invoke GetBareMetalServerProfile with error: Operation validation and request error`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -42739,58 +42372,22 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the ZoneIdentityByName model - zoneIdentityModel := new(vpcv1.ZoneIdentityByName) - zoneIdentityModel.Name = core.StringPtr("us-south-1") - - // Construct an instance of the BackupPolicyPlanClonePolicyPrototype model - backupPolicyPlanClonePolicyPrototypeModel := new(vpcv1.BackupPolicyPlanClonePolicyPrototype) - backupPolicyPlanClonePolicyPrototypeModel.MaxSnapshots = core.Int64Ptr(int64(5)) - backupPolicyPlanClonePolicyPrototypeModel.Zones = []vpcv1.ZoneIdentityIntf{zoneIdentityModel} - - // 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 EncryptionKeyIdentityByCRN model - encryptionKeyIdentityModel := new(vpcv1.EncryptionKeyIdentityByCRN) - encryptionKeyIdentityModel.CRN = core.StringPtr("crn:v1:bluemix:public:kms:us-south:a/123456:e4a29d1a-2ef0-42a6-8fd2-350deb1c647e:key:5437653b-c4b1-447f-9646-b2a2a4cd6179") - - // Construct an instance of the RegionIdentityByName model - regionIdentityModel := new(vpcv1.RegionIdentityByName) - regionIdentityModel.Name = core.StringPtr("us-south") - - // Construct an instance of the BackupPolicyPlanRemoteRegionPolicyPrototype model - backupPolicyPlanRemoteRegionPolicyPrototypeModel := new(vpcv1.BackupPolicyPlanRemoteRegionPolicyPrototype) - backupPolicyPlanRemoteRegionPolicyPrototypeModel.DeleteOverCount = core.Int64Ptr(int64(5)) - backupPolicyPlanRemoteRegionPolicyPrototypeModel.EncryptionKey = encryptionKeyIdentityModel - backupPolicyPlanRemoteRegionPolicyPrototypeModel.Region = regionIdentityModel - - // Construct an instance of the CreateBackupPolicyPlanOptions model - createBackupPolicyPlanOptionsModel := new(vpcv1.CreateBackupPolicyPlanOptions) - createBackupPolicyPlanOptionsModel.BackupPolicyID = core.StringPtr("testString") - createBackupPolicyPlanOptionsModel.CronSpec = core.StringPtr("30 */2 * * 1-5") - createBackupPolicyPlanOptionsModel.Active = core.BoolPtr(true) - createBackupPolicyPlanOptionsModel.AttachUserTags = []string{"my-daily-backup-plan"} - createBackupPolicyPlanOptionsModel.ClonePolicy = backupPolicyPlanClonePolicyPrototypeModel - createBackupPolicyPlanOptionsModel.CopyUserTags = core.BoolPtr(true) - createBackupPolicyPlanOptionsModel.DeletionTrigger = backupPolicyPlanDeletionTriggerPrototypeModel - createBackupPolicyPlanOptionsModel.Name = core.StringPtr("my-policy-plan") - createBackupPolicyPlanOptionsModel.RemoteRegionPolicies = []vpcv1.BackupPolicyPlanRemoteRegionPolicyPrototype{*backupPolicyPlanRemoteRegionPolicyPrototypeModel} - createBackupPolicyPlanOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the GetBareMetalServerProfileOptions model + getBareMetalServerProfileOptionsModel := new(vpcv1.GetBareMetalServerProfileOptions) + getBareMetalServerProfileOptionsModel.Name = core.StringPtr("testString") + getBareMetalServerProfileOptionsModel.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) + result, response, operationErr := vpcService.GetBareMetalServerProfile(getBareMetalServerProfileOptionsModel) 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) + // Construct a second instance of the GetBareMetalServerProfileOptions model with no property values + getBareMetalServerProfileOptionsModelNew := new(vpcv1.GetBareMetalServerProfileOptions) // Invoke operation with invalid model (negative test) - result, response, operationErr = vpcService.CreateBackupPolicyPlan(createBackupPolicyPlanOptionsModelNew) + result, response, operationErr = vpcService.GetBareMetalServerProfile(getBareMetalServerProfileOptionsModelNew) Expect(operationErr).ToNot(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) @@ -42805,10 +42402,10 @@ var _ = Describe(`VpcV1`, func() { defer GinkgoRecover() // Set success status code with no respoonse body - res.WriteHeader(201) + res.WriteHeader(200) })) }) - It(`Invoke CreateBackupPolicyPlan successfully`, func() { + It(`Invoke GetBareMetalServerProfile successfully`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -42817,51 +42414,15 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the ZoneIdentityByName model - zoneIdentityModel := new(vpcv1.ZoneIdentityByName) - zoneIdentityModel.Name = core.StringPtr("us-south-1") + // Construct an instance of the GetBareMetalServerProfileOptions model + getBareMetalServerProfileOptionsModel := new(vpcv1.GetBareMetalServerProfileOptions) + getBareMetalServerProfileOptionsModel.Name = core.StringPtr("testString") + getBareMetalServerProfileOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} - // Construct an instance of the BackupPolicyPlanClonePolicyPrototype model - backupPolicyPlanClonePolicyPrototypeModel := new(vpcv1.BackupPolicyPlanClonePolicyPrototype) - backupPolicyPlanClonePolicyPrototypeModel.MaxSnapshots = core.Int64Ptr(int64(5)) - backupPolicyPlanClonePolicyPrototypeModel.Zones = []vpcv1.ZoneIdentityIntf{zoneIdentityModel} - - // 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 EncryptionKeyIdentityByCRN model - encryptionKeyIdentityModel := new(vpcv1.EncryptionKeyIdentityByCRN) - encryptionKeyIdentityModel.CRN = core.StringPtr("crn:v1:bluemix:public:kms:us-south:a/123456:e4a29d1a-2ef0-42a6-8fd2-350deb1c647e:key:5437653b-c4b1-447f-9646-b2a2a4cd6179") - - // Construct an instance of the RegionIdentityByName model - regionIdentityModel := new(vpcv1.RegionIdentityByName) - regionIdentityModel.Name = core.StringPtr("us-south") - - // Construct an instance of the BackupPolicyPlanRemoteRegionPolicyPrototype model - backupPolicyPlanRemoteRegionPolicyPrototypeModel := new(vpcv1.BackupPolicyPlanRemoteRegionPolicyPrototype) - backupPolicyPlanRemoteRegionPolicyPrototypeModel.DeleteOverCount = core.Int64Ptr(int64(5)) - backupPolicyPlanRemoteRegionPolicyPrototypeModel.EncryptionKey = encryptionKeyIdentityModel - backupPolicyPlanRemoteRegionPolicyPrototypeModel.Region = regionIdentityModel - - // Construct an instance of the CreateBackupPolicyPlanOptions model - createBackupPolicyPlanOptionsModel := new(vpcv1.CreateBackupPolicyPlanOptions) - createBackupPolicyPlanOptionsModel.BackupPolicyID = core.StringPtr("testString") - createBackupPolicyPlanOptionsModel.CronSpec = core.StringPtr("30 */2 * * 1-5") - createBackupPolicyPlanOptionsModel.Active = core.BoolPtr(true) - createBackupPolicyPlanOptionsModel.AttachUserTags = []string{"my-daily-backup-plan"} - createBackupPolicyPlanOptionsModel.ClonePolicy = backupPolicyPlanClonePolicyPrototypeModel - createBackupPolicyPlanOptionsModel.CopyUserTags = core.BoolPtr(true) - createBackupPolicyPlanOptionsModel.DeletionTrigger = backupPolicyPlanDeletionTriggerPrototypeModel - createBackupPolicyPlanOptionsModel.Name = core.StringPtr("my-policy-plan") - createBackupPolicyPlanOptionsModel.RemoteRegionPolicies = []vpcv1.BackupPolicyPlanRemoteRegionPolicyPrototype{*backupPolicyPlanRemoteRegionPolicyPrototypeModel} - 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()) + // Invoke operation + result, response, operationErr := vpcService.GetBareMetalServerProfile(getBareMetalServerProfileOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) // Verify a nil result Expect(result).To(BeNil()) @@ -42871,27 +42432,32 @@ var _ = Describe(`VpcV1`, func() { }) }) }) - Describe(`DeleteBackupPolicyPlan(deleteBackupPolicyPlanOptions *DeleteBackupPolicyPlanOptions) - Operation response error`, func() { + Describe(`ListBareMetalServers(listBareMetalServersOptions *ListBareMetalServersOptions) - Operation response error`, func() { version := "testString" - deleteBackupPolicyPlanPath := "/backup_policies/testString/plans/testString" + listBareMetalServersPath := "/bare_metal_servers" 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.EscapedPath()).To(Equal(listBareMetalServersPath)) + Expect(req.Method).To(Equal("GET")) Expect(req.URL.Query()["version"]).To(Equal([]string{"testString"})) Expect(req.URL.Query()["generation"]).To(Equal([]string{fmt.Sprint(int64(2))})) + Expect(req.URL.Query()["start"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["limit"]).To(Equal([]string{fmt.Sprint(int64(10))})) + Expect(req.URL.Query()["resource_group.id"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["name"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["vpc.id"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["vpc.crn"]).To(Equal([]string{"crn:v1:bluemix:public:is:us-south:a/123456::vpc:4727d842-f94f-4a2d-824a-9bc9b02c523b"})) + Expect(req.URL.Query()["vpc.name"]).To(Equal([]string{"my-vpc"})) res.Header().Set("Content-type", "application/json") - res.WriteHeader(202) + res.WriteHeader(200) fmt.Fprint(res, `} this is not valid json {`) })) }) - It(`Invoke DeleteBackupPolicyPlan with error: Operation response processing error`, func() { + It(`Invoke ListBareMetalServers with error: Operation response processing error`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -42900,21 +42466,25 @@ var _ = Describe(`VpcV1`, func() { 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"} + // Construct an instance of the ListBareMetalServersOptions model + listBareMetalServersOptionsModel := new(vpcv1.ListBareMetalServersOptions) + listBareMetalServersOptionsModel.Start = core.StringPtr("testString") + listBareMetalServersOptionsModel.Limit = core.Int64Ptr(int64(10)) + listBareMetalServersOptionsModel.ResourceGroupID = core.StringPtr("testString") + listBareMetalServersOptionsModel.Name = core.StringPtr("testString") + listBareMetalServersOptionsModel.VPCID = core.StringPtr("testString") + listBareMetalServersOptionsModel.VPCCRN = core.StringPtr("crn:v1:bluemix:public:is:us-south:a/123456::vpc:4727d842-f94f-4a2d-824a-9bc9b02c523b") + listBareMetalServersOptionsModel.VPCName = core.StringPtr("my-vpc") + listBareMetalServersOptionsModel.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) + result, response, operationErr := vpcService.ListBareMetalServers(listBareMetalServersOptionsModel) 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) + result, response, operationErr = vpcService.ListBareMetalServers(listBareMetalServersOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).To(BeNil()) @@ -42924,32 +42494,37 @@ var _ = Describe(`VpcV1`, func() { }) }) }) - Describe(`DeleteBackupPolicyPlan(deleteBackupPolicyPlanOptions *DeleteBackupPolicyPlanOptions)`, func() { + Describe(`ListBareMetalServers(listBareMetalServersOptions *ListBareMetalServersOptions)`, func() { version := "testString" - deleteBackupPolicyPlanPath := "/backup_policies/testString/plans/testString" + listBareMetalServersPath := "/bare_metal_servers" 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.URL.EscapedPath()).To(Equal(listBareMetalServersPath)) + Expect(req.Method).To(Equal("GET")) - 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))})) + Expect(req.URL.Query()["start"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["limit"]).To(Equal([]string{fmt.Sprint(int64(10))})) + Expect(req.URL.Query()["resource_group.id"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["name"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["vpc.id"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["vpc.crn"]).To(Equal([]string{"crn:v1:bluemix:public:is:us-south:a/123456::vpc:4727d842-f94f-4a2d-824a-9bc9b02c523b"})) + Expect(req.URL.Query()["vpc.name"]).To(Equal([]string{"my-vpc"})) // 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"], "clone_policy": {"max_snapshots": 1, "zones": [{"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south/zones/us-south-1", "name": "us-south-1"}]}, "copy_user_tags": true, "created_at": "2019-01-01T12:00:00.000Z", "cron_spec": "30 */2 * * 1-5", "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", "remote_region_policies": [{"delete_over_count": 1, "encryption_key": {"crn": "crn:v1:bluemix:public:kms:us-south:a/123456:e4a29d1a-2ef0-42a6-8fd2-350deb1c647e:key:5437653b-c4b1-447f-9646-b2a2a4cd6179"}, "region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}], "resource_type": "backup_policy_plan"}`) + res.WriteHeader(200) + fmt.Fprintf(res, "%s", `{"bare_metal_servers": [{"bandwidth": 20000, "boot_target": {"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/1e09281b-f177-46fb-baf1-bc152b2e391a/disks/10c02d81-0ecb-4dc5-897d-28392913b81e", "id": "10c02d81-0ecb-4dc5-897d-28392913b81e", "name": "my-bare-metal-server-disk", "resource_type": "bare_metal_server_disk"}, "cpu": {"architecture": "amd64", "core_count": 80, "socket_count": 4, "threads_per_core": 2}, "created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::bare-metal-server:1e09281b-f177-46fb-baf1-bc152b2e391a", "disks": [{"created_at": "2019-01-01T12:00:00.000Z", "href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/1e09281b-f177-46fb-baf1-bc152b2e391a/disks/10c02d81-0ecb-4dc5-897d-28392913b81e", "id": "10c02d81-0ecb-4dc5-897d-28392913b81e", "interface_type": "fcp", "name": "my-bare-metal-server-disk", "resource_type": "bare_metal_server_disk", "size": 100}], "enable_secure_boot": false, "href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/1e09281b-f177-46fb-baf1-bc152b2e391a", "id": "1e09281b-f177-46fb-baf1-bc152b2e391a", "lifecycle_reasons": [{"code": "resource_suspended_by_provider", "message": "The resource has been suspended. Contact IBM support with the CRN for next steps.", "more_info": "https://cloud.ibm.com/apidocs/vpc#resource-suspension"}], "lifecycle_state": "stable", "memory": 1536, "name": "my-bare-metal-server", "network_attachments": [{"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/2302-f7a2bf57-af7c-49d9-b599-b2c91293d30c/network_attachments/2302-da8c43ec-b6ca-4bd2-871e-72e288c66ee6", "id": "2302-da8c43ec-b6ca-4bd2-871e-72e288c66ee6", "name": "my-bare-metal-server-network-attachment", "primary_ip": {"address": "192.168.3.4", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e/reserved_ips/6d353a0f-aeb1-4ae1-832e-1110d10981bb", "id": "6d353a0f-aeb1-4ae1-832e-1110d10981bb", "name": "my-reserved-ip", "resource_type": "subnet_reserved_ip"}, "resource_type": "bare_metal_server_network_attachment", "subnet": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "id": "7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "name": "my-subnet", "resource_type": "subnet"}}], "network_interfaces": [{"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/1e09281b-f177-46fb-baf1-bc152b2e391a/network_interfaces/10c02d81-0ecb-4dc5-897d-28392913b81e", "id": "10c02d81-0ecb-4dc5-897d-28392913b81e", "name": "my-bare-metal-server-network-interface", "primary_ip": {"address": "192.168.3.4", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e/reserved_ips/6d353a0f-aeb1-4ae1-832e-1110d10981bb", "id": "6d353a0f-aeb1-4ae1-832e-1110d10981bb", "name": "my-reserved-ip", "resource_type": "subnet_reserved_ip"}, "resource_type": "network_interface", "subnet": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "id": "7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "name": "my-subnet", "resource_type": "subnet"}}], "primary_network_attachment": {"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/2302-f7a2bf57-af7c-49d9-b599-b2c91293d30c/network_attachments/2302-da8c43ec-b6ca-4bd2-871e-72e288c66ee6", "id": "2302-da8c43ec-b6ca-4bd2-871e-72e288c66ee6", "name": "my-bare-metal-server-network-attachment", "primary_ip": {"address": "192.168.3.4", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e/reserved_ips/6d353a0f-aeb1-4ae1-832e-1110d10981bb", "id": "6d353a0f-aeb1-4ae1-832e-1110d10981bb", "name": "my-reserved-ip", "resource_type": "subnet_reserved_ip"}, "resource_type": "bare_metal_server_network_attachment", "subnet": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "id": "7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "name": "my-subnet", "resource_type": "subnet"}}, "primary_network_interface": {"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/1e09281b-f177-46fb-baf1-bc152b2e391a/network_interfaces/10c02d81-0ecb-4dc5-897d-28392913b81e", "id": "10c02d81-0ecb-4dc5-897d-28392913b81e", "name": "my-bare-metal-server-network-interface", "primary_ip": {"address": "192.168.3.4", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e/reserved_ips/6d353a0f-aeb1-4ae1-832e-1110d10981bb", "id": "6d353a0f-aeb1-4ae1-832e-1110d10981bb", "name": "my-reserved-ip", "resource_type": "subnet_reserved_ip"}, "resource_type": "network_interface", "subnet": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "id": "7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "name": "my-subnet", "resource_type": "subnet"}}, "profile": {"href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/profiles/bx2-metal-192x768", "name": "bx2-metal-192x768", "resource_type": "bare_metal_server_profile"}, "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "resource_type": "bare_metal_server", "status": "deleting", "status_reasons": [{"code": "cannot_start_capacity", "message": "The bare metal server cannot start as there is no more capacity in this\nzone for a bare metal server with the requested profile.", "more_info": "https://console.bluemix.net/docs/iaas/bare_metal_server.html"}], "trusted_platform_module": {"enabled": true, "mode": "disabled", "supported_modes": ["disabled"]}, "vpc": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::vpc:4727d842-f94f-4a2d-824a-9bc9b02c523b", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/vpcs/4727d842-f94f-4a2d-824a-9bc9b02c523b", "id": "4727d842-f94f-4a2d-824a-9bc9b02c523b", "name": "my-vpc", "resource_type": "vpc"}, "zone": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south/zones/us-south-1", "name": "us-south-1"}}], "first": {"href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers?limit=20"}, "limit": 20, "next": {"href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers?start=9d5a91a3e2cbd233b5a5b33436855ed1&limit=20"}, "total_count": 132}`) })) }) - It(`Invoke DeleteBackupPolicyPlan successfully with retries`, func() { + It(`Invoke ListBareMetalServers successfully with retries`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -42959,23 +42534,27 @@ var _ = Describe(`VpcV1`, func() { 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"} + // Construct an instance of the ListBareMetalServersOptions model + listBareMetalServersOptionsModel := new(vpcv1.ListBareMetalServersOptions) + listBareMetalServersOptionsModel.Start = core.StringPtr("testString") + listBareMetalServersOptionsModel.Limit = core.Int64Ptr(int64(10)) + listBareMetalServersOptionsModel.ResourceGroupID = core.StringPtr("testString") + listBareMetalServersOptionsModel.Name = core.StringPtr("testString") + listBareMetalServersOptionsModel.VPCID = core.StringPtr("testString") + listBareMetalServersOptionsModel.VPCCRN = core.StringPtr("crn:v1:bluemix:public:is:us-south:a/123456::vpc:4727d842-f94f-4a2d-824a-9bc9b02c523b") + listBareMetalServersOptionsModel.VPCName = core.StringPtr("my-vpc") + listBareMetalServersOptionsModel.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) + _, _, operationErr := vpcService.ListBareMetalServersWithContext(ctx, listBareMetalServersOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) // Disable retries and test again vpcService.DisableRetries() - result, response, operationErr := vpcService.DeleteBackupPolicyPlan(deleteBackupPolicyPlanOptionsModel) + result, response, operationErr := vpcService.ListBareMetalServers(listBareMetalServersOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) @@ -42983,7 +42562,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.DeleteBackupPolicyPlanWithContext(ctx, deleteBackupPolicyPlanOptionsModel) + _, _, operationErr = vpcService.ListBareMetalServersWithContext(ctx, listBareMetalServersOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) }) @@ -42997,20 +42576,25 @@ var _ = Describe(`VpcV1`, func() { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(deleteBackupPolicyPlanPath)) - Expect(req.Method).To(Equal("DELETE")) + Expect(req.URL.EscapedPath()).To(Equal(listBareMetalServersPath)) + Expect(req.Method).To(Equal("GET")) - 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))})) + Expect(req.URL.Query()["start"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["limit"]).To(Equal([]string{fmt.Sprint(int64(10))})) + Expect(req.URL.Query()["resource_group.id"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["name"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["vpc.id"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["vpc.crn"]).To(Equal([]string{"crn:v1:bluemix:public:is:us-south:a/123456::vpc:4727d842-f94f-4a2d-824a-9bc9b02c523b"})) + Expect(req.URL.Query()["vpc.name"]).To(Equal([]string{"my-vpc"})) // Set mock response res.Header().Set("Content-type", "application/json") - res.WriteHeader(202) - fmt.Fprintf(res, "%s", `{"active": true, "attach_user_tags": ["AttachUserTags"], "clone_policy": {"max_snapshots": 1, "zones": [{"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south/zones/us-south-1", "name": "us-south-1"}]}, "copy_user_tags": true, "created_at": "2019-01-01T12:00:00.000Z", "cron_spec": "30 */2 * * 1-5", "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", "remote_region_policies": [{"delete_over_count": 1, "encryption_key": {"crn": "crn:v1:bluemix:public:kms:us-south:a/123456:e4a29d1a-2ef0-42a6-8fd2-350deb1c647e:key:5437653b-c4b1-447f-9646-b2a2a4cd6179"}, "region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}], "resource_type": "backup_policy_plan"}`) + res.WriteHeader(200) + fmt.Fprintf(res, "%s", `{"bare_metal_servers": [{"bandwidth": 20000, "boot_target": {"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/1e09281b-f177-46fb-baf1-bc152b2e391a/disks/10c02d81-0ecb-4dc5-897d-28392913b81e", "id": "10c02d81-0ecb-4dc5-897d-28392913b81e", "name": "my-bare-metal-server-disk", "resource_type": "bare_metal_server_disk"}, "cpu": {"architecture": "amd64", "core_count": 80, "socket_count": 4, "threads_per_core": 2}, "created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::bare-metal-server:1e09281b-f177-46fb-baf1-bc152b2e391a", "disks": [{"created_at": "2019-01-01T12:00:00.000Z", "href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/1e09281b-f177-46fb-baf1-bc152b2e391a/disks/10c02d81-0ecb-4dc5-897d-28392913b81e", "id": "10c02d81-0ecb-4dc5-897d-28392913b81e", "interface_type": "fcp", "name": "my-bare-metal-server-disk", "resource_type": "bare_metal_server_disk", "size": 100}], "enable_secure_boot": false, "href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/1e09281b-f177-46fb-baf1-bc152b2e391a", "id": "1e09281b-f177-46fb-baf1-bc152b2e391a", "lifecycle_reasons": [{"code": "resource_suspended_by_provider", "message": "The resource has been suspended. Contact IBM support with the CRN for next steps.", "more_info": "https://cloud.ibm.com/apidocs/vpc#resource-suspension"}], "lifecycle_state": "stable", "memory": 1536, "name": "my-bare-metal-server", "network_attachments": [{"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/2302-f7a2bf57-af7c-49d9-b599-b2c91293d30c/network_attachments/2302-da8c43ec-b6ca-4bd2-871e-72e288c66ee6", "id": "2302-da8c43ec-b6ca-4bd2-871e-72e288c66ee6", "name": "my-bare-metal-server-network-attachment", "primary_ip": {"address": "192.168.3.4", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e/reserved_ips/6d353a0f-aeb1-4ae1-832e-1110d10981bb", "id": "6d353a0f-aeb1-4ae1-832e-1110d10981bb", "name": "my-reserved-ip", "resource_type": "subnet_reserved_ip"}, "resource_type": "bare_metal_server_network_attachment", "subnet": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "id": "7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "name": "my-subnet", "resource_type": "subnet"}}], "network_interfaces": [{"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/1e09281b-f177-46fb-baf1-bc152b2e391a/network_interfaces/10c02d81-0ecb-4dc5-897d-28392913b81e", "id": "10c02d81-0ecb-4dc5-897d-28392913b81e", "name": "my-bare-metal-server-network-interface", "primary_ip": {"address": "192.168.3.4", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e/reserved_ips/6d353a0f-aeb1-4ae1-832e-1110d10981bb", "id": "6d353a0f-aeb1-4ae1-832e-1110d10981bb", "name": "my-reserved-ip", "resource_type": "subnet_reserved_ip"}, "resource_type": "network_interface", "subnet": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "id": "7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "name": "my-subnet", "resource_type": "subnet"}}], "primary_network_attachment": {"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/2302-f7a2bf57-af7c-49d9-b599-b2c91293d30c/network_attachments/2302-da8c43ec-b6ca-4bd2-871e-72e288c66ee6", "id": "2302-da8c43ec-b6ca-4bd2-871e-72e288c66ee6", "name": "my-bare-metal-server-network-attachment", "primary_ip": {"address": "192.168.3.4", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e/reserved_ips/6d353a0f-aeb1-4ae1-832e-1110d10981bb", "id": "6d353a0f-aeb1-4ae1-832e-1110d10981bb", "name": "my-reserved-ip", "resource_type": "subnet_reserved_ip"}, "resource_type": "bare_metal_server_network_attachment", "subnet": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "id": "7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "name": "my-subnet", "resource_type": "subnet"}}, "primary_network_interface": {"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/1e09281b-f177-46fb-baf1-bc152b2e391a/network_interfaces/10c02d81-0ecb-4dc5-897d-28392913b81e", "id": "10c02d81-0ecb-4dc5-897d-28392913b81e", "name": "my-bare-metal-server-network-interface", "primary_ip": {"address": "192.168.3.4", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e/reserved_ips/6d353a0f-aeb1-4ae1-832e-1110d10981bb", "id": "6d353a0f-aeb1-4ae1-832e-1110d10981bb", "name": "my-reserved-ip", "resource_type": "subnet_reserved_ip"}, "resource_type": "network_interface", "subnet": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "id": "7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "name": "my-subnet", "resource_type": "subnet"}}, "profile": {"href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/profiles/bx2-metal-192x768", "name": "bx2-metal-192x768", "resource_type": "bare_metal_server_profile"}, "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "resource_type": "bare_metal_server", "status": "deleting", "status_reasons": [{"code": "cannot_start_capacity", "message": "The bare metal server cannot start as there is no more capacity in this\nzone for a bare metal server with the requested profile.", "more_info": "https://console.bluemix.net/docs/iaas/bare_metal_server.html"}], "trusted_platform_module": {"enabled": true, "mode": "disabled", "supported_modes": ["disabled"]}, "vpc": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::vpc:4727d842-f94f-4a2d-824a-9bc9b02c523b", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/vpcs/4727d842-f94f-4a2d-824a-9bc9b02c523b", "id": "4727d842-f94f-4a2d-824a-9bc9b02c523b", "name": "my-vpc", "resource_type": "vpc"}, "zone": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south/zones/us-south-1", "name": "us-south-1"}}], "first": {"href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers?limit=20"}, "limit": 20, "next": {"href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers?start=9d5a91a3e2cbd233b5a5b33436855ed1&limit=20"}, "total_count": 132}`) })) }) - It(`Invoke DeleteBackupPolicyPlan successfully`, func() { + It(`Invoke ListBareMetalServers successfully`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -43020,26 +42604,30 @@ var _ = Describe(`VpcV1`, func() { Expect(vpcService).ToNot(BeNil()) // Invoke operation with nil options model (negative test) - result, response, operationErr := vpcService.DeleteBackupPolicyPlan(nil) + result, response, operationErr := vpcService.ListBareMetalServers(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"} + // Construct an instance of the ListBareMetalServersOptions model + listBareMetalServersOptionsModel := new(vpcv1.ListBareMetalServersOptions) + listBareMetalServersOptionsModel.Start = core.StringPtr("testString") + listBareMetalServersOptionsModel.Limit = core.Int64Ptr(int64(10)) + listBareMetalServersOptionsModel.ResourceGroupID = core.StringPtr("testString") + listBareMetalServersOptionsModel.Name = core.StringPtr("testString") + listBareMetalServersOptionsModel.VPCID = core.StringPtr("testString") + listBareMetalServersOptionsModel.VPCCRN = core.StringPtr("crn:v1:bluemix:public:is:us-south:a/123456::vpc:4727d842-f94f-4a2d-824a-9bc9b02c523b") + listBareMetalServersOptionsModel.VPCName = core.StringPtr("my-vpc") + listBareMetalServersOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with valid options model (positive test) - result, response, operationErr = vpcService.DeleteBackupPolicyPlan(deleteBackupPolicyPlanOptionsModel) + result, response, operationErr = vpcService.ListBareMetalServers(listBareMetalServersOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) }) - It(`Invoke DeleteBackupPolicyPlan with error: Operation validation and request error`, func() { + It(`Invoke ListBareMetalServers with error: Operation request error`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -43048,27 +42636,24 @@ var _ = Describe(`VpcV1`, func() { 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"} + // Construct an instance of the ListBareMetalServersOptions model + listBareMetalServersOptionsModel := new(vpcv1.ListBareMetalServersOptions) + listBareMetalServersOptionsModel.Start = core.StringPtr("testString") + listBareMetalServersOptionsModel.Limit = core.Int64Ptr(int64(10)) + listBareMetalServersOptionsModel.ResourceGroupID = core.StringPtr("testString") + listBareMetalServersOptionsModel.Name = core.StringPtr("testString") + listBareMetalServersOptionsModel.VPCID = core.StringPtr("testString") + listBareMetalServersOptionsModel.VPCCRN = core.StringPtr("crn:v1:bluemix:public:is:us-south:a/123456::vpc:4727d842-f94f-4a2d-824a-9bc9b02c523b") + listBareMetalServersOptionsModel.VPCName = core.StringPtr("my-vpc") + listBareMetalServersOptionsModel.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) + result, response, operationErr := vpcService.ListBareMetalServers(listBareMetalServersOptionsModel) 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() @@ -43080,10 +42665,10 @@ var _ = Describe(`VpcV1`, func() { defer GinkgoRecover() // Set success status code with no respoonse body - res.WriteHeader(202) + res.WriteHeader(200) })) }) - It(`Invoke DeleteBackupPolicyPlan successfully`, func() { + It(`Invoke ListBareMetalServers successfully`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -43092,15 +42677,19 @@ var _ = Describe(`VpcV1`, func() { 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"} + // Construct an instance of the ListBareMetalServersOptions model + listBareMetalServersOptionsModel := new(vpcv1.ListBareMetalServersOptions) + listBareMetalServersOptionsModel.Start = core.StringPtr("testString") + listBareMetalServersOptionsModel.Limit = core.Int64Ptr(int64(10)) + listBareMetalServersOptionsModel.ResourceGroupID = core.StringPtr("testString") + listBareMetalServersOptionsModel.Name = core.StringPtr("testString") + listBareMetalServersOptionsModel.VPCID = core.StringPtr("testString") + listBareMetalServersOptionsModel.VPCCRN = core.StringPtr("crn:v1:bluemix:public:is:us-south:a/123456::vpc:4727d842-f94f-4a2d-824a-9bc9b02c523b") + listBareMetalServersOptionsModel.VPCName = core.StringPtr("my-vpc") + listBareMetalServersOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation - result, response, operationErr := vpcService.DeleteBackupPolicyPlan(deleteBackupPolicyPlanOptionsModel) + result, response, operationErr := vpcService.ListBareMetalServers(listBareMetalServersOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) @@ -43111,26 +42700,59 @@ var _ = Describe(`VpcV1`, 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() { + Context(`Test pagination helper method on response`, func() { + It(`Invoke GetNextStart successfully`, func() { + responseObject := new(vpcv1.BareMetalServerCollection) + nextObject := new(vpcv1.BareMetalServerCollectionNext) + 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.BareMetalServerCollection) + + 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.BareMetalServerCollection) + nextObject := new(vpcv1.BareMetalServerCollectionNext) + nextObject.Href = core.StringPtr("ibm.com") + responseObject.Next = nextObject + + value, err := responseObject.GetNextStart() + Expect(err).To(BeNil()) + Expect(value).To(BeNil()) + }) + }) + Context(`Using mock server endpoint - paginated response`, func() { BeforeEach(func() { + var requestNumber int = 0 testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(getBackupPolicyPlanPath)) + Expect(req.URL.EscapedPath()).To(Equal(listBareMetalServersPath)) 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.Fprint(res, `} this is not valid json {`) + requestNumber++ + if requestNumber == 1 { + fmt.Fprintf(res, "%s", `{"next":{"href":"https://myhost.com/somePath?start=1"},"total_count":2,"limit":1,"bare_metal_servers":[{"bandwidth":20000,"boot_target":{"deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/1e09281b-f177-46fb-baf1-bc152b2e391a/disks/10c02d81-0ecb-4dc5-897d-28392913b81e","id":"10c02d81-0ecb-4dc5-897d-28392913b81e","name":"my-bare-metal-server-disk","resource_type":"bare_metal_server_disk"},"cpu":{"architecture":"amd64","core_count":80,"socket_count":4,"threads_per_core":2},"created_at":"2019-01-01T12:00:00.000Z","crn":"crn:v1:bluemix:public:is:us-south-1:a/123456::bare-metal-server:1e09281b-f177-46fb-baf1-bc152b2e391a","disks":[{"created_at":"2019-01-01T12:00:00.000Z","href":"https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/1e09281b-f177-46fb-baf1-bc152b2e391a/disks/10c02d81-0ecb-4dc5-897d-28392913b81e","id":"10c02d81-0ecb-4dc5-897d-28392913b81e","interface_type":"fcp","name":"my-bare-metal-server-disk","resource_type":"bare_metal_server_disk","size":100}],"enable_secure_boot":false,"href":"https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/1e09281b-f177-46fb-baf1-bc152b2e391a","id":"1e09281b-f177-46fb-baf1-bc152b2e391a","lifecycle_reasons":[{"code":"resource_suspended_by_provider","message":"The resource has been suspended. Contact IBM support with the CRN for next steps.","more_info":"https://cloud.ibm.com/apidocs/vpc#resource-suspension"}],"lifecycle_state":"stable","memory":1536,"name":"my-bare-metal-server","network_attachments":[{"deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/2302-f7a2bf57-af7c-49d9-b599-b2c91293d30c/network_attachments/2302-da8c43ec-b6ca-4bd2-871e-72e288c66ee6","id":"2302-da8c43ec-b6ca-4bd2-871e-72e288c66ee6","name":"my-bare-metal-server-network-attachment","primary_ip":{"address":"192.168.3.4","deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e/reserved_ips/6d353a0f-aeb1-4ae1-832e-1110d10981bb","id":"6d353a0f-aeb1-4ae1-832e-1110d10981bb","name":"my-reserved-ip","resource_type":"subnet_reserved_ip"},"resource_type":"bare_metal_server_network_attachment","subnet":{"crn":"crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e","deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e","id":"7ec86020-1c6e-4889-b3f0-a15f2e50f87e","name":"my-subnet","resource_type":"subnet"}}],"network_interfaces":[{"deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/1e09281b-f177-46fb-baf1-bc152b2e391a/network_interfaces/10c02d81-0ecb-4dc5-897d-28392913b81e","id":"10c02d81-0ecb-4dc5-897d-28392913b81e","name":"my-bare-metal-server-network-interface","primary_ip":{"address":"192.168.3.4","deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e/reserved_ips/6d353a0f-aeb1-4ae1-832e-1110d10981bb","id":"6d353a0f-aeb1-4ae1-832e-1110d10981bb","name":"my-reserved-ip","resource_type":"subnet_reserved_ip"},"resource_type":"network_interface","subnet":{"crn":"crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e","deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e","id":"7ec86020-1c6e-4889-b3f0-a15f2e50f87e","name":"my-subnet","resource_type":"subnet"}}],"primary_network_attachment":{"deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/2302-f7a2bf57-af7c-49d9-b599-b2c91293d30c/network_attachments/2302-da8c43ec-b6ca-4bd2-871e-72e288c66ee6","id":"2302-da8c43ec-b6ca-4bd2-871e-72e288c66ee6","name":"my-bare-metal-server-network-attachment","primary_ip":{"address":"192.168.3.4","deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e/reserved_ips/6d353a0f-aeb1-4ae1-832e-1110d10981bb","id":"6d353a0f-aeb1-4ae1-832e-1110d10981bb","name":"my-reserved-ip","resource_type":"subnet_reserved_ip"},"resource_type":"bare_metal_server_network_attachment","subnet":{"crn":"crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e","deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e","id":"7ec86020-1c6e-4889-b3f0-a15f2e50f87e","name":"my-subnet","resource_type":"subnet"}},"primary_network_interface":{"deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/1e09281b-f177-46fb-baf1-bc152b2e391a/network_interfaces/10c02d81-0ecb-4dc5-897d-28392913b81e","id":"10c02d81-0ecb-4dc5-897d-28392913b81e","name":"my-bare-metal-server-network-interface","primary_ip":{"address":"192.168.3.4","deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e/reserved_ips/6d353a0f-aeb1-4ae1-832e-1110d10981bb","id":"6d353a0f-aeb1-4ae1-832e-1110d10981bb","name":"my-reserved-ip","resource_type":"subnet_reserved_ip"},"resource_type":"network_interface","subnet":{"crn":"crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e","deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e","id":"7ec86020-1c6e-4889-b3f0-a15f2e50f87e","name":"my-subnet","resource_type":"subnet"}},"profile":{"href":"https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/profiles/bx2-metal-192x768","name":"bx2-metal-192x768","resource_type":"bare_metal_server_profile"},"resource_group":{"href":"https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345","id":"fee82deba12e4c0fb69c3b09d1f12345","name":"my-resource-group"},"resource_type":"bare_metal_server","status":"deleting","status_reasons":[{"code":"cannot_start_capacity","message":"The bare metal server cannot start as there is no more capacity in this\\nzone for a bare metal server with the requested profile.","more_info":"https://console.bluemix.net/docs/iaas/bare_metal_server.html"}],"trusted_platform_module":{"enabled":true,"mode":"disabled","supported_modes":["disabled"]},"vpc":{"crn":"crn:v1:bluemix:public:is:us-south:a/123456::vpc:4727d842-f94f-4a2d-824a-9bc9b02c523b","deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/vpcs/4727d842-f94f-4a2d-824a-9bc9b02c523b","id":"4727d842-f94f-4a2d-824a-9bc9b02c523b","name":"my-vpc","resource_type":"vpc"},"zone":{"href":"https://us-south.iaas.cloud.ibm.com/v1/regions/us-south/zones/us-south-1","name":"us-south-1"}}]}`) + } else if requestNumber == 2 { + fmt.Fprintf(res, "%s", `{"total_count":2,"limit":1,"bare_metal_servers":[{"bandwidth":20000,"boot_target":{"deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/1e09281b-f177-46fb-baf1-bc152b2e391a/disks/10c02d81-0ecb-4dc5-897d-28392913b81e","id":"10c02d81-0ecb-4dc5-897d-28392913b81e","name":"my-bare-metal-server-disk","resource_type":"bare_metal_server_disk"},"cpu":{"architecture":"amd64","core_count":80,"socket_count":4,"threads_per_core":2},"created_at":"2019-01-01T12:00:00.000Z","crn":"crn:v1:bluemix:public:is:us-south-1:a/123456::bare-metal-server:1e09281b-f177-46fb-baf1-bc152b2e391a","disks":[{"created_at":"2019-01-01T12:00:00.000Z","href":"https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/1e09281b-f177-46fb-baf1-bc152b2e391a/disks/10c02d81-0ecb-4dc5-897d-28392913b81e","id":"10c02d81-0ecb-4dc5-897d-28392913b81e","interface_type":"fcp","name":"my-bare-metal-server-disk","resource_type":"bare_metal_server_disk","size":100}],"enable_secure_boot":false,"href":"https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/1e09281b-f177-46fb-baf1-bc152b2e391a","id":"1e09281b-f177-46fb-baf1-bc152b2e391a","lifecycle_reasons":[{"code":"resource_suspended_by_provider","message":"The resource has been suspended. Contact IBM support with the CRN for next steps.","more_info":"https://cloud.ibm.com/apidocs/vpc#resource-suspension"}],"lifecycle_state":"stable","memory":1536,"name":"my-bare-metal-server","network_attachments":[{"deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/2302-f7a2bf57-af7c-49d9-b599-b2c91293d30c/network_attachments/2302-da8c43ec-b6ca-4bd2-871e-72e288c66ee6","id":"2302-da8c43ec-b6ca-4bd2-871e-72e288c66ee6","name":"my-bare-metal-server-network-attachment","primary_ip":{"address":"192.168.3.4","deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e/reserved_ips/6d353a0f-aeb1-4ae1-832e-1110d10981bb","id":"6d353a0f-aeb1-4ae1-832e-1110d10981bb","name":"my-reserved-ip","resource_type":"subnet_reserved_ip"},"resource_type":"bare_metal_server_network_attachment","subnet":{"crn":"crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e","deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e","id":"7ec86020-1c6e-4889-b3f0-a15f2e50f87e","name":"my-subnet","resource_type":"subnet"}}],"network_interfaces":[{"deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/1e09281b-f177-46fb-baf1-bc152b2e391a/network_interfaces/10c02d81-0ecb-4dc5-897d-28392913b81e","id":"10c02d81-0ecb-4dc5-897d-28392913b81e","name":"my-bare-metal-server-network-interface","primary_ip":{"address":"192.168.3.4","deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e/reserved_ips/6d353a0f-aeb1-4ae1-832e-1110d10981bb","id":"6d353a0f-aeb1-4ae1-832e-1110d10981bb","name":"my-reserved-ip","resource_type":"subnet_reserved_ip"},"resource_type":"network_interface","subnet":{"crn":"crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e","deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e","id":"7ec86020-1c6e-4889-b3f0-a15f2e50f87e","name":"my-subnet","resource_type":"subnet"}}],"primary_network_attachment":{"deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/2302-f7a2bf57-af7c-49d9-b599-b2c91293d30c/network_attachments/2302-da8c43ec-b6ca-4bd2-871e-72e288c66ee6","id":"2302-da8c43ec-b6ca-4bd2-871e-72e288c66ee6","name":"my-bare-metal-server-network-attachment","primary_ip":{"address":"192.168.3.4","deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e/reserved_ips/6d353a0f-aeb1-4ae1-832e-1110d10981bb","id":"6d353a0f-aeb1-4ae1-832e-1110d10981bb","name":"my-reserved-ip","resource_type":"subnet_reserved_ip"},"resource_type":"bare_metal_server_network_attachment","subnet":{"crn":"crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e","deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e","id":"7ec86020-1c6e-4889-b3f0-a15f2e50f87e","name":"my-subnet","resource_type":"subnet"}},"primary_network_interface":{"deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/1e09281b-f177-46fb-baf1-bc152b2e391a/network_interfaces/10c02d81-0ecb-4dc5-897d-28392913b81e","id":"10c02d81-0ecb-4dc5-897d-28392913b81e","name":"my-bare-metal-server-network-interface","primary_ip":{"address":"192.168.3.4","deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e/reserved_ips/6d353a0f-aeb1-4ae1-832e-1110d10981bb","id":"6d353a0f-aeb1-4ae1-832e-1110d10981bb","name":"my-reserved-ip","resource_type":"subnet_reserved_ip"},"resource_type":"network_interface","subnet":{"crn":"crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e","deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e","id":"7ec86020-1c6e-4889-b3f0-a15f2e50f87e","name":"my-subnet","resource_type":"subnet"}},"profile":{"href":"https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/profiles/bx2-metal-192x768","name":"bx2-metal-192x768","resource_type":"bare_metal_server_profile"},"resource_group":{"href":"https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345","id":"fee82deba12e4c0fb69c3b09d1f12345","name":"my-resource-group"},"resource_type":"bare_metal_server","status":"deleting","status_reasons":[{"code":"cannot_start_capacity","message":"The bare metal server cannot start as there is no more capacity in this\\nzone for a bare metal server with the requested profile.","more_info":"https://console.bluemix.net/docs/iaas/bare_metal_server.html"}],"trusted_platform_module":{"enabled":true,"mode":"disabled","supported_modes":["disabled"]},"vpc":{"crn":"crn:v1:bluemix:public:is:us-south:a/123456::vpc:4727d842-f94f-4a2d-824a-9bc9b02c523b","deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/vpcs/4727d842-f94f-4a2d-824a-9bc9b02c523b","id":"4727d842-f94f-4a2d-824a-9bc9b02c523b","name":"my-vpc","resource_type":"vpc"},"zone":{"href":"https://us-south.iaas.cloud.ibm.com/v1/regions/us-south/zones/us-south-1","name":"us-south-1"}}]}`) + } else { + res.WriteHeader(400) + } })) }) - It(`Invoke GetBackupPolicyPlan with error: Operation response processing error`, func() { + It(`Use BareMetalServersPager.GetNext successfully`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -43139,53 +42761,76 @@ var _ = Describe(`VpcV1`, func() { 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()) + listBareMetalServersOptionsModel := &vpcv1.ListBareMetalServersOptions{ + Limit: core.Int64Ptr(int64(10)), + ResourceGroupID: core.StringPtr("testString"), + Name: core.StringPtr("testString"), + VPCID: core.StringPtr("testString"), + VPCCRN: core.StringPtr("crn:v1:bluemix:public:is:us-south:a/123456::vpc:4727d842-f94f-4a2d-824a-9bc9b02c523b"), + VPCName: core.StringPtr("my-vpc"), + } - // 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()) + pager, err := vpcService.NewBareMetalServersPager(listBareMetalServersOptionsModel) + Expect(err).To(BeNil()) + Expect(pager).ToNot(BeNil()) + + var allResults []vpcv1.BareMetalServer + for pager.HasNext() { + nextPage, err := pager.GetNext() + Expect(err).To(BeNil()) + Expect(nextPage).ToNot(BeNil()) + allResults = append(allResults, nextPage...) + } + Expect(len(allResults)).To(Equal(2)) }) - AfterEach(func() { - testServer.Close() + It(`Use BareMetalServersPager.GetAll successfully`, func() { + vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + Version: core.StringPtr(version), + }) + Expect(serviceErr).To(BeNil()) + Expect(vpcService).ToNot(BeNil()) + + listBareMetalServersOptionsModel := &vpcv1.ListBareMetalServersOptions{ + Limit: core.Int64Ptr(int64(10)), + ResourceGroupID: core.StringPtr("testString"), + Name: core.StringPtr("testString"), + VPCID: core.StringPtr("testString"), + VPCCRN: core.StringPtr("crn:v1:bluemix:public:is:us-south:a/123456::vpc:4727d842-f94f-4a2d-824a-9bc9b02c523b"), + VPCName: core.StringPtr("my-vpc"), + } + + pager, err := vpcService.NewBareMetalServersPager(listBareMetalServersOptionsModel) + Expect(err).To(BeNil()) + Expect(pager).ToNot(BeNil()) + + allResults, err := pager.GetAll() + Expect(err).To(BeNil()) + Expect(allResults).ToNot(BeNil()) + Expect(len(allResults)).To(Equal(2)) }) }) }) - Describe(`GetBackupPolicyPlan(getBackupPolicyPlanOptions *GetBackupPolicyPlanOptions)`, func() { + Describe(`CreateBareMetalServer(createBareMetalServerOptions *CreateBareMetalServerOptions) - Operation response error`, func() { version := "testString" - getBackupPolicyPlanPath := "/backup_policies/testString/plans/testString" - Context(`Using mock server endpoint with timeout`, func() { + createBareMetalServerPath := "/bare_metal_servers" + 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.EscapedPath()).To(Equal(createBareMetalServerPath)) + 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))})) - // 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"], "clone_policy": {"max_snapshots": 1, "zones": [{"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south/zones/us-south-1", "name": "us-south-1"}]}, "copy_user_tags": true, "created_at": "2019-01-01T12:00:00.000Z", "cron_spec": "30 */2 * * 1-5", "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", "remote_region_policies": [{"delete_over_count": 1, "encryption_key": {"crn": "crn:v1:bluemix:public:kms:us-south:a/123456:e4a29d1a-2ef0-42a6-8fd2-350deb1c647e:key:5437653b-c4b1-447f-9646-b2a2a4cd6179"}, "region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}], "resource_type": "backup_policy_plan"}`) + res.WriteHeader(201) + fmt.Fprint(res, `} this is not valid json {`) })) }) - It(`Invoke GetBackupPolicyPlan successfully with retries`, func() { + It(`Invoke CreateBareMetalServer with error: Operation response processing error`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -43193,57 +42838,162 @@ var _ = Describe(`VpcV1`, func() { }) 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"} + // Construct an instance of the ImageIdentityByID model + imageIdentityModel := new(vpcv1.ImageIdentityByID) + imageIdentityModel.ID = core.StringPtr("72b27b5c-f4b0-48bb-b954-5becc7c1dcb8") - // 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")) + // Construct an instance of the KeyIdentityByID model + keyIdentityModel := new(vpcv1.KeyIdentityByID) + keyIdentityModel.ID = core.StringPtr("a6b1a881-2ce8-41a3-80fc-36316a73f803") - // Disable retries and test again - vpcService.DisableRetries() - result, response, operationErr := vpcService.GetBackupPolicyPlan(getBackupPolicyPlanOptionsModel) - Expect(operationErr).To(BeNil()) + // Construct an instance of the BareMetalServerInitializationPrototype model + bareMetalServerInitializationPrototypeModel := new(vpcv1.BareMetalServerInitializationPrototype) + bareMetalServerInitializationPrototypeModel.Image = imageIdentityModel + bareMetalServerInitializationPrototypeModel.Keys = []vpcv1.KeyIdentityIntf{keyIdentityModel} + bareMetalServerInitializationPrototypeModel.UserData = core.StringPtr("testString") + + // Construct an instance of the BareMetalServerProfileIdentityByName model + bareMetalServerProfileIdentityModel := new(vpcv1.BareMetalServerProfileIdentityByName) + bareMetalServerProfileIdentityModel.Name = core.StringPtr("bx2-metal-192x768") + + // Construct an instance of the ResourceGroupIdentityByID model + resourceGroupIdentityModel := new(vpcv1.ResourceGroupIdentityByID) + resourceGroupIdentityModel.ID = core.StringPtr("fee82deba12e4c0fb69c3b09d1f12345") + + // Construct an instance of the BareMetalServerTrustedPlatformModulePrototype model + bareMetalServerTrustedPlatformModulePrototypeModel := new(vpcv1.BareMetalServerTrustedPlatformModulePrototype) + bareMetalServerTrustedPlatformModulePrototypeModel.Mode = core.StringPtr("disabled") + + // Construct an instance of the VPCIdentityByID model + vpcIdentityModel := new(vpcv1.VPCIdentityByID) + vpcIdentityModel.ID = core.StringPtr("4727d842-f94f-4a2d-824a-9bc9b02c523b") + + // Construct an instance of the ZoneIdentityByName model + zoneIdentityModel := new(vpcv1.ZoneIdentityByName) + zoneIdentityModel.Name = core.StringPtr("us-south-1") + + // Construct an instance of the VirtualNetworkInterfaceIPPrototypeReservedIPPrototypeVirtualNetworkInterfaceIPsContext model + virtualNetworkInterfaceIPPrototypeModel := new(vpcv1.VirtualNetworkInterfaceIPPrototypeReservedIPPrototypeVirtualNetworkInterfaceIPsContext) + virtualNetworkInterfaceIPPrototypeModel.Address = core.StringPtr("10.0.0.5") + virtualNetworkInterfaceIPPrototypeModel.AutoDelete = core.BoolPtr(false) + virtualNetworkInterfaceIPPrototypeModel.Name = core.StringPtr("my-reserved-ip") + + // Construct an instance of the VirtualNetworkInterfacePrimaryIPPrototypeReservedIPPrototypeVirtualNetworkInterfacePrimaryIPContext model + virtualNetworkInterfacePrimaryIPPrototypeModel := new(vpcv1.VirtualNetworkInterfacePrimaryIPPrototypeReservedIPPrototypeVirtualNetworkInterfacePrimaryIPContext) + virtualNetworkInterfacePrimaryIPPrototypeModel.Address = core.StringPtr("10.0.0.5") + virtualNetworkInterfacePrimaryIPPrototypeModel.AutoDelete = core.BoolPtr(false) + virtualNetworkInterfacePrimaryIPPrototypeModel.Name = core.StringPtr("my-reserved-ip") + + // Construct an instance of the SecurityGroupIdentityByID model + securityGroupIdentityModel := new(vpcv1.SecurityGroupIdentityByID) + securityGroupIdentityModel.ID = core.StringPtr("be5df5ca-12a0-494b-907e-aa6ec2bfa271") + + // Construct an instance of the SubnetIdentityByID model + subnetIdentityModel := new(vpcv1.SubnetIdentityByID) + subnetIdentityModel.ID = core.StringPtr("7ec86020-1c6e-4889-b3f0-a15f2e50f87e") + + // Construct an instance of the BareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceVirtualNetworkInterfacePrototypeBareMetalServerNetworkAttachmentContext model + bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel := new(vpcv1.BareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceVirtualNetworkInterfacePrototypeBareMetalServerNetworkAttachmentContext) + bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel.AllowIPSpoofing = core.BoolPtr(true) + bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel.AutoDelete = core.BoolPtr(false) + bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel.EnableInfrastructureNat = core.BoolPtr(true) + bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel.Ips = []vpcv1.VirtualNetworkInterfaceIPPrototypeIntf{virtualNetworkInterfaceIPPrototypeModel} + bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel.Name = core.StringPtr("my-virtual-network-interface") + bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel.PrimaryIP = virtualNetworkInterfacePrimaryIPPrototypeModel + bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel.ResourceGroup = resourceGroupIdentityModel + bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel.SecurityGroups = []vpcv1.SecurityGroupIdentityIntf{securityGroupIdentityModel} + bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel.Subnet = subnetIdentityModel + + // Construct an instance of the BareMetalServerNetworkAttachmentPrototypeBareMetalServerNetworkAttachmentByPciPrototype model + bareMetalServerNetworkAttachmentPrototypeModel := new(vpcv1.BareMetalServerNetworkAttachmentPrototypeBareMetalServerNetworkAttachmentByPciPrototype) + bareMetalServerNetworkAttachmentPrototypeModel.Name = core.StringPtr("my-bare-metal-server-network-attachment") + bareMetalServerNetworkAttachmentPrototypeModel.VirtualNetworkInterface = bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel + bareMetalServerNetworkAttachmentPrototypeModel.AllowedVlans = []int64{} + bareMetalServerNetworkAttachmentPrototypeModel.InterfaceType = core.StringPtr("pci") + + // Construct an instance of the BareMetalServerPrimaryNetworkAttachmentPrototypeBareMetalServerPrimaryNetworkAttachmentByPciPrototype model + bareMetalServerPrimaryNetworkAttachmentPrototypeModel := new(vpcv1.BareMetalServerPrimaryNetworkAttachmentPrototypeBareMetalServerPrimaryNetworkAttachmentByPciPrototype) + bareMetalServerPrimaryNetworkAttachmentPrototypeModel.Name = core.StringPtr("my-bare-metal-server-network-attachment") + bareMetalServerPrimaryNetworkAttachmentPrototypeModel.VirtualNetworkInterface = bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel + bareMetalServerPrimaryNetworkAttachmentPrototypeModel.AllowedVlans = []int64{} + bareMetalServerPrimaryNetworkAttachmentPrototypeModel.InterfaceType = core.StringPtr("pci") + + // Construct an instance of the BareMetalServerPrototypeBareMetalServerByNetworkAttachment model + bareMetalServerPrototypeModel := new(vpcv1.BareMetalServerPrototypeBareMetalServerByNetworkAttachment) + bareMetalServerPrototypeModel.EnableSecureBoot = core.BoolPtr(false) + bareMetalServerPrototypeModel.Initialization = bareMetalServerInitializationPrototypeModel + bareMetalServerPrototypeModel.Name = core.StringPtr("my-bare-metal-server") + bareMetalServerPrototypeModel.Profile = bareMetalServerProfileIdentityModel + bareMetalServerPrototypeModel.ResourceGroup = resourceGroupIdentityModel + bareMetalServerPrototypeModel.TrustedPlatformModule = bareMetalServerTrustedPlatformModulePrototypeModel + bareMetalServerPrototypeModel.VPC = vpcIdentityModel + bareMetalServerPrototypeModel.Zone = zoneIdentityModel + bareMetalServerPrototypeModel.NetworkAttachments = []vpcv1.BareMetalServerNetworkAttachmentPrototypeIntf{bareMetalServerNetworkAttachmentPrototypeModel} + bareMetalServerPrototypeModel.PrimaryNetworkAttachment = bareMetalServerPrimaryNetworkAttachmentPrototypeModel + + // Construct an instance of the CreateBareMetalServerOptions model + createBareMetalServerOptionsModel := new(vpcv1.CreateBareMetalServerOptions) + createBareMetalServerOptionsModel.BareMetalServerPrototype = bareMetalServerPrototypeModel + createBareMetalServerOptionsModel.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.CreateBareMetalServer(createBareMetalServerOptionsModel) + Expect(operationErr).ToNot(BeNil()) Expect(response).ToNot(BeNil()) - Expect(result).ToNot(BeNil()) + Expect(result).To(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) + // Enable retries and test again + vpcService.EnableRetries(0, 0) + result, response, operationErr = vpcService.CreateBareMetalServer(createBareMetalServerOptionsModel) Expect(operationErr).ToNot(BeNil()) - Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) + Expect(response).ToNot(BeNil()) + Expect(result).To(BeNil()) }) AfterEach(func() { testServer.Close() }) }) - Context(`Using mock server endpoint`, func() { + }) + Describe(`CreateBareMetalServer(createBareMetalServerOptions *CreateBareMetalServerOptions)`, func() { + version := "testString" + createBareMetalServerPath := "/bare_metal_servers" + 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.EscapedPath()).To(Equal(createBareMetalServerPath)) + 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(200) - fmt.Fprintf(res, "%s", `{"active": true, "attach_user_tags": ["AttachUserTags"], "clone_policy": {"max_snapshots": 1, "zones": [{"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south/zones/us-south-1", "name": "us-south-1"}]}, "copy_user_tags": true, "created_at": "2019-01-01T12:00:00.000Z", "cron_spec": "30 */2 * * 1-5", "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", "remote_region_policies": [{"delete_over_count": 1, "encryption_key": {"crn": "crn:v1:bluemix:public:kms:us-south:a/123456:e4a29d1a-2ef0-42a6-8fd2-350deb1c647e:key:5437653b-c4b1-447f-9646-b2a2a4cd6179"}, "region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}], "resource_type": "backup_policy_plan"}`) + res.WriteHeader(201) + fmt.Fprintf(res, "%s", `{"bandwidth": 20000, "boot_target": {"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/1e09281b-f177-46fb-baf1-bc152b2e391a/disks/10c02d81-0ecb-4dc5-897d-28392913b81e", "id": "10c02d81-0ecb-4dc5-897d-28392913b81e", "name": "my-bare-metal-server-disk", "resource_type": "bare_metal_server_disk"}, "cpu": {"architecture": "amd64", "core_count": 80, "socket_count": 4, "threads_per_core": 2}, "created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::bare-metal-server:1e09281b-f177-46fb-baf1-bc152b2e391a", "disks": [{"created_at": "2019-01-01T12:00:00.000Z", "href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/1e09281b-f177-46fb-baf1-bc152b2e391a/disks/10c02d81-0ecb-4dc5-897d-28392913b81e", "id": "10c02d81-0ecb-4dc5-897d-28392913b81e", "interface_type": "fcp", "name": "my-bare-metal-server-disk", "resource_type": "bare_metal_server_disk", "size": 100}], "enable_secure_boot": false, "href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/1e09281b-f177-46fb-baf1-bc152b2e391a", "id": "1e09281b-f177-46fb-baf1-bc152b2e391a", "lifecycle_reasons": [{"code": "resource_suspended_by_provider", "message": "The resource has been suspended. Contact IBM support with the CRN for next steps.", "more_info": "https://cloud.ibm.com/apidocs/vpc#resource-suspension"}], "lifecycle_state": "stable", "memory": 1536, "name": "my-bare-metal-server", "network_attachments": [{"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/2302-f7a2bf57-af7c-49d9-b599-b2c91293d30c/network_attachments/2302-da8c43ec-b6ca-4bd2-871e-72e288c66ee6", "id": "2302-da8c43ec-b6ca-4bd2-871e-72e288c66ee6", "name": "my-bare-metal-server-network-attachment", "primary_ip": {"address": "192.168.3.4", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e/reserved_ips/6d353a0f-aeb1-4ae1-832e-1110d10981bb", "id": "6d353a0f-aeb1-4ae1-832e-1110d10981bb", "name": "my-reserved-ip", "resource_type": "subnet_reserved_ip"}, "resource_type": "bare_metal_server_network_attachment", "subnet": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "id": "7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "name": "my-subnet", "resource_type": "subnet"}}], "network_interfaces": [{"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/1e09281b-f177-46fb-baf1-bc152b2e391a/network_interfaces/10c02d81-0ecb-4dc5-897d-28392913b81e", "id": "10c02d81-0ecb-4dc5-897d-28392913b81e", "name": "my-bare-metal-server-network-interface", "primary_ip": {"address": "192.168.3.4", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e/reserved_ips/6d353a0f-aeb1-4ae1-832e-1110d10981bb", "id": "6d353a0f-aeb1-4ae1-832e-1110d10981bb", "name": "my-reserved-ip", "resource_type": "subnet_reserved_ip"}, "resource_type": "network_interface", "subnet": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "id": "7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "name": "my-subnet", "resource_type": "subnet"}}], "primary_network_attachment": {"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/2302-f7a2bf57-af7c-49d9-b599-b2c91293d30c/network_attachments/2302-da8c43ec-b6ca-4bd2-871e-72e288c66ee6", "id": "2302-da8c43ec-b6ca-4bd2-871e-72e288c66ee6", "name": "my-bare-metal-server-network-attachment", "primary_ip": {"address": "192.168.3.4", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e/reserved_ips/6d353a0f-aeb1-4ae1-832e-1110d10981bb", "id": "6d353a0f-aeb1-4ae1-832e-1110d10981bb", "name": "my-reserved-ip", "resource_type": "subnet_reserved_ip"}, "resource_type": "bare_metal_server_network_attachment", "subnet": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "id": "7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "name": "my-subnet", "resource_type": "subnet"}}, "primary_network_interface": {"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/1e09281b-f177-46fb-baf1-bc152b2e391a/network_interfaces/10c02d81-0ecb-4dc5-897d-28392913b81e", "id": "10c02d81-0ecb-4dc5-897d-28392913b81e", "name": "my-bare-metal-server-network-interface", "primary_ip": {"address": "192.168.3.4", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e/reserved_ips/6d353a0f-aeb1-4ae1-832e-1110d10981bb", "id": "6d353a0f-aeb1-4ae1-832e-1110d10981bb", "name": "my-reserved-ip", "resource_type": "subnet_reserved_ip"}, "resource_type": "network_interface", "subnet": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "id": "7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "name": "my-subnet", "resource_type": "subnet"}}, "profile": {"href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/profiles/bx2-metal-192x768", "name": "bx2-metal-192x768", "resource_type": "bare_metal_server_profile"}, "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "resource_type": "bare_metal_server", "status": "deleting", "status_reasons": [{"code": "cannot_start_capacity", "message": "The bare metal server cannot start as there is no more capacity in this\nzone for a bare metal server with the requested profile.", "more_info": "https://console.bluemix.net/docs/iaas/bare_metal_server.html"}], "trusted_platform_module": {"enabled": true, "mode": "disabled", "supported_modes": ["disabled"]}, "vpc": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::vpc:4727d842-f94f-4a2d-824a-9bc9b02c523b", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/vpcs/4727d842-f94f-4a2d-824a-9bc9b02c523b", "id": "4727d842-f94f-4a2d-824a-9bc9b02c523b", "name": "my-vpc", "resource_type": "vpc"}, "zone": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south/zones/us-south-1", "name": "us-south-1"}}`) })) }) - It(`Invoke GetBackupPolicyPlan successfully`, func() { + It(`Invoke CreateBareMetalServer successfully with retries`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -43251,27 +43001,734 @@ var _ = Describe(`VpcV1`, func() { }) Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) + vpcService.EnableRetries(0, 0) - // 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 ImageIdentityByID model + imageIdentityModel := new(vpcv1.ImageIdentityByID) + imageIdentityModel.ID = core.StringPtr("72b27b5c-f4b0-48bb-b954-5becc7c1dcb8") - // 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"} + // Construct an instance of the KeyIdentityByID model + keyIdentityModel := new(vpcv1.KeyIdentityByID) + keyIdentityModel.ID = core.StringPtr("a6b1a881-2ce8-41a3-80fc-36316a73f803") + + // Construct an instance of the BareMetalServerInitializationPrototype model + bareMetalServerInitializationPrototypeModel := new(vpcv1.BareMetalServerInitializationPrototype) + bareMetalServerInitializationPrototypeModel.Image = imageIdentityModel + bareMetalServerInitializationPrototypeModel.Keys = []vpcv1.KeyIdentityIntf{keyIdentityModel} + bareMetalServerInitializationPrototypeModel.UserData = core.StringPtr("testString") + + // Construct an instance of the BareMetalServerProfileIdentityByName model + bareMetalServerProfileIdentityModel := new(vpcv1.BareMetalServerProfileIdentityByName) + bareMetalServerProfileIdentityModel.Name = core.StringPtr("bx2-metal-192x768") + + // Construct an instance of the ResourceGroupIdentityByID model + resourceGroupIdentityModel := new(vpcv1.ResourceGroupIdentityByID) + resourceGroupIdentityModel.ID = core.StringPtr("fee82deba12e4c0fb69c3b09d1f12345") + + // Construct an instance of the BareMetalServerTrustedPlatformModulePrototype model + bareMetalServerTrustedPlatformModulePrototypeModel := new(vpcv1.BareMetalServerTrustedPlatformModulePrototype) + bareMetalServerTrustedPlatformModulePrototypeModel.Mode = core.StringPtr("disabled") + + // Construct an instance of the VPCIdentityByID model + vpcIdentityModel := new(vpcv1.VPCIdentityByID) + vpcIdentityModel.ID = core.StringPtr("4727d842-f94f-4a2d-824a-9bc9b02c523b") + + // Construct an instance of the ZoneIdentityByName model + zoneIdentityModel := new(vpcv1.ZoneIdentityByName) + zoneIdentityModel.Name = core.StringPtr("us-south-1") + + // Construct an instance of the VirtualNetworkInterfaceIPPrototypeReservedIPPrototypeVirtualNetworkInterfaceIPsContext model + virtualNetworkInterfaceIPPrototypeModel := new(vpcv1.VirtualNetworkInterfaceIPPrototypeReservedIPPrototypeVirtualNetworkInterfaceIPsContext) + virtualNetworkInterfaceIPPrototypeModel.Address = core.StringPtr("10.0.0.5") + virtualNetworkInterfaceIPPrototypeModel.AutoDelete = core.BoolPtr(false) + virtualNetworkInterfaceIPPrototypeModel.Name = core.StringPtr("my-reserved-ip") + + // Construct an instance of the VirtualNetworkInterfacePrimaryIPPrototypeReservedIPPrototypeVirtualNetworkInterfacePrimaryIPContext model + virtualNetworkInterfacePrimaryIPPrototypeModel := new(vpcv1.VirtualNetworkInterfacePrimaryIPPrototypeReservedIPPrototypeVirtualNetworkInterfacePrimaryIPContext) + virtualNetworkInterfacePrimaryIPPrototypeModel.Address = core.StringPtr("10.0.0.5") + virtualNetworkInterfacePrimaryIPPrototypeModel.AutoDelete = core.BoolPtr(false) + virtualNetworkInterfacePrimaryIPPrototypeModel.Name = core.StringPtr("my-reserved-ip") + + // Construct an instance of the SecurityGroupIdentityByID model + securityGroupIdentityModel := new(vpcv1.SecurityGroupIdentityByID) + securityGroupIdentityModel.ID = core.StringPtr("be5df5ca-12a0-494b-907e-aa6ec2bfa271") + + // Construct an instance of the SubnetIdentityByID model + subnetIdentityModel := new(vpcv1.SubnetIdentityByID) + subnetIdentityModel.ID = core.StringPtr("7ec86020-1c6e-4889-b3f0-a15f2e50f87e") + + // Construct an instance of the BareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceVirtualNetworkInterfacePrototypeBareMetalServerNetworkAttachmentContext model + bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel := new(vpcv1.BareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceVirtualNetworkInterfacePrototypeBareMetalServerNetworkAttachmentContext) + bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel.AllowIPSpoofing = core.BoolPtr(true) + bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel.AutoDelete = core.BoolPtr(false) + bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel.EnableInfrastructureNat = core.BoolPtr(true) + bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel.Ips = []vpcv1.VirtualNetworkInterfaceIPPrototypeIntf{virtualNetworkInterfaceIPPrototypeModel} + bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel.Name = core.StringPtr("my-virtual-network-interface") + bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel.PrimaryIP = virtualNetworkInterfacePrimaryIPPrototypeModel + bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel.ResourceGroup = resourceGroupIdentityModel + bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel.SecurityGroups = []vpcv1.SecurityGroupIdentityIntf{securityGroupIdentityModel} + bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel.Subnet = subnetIdentityModel + + // Construct an instance of the BareMetalServerNetworkAttachmentPrototypeBareMetalServerNetworkAttachmentByPciPrototype model + bareMetalServerNetworkAttachmentPrototypeModel := new(vpcv1.BareMetalServerNetworkAttachmentPrototypeBareMetalServerNetworkAttachmentByPciPrototype) + bareMetalServerNetworkAttachmentPrototypeModel.Name = core.StringPtr("my-bare-metal-server-network-attachment") + bareMetalServerNetworkAttachmentPrototypeModel.VirtualNetworkInterface = bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel + bareMetalServerNetworkAttachmentPrototypeModel.AllowedVlans = []int64{} + bareMetalServerNetworkAttachmentPrototypeModel.InterfaceType = core.StringPtr("pci") + + // Construct an instance of the BareMetalServerPrimaryNetworkAttachmentPrototypeBareMetalServerPrimaryNetworkAttachmentByPciPrototype model + bareMetalServerPrimaryNetworkAttachmentPrototypeModel := new(vpcv1.BareMetalServerPrimaryNetworkAttachmentPrototypeBareMetalServerPrimaryNetworkAttachmentByPciPrototype) + bareMetalServerPrimaryNetworkAttachmentPrototypeModel.Name = core.StringPtr("my-bare-metal-server-network-attachment") + bareMetalServerPrimaryNetworkAttachmentPrototypeModel.VirtualNetworkInterface = bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel + bareMetalServerPrimaryNetworkAttachmentPrototypeModel.AllowedVlans = []int64{} + bareMetalServerPrimaryNetworkAttachmentPrototypeModel.InterfaceType = core.StringPtr("pci") + + // Construct an instance of the BareMetalServerPrototypeBareMetalServerByNetworkAttachment model + bareMetalServerPrototypeModel := new(vpcv1.BareMetalServerPrototypeBareMetalServerByNetworkAttachment) + bareMetalServerPrototypeModel.EnableSecureBoot = core.BoolPtr(false) + bareMetalServerPrototypeModel.Initialization = bareMetalServerInitializationPrototypeModel + bareMetalServerPrototypeModel.Name = core.StringPtr("my-bare-metal-server") + bareMetalServerPrototypeModel.Profile = bareMetalServerProfileIdentityModel + bareMetalServerPrototypeModel.ResourceGroup = resourceGroupIdentityModel + bareMetalServerPrototypeModel.TrustedPlatformModule = bareMetalServerTrustedPlatformModulePrototypeModel + bareMetalServerPrototypeModel.VPC = vpcIdentityModel + bareMetalServerPrototypeModel.Zone = zoneIdentityModel + bareMetalServerPrototypeModel.NetworkAttachments = []vpcv1.BareMetalServerNetworkAttachmentPrototypeIntf{bareMetalServerNetworkAttachmentPrototypeModel} + bareMetalServerPrototypeModel.PrimaryNetworkAttachment = bareMetalServerPrimaryNetworkAttachmentPrototypeModel + + // Construct an instance of the CreateBareMetalServerOptions model + createBareMetalServerOptionsModel := new(vpcv1.CreateBareMetalServerOptions) + createBareMetalServerOptionsModel.BareMetalServerPrototype = bareMetalServerPrototypeModel + createBareMetalServerOptionsModel.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.CreateBareMetalServerWithContext(ctx, createBareMetalServerOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) + + // Disable retries and test again + vpcService.DisableRetries() + result, response, operationErr := vpcService.CreateBareMetalServer(createBareMetalServerOptionsModel) + 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.CreateBareMetalServerWithContext(ctx, createBareMetalServerOptionsModel) + 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(createBareMetalServerPath)) + 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", `{"bandwidth": 20000, "boot_target": {"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/1e09281b-f177-46fb-baf1-bc152b2e391a/disks/10c02d81-0ecb-4dc5-897d-28392913b81e", "id": "10c02d81-0ecb-4dc5-897d-28392913b81e", "name": "my-bare-metal-server-disk", "resource_type": "bare_metal_server_disk"}, "cpu": {"architecture": "amd64", "core_count": 80, "socket_count": 4, "threads_per_core": 2}, "created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::bare-metal-server:1e09281b-f177-46fb-baf1-bc152b2e391a", "disks": [{"created_at": "2019-01-01T12:00:00.000Z", "href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/1e09281b-f177-46fb-baf1-bc152b2e391a/disks/10c02d81-0ecb-4dc5-897d-28392913b81e", "id": "10c02d81-0ecb-4dc5-897d-28392913b81e", "interface_type": "fcp", "name": "my-bare-metal-server-disk", "resource_type": "bare_metal_server_disk", "size": 100}], "enable_secure_boot": false, "href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/1e09281b-f177-46fb-baf1-bc152b2e391a", "id": "1e09281b-f177-46fb-baf1-bc152b2e391a", "lifecycle_reasons": [{"code": "resource_suspended_by_provider", "message": "The resource has been suspended. Contact IBM support with the CRN for next steps.", "more_info": "https://cloud.ibm.com/apidocs/vpc#resource-suspension"}], "lifecycle_state": "stable", "memory": 1536, "name": "my-bare-metal-server", "network_attachments": [{"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/2302-f7a2bf57-af7c-49d9-b599-b2c91293d30c/network_attachments/2302-da8c43ec-b6ca-4bd2-871e-72e288c66ee6", "id": "2302-da8c43ec-b6ca-4bd2-871e-72e288c66ee6", "name": "my-bare-metal-server-network-attachment", "primary_ip": {"address": "192.168.3.4", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e/reserved_ips/6d353a0f-aeb1-4ae1-832e-1110d10981bb", "id": "6d353a0f-aeb1-4ae1-832e-1110d10981bb", "name": "my-reserved-ip", "resource_type": "subnet_reserved_ip"}, "resource_type": "bare_metal_server_network_attachment", "subnet": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "id": "7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "name": "my-subnet", "resource_type": "subnet"}}], "network_interfaces": [{"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/1e09281b-f177-46fb-baf1-bc152b2e391a/network_interfaces/10c02d81-0ecb-4dc5-897d-28392913b81e", "id": "10c02d81-0ecb-4dc5-897d-28392913b81e", "name": "my-bare-metal-server-network-interface", "primary_ip": {"address": "192.168.3.4", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e/reserved_ips/6d353a0f-aeb1-4ae1-832e-1110d10981bb", "id": "6d353a0f-aeb1-4ae1-832e-1110d10981bb", "name": "my-reserved-ip", "resource_type": "subnet_reserved_ip"}, "resource_type": "network_interface", "subnet": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "id": "7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "name": "my-subnet", "resource_type": "subnet"}}], "primary_network_attachment": {"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/2302-f7a2bf57-af7c-49d9-b599-b2c91293d30c/network_attachments/2302-da8c43ec-b6ca-4bd2-871e-72e288c66ee6", "id": "2302-da8c43ec-b6ca-4bd2-871e-72e288c66ee6", "name": "my-bare-metal-server-network-attachment", "primary_ip": {"address": "192.168.3.4", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e/reserved_ips/6d353a0f-aeb1-4ae1-832e-1110d10981bb", "id": "6d353a0f-aeb1-4ae1-832e-1110d10981bb", "name": "my-reserved-ip", "resource_type": "subnet_reserved_ip"}, "resource_type": "bare_metal_server_network_attachment", "subnet": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "id": "7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "name": "my-subnet", "resource_type": "subnet"}}, "primary_network_interface": {"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/1e09281b-f177-46fb-baf1-bc152b2e391a/network_interfaces/10c02d81-0ecb-4dc5-897d-28392913b81e", "id": "10c02d81-0ecb-4dc5-897d-28392913b81e", "name": "my-bare-metal-server-network-interface", "primary_ip": {"address": "192.168.3.4", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e/reserved_ips/6d353a0f-aeb1-4ae1-832e-1110d10981bb", "id": "6d353a0f-aeb1-4ae1-832e-1110d10981bb", "name": "my-reserved-ip", "resource_type": "subnet_reserved_ip"}, "resource_type": "network_interface", "subnet": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "id": "7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "name": "my-subnet", "resource_type": "subnet"}}, "profile": {"href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/profiles/bx2-metal-192x768", "name": "bx2-metal-192x768", "resource_type": "bare_metal_server_profile"}, "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "resource_type": "bare_metal_server", "status": "deleting", "status_reasons": [{"code": "cannot_start_capacity", "message": "The bare metal server cannot start as there is no more capacity in this\nzone for a bare metal server with the requested profile.", "more_info": "https://console.bluemix.net/docs/iaas/bare_metal_server.html"}], "trusted_platform_module": {"enabled": true, "mode": "disabled", "supported_modes": ["disabled"]}, "vpc": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::vpc:4727d842-f94f-4a2d-824a-9bc9b02c523b", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/vpcs/4727d842-f94f-4a2d-824a-9bc9b02c523b", "id": "4727d842-f94f-4a2d-824a-9bc9b02c523b", "name": "my-vpc", "resource_type": "vpc"}, "zone": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south/zones/us-south-1", "name": "us-south-1"}}`) + })) + }) + It(`Invoke CreateBareMetalServer 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.CreateBareMetalServer(nil) + Expect(operationErr).NotTo(BeNil()) + Expect(response).To(BeNil()) + Expect(result).To(BeNil()) + + // Construct an instance of the ImageIdentityByID model + imageIdentityModel := new(vpcv1.ImageIdentityByID) + imageIdentityModel.ID = core.StringPtr("72b27b5c-f4b0-48bb-b954-5becc7c1dcb8") + + // Construct an instance of the KeyIdentityByID model + keyIdentityModel := new(vpcv1.KeyIdentityByID) + keyIdentityModel.ID = core.StringPtr("a6b1a881-2ce8-41a3-80fc-36316a73f803") + + // Construct an instance of the BareMetalServerInitializationPrototype model + bareMetalServerInitializationPrototypeModel := new(vpcv1.BareMetalServerInitializationPrototype) + bareMetalServerInitializationPrototypeModel.Image = imageIdentityModel + bareMetalServerInitializationPrototypeModel.Keys = []vpcv1.KeyIdentityIntf{keyIdentityModel} + bareMetalServerInitializationPrototypeModel.UserData = core.StringPtr("testString") + + // Construct an instance of the BareMetalServerProfileIdentityByName model + bareMetalServerProfileIdentityModel := new(vpcv1.BareMetalServerProfileIdentityByName) + bareMetalServerProfileIdentityModel.Name = core.StringPtr("bx2-metal-192x768") + + // Construct an instance of the ResourceGroupIdentityByID model + resourceGroupIdentityModel := new(vpcv1.ResourceGroupIdentityByID) + resourceGroupIdentityModel.ID = core.StringPtr("fee82deba12e4c0fb69c3b09d1f12345") + + // Construct an instance of the BareMetalServerTrustedPlatformModulePrototype model + bareMetalServerTrustedPlatformModulePrototypeModel := new(vpcv1.BareMetalServerTrustedPlatformModulePrototype) + bareMetalServerTrustedPlatformModulePrototypeModel.Mode = core.StringPtr("disabled") + + // Construct an instance of the VPCIdentityByID model + vpcIdentityModel := new(vpcv1.VPCIdentityByID) + vpcIdentityModel.ID = core.StringPtr("4727d842-f94f-4a2d-824a-9bc9b02c523b") + + // Construct an instance of the ZoneIdentityByName model + zoneIdentityModel := new(vpcv1.ZoneIdentityByName) + zoneIdentityModel.Name = core.StringPtr("us-south-1") + + // Construct an instance of the VirtualNetworkInterfaceIPPrototypeReservedIPPrototypeVirtualNetworkInterfaceIPsContext model + virtualNetworkInterfaceIPPrototypeModel := new(vpcv1.VirtualNetworkInterfaceIPPrototypeReservedIPPrototypeVirtualNetworkInterfaceIPsContext) + virtualNetworkInterfaceIPPrototypeModel.Address = core.StringPtr("10.0.0.5") + virtualNetworkInterfaceIPPrototypeModel.AutoDelete = core.BoolPtr(false) + virtualNetworkInterfaceIPPrototypeModel.Name = core.StringPtr("my-reserved-ip") + + // Construct an instance of the VirtualNetworkInterfacePrimaryIPPrototypeReservedIPPrototypeVirtualNetworkInterfacePrimaryIPContext model + virtualNetworkInterfacePrimaryIPPrototypeModel := new(vpcv1.VirtualNetworkInterfacePrimaryIPPrototypeReservedIPPrototypeVirtualNetworkInterfacePrimaryIPContext) + virtualNetworkInterfacePrimaryIPPrototypeModel.Address = core.StringPtr("10.0.0.5") + virtualNetworkInterfacePrimaryIPPrototypeModel.AutoDelete = core.BoolPtr(false) + virtualNetworkInterfacePrimaryIPPrototypeModel.Name = core.StringPtr("my-reserved-ip") + + // Construct an instance of the SecurityGroupIdentityByID model + securityGroupIdentityModel := new(vpcv1.SecurityGroupIdentityByID) + securityGroupIdentityModel.ID = core.StringPtr("be5df5ca-12a0-494b-907e-aa6ec2bfa271") + + // Construct an instance of the SubnetIdentityByID model + subnetIdentityModel := new(vpcv1.SubnetIdentityByID) + subnetIdentityModel.ID = core.StringPtr("7ec86020-1c6e-4889-b3f0-a15f2e50f87e") + + // Construct an instance of the BareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceVirtualNetworkInterfacePrototypeBareMetalServerNetworkAttachmentContext model + bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel := new(vpcv1.BareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceVirtualNetworkInterfacePrototypeBareMetalServerNetworkAttachmentContext) + bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel.AllowIPSpoofing = core.BoolPtr(true) + bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel.AutoDelete = core.BoolPtr(false) + bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel.EnableInfrastructureNat = core.BoolPtr(true) + bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel.Ips = []vpcv1.VirtualNetworkInterfaceIPPrototypeIntf{virtualNetworkInterfaceIPPrototypeModel} + bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel.Name = core.StringPtr("my-virtual-network-interface") + bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel.PrimaryIP = virtualNetworkInterfacePrimaryIPPrototypeModel + bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel.ResourceGroup = resourceGroupIdentityModel + bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel.SecurityGroups = []vpcv1.SecurityGroupIdentityIntf{securityGroupIdentityModel} + bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel.Subnet = subnetIdentityModel + + // Construct an instance of the BareMetalServerNetworkAttachmentPrototypeBareMetalServerNetworkAttachmentByPciPrototype model + bareMetalServerNetworkAttachmentPrototypeModel := new(vpcv1.BareMetalServerNetworkAttachmentPrototypeBareMetalServerNetworkAttachmentByPciPrototype) + bareMetalServerNetworkAttachmentPrototypeModel.Name = core.StringPtr("my-bare-metal-server-network-attachment") + bareMetalServerNetworkAttachmentPrototypeModel.VirtualNetworkInterface = bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel + bareMetalServerNetworkAttachmentPrototypeModel.AllowedVlans = []int64{} + bareMetalServerNetworkAttachmentPrototypeModel.InterfaceType = core.StringPtr("pci") + + // Construct an instance of the BareMetalServerPrimaryNetworkAttachmentPrototypeBareMetalServerPrimaryNetworkAttachmentByPciPrototype model + bareMetalServerPrimaryNetworkAttachmentPrototypeModel := new(vpcv1.BareMetalServerPrimaryNetworkAttachmentPrototypeBareMetalServerPrimaryNetworkAttachmentByPciPrototype) + bareMetalServerPrimaryNetworkAttachmentPrototypeModel.Name = core.StringPtr("my-bare-metal-server-network-attachment") + bareMetalServerPrimaryNetworkAttachmentPrototypeModel.VirtualNetworkInterface = bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel + bareMetalServerPrimaryNetworkAttachmentPrototypeModel.AllowedVlans = []int64{} + bareMetalServerPrimaryNetworkAttachmentPrototypeModel.InterfaceType = core.StringPtr("pci") + + // Construct an instance of the BareMetalServerPrototypeBareMetalServerByNetworkAttachment model + bareMetalServerPrototypeModel := new(vpcv1.BareMetalServerPrototypeBareMetalServerByNetworkAttachment) + bareMetalServerPrototypeModel.EnableSecureBoot = core.BoolPtr(false) + bareMetalServerPrototypeModel.Initialization = bareMetalServerInitializationPrototypeModel + bareMetalServerPrototypeModel.Name = core.StringPtr("my-bare-metal-server") + bareMetalServerPrototypeModel.Profile = bareMetalServerProfileIdentityModel + bareMetalServerPrototypeModel.ResourceGroup = resourceGroupIdentityModel + bareMetalServerPrototypeModel.TrustedPlatformModule = bareMetalServerTrustedPlatformModulePrototypeModel + bareMetalServerPrototypeModel.VPC = vpcIdentityModel + bareMetalServerPrototypeModel.Zone = zoneIdentityModel + bareMetalServerPrototypeModel.NetworkAttachments = []vpcv1.BareMetalServerNetworkAttachmentPrototypeIntf{bareMetalServerNetworkAttachmentPrototypeModel} + bareMetalServerPrototypeModel.PrimaryNetworkAttachment = bareMetalServerPrimaryNetworkAttachmentPrototypeModel + + // Construct an instance of the CreateBareMetalServerOptions model + createBareMetalServerOptionsModel := new(vpcv1.CreateBareMetalServerOptions) + createBareMetalServerOptionsModel.BareMetalServerPrototype = bareMetalServerPrototypeModel + createBareMetalServerOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation with valid options model (positive test) + result, response, operationErr = vpcService.CreateBareMetalServer(createBareMetalServerOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).ToNot(BeNil()) + + }) + It(`Invoke CreateBareMetalServer 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 ImageIdentityByID model + imageIdentityModel := new(vpcv1.ImageIdentityByID) + imageIdentityModel.ID = core.StringPtr("72b27b5c-f4b0-48bb-b954-5becc7c1dcb8") + + // Construct an instance of the KeyIdentityByID model + keyIdentityModel := new(vpcv1.KeyIdentityByID) + keyIdentityModel.ID = core.StringPtr("a6b1a881-2ce8-41a3-80fc-36316a73f803") + + // Construct an instance of the BareMetalServerInitializationPrototype model + bareMetalServerInitializationPrototypeModel := new(vpcv1.BareMetalServerInitializationPrototype) + bareMetalServerInitializationPrototypeModel.Image = imageIdentityModel + bareMetalServerInitializationPrototypeModel.Keys = []vpcv1.KeyIdentityIntf{keyIdentityModel} + bareMetalServerInitializationPrototypeModel.UserData = core.StringPtr("testString") + + // Construct an instance of the BareMetalServerProfileIdentityByName model + bareMetalServerProfileIdentityModel := new(vpcv1.BareMetalServerProfileIdentityByName) + bareMetalServerProfileIdentityModel.Name = core.StringPtr("bx2-metal-192x768") + + // Construct an instance of the ResourceGroupIdentityByID model + resourceGroupIdentityModel := new(vpcv1.ResourceGroupIdentityByID) + resourceGroupIdentityModel.ID = core.StringPtr("fee82deba12e4c0fb69c3b09d1f12345") + + // Construct an instance of the BareMetalServerTrustedPlatformModulePrototype model + bareMetalServerTrustedPlatformModulePrototypeModel := new(vpcv1.BareMetalServerTrustedPlatformModulePrototype) + bareMetalServerTrustedPlatformModulePrototypeModel.Mode = core.StringPtr("disabled") + + // Construct an instance of the VPCIdentityByID model + vpcIdentityModel := new(vpcv1.VPCIdentityByID) + vpcIdentityModel.ID = core.StringPtr("4727d842-f94f-4a2d-824a-9bc9b02c523b") + + // Construct an instance of the ZoneIdentityByName model + zoneIdentityModel := new(vpcv1.ZoneIdentityByName) + zoneIdentityModel.Name = core.StringPtr("us-south-1") + + // Construct an instance of the VirtualNetworkInterfaceIPPrototypeReservedIPPrototypeVirtualNetworkInterfaceIPsContext model + virtualNetworkInterfaceIPPrototypeModel := new(vpcv1.VirtualNetworkInterfaceIPPrototypeReservedIPPrototypeVirtualNetworkInterfaceIPsContext) + virtualNetworkInterfaceIPPrototypeModel.Address = core.StringPtr("10.0.0.5") + virtualNetworkInterfaceIPPrototypeModel.AutoDelete = core.BoolPtr(false) + virtualNetworkInterfaceIPPrototypeModel.Name = core.StringPtr("my-reserved-ip") + + // Construct an instance of the VirtualNetworkInterfacePrimaryIPPrototypeReservedIPPrototypeVirtualNetworkInterfacePrimaryIPContext model + virtualNetworkInterfacePrimaryIPPrototypeModel := new(vpcv1.VirtualNetworkInterfacePrimaryIPPrototypeReservedIPPrototypeVirtualNetworkInterfacePrimaryIPContext) + virtualNetworkInterfacePrimaryIPPrototypeModel.Address = core.StringPtr("10.0.0.5") + virtualNetworkInterfacePrimaryIPPrototypeModel.AutoDelete = core.BoolPtr(false) + virtualNetworkInterfacePrimaryIPPrototypeModel.Name = core.StringPtr("my-reserved-ip") + + // Construct an instance of the SecurityGroupIdentityByID model + securityGroupIdentityModel := new(vpcv1.SecurityGroupIdentityByID) + securityGroupIdentityModel.ID = core.StringPtr("be5df5ca-12a0-494b-907e-aa6ec2bfa271") + + // Construct an instance of the SubnetIdentityByID model + subnetIdentityModel := new(vpcv1.SubnetIdentityByID) + subnetIdentityModel.ID = core.StringPtr("7ec86020-1c6e-4889-b3f0-a15f2e50f87e") + + // Construct an instance of the BareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceVirtualNetworkInterfacePrototypeBareMetalServerNetworkAttachmentContext model + bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel := new(vpcv1.BareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceVirtualNetworkInterfacePrototypeBareMetalServerNetworkAttachmentContext) + bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel.AllowIPSpoofing = core.BoolPtr(true) + bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel.AutoDelete = core.BoolPtr(false) + bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel.EnableInfrastructureNat = core.BoolPtr(true) + bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel.Ips = []vpcv1.VirtualNetworkInterfaceIPPrototypeIntf{virtualNetworkInterfaceIPPrototypeModel} + bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel.Name = core.StringPtr("my-virtual-network-interface") + bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel.PrimaryIP = virtualNetworkInterfacePrimaryIPPrototypeModel + bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel.ResourceGroup = resourceGroupIdentityModel + bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel.SecurityGroups = []vpcv1.SecurityGroupIdentityIntf{securityGroupIdentityModel} + bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel.Subnet = subnetIdentityModel + + // Construct an instance of the BareMetalServerNetworkAttachmentPrototypeBareMetalServerNetworkAttachmentByPciPrototype model + bareMetalServerNetworkAttachmentPrototypeModel := new(vpcv1.BareMetalServerNetworkAttachmentPrototypeBareMetalServerNetworkAttachmentByPciPrototype) + bareMetalServerNetworkAttachmentPrototypeModel.Name = core.StringPtr("my-bare-metal-server-network-attachment") + bareMetalServerNetworkAttachmentPrototypeModel.VirtualNetworkInterface = bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel + bareMetalServerNetworkAttachmentPrototypeModel.AllowedVlans = []int64{} + bareMetalServerNetworkAttachmentPrototypeModel.InterfaceType = core.StringPtr("pci") + + // Construct an instance of the BareMetalServerPrimaryNetworkAttachmentPrototypeBareMetalServerPrimaryNetworkAttachmentByPciPrototype model + bareMetalServerPrimaryNetworkAttachmentPrototypeModel := new(vpcv1.BareMetalServerPrimaryNetworkAttachmentPrototypeBareMetalServerPrimaryNetworkAttachmentByPciPrototype) + bareMetalServerPrimaryNetworkAttachmentPrototypeModel.Name = core.StringPtr("my-bare-metal-server-network-attachment") + bareMetalServerPrimaryNetworkAttachmentPrototypeModel.VirtualNetworkInterface = bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel + bareMetalServerPrimaryNetworkAttachmentPrototypeModel.AllowedVlans = []int64{} + bareMetalServerPrimaryNetworkAttachmentPrototypeModel.InterfaceType = core.StringPtr("pci") + + // Construct an instance of the BareMetalServerPrototypeBareMetalServerByNetworkAttachment model + bareMetalServerPrototypeModel := new(vpcv1.BareMetalServerPrototypeBareMetalServerByNetworkAttachment) + bareMetalServerPrototypeModel.EnableSecureBoot = core.BoolPtr(false) + bareMetalServerPrototypeModel.Initialization = bareMetalServerInitializationPrototypeModel + bareMetalServerPrototypeModel.Name = core.StringPtr("my-bare-metal-server") + bareMetalServerPrototypeModel.Profile = bareMetalServerProfileIdentityModel + bareMetalServerPrototypeModel.ResourceGroup = resourceGroupIdentityModel + bareMetalServerPrototypeModel.TrustedPlatformModule = bareMetalServerTrustedPlatformModulePrototypeModel + bareMetalServerPrototypeModel.VPC = vpcIdentityModel + bareMetalServerPrototypeModel.Zone = zoneIdentityModel + bareMetalServerPrototypeModel.NetworkAttachments = []vpcv1.BareMetalServerNetworkAttachmentPrototypeIntf{bareMetalServerNetworkAttachmentPrototypeModel} + bareMetalServerPrototypeModel.PrimaryNetworkAttachment = bareMetalServerPrimaryNetworkAttachmentPrototypeModel + + // Construct an instance of the CreateBareMetalServerOptions model + createBareMetalServerOptionsModel := new(vpcv1.CreateBareMetalServerOptions) + createBareMetalServerOptionsModel.BareMetalServerPrototype = bareMetalServerPrototypeModel + createBareMetalServerOptionsModel.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.CreateBareMetalServer(createBareMetalServerOptionsModel) + 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 CreateBareMetalServerOptions model with no property values + createBareMetalServerOptionsModelNew := new(vpcv1.CreateBareMetalServerOptions) + // Invoke operation with invalid model (negative test) + result, response, operationErr = vpcService.CreateBareMetalServer(createBareMetalServerOptionsModelNew) + 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 CreateBareMetalServer 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 ImageIdentityByID model + imageIdentityModel := new(vpcv1.ImageIdentityByID) + imageIdentityModel.ID = core.StringPtr("72b27b5c-f4b0-48bb-b954-5becc7c1dcb8") + + // Construct an instance of the KeyIdentityByID model + keyIdentityModel := new(vpcv1.KeyIdentityByID) + keyIdentityModel.ID = core.StringPtr("a6b1a881-2ce8-41a3-80fc-36316a73f803") + + // Construct an instance of the BareMetalServerInitializationPrototype model + bareMetalServerInitializationPrototypeModel := new(vpcv1.BareMetalServerInitializationPrototype) + bareMetalServerInitializationPrototypeModel.Image = imageIdentityModel + bareMetalServerInitializationPrototypeModel.Keys = []vpcv1.KeyIdentityIntf{keyIdentityModel} + bareMetalServerInitializationPrototypeModel.UserData = core.StringPtr("testString") + + // Construct an instance of the BareMetalServerProfileIdentityByName model + bareMetalServerProfileIdentityModel := new(vpcv1.BareMetalServerProfileIdentityByName) + bareMetalServerProfileIdentityModel.Name = core.StringPtr("bx2-metal-192x768") + + // Construct an instance of the ResourceGroupIdentityByID model + resourceGroupIdentityModel := new(vpcv1.ResourceGroupIdentityByID) + resourceGroupIdentityModel.ID = core.StringPtr("fee82deba12e4c0fb69c3b09d1f12345") + + // Construct an instance of the BareMetalServerTrustedPlatformModulePrototype model + bareMetalServerTrustedPlatformModulePrototypeModel := new(vpcv1.BareMetalServerTrustedPlatformModulePrototype) + bareMetalServerTrustedPlatformModulePrototypeModel.Mode = core.StringPtr("disabled") + + // Construct an instance of the VPCIdentityByID model + vpcIdentityModel := new(vpcv1.VPCIdentityByID) + vpcIdentityModel.ID = core.StringPtr("4727d842-f94f-4a2d-824a-9bc9b02c523b") + + // Construct an instance of the ZoneIdentityByName model + zoneIdentityModel := new(vpcv1.ZoneIdentityByName) + zoneIdentityModel.Name = core.StringPtr("us-south-1") + + // Construct an instance of the VirtualNetworkInterfaceIPPrototypeReservedIPPrototypeVirtualNetworkInterfaceIPsContext model + virtualNetworkInterfaceIPPrototypeModel := new(vpcv1.VirtualNetworkInterfaceIPPrototypeReservedIPPrototypeVirtualNetworkInterfaceIPsContext) + virtualNetworkInterfaceIPPrototypeModel.Address = core.StringPtr("10.0.0.5") + virtualNetworkInterfaceIPPrototypeModel.AutoDelete = core.BoolPtr(false) + virtualNetworkInterfaceIPPrototypeModel.Name = core.StringPtr("my-reserved-ip") + + // Construct an instance of the VirtualNetworkInterfacePrimaryIPPrototypeReservedIPPrototypeVirtualNetworkInterfacePrimaryIPContext model + virtualNetworkInterfacePrimaryIPPrototypeModel := new(vpcv1.VirtualNetworkInterfacePrimaryIPPrototypeReservedIPPrototypeVirtualNetworkInterfacePrimaryIPContext) + virtualNetworkInterfacePrimaryIPPrototypeModel.Address = core.StringPtr("10.0.0.5") + virtualNetworkInterfacePrimaryIPPrototypeModel.AutoDelete = core.BoolPtr(false) + virtualNetworkInterfacePrimaryIPPrototypeModel.Name = core.StringPtr("my-reserved-ip") + + // Construct an instance of the SecurityGroupIdentityByID model + securityGroupIdentityModel := new(vpcv1.SecurityGroupIdentityByID) + securityGroupIdentityModel.ID = core.StringPtr("be5df5ca-12a0-494b-907e-aa6ec2bfa271") + + // Construct an instance of the SubnetIdentityByID model + subnetIdentityModel := new(vpcv1.SubnetIdentityByID) + subnetIdentityModel.ID = core.StringPtr("7ec86020-1c6e-4889-b3f0-a15f2e50f87e") + + // Construct an instance of the BareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceVirtualNetworkInterfacePrototypeBareMetalServerNetworkAttachmentContext model + bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel := new(vpcv1.BareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceVirtualNetworkInterfacePrototypeBareMetalServerNetworkAttachmentContext) + bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel.AllowIPSpoofing = core.BoolPtr(true) + bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel.AutoDelete = core.BoolPtr(false) + bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel.EnableInfrastructureNat = core.BoolPtr(true) + bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel.Ips = []vpcv1.VirtualNetworkInterfaceIPPrototypeIntf{virtualNetworkInterfaceIPPrototypeModel} + bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel.Name = core.StringPtr("my-virtual-network-interface") + bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel.PrimaryIP = virtualNetworkInterfacePrimaryIPPrototypeModel + bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel.ResourceGroup = resourceGroupIdentityModel + bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel.SecurityGroups = []vpcv1.SecurityGroupIdentityIntf{securityGroupIdentityModel} + bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel.Subnet = subnetIdentityModel + + // Construct an instance of the BareMetalServerNetworkAttachmentPrototypeBareMetalServerNetworkAttachmentByPciPrototype model + bareMetalServerNetworkAttachmentPrototypeModel := new(vpcv1.BareMetalServerNetworkAttachmentPrototypeBareMetalServerNetworkAttachmentByPciPrototype) + bareMetalServerNetworkAttachmentPrototypeModel.Name = core.StringPtr("my-bare-metal-server-network-attachment") + bareMetalServerNetworkAttachmentPrototypeModel.VirtualNetworkInterface = bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel + bareMetalServerNetworkAttachmentPrototypeModel.AllowedVlans = []int64{} + bareMetalServerNetworkAttachmentPrototypeModel.InterfaceType = core.StringPtr("pci") + + // Construct an instance of the BareMetalServerPrimaryNetworkAttachmentPrototypeBareMetalServerPrimaryNetworkAttachmentByPciPrototype model + bareMetalServerPrimaryNetworkAttachmentPrototypeModel := new(vpcv1.BareMetalServerPrimaryNetworkAttachmentPrototypeBareMetalServerPrimaryNetworkAttachmentByPciPrototype) + bareMetalServerPrimaryNetworkAttachmentPrototypeModel.Name = core.StringPtr("my-bare-metal-server-network-attachment") + bareMetalServerPrimaryNetworkAttachmentPrototypeModel.VirtualNetworkInterface = bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel + bareMetalServerPrimaryNetworkAttachmentPrototypeModel.AllowedVlans = []int64{} + bareMetalServerPrimaryNetworkAttachmentPrototypeModel.InterfaceType = core.StringPtr("pci") + + // Construct an instance of the BareMetalServerPrototypeBareMetalServerByNetworkAttachment model + bareMetalServerPrototypeModel := new(vpcv1.BareMetalServerPrototypeBareMetalServerByNetworkAttachment) + bareMetalServerPrototypeModel.EnableSecureBoot = core.BoolPtr(false) + bareMetalServerPrototypeModel.Initialization = bareMetalServerInitializationPrototypeModel + bareMetalServerPrototypeModel.Name = core.StringPtr("my-bare-metal-server") + bareMetalServerPrototypeModel.Profile = bareMetalServerProfileIdentityModel + bareMetalServerPrototypeModel.ResourceGroup = resourceGroupIdentityModel + bareMetalServerPrototypeModel.TrustedPlatformModule = bareMetalServerTrustedPlatformModulePrototypeModel + bareMetalServerPrototypeModel.VPC = vpcIdentityModel + bareMetalServerPrototypeModel.Zone = zoneIdentityModel + bareMetalServerPrototypeModel.NetworkAttachments = []vpcv1.BareMetalServerNetworkAttachmentPrototypeIntf{bareMetalServerNetworkAttachmentPrototypeModel} + bareMetalServerPrototypeModel.PrimaryNetworkAttachment = bareMetalServerPrimaryNetworkAttachmentPrototypeModel + + // Construct an instance of the CreateBareMetalServerOptions model + createBareMetalServerOptionsModel := new(vpcv1.CreateBareMetalServerOptions) + createBareMetalServerOptionsModel.BareMetalServerPrototype = bareMetalServerPrototypeModel + createBareMetalServerOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation + result, response, operationErr := vpcService.CreateBareMetalServer(createBareMetalServerOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + + // Verify a nil result + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + }) + Describe(`CreateBareMetalServerConsoleAccessToken(createBareMetalServerConsoleAccessTokenOptions *CreateBareMetalServerConsoleAccessTokenOptions) - Operation response error`, func() { + version := "testString" + createBareMetalServerConsoleAccessTokenPath := "/bare_metal_servers/testString/console_access_token" + 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(createBareMetalServerConsoleAccessTokenPath)) + 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) + fmt.Fprint(res, `} this is not valid json {`) + })) + }) + It(`Invoke CreateBareMetalServerConsoleAccessToken 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 CreateBareMetalServerConsoleAccessTokenOptions model + createBareMetalServerConsoleAccessTokenOptionsModel := new(vpcv1.CreateBareMetalServerConsoleAccessTokenOptions) + createBareMetalServerConsoleAccessTokenOptionsModel.BareMetalServerID = core.StringPtr("testString") + createBareMetalServerConsoleAccessTokenOptionsModel.ConsoleType = core.StringPtr("serial") + createBareMetalServerConsoleAccessTokenOptionsModel.Force = core.BoolPtr(false) + createBareMetalServerConsoleAccessTokenOptionsModel.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.CreateBareMetalServerConsoleAccessToken(createBareMetalServerConsoleAccessTokenOptionsModel) + 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.CreateBareMetalServerConsoleAccessToken(createBareMetalServerConsoleAccessTokenOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + }) + Describe(`CreateBareMetalServerConsoleAccessToken(createBareMetalServerConsoleAccessTokenOptions *CreateBareMetalServerConsoleAccessTokenOptions)`, func() { + version := "testString" + createBareMetalServerConsoleAccessTokenPath := "/bare_metal_servers/testString/console_access_token" + 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(createBareMetalServerConsoleAccessTokenPath)) + 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(200) + fmt.Fprintf(res, "%s", `{"access_token": "VGhpcyBJcyBhIHRva2Vu", "console_type": "serial", "created_at": "2020-07-27T21:50:14.000Z", "expires_at": "2020-07-27T21:51:14.000Z", "force": false, "href": "wss://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/1e09281b-f177-46fb-baf1-bc152b2e391a/console?access_token=VGhpcyBJcyBhIHRva2Vu"}`) + })) + }) + It(`Invoke CreateBareMetalServerConsoleAccessToken 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 CreateBareMetalServerConsoleAccessTokenOptions model + createBareMetalServerConsoleAccessTokenOptionsModel := new(vpcv1.CreateBareMetalServerConsoleAccessTokenOptions) + createBareMetalServerConsoleAccessTokenOptionsModel.BareMetalServerID = core.StringPtr("testString") + createBareMetalServerConsoleAccessTokenOptionsModel.ConsoleType = core.StringPtr("serial") + createBareMetalServerConsoleAccessTokenOptionsModel.Force = core.BoolPtr(false) + createBareMetalServerConsoleAccessTokenOptionsModel.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.CreateBareMetalServerConsoleAccessTokenWithContext(ctx, createBareMetalServerConsoleAccessTokenOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) + + // Disable retries and test again + vpcService.DisableRetries() + result, response, operationErr := vpcService.CreateBareMetalServerConsoleAccessToken(createBareMetalServerConsoleAccessTokenOptionsModel) + 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.CreateBareMetalServerConsoleAccessTokenWithContext(ctx, createBareMetalServerConsoleAccessTokenOptionsModel) + 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(createBareMetalServerConsoleAccessTokenPath)) + 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(200) + fmt.Fprintf(res, "%s", `{"access_token": "VGhpcyBJcyBhIHRva2Vu", "console_type": "serial", "created_at": "2020-07-27T21:50:14.000Z", "expires_at": "2020-07-27T21:51:14.000Z", "force": false, "href": "wss://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/1e09281b-f177-46fb-baf1-bc152b2e391a/console?access_token=VGhpcyBJcyBhIHRva2Vu"}`) + })) + }) + It(`Invoke CreateBareMetalServerConsoleAccessToken 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.CreateBareMetalServerConsoleAccessToken(nil) + Expect(operationErr).NotTo(BeNil()) + Expect(response).To(BeNil()) + Expect(result).To(BeNil()) + + // Construct an instance of the CreateBareMetalServerConsoleAccessTokenOptions model + createBareMetalServerConsoleAccessTokenOptionsModel := new(vpcv1.CreateBareMetalServerConsoleAccessTokenOptions) + createBareMetalServerConsoleAccessTokenOptionsModel.BareMetalServerID = core.StringPtr("testString") + createBareMetalServerConsoleAccessTokenOptionsModel.ConsoleType = core.StringPtr("serial") + createBareMetalServerConsoleAccessTokenOptionsModel.Force = core.BoolPtr(false) + createBareMetalServerConsoleAccessTokenOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with valid options model (positive test) - result, response, operationErr = vpcService.GetBackupPolicyPlan(getBackupPolicyPlanOptionsModel) + result, response, operationErr = vpcService.CreateBareMetalServerConsoleAccessToken(createBareMetalServerConsoleAccessTokenOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) }) - It(`Invoke GetBackupPolicyPlan with error: Operation validation and request error`, func() { + It(`Invoke CreateBareMetalServerConsoleAccessToken with error: Operation validation and request error`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -43280,23 +43737,24 @@ var _ = Describe(`VpcV1`, func() { 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"} + // Construct an instance of the CreateBareMetalServerConsoleAccessTokenOptions model + createBareMetalServerConsoleAccessTokenOptionsModel := new(vpcv1.CreateBareMetalServerConsoleAccessTokenOptions) + createBareMetalServerConsoleAccessTokenOptionsModel.BareMetalServerID = core.StringPtr("testString") + createBareMetalServerConsoleAccessTokenOptionsModel.ConsoleType = core.StringPtr("serial") + createBareMetalServerConsoleAccessTokenOptionsModel.Force = core.BoolPtr(false) + createBareMetalServerConsoleAccessTokenOptionsModel.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) + result, response, operationErr := vpcService.CreateBareMetalServerConsoleAccessToken(createBareMetalServerConsoleAccessTokenOptionsModel) 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) + // Construct a second instance of the CreateBareMetalServerConsoleAccessTokenOptions model with no property values + createBareMetalServerConsoleAccessTokenOptionsModelNew := new(vpcv1.CreateBareMetalServerConsoleAccessTokenOptions) // Invoke operation with invalid model (negative test) - result, response, operationErr = vpcService.GetBackupPolicyPlan(getBackupPolicyPlanOptionsModelNew) + result, response, operationErr = vpcService.CreateBareMetalServerConsoleAccessToken(createBareMetalServerConsoleAccessTokenOptionsModelNew) Expect(operationErr).ToNot(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) @@ -43314,7 +43772,7 @@ var _ = Describe(`VpcV1`, func() { res.WriteHeader(200) })) }) - It(`Invoke GetBackupPolicyPlan successfully`, func() { + It(`Invoke CreateBareMetalServerConsoleAccessToken successfully`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -43323,14 +43781,15 @@ var _ = Describe(`VpcV1`, func() { 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"} + // Construct an instance of the CreateBareMetalServerConsoleAccessTokenOptions model + createBareMetalServerConsoleAccessTokenOptionsModel := new(vpcv1.CreateBareMetalServerConsoleAccessTokenOptions) + createBareMetalServerConsoleAccessTokenOptionsModel.BareMetalServerID = core.StringPtr("testString") + createBareMetalServerConsoleAccessTokenOptionsModel.ConsoleType = core.StringPtr("serial") + createBareMetalServerConsoleAccessTokenOptionsModel.Force = core.BoolPtr(false) + createBareMetalServerConsoleAccessTokenOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation - result, response, operationErr := vpcService.GetBackupPolicyPlan(getBackupPolicyPlanOptionsModel) + result, response, operationErr := vpcService.CreateBareMetalServerConsoleAccessToken(createBareMetalServerConsoleAccessTokenOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) @@ -43342,19 +43801,17 @@ var _ = Describe(`VpcV1`, func() { }) }) }) - Describe(`UpdateBackupPolicyPlan(updateBackupPolicyPlanOptions *UpdateBackupPolicyPlanOptions) - Operation response error`, func() { + Describe(`ListBareMetalServerDisks(listBareMetalServerDisksOptions *ListBareMetalServerDisksOptions) - Operation response error`, func() { version := "testString" - updateBackupPolicyPlanPath := "/backup_policies/testString/plans/testString" + listBareMetalServerDisksPath := "/bare_metal_servers/testString/disks" 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.EscapedPath()).To(Equal(listBareMetalServerDisksPath)) + 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") @@ -43362,7 +43819,7 @@ var _ = Describe(`VpcV1`, func() { fmt.Fprint(res, `} this is not valid json {`) })) }) - It(`Invoke UpdateBackupPolicyPlan with error: Operation response processing error`, func() { + It(`Invoke ListBareMetalServerDisks with error: Operation response processing error`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -43371,63 +43828,19 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the ZoneIdentityByName model - zoneIdentityModel := new(vpcv1.ZoneIdentityByName) - zoneIdentityModel.Name = core.StringPtr("us-south-1") - - // Construct an instance of the BackupPolicyPlanClonePolicyPatch model - backupPolicyPlanClonePolicyPatchModel := new(vpcv1.BackupPolicyPlanClonePolicyPatch) - backupPolicyPlanClonePolicyPatchModel.MaxSnapshots = core.Int64Ptr(int64(1)) - backupPolicyPlanClonePolicyPatchModel.Zones = []vpcv1.ZoneIdentityIntf{zoneIdentityModel} - - // Construct an instance of the BackupPolicyPlanDeletionTriggerPatch model - backupPolicyPlanDeletionTriggerPatchModel := new(vpcv1.BackupPolicyPlanDeletionTriggerPatch) - backupPolicyPlanDeletionTriggerPatchModel.DeleteAfter = core.Int64Ptr(int64(20)) - backupPolicyPlanDeletionTriggerPatchModel.DeleteOverCount = core.Int64Ptr(int64(1)) - - // Construct an instance of the EncryptionKeyIdentityByCRN model - encryptionKeyIdentityModel := new(vpcv1.EncryptionKeyIdentityByCRN) - encryptionKeyIdentityModel.CRN = core.StringPtr("crn:v1:bluemix:public:kms:us-south:a/123456:e4a29d1a-2ef0-42a6-8fd2-350deb1c647e:key:5437653b-c4b1-447f-9646-b2a2a4cd6179") - - // Construct an instance of the RegionIdentityByName model - regionIdentityModel := new(vpcv1.RegionIdentityByName) - regionIdentityModel.Name = core.StringPtr("us-south") - - // Construct an instance of the BackupPolicyPlanRemoteRegionPolicyPrototype model - backupPolicyPlanRemoteRegionPolicyPrototypeModel := new(vpcv1.BackupPolicyPlanRemoteRegionPolicyPrototype) - backupPolicyPlanRemoteRegionPolicyPrototypeModel.DeleteOverCount = core.Int64Ptr(int64(5)) - backupPolicyPlanRemoteRegionPolicyPrototypeModel.EncryptionKey = encryptionKeyIdentityModel - backupPolicyPlanRemoteRegionPolicyPrototypeModel.Region = regionIdentityModel - - // Construct an instance of the BackupPolicyPlanPatch model - backupPolicyPlanPatchModel := new(vpcv1.BackupPolicyPlanPatch) - backupPolicyPlanPatchModel.Active = core.BoolPtr(true) - backupPolicyPlanPatchModel.AttachUserTags = []string{"my-daily-backup-plan"} - backupPolicyPlanPatchModel.ClonePolicy = backupPolicyPlanClonePolicyPatchModel - backupPolicyPlanPatchModel.CopyUserTags = core.BoolPtr(true) - backupPolicyPlanPatchModel.CronSpec = core.StringPtr("30 */2 * * 1-5") - backupPolicyPlanPatchModel.DeletionTrigger = backupPolicyPlanDeletionTriggerPatchModel - backupPolicyPlanPatchModel.Name = core.StringPtr("my-policy-plan") - backupPolicyPlanPatchModel.RemoteRegionPolicies = []vpcv1.BackupPolicyPlanRemoteRegionPolicyPrototype{*backupPolicyPlanRemoteRegionPolicyPrototypeModel} - 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"} + // Construct an instance of the ListBareMetalServerDisksOptions model + listBareMetalServerDisksOptionsModel := new(vpcv1.ListBareMetalServerDisksOptions) + listBareMetalServerDisksOptionsModel.BareMetalServerID = core.StringPtr("testString") + listBareMetalServerDisksOptionsModel.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) + result, response, operationErr := vpcService.ListBareMetalServerDisks(listBareMetalServerDisksOptionsModel) 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) + result, response, operationErr = vpcService.ListBareMetalServerDisks(listBareMetalServerDisksOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).To(BeNil()) @@ -43437,36 +43850,18 @@ var _ = Describe(`VpcV1`, func() { }) }) }) - Describe(`UpdateBackupPolicyPlan(updateBackupPolicyPlanOptions *UpdateBackupPolicyPlanOptions)`, func() { + Describe(`ListBareMetalServerDisks(listBareMetalServerDisksOptions *ListBareMetalServerDisksOptions)`, func() { version := "testString" - updateBackupPolicyPlanPath := "/backup_policies/testString/plans/testString" + listBareMetalServerDisksPath := "/bare_metal_servers/testString/disks" 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.URL.EscapedPath()).To(Equal(listBareMetalServerDisksPath)) + Expect(req.Method).To(Equal("GET")) - 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 @@ -43475,10 +43870,10 @@ var _ = Describe(`VpcV1`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"active": true, "attach_user_tags": ["AttachUserTags"], "clone_policy": {"max_snapshots": 1, "zones": [{"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south/zones/us-south-1", "name": "us-south-1"}]}, "copy_user_tags": true, "created_at": "2019-01-01T12:00:00.000Z", "cron_spec": "30 */2 * * 1-5", "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", "remote_region_policies": [{"delete_over_count": 1, "encryption_key": {"crn": "crn:v1:bluemix:public:kms:us-south:a/123456:e4a29d1a-2ef0-42a6-8fd2-350deb1c647e:key:5437653b-c4b1-447f-9646-b2a2a4cd6179"}, "region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}], "resource_type": "backup_policy_plan"}`) + fmt.Fprintf(res, "%s", `{"disks": [{"created_at": "2019-01-01T12:00:00.000Z", "href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/1e09281b-f177-46fb-baf1-bc152b2e391a/disks/10c02d81-0ecb-4dc5-897d-28392913b81e", "id": "10c02d81-0ecb-4dc5-897d-28392913b81e", "interface_type": "fcp", "name": "my-bare-metal-server-disk", "resource_type": "bare_metal_server_disk", "size": 100}]}`) })) }) - It(`Invoke UpdateBackupPolicyPlan successfully with retries`, func() { + It(`Invoke ListBareMetalServerDisks successfully with retries`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -43488,65 +43883,248 @@ var _ = Describe(`VpcV1`, func() { Expect(vpcService).ToNot(BeNil()) vpcService.EnableRetries(0, 0) - // Construct an instance of the ZoneIdentityByName model - zoneIdentityModel := new(vpcv1.ZoneIdentityByName) - zoneIdentityModel.Name = core.StringPtr("us-south-1") + // Construct an instance of the ListBareMetalServerDisksOptions model + listBareMetalServerDisksOptionsModel := new(vpcv1.ListBareMetalServerDisksOptions) + listBareMetalServerDisksOptionsModel.BareMetalServerID = core.StringPtr("testString") + listBareMetalServerDisksOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} - // Construct an instance of the BackupPolicyPlanClonePolicyPatch model - backupPolicyPlanClonePolicyPatchModel := new(vpcv1.BackupPolicyPlanClonePolicyPatch) - backupPolicyPlanClonePolicyPatchModel.MaxSnapshots = core.Int64Ptr(int64(1)) - backupPolicyPlanClonePolicyPatchModel.Zones = []vpcv1.ZoneIdentityIntf{zoneIdentityModel} + // Invoke operation with a Context to test a timeout error + ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond) + defer cancelFunc() + _, _, operationErr := vpcService.ListBareMetalServerDisksWithContext(ctx, listBareMetalServerDisksOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) - // Construct an instance of the BackupPolicyPlanDeletionTriggerPatch model - backupPolicyPlanDeletionTriggerPatchModel := new(vpcv1.BackupPolicyPlanDeletionTriggerPatch) - backupPolicyPlanDeletionTriggerPatchModel.DeleteAfter = core.Int64Ptr(int64(20)) - backupPolicyPlanDeletionTriggerPatchModel.DeleteOverCount = core.Int64Ptr(int64(1)) + // Disable retries and test again + vpcService.DisableRetries() + result, response, operationErr := vpcService.ListBareMetalServerDisks(listBareMetalServerDisksOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).ToNot(BeNil()) - // Construct an instance of the EncryptionKeyIdentityByCRN model - encryptionKeyIdentityModel := new(vpcv1.EncryptionKeyIdentityByCRN) - encryptionKeyIdentityModel.CRN = core.StringPtr("crn:v1:bluemix:public:kms:us-south:a/123456:e4a29d1a-2ef0-42a6-8fd2-350deb1c647e:key:5437653b-c4b1-447f-9646-b2a2a4cd6179") + // Re-test the timeout error with retries disabled + ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond) + defer cancelFunc2() + _, _, operationErr = vpcService.ListBareMetalServerDisksWithContext(ctx, listBareMetalServerDisksOptionsModel) + 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() - // Construct an instance of the RegionIdentityByName model - regionIdentityModel := new(vpcv1.RegionIdentityByName) - regionIdentityModel.Name = core.StringPtr("us-south") + // Verify the contents of the request + Expect(req.URL.EscapedPath()).To(Equal(listBareMetalServerDisksPath)) + Expect(req.Method).To(Equal("GET")) - // Construct an instance of the BackupPolicyPlanRemoteRegionPolicyPrototype model - backupPolicyPlanRemoteRegionPolicyPrototypeModel := new(vpcv1.BackupPolicyPlanRemoteRegionPolicyPrototype) - backupPolicyPlanRemoteRegionPolicyPrototypeModel.DeleteOverCount = core.Int64Ptr(int64(5)) - backupPolicyPlanRemoteRegionPolicyPrototypeModel.EncryptionKey = encryptionKeyIdentityModel - backupPolicyPlanRemoteRegionPolicyPrototypeModel.Region = regionIdentityModel + 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", `{"disks": [{"created_at": "2019-01-01T12:00:00.000Z", "href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/1e09281b-f177-46fb-baf1-bc152b2e391a/disks/10c02d81-0ecb-4dc5-897d-28392913b81e", "id": "10c02d81-0ecb-4dc5-897d-28392913b81e", "interface_type": "fcp", "name": "my-bare-metal-server-disk", "resource_type": "bare_metal_server_disk", "size": 100}]}`) + })) + }) + It(`Invoke ListBareMetalServerDisks 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 BackupPolicyPlanPatch model - backupPolicyPlanPatchModel := new(vpcv1.BackupPolicyPlanPatch) - backupPolicyPlanPatchModel.Active = core.BoolPtr(true) - backupPolicyPlanPatchModel.AttachUserTags = []string{"my-daily-backup-plan"} - backupPolicyPlanPatchModel.ClonePolicy = backupPolicyPlanClonePolicyPatchModel - backupPolicyPlanPatchModel.CopyUserTags = core.BoolPtr(true) - backupPolicyPlanPatchModel.CronSpec = core.StringPtr("30 */2 * * 1-5") - backupPolicyPlanPatchModel.DeletionTrigger = backupPolicyPlanDeletionTriggerPatchModel - backupPolicyPlanPatchModel.Name = core.StringPtr("my-policy-plan") - backupPolicyPlanPatchModel.RemoteRegionPolicies = []vpcv1.BackupPolicyPlanRemoteRegionPolicyPrototype{*backupPolicyPlanRemoteRegionPolicyPrototypeModel} - backupPolicyPlanPatchModelAsPatch, asPatchErr := backupPolicyPlanPatchModel.AsPatch() - Expect(asPatchErr).To(BeNil()) + // Invoke operation with nil options model (negative test) + result, response, operationErr := vpcService.ListBareMetalServerDisks(nil) + Expect(operationErr).NotTo(BeNil()) + Expect(response).To(BeNil()) + Expect(result).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"} + // Construct an instance of the ListBareMetalServerDisksOptions model + listBareMetalServerDisksOptionsModel := new(vpcv1.ListBareMetalServerDisksOptions) + listBareMetalServerDisksOptionsModel.BareMetalServerID = core.StringPtr("testString") + listBareMetalServerDisksOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation with valid options model (positive test) + result, response, operationErr = vpcService.ListBareMetalServerDisks(listBareMetalServerDisksOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).ToNot(BeNil()) + + }) + It(`Invoke ListBareMetalServerDisks 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 ListBareMetalServerDisksOptions model + listBareMetalServerDisksOptionsModel := new(vpcv1.ListBareMetalServerDisksOptions) + listBareMetalServerDisksOptionsModel.BareMetalServerID = core.StringPtr("testString") + listBareMetalServerDisksOptionsModel.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.ListBareMetalServerDisks(listBareMetalServerDisksOptionsModel) + 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 ListBareMetalServerDisksOptions model with no property values + listBareMetalServerDisksOptionsModelNew := new(vpcv1.ListBareMetalServerDisksOptions) + // Invoke operation with invalid model (negative test) + result, response, operationErr = vpcService.ListBareMetalServerDisks(listBareMetalServerDisksOptionsModelNew) + 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 ListBareMetalServerDisks 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 ListBareMetalServerDisksOptions model + listBareMetalServerDisksOptionsModel := new(vpcv1.ListBareMetalServerDisksOptions) + listBareMetalServerDisksOptionsModel.BareMetalServerID = core.StringPtr("testString") + listBareMetalServerDisksOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation + result, response, operationErr := vpcService.ListBareMetalServerDisks(listBareMetalServerDisksOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + + // Verify a nil result + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + }) + Describe(`GetBareMetalServerDisk(getBareMetalServerDiskOptions *GetBareMetalServerDiskOptions) - Operation response error`, func() { + version := "testString" + getBareMetalServerDiskPath := "/bare_metal_servers/testString/disks/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(getBareMetalServerDiskPath)) + 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 GetBareMetalServerDisk 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 GetBareMetalServerDiskOptions model + getBareMetalServerDiskOptionsModel := new(vpcv1.GetBareMetalServerDiskOptions) + getBareMetalServerDiskOptionsModel.BareMetalServerID = core.StringPtr("testString") + getBareMetalServerDiskOptionsModel.ID = core.StringPtr("testString") + getBareMetalServerDiskOptionsModel.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.GetBareMetalServerDisk(getBareMetalServerDiskOptionsModel) + 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.GetBareMetalServerDisk(getBareMetalServerDiskOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + }) + Describe(`GetBareMetalServerDisk(getBareMetalServerDiskOptions *GetBareMetalServerDiskOptions)`, func() { + version := "testString" + getBareMetalServerDiskPath := "/bare_metal_servers/testString/disks/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(getBareMetalServerDiskPath)) + 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", "href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/1e09281b-f177-46fb-baf1-bc152b2e391a/disks/10c02d81-0ecb-4dc5-897d-28392913b81e", "id": "10c02d81-0ecb-4dc5-897d-28392913b81e", "interface_type": "fcp", "name": "my-bare-metal-server-disk", "resource_type": "bare_metal_server_disk", "size": 100}`) + })) + }) + It(`Invoke GetBareMetalServerDisk 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 GetBareMetalServerDiskOptions model + getBareMetalServerDiskOptionsModel := new(vpcv1.GetBareMetalServerDiskOptions) + getBareMetalServerDiskOptionsModel.BareMetalServerID = core.StringPtr("testString") + getBareMetalServerDiskOptionsModel.ID = core.StringPtr("testString") + getBareMetalServerDiskOptionsModel.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) + _, _, operationErr := vpcService.GetBareMetalServerDiskWithContext(ctx, getBareMetalServerDiskOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) // Disable retries and test again vpcService.DisableRetries() - result, response, operationErr := vpcService.UpdateBackupPolicyPlan(updateBackupPolicyPlanOptionsModel) + result, response, operationErr := vpcService.GetBareMetalServerDisk(getBareMetalServerDiskOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) @@ -43554,7 +44132,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.UpdateBackupPolicyPlanWithContext(ctx, updateBackupPolicyPlanOptionsModel) + _, _, operationErr = vpcService.GetBareMetalServerDiskWithContext(ctx, getBareMetalServerDiskOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) }) @@ -43568,36 +44146,18 @@ var _ = Describe(`VpcV1`, func() { 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.URL.EscapedPath()).To(Equal(getBareMetalServerDiskPath)) + Expect(req.Method).To(Equal("GET")) - 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"], "clone_policy": {"max_snapshots": 1, "zones": [{"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south/zones/us-south-1", "name": "us-south-1"}]}, "copy_user_tags": true, "created_at": "2019-01-01T12:00:00.000Z", "cron_spec": "30 */2 * * 1-5", "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", "remote_region_policies": [{"delete_over_count": 1, "encryption_key": {"crn": "crn:v1:bluemix:public:kms:us-south:a/123456:e4a29d1a-2ef0-42a6-8fd2-350deb1c647e:key:5437653b-c4b1-447f-9646-b2a2a4cd6179"}, "region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}], "resource_type": "backup_policy_plan"}`) + fmt.Fprintf(res, "%s", `{"created_at": "2019-01-01T12:00:00.000Z", "href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/1e09281b-f177-46fb-baf1-bc152b2e391a/disks/10c02d81-0ecb-4dc5-897d-28392913b81e", "id": "10c02d81-0ecb-4dc5-897d-28392913b81e", "interface_type": "fcp", "name": "my-bare-metal-server-disk", "resource_type": "bare_metal_server_disk", "size": 100}`) })) }) - It(`Invoke UpdateBackupPolicyPlan successfully`, func() { + It(`Invoke GetBareMetalServerDisk successfully`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -43607,68 +44167,25 @@ var _ = Describe(`VpcV1`, func() { Expect(vpcService).ToNot(BeNil()) // Invoke operation with nil options model (negative test) - result, response, operationErr := vpcService.UpdateBackupPolicyPlan(nil) + result, response, operationErr := vpcService.GetBareMetalServerDisk(nil) Expect(operationErr).NotTo(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) - // Construct an instance of the ZoneIdentityByName model - zoneIdentityModel := new(vpcv1.ZoneIdentityByName) - zoneIdentityModel.Name = core.StringPtr("us-south-1") - - // Construct an instance of the BackupPolicyPlanClonePolicyPatch model - backupPolicyPlanClonePolicyPatchModel := new(vpcv1.BackupPolicyPlanClonePolicyPatch) - backupPolicyPlanClonePolicyPatchModel.MaxSnapshots = core.Int64Ptr(int64(1)) - backupPolicyPlanClonePolicyPatchModel.Zones = []vpcv1.ZoneIdentityIntf{zoneIdentityModel} - - // Construct an instance of the BackupPolicyPlanDeletionTriggerPatch model - backupPolicyPlanDeletionTriggerPatchModel := new(vpcv1.BackupPolicyPlanDeletionTriggerPatch) - backupPolicyPlanDeletionTriggerPatchModel.DeleteAfter = core.Int64Ptr(int64(20)) - backupPolicyPlanDeletionTriggerPatchModel.DeleteOverCount = core.Int64Ptr(int64(1)) - - // Construct an instance of the EncryptionKeyIdentityByCRN model - encryptionKeyIdentityModel := new(vpcv1.EncryptionKeyIdentityByCRN) - encryptionKeyIdentityModel.CRN = core.StringPtr("crn:v1:bluemix:public:kms:us-south:a/123456:e4a29d1a-2ef0-42a6-8fd2-350deb1c647e:key:5437653b-c4b1-447f-9646-b2a2a4cd6179") - - // Construct an instance of the RegionIdentityByName model - regionIdentityModel := new(vpcv1.RegionIdentityByName) - regionIdentityModel.Name = core.StringPtr("us-south") - - // Construct an instance of the BackupPolicyPlanRemoteRegionPolicyPrototype model - backupPolicyPlanRemoteRegionPolicyPrototypeModel := new(vpcv1.BackupPolicyPlanRemoteRegionPolicyPrototype) - backupPolicyPlanRemoteRegionPolicyPrototypeModel.DeleteOverCount = core.Int64Ptr(int64(5)) - backupPolicyPlanRemoteRegionPolicyPrototypeModel.EncryptionKey = encryptionKeyIdentityModel - backupPolicyPlanRemoteRegionPolicyPrototypeModel.Region = regionIdentityModel - - // Construct an instance of the BackupPolicyPlanPatch model - backupPolicyPlanPatchModel := new(vpcv1.BackupPolicyPlanPatch) - backupPolicyPlanPatchModel.Active = core.BoolPtr(true) - backupPolicyPlanPatchModel.AttachUserTags = []string{"my-daily-backup-plan"} - backupPolicyPlanPatchModel.ClonePolicy = backupPolicyPlanClonePolicyPatchModel - backupPolicyPlanPatchModel.CopyUserTags = core.BoolPtr(true) - backupPolicyPlanPatchModel.CronSpec = core.StringPtr("30 */2 * * 1-5") - backupPolicyPlanPatchModel.DeletionTrigger = backupPolicyPlanDeletionTriggerPatchModel - backupPolicyPlanPatchModel.Name = core.StringPtr("my-policy-plan") - backupPolicyPlanPatchModel.RemoteRegionPolicies = []vpcv1.BackupPolicyPlanRemoteRegionPolicyPrototype{*backupPolicyPlanRemoteRegionPolicyPrototypeModel} - 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"} + // Construct an instance of the GetBareMetalServerDiskOptions model + getBareMetalServerDiskOptionsModel := new(vpcv1.GetBareMetalServerDiskOptions) + getBareMetalServerDiskOptionsModel.BareMetalServerID = core.StringPtr("testString") + getBareMetalServerDiskOptionsModel.ID = core.StringPtr("testString") + getBareMetalServerDiskOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with valid options model (positive test) - result, response, operationErr = vpcService.UpdateBackupPolicyPlan(updateBackupPolicyPlanOptionsModel) + result, response, operationErr = vpcService.GetBareMetalServerDisk(getBareMetalServerDiskOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) }) - It(`Invoke UpdateBackupPolicyPlan with error: Operation validation and request error`, func() { + It(`Invoke GetBareMetalServerDisk with error: Operation validation and request error`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -43677,66 +44194,23 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the ZoneIdentityByName model - zoneIdentityModel := new(vpcv1.ZoneIdentityByName) - zoneIdentityModel.Name = core.StringPtr("us-south-1") - - // Construct an instance of the BackupPolicyPlanClonePolicyPatch model - backupPolicyPlanClonePolicyPatchModel := new(vpcv1.BackupPolicyPlanClonePolicyPatch) - backupPolicyPlanClonePolicyPatchModel.MaxSnapshots = core.Int64Ptr(int64(1)) - backupPolicyPlanClonePolicyPatchModel.Zones = []vpcv1.ZoneIdentityIntf{zoneIdentityModel} - - // Construct an instance of the BackupPolicyPlanDeletionTriggerPatch model - backupPolicyPlanDeletionTriggerPatchModel := new(vpcv1.BackupPolicyPlanDeletionTriggerPatch) - backupPolicyPlanDeletionTriggerPatchModel.DeleteAfter = core.Int64Ptr(int64(20)) - backupPolicyPlanDeletionTriggerPatchModel.DeleteOverCount = core.Int64Ptr(int64(1)) - - // Construct an instance of the EncryptionKeyIdentityByCRN model - encryptionKeyIdentityModel := new(vpcv1.EncryptionKeyIdentityByCRN) - encryptionKeyIdentityModel.CRN = core.StringPtr("crn:v1:bluemix:public:kms:us-south:a/123456:e4a29d1a-2ef0-42a6-8fd2-350deb1c647e:key:5437653b-c4b1-447f-9646-b2a2a4cd6179") - - // Construct an instance of the RegionIdentityByName model - regionIdentityModel := new(vpcv1.RegionIdentityByName) - regionIdentityModel.Name = core.StringPtr("us-south") - - // Construct an instance of the BackupPolicyPlanRemoteRegionPolicyPrototype model - backupPolicyPlanRemoteRegionPolicyPrototypeModel := new(vpcv1.BackupPolicyPlanRemoteRegionPolicyPrototype) - backupPolicyPlanRemoteRegionPolicyPrototypeModel.DeleteOverCount = core.Int64Ptr(int64(5)) - backupPolicyPlanRemoteRegionPolicyPrototypeModel.EncryptionKey = encryptionKeyIdentityModel - backupPolicyPlanRemoteRegionPolicyPrototypeModel.Region = regionIdentityModel - - // Construct an instance of the BackupPolicyPlanPatch model - backupPolicyPlanPatchModel := new(vpcv1.BackupPolicyPlanPatch) - backupPolicyPlanPatchModel.Active = core.BoolPtr(true) - backupPolicyPlanPatchModel.AttachUserTags = []string{"my-daily-backup-plan"} - backupPolicyPlanPatchModel.ClonePolicy = backupPolicyPlanClonePolicyPatchModel - backupPolicyPlanPatchModel.CopyUserTags = core.BoolPtr(true) - backupPolicyPlanPatchModel.CronSpec = core.StringPtr("30 */2 * * 1-5") - backupPolicyPlanPatchModel.DeletionTrigger = backupPolicyPlanDeletionTriggerPatchModel - backupPolicyPlanPatchModel.Name = core.StringPtr("my-policy-plan") - backupPolicyPlanPatchModel.RemoteRegionPolicies = []vpcv1.BackupPolicyPlanRemoteRegionPolicyPrototype{*backupPolicyPlanRemoteRegionPolicyPrototypeModel} - 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"} + // Construct an instance of the GetBareMetalServerDiskOptions model + getBareMetalServerDiskOptionsModel := new(vpcv1.GetBareMetalServerDiskOptions) + getBareMetalServerDiskOptionsModel.BareMetalServerID = core.StringPtr("testString") + getBareMetalServerDiskOptionsModel.ID = core.StringPtr("testString") + getBareMetalServerDiskOptionsModel.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) + result, response, operationErr := vpcService.GetBareMetalServerDisk(getBareMetalServerDiskOptionsModel) 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) + // Construct a second instance of the GetBareMetalServerDiskOptions model with no property values + getBareMetalServerDiskOptionsModelNew := new(vpcv1.GetBareMetalServerDiskOptions) // Invoke operation with invalid model (negative test) - result, response, operationErr = vpcService.UpdateBackupPolicyPlan(updateBackupPolicyPlanOptionsModelNew) + result, response, operationErr = vpcService.GetBareMetalServerDisk(getBareMetalServerDiskOptionsModelNew) Expect(operationErr).ToNot(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) @@ -43754,7 +44228,7 @@ var _ = Describe(`VpcV1`, func() { res.WriteHeader(200) })) }) - It(`Invoke UpdateBackupPolicyPlan successfully`, func() { + It(`Invoke GetBareMetalServerDisk successfully`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -43763,57 +44237,14 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the ZoneIdentityByName model - zoneIdentityModel := new(vpcv1.ZoneIdentityByName) - zoneIdentityModel.Name = core.StringPtr("us-south-1") - - // Construct an instance of the BackupPolicyPlanClonePolicyPatch model - backupPolicyPlanClonePolicyPatchModel := new(vpcv1.BackupPolicyPlanClonePolicyPatch) - backupPolicyPlanClonePolicyPatchModel.MaxSnapshots = core.Int64Ptr(int64(1)) - backupPolicyPlanClonePolicyPatchModel.Zones = []vpcv1.ZoneIdentityIntf{zoneIdentityModel} - - // Construct an instance of the BackupPolicyPlanDeletionTriggerPatch model - backupPolicyPlanDeletionTriggerPatchModel := new(vpcv1.BackupPolicyPlanDeletionTriggerPatch) - backupPolicyPlanDeletionTriggerPatchModel.DeleteAfter = core.Int64Ptr(int64(20)) - backupPolicyPlanDeletionTriggerPatchModel.DeleteOverCount = core.Int64Ptr(int64(1)) - - // Construct an instance of the EncryptionKeyIdentityByCRN model - encryptionKeyIdentityModel := new(vpcv1.EncryptionKeyIdentityByCRN) - encryptionKeyIdentityModel.CRN = core.StringPtr("crn:v1:bluemix:public:kms:us-south:a/123456:e4a29d1a-2ef0-42a6-8fd2-350deb1c647e:key:5437653b-c4b1-447f-9646-b2a2a4cd6179") - - // Construct an instance of the RegionIdentityByName model - regionIdentityModel := new(vpcv1.RegionIdentityByName) - regionIdentityModel.Name = core.StringPtr("us-south") - - // Construct an instance of the BackupPolicyPlanRemoteRegionPolicyPrototype model - backupPolicyPlanRemoteRegionPolicyPrototypeModel := new(vpcv1.BackupPolicyPlanRemoteRegionPolicyPrototype) - backupPolicyPlanRemoteRegionPolicyPrototypeModel.DeleteOverCount = core.Int64Ptr(int64(5)) - backupPolicyPlanRemoteRegionPolicyPrototypeModel.EncryptionKey = encryptionKeyIdentityModel - backupPolicyPlanRemoteRegionPolicyPrototypeModel.Region = regionIdentityModel - - // Construct an instance of the BackupPolicyPlanPatch model - backupPolicyPlanPatchModel := new(vpcv1.BackupPolicyPlanPatch) - backupPolicyPlanPatchModel.Active = core.BoolPtr(true) - backupPolicyPlanPatchModel.AttachUserTags = []string{"my-daily-backup-plan"} - backupPolicyPlanPatchModel.ClonePolicy = backupPolicyPlanClonePolicyPatchModel - backupPolicyPlanPatchModel.CopyUserTags = core.BoolPtr(true) - backupPolicyPlanPatchModel.CronSpec = core.StringPtr("30 */2 * * 1-5") - backupPolicyPlanPatchModel.DeletionTrigger = backupPolicyPlanDeletionTriggerPatchModel - backupPolicyPlanPatchModel.Name = core.StringPtr("my-policy-plan") - backupPolicyPlanPatchModel.RemoteRegionPolicies = []vpcv1.BackupPolicyPlanRemoteRegionPolicyPrototype{*backupPolicyPlanRemoteRegionPolicyPrototypeModel} - 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"} + // Construct an instance of the GetBareMetalServerDiskOptions model + getBareMetalServerDiskOptionsModel := new(vpcv1.GetBareMetalServerDiskOptions) + getBareMetalServerDiskOptionsModel.BareMetalServerID = core.StringPtr("testString") + getBareMetalServerDiskOptionsModel.ID = core.StringPtr("testString") + getBareMetalServerDiskOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation - result, response, operationErr := vpcService.UpdateBackupPolicyPlan(updateBackupPolicyPlanOptionsModel) + result, response, operationErr := vpcService.GetBareMetalServerDisk(getBareMetalServerDiskOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) @@ -43825,27 +44256,25 @@ var _ = Describe(`VpcV1`, func() { }) }) }) - Describe(`DeleteBackupPolicy(deleteBackupPolicyOptions *DeleteBackupPolicyOptions) - Operation response error`, func() { + Describe(`UpdateBareMetalServerDisk(updateBareMetalServerDiskOptions *UpdateBareMetalServerDiskOptions) - Operation response error`, func() { version := "testString" - deleteBackupPolicyPath := "/backup_policies/testString" + updateBareMetalServerDiskPath := "/bare_metal_servers/testString/disks/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.EscapedPath()).To(Equal(updateBareMetalServerDiskPath)) + 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(202) + res.WriteHeader(200) fmt.Fprint(res, `} this is not valid json {`) })) }) - It(`Invoke DeleteBackupPolicy with error: Operation response processing error`, func() { + It(`Invoke UpdateBareMetalServerDisk with error: Operation response processing error`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -43854,20 +44283,27 @@ var _ = Describe(`VpcV1`, func() { 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"} + // Construct an instance of the BareMetalServerDiskPatch model + bareMetalServerDiskPatchModel := new(vpcv1.BareMetalServerDiskPatch) + bareMetalServerDiskPatchModel.Name = core.StringPtr("my-bare-metal-server-disk-updated") + bareMetalServerDiskPatchModelAsPatch, asPatchErr := bareMetalServerDiskPatchModel.AsPatch() + Expect(asPatchErr).To(BeNil()) + + // Construct an instance of the UpdateBareMetalServerDiskOptions model + updateBareMetalServerDiskOptionsModel := new(vpcv1.UpdateBareMetalServerDiskOptions) + updateBareMetalServerDiskOptionsModel.BareMetalServerID = core.StringPtr("testString") + updateBareMetalServerDiskOptionsModel.ID = core.StringPtr("testString") + updateBareMetalServerDiskOptionsModel.BareMetalServerDiskPatch = bareMetalServerDiskPatchModelAsPatch + updateBareMetalServerDiskOptionsModel.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) + result, response, operationErr := vpcService.UpdateBareMetalServerDisk(updateBareMetalServerDiskOptionsModel) 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) + result, response, operationErr = vpcService.UpdateBareMetalServerDisk(updateBareMetalServerDiskOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).To(BeNil()) @@ -43877,20 +44313,34 @@ var _ = Describe(`VpcV1`, func() { }) }) }) - Describe(`DeleteBackupPolicy(deleteBackupPolicyOptions *DeleteBackupPolicyOptions)`, func() { + Describe(`UpdateBareMetalServerDisk(updateBareMetalServerDiskOptions *UpdateBareMetalServerDiskOptions)`, func() { version := "testString" - deleteBackupPolicyPath := "/backup_policies/testString" + updateBareMetalServerDiskPath := "/bare_metal_servers/testString/disks/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.URL.EscapedPath()).To(Equal(updateBareMetalServerDiskPath)) + 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 @@ -43898,11 +44348,11 @@ var _ = Describe(`VpcV1`, func() { // Set mock response res.Header().Set("Content-type", "application/json") - res.WriteHeader(202) - fmt.Fprintf(res, "%s", `{"created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south:a/123456::backup-policy:r134-076191ba-49c2-4763-94fd-c70de73ee2e6", "health_reasons": [{"code": "missing_service_authorization_policies", "message": "One or more accounts are missing service authorization policies", "more_info": "https://cloud.ibm.com/docs/vpc?topic=vpc-backup-service-about&interface=ui"}], "health_state": "ok", "href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6", "id": "r134-076191ba-49c2-4763-94fd-c70de73ee2e6", "last_job_completed_at": "2019-01-01T12:00:00.000Z", "lifecycle_state": "stable", "match_user_tags": ["MatchUserTags"], "name": "my-backup-policy", "plans": [{"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6/plans/r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "id": "r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "name": "my-policy-plan", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "backup_policy_plan"}], "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "resource_type": "backup_policy", "scope": {"crn": "crn:v1:bluemix:public:enterprise::a/123456::enterprise:ebc2b430240943458b9e91e1432cfcce", "id": "fee82deba12e4c0fb69c3b09d1f12345", "resource_type": "enterprise"}, "included_content": ["data_volumes"], "match_resource_type": "instance"}`) + res.WriteHeader(200) + fmt.Fprintf(res, "%s", `{"created_at": "2019-01-01T12:00:00.000Z", "href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/1e09281b-f177-46fb-baf1-bc152b2e391a/disks/10c02d81-0ecb-4dc5-897d-28392913b81e", "id": "10c02d81-0ecb-4dc5-897d-28392913b81e", "interface_type": "fcp", "name": "my-bare-metal-server-disk", "resource_type": "bare_metal_server_disk", "size": 100}`) })) }) - It(`Invoke DeleteBackupPolicy successfully with retries`, func() { + It(`Invoke UpdateBareMetalServerDisk successfully with retries`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -43912,22 +44362,29 @@ var _ = Describe(`VpcV1`, func() { 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"} + // Construct an instance of the BareMetalServerDiskPatch model + bareMetalServerDiskPatchModel := new(vpcv1.BareMetalServerDiskPatch) + bareMetalServerDiskPatchModel.Name = core.StringPtr("my-bare-metal-server-disk-updated") + bareMetalServerDiskPatchModelAsPatch, asPatchErr := bareMetalServerDiskPatchModel.AsPatch() + Expect(asPatchErr).To(BeNil()) + + // Construct an instance of the UpdateBareMetalServerDiskOptions model + updateBareMetalServerDiskOptionsModel := new(vpcv1.UpdateBareMetalServerDiskOptions) + updateBareMetalServerDiskOptionsModel.BareMetalServerID = core.StringPtr("testString") + updateBareMetalServerDiskOptionsModel.ID = core.StringPtr("testString") + updateBareMetalServerDiskOptionsModel.BareMetalServerDiskPatch = bareMetalServerDiskPatchModelAsPatch + updateBareMetalServerDiskOptionsModel.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) + _, _, operationErr := vpcService.UpdateBareMetalServerDiskWithContext(ctx, updateBareMetalServerDiskOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) // Disable retries and test again vpcService.DisableRetries() - result, response, operationErr := vpcService.DeleteBackupPolicy(deleteBackupPolicyOptionsModel) + result, response, operationErr := vpcService.UpdateBareMetalServerDisk(updateBareMetalServerDiskOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) @@ -43935,7 +44392,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.DeleteBackupPolicyWithContext(ctx, deleteBackupPolicyOptionsModel) + _, _, operationErr = vpcService.UpdateBareMetalServerDiskWithContext(ctx, updateBareMetalServerDiskOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) }) @@ -43949,20 +44406,34 @@ var _ = Describe(`VpcV1`, func() { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(deleteBackupPolicyPath)) - Expect(req.Method).To(Equal("DELETE")) + Expect(req.URL.EscapedPath()).To(Equal(updateBareMetalServerDiskPath)) + 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(202) - fmt.Fprintf(res, "%s", `{"created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south:a/123456::backup-policy:r134-076191ba-49c2-4763-94fd-c70de73ee2e6", "health_reasons": [{"code": "missing_service_authorization_policies", "message": "One or more accounts are missing service authorization policies", "more_info": "https://cloud.ibm.com/docs/vpc?topic=vpc-backup-service-about&interface=ui"}], "health_state": "ok", "href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6", "id": "r134-076191ba-49c2-4763-94fd-c70de73ee2e6", "last_job_completed_at": "2019-01-01T12:00:00.000Z", "lifecycle_state": "stable", "match_user_tags": ["MatchUserTags"], "name": "my-backup-policy", "plans": [{"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6/plans/r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "id": "r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "name": "my-policy-plan", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "backup_policy_plan"}], "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "resource_type": "backup_policy", "scope": {"crn": "crn:v1:bluemix:public:enterprise::a/123456::enterprise:ebc2b430240943458b9e91e1432cfcce", "id": "fee82deba12e4c0fb69c3b09d1f12345", "resource_type": "enterprise"}, "included_content": ["data_volumes"], "match_resource_type": "instance"}`) + res.WriteHeader(200) + fmt.Fprintf(res, "%s", `{"created_at": "2019-01-01T12:00:00.000Z", "href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/1e09281b-f177-46fb-baf1-bc152b2e391a/disks/10c02d81-0ecb-4dc5-897d-28392913b81e", "id": "10c02d81-0ecb-4dc5-897d-28392913b81e", "interface_type": "fcp", "name": "my-bare-metal-server-disk", "resource_type": "bare_metal_server_disk", "size": 100}`) })) }) - It(`Invoke DeleteBackupPolicy successfully`, func() { + It(`Invoke UpdateBareMetalServerDisk successfully`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -43972,25 +44443,32 @@ var _ = Describe(`VpcV1`, func() { Expect(vpcService).ToNot(BeNil()) // Invoke operation with nil options model (negative test) - result, response, operationErr := vpcService.DeleteBackupPolicy(nil) + result, response, operationErr := vpcService.UpdateBareMetalServerDisk(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"} + // Construct an instance of the BareMetalServerDiskPatch model + bareMetalServerDiskPatchModel := new(vpcv1.BareMetalServerDiskPatch) + bareMetalServerDiskPatchModel.Name = core.StringPtr("my-bare-metal-server-disk-updated") + bareMetalServerDiskPatchModelAsPatch, asPatchErr := bareMetalServerDiskPatchModel.AsPatch() + Expect(asPatchErr).To(BeNil()) + + // Construct an instance of the UpdateBareMetalServerDiskOptions model + updateBareMetalServerDiskOptionsModel := new(vpcv1.UpdateBareMetalServerDiskOptions) + updateBareMetalServerDiskOptionsModel.BareMetalServerID = core.StringPtr("testString") + updateBareMetalServerDiskOptionsModel.ID = core.StringPtr("testString") + updateBareMetalServerDiskOptionsModel.BareMetalServerDiskPatch = bareMetalServerDiskPatchModelAsPatch + updateBareMetalServerDiskOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with valid options model (positive test) - result, response, operationErr = vpcService.DeleteBackupPolicy(deleteBackupPolicyOptionsModel) + result, response, operationErr = vpcService.UpdateBareMetalServerDisk(updateBareMetalServerDiskOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) }) - It(`Invoke DeleteBackupPolicy with error: Operation validation and request error`, func() { + It(`Invoke UpdateBareMetalServerDisk with error: Operation validation and request error`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -43999,23 +44477,30 @@ var _ = Describe(`VpcV1`, func() { 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"} + // Construct an instance of the BareMetalServerDiskPatch model + bareMetalServerDiskPatchModel := new(vpcv1.BareMetalServerDiskPatch) + bareMetalServerDiskPatchModel.Name = core.StringPtr("my-bare-metal-server-disk-updated") + bareMetalServerDiskPatchModelAsPatch, asPatchErr := bareMetalServerDiskPatchModel.AsPatch() + Expect(asPatchErr).To(BeNil()) + + // Construct an instance of the UpdateBareMetalServerDiskOptions model + updateBareMetalServerDiskOptionsModel := new(vpcv1.UpdateBareMetalServerDiskOptions) + updateBareMetalServerDiskOptionsModel.BareMetalServerID = core.StringPtr("testString") + updateBareMetalServerDiskOptionsModel.ID = core.StringPtr("testString") + updateBareMetalServerDiskOptionsModel.BareMetalServerDiskPatch = bareMetalServerDiskPatchModelAsPatch + updateBareMetalServerDiskOptionsModel.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) + result, response, operationErr := vpcService.UpdateBareMetalServerDisk(updateBareMetalServerDiskOptionsModel) 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) + // Construct a second instance of the UpdateBareMetalServerDiskOptions model with no property values + updateBareMetalServerDiskOptionsModelNew := new(vpcv1.UpdateBareMetalServerDiskOptions) // Invoke operation with invalid model (negative test) - result, response, operationErr = vpcService.DeleteBackupPolicy(deleteBackupPolicyOptionsModelNew) + result, response, operationErr = vpcService.UpdateBareMetalServerDisk(updateBareMetalServerDiskOptionsModelNew) Expect(operationErr).ToNot(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) @@ -44030,10 +44515,10 @@ var _ = Describe(`VpcV1`, func() { defer GinkgoRecover() // Set success status code with no respoonse body - res.WriteHeader(202) + res.WriteHeader(200) })) }) - It(`Invoke DeleteBackupPolicy successfully`, func() { + It(`Invoke UpdateBareMetalServerDisk successfully`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -44042,14 +44527,21 @@ var _ = Describe(`VpcV1`, func() { 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"} + // Construct an instance of the BareMetalServerDiskPatch model + bareMetalServerDiskPatchModel := new(vpcv1.BareMetalServerDiskPatch) + bareMetalServerDiskPatchModel.Name = core.StringPtr("my-bare-metal-server-disk-updated") + bareMetalServerDiskPatchModelAsPatch, asPatchErr := bareMetalServerDiskPatchModel.AsPatch() + Expect(asPatchErr).To(BeNil()) + + // Construct an instance of the UpdateBareMetalServerDiskOptions model + updateBareMetalServerDiskOptionsModel := new(vpcv1.UpdateBareMetalServerDiskOptions) + updateBareMetalServerDiskOptionsModel.BareMetalServerID = core.StringPtr("testString") + updateBareMetalServerDiskOptionsModel.ID = core.StringPtr("testString") + updateBareMetalServerDiskOptionsModel.BareMetalServerDiskPatch = bareMetalServerDiskPatchModelAsPatch + updateBareMetalServerDiskOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation - result, response, operationErr := vpcService.DeleteBackupPolicy(deleteBackupPolicyOptionsModel) + result, response, operationErr := vpcService.UpdateBareMetalServerDisk(updateBareMetalServerDiskOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) @@ -44061,25 +44553,27 @@ var _ = Describe(`VpcV1`, func() { }) }) }) - Describe(`GetBackupPolicy(getBackupPolicyOptions *GetBackupPolicyOptions) - Operation response error`, func() { + Describe(`ListBareMetalServerNetworkAttachments(listBareMetalServerNetworkAttachmentsOptions *ListBareMetalServerNetworkAttachmentsOptions) - Operation response error`, func() { version := "testString" - getBackupPolicyPath := "/backup_policies/testString" + listBareMetalServerNetworkAttachmentsPath := "/bare_metal_servers/testString/network_attachments" 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.URL.EscapedPath()).To(Equal(listBareMetalServerNetworkAttachmentsPath)) Expect(req.Method).To(Equal("GET")) Expect(req.URL.Query()["version"]).To(Equal([]string{"testString"})) Expect(req.URL.Query()["generation"]).To(Equal([]string{fmt.Sprint(int64(2))})) + Expect(req.URL.Query()["start"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["limit"]).To(Equal([]string{fmt.Sprint(int64(10))})) 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() { + It(`Invoke ListBareMetalServerNetworkAttachments with error: Operation response processing error`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -44088,19 +44582,21 @@ var _ = Describe(`VpcV1`, func() { 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"} + // Construct an instance of the ListBareMetalServerNetworkAttachmentsOptions model + listBareMetalServerNetworkAttachmentsOptionsModel := new(vpcv1.ListBareMetalServerNetworkAttachmentsOptions) + listBareMetalServerNetworkAttachmentsOptionsModel.BareMetalServerID = core.StringPtr("testString") + listBareMetalServerNetworkAttachmentsOptionsModel.Start = core.StringPtr("testString") + listBareMetalServerNetworkAttachmentsOptionsModel.Limit = core.Int64Ptr(int64(10)) + listBareMetalServerNetworkAttachmentsOptionsModel.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) + result, response, operationErr := vpcService.ListBareMetalServerNetworkAttachments(listBareMetalServerNetworkAttachmentsOptionsModel) 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) + result, response, operationErr = vpcService.ListBareMetalServerNetworkAttachments(listBareMetalServerNetworkAttachmentsOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).To(BeNil()) @@ -44110,30 +44606,32 @@ var _ = Describe(`VpcV1`, func() { }) }) }) - Describe(`GetBackupPolicy(getBackupPolicyOptions *GetBackupPolicyOptions)`, func() { + Describe(`ListBareMetalServerNetworkAttachments(listBareMetalServerNetworkAttachmentsOptions *ListBareMetalServerNetworkAttachmentsOptions)`, func() { version := "testString" - getBackupPolicyPath := "/backup_policies/testString" + listBareMetalServerNetworkAttachmentsPath := "/bare_metal_servers/testString/network_attachments" 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.URL.EscapedPath()).To(Equal(listBareMetalServerNetworkAttachmentsPath)) Expect(req.Method).To(Equal("GET")) Expect(req.URL.Query()["version"]).To(Equal([]string{"testString"})) Expect(req.URL.Query()["generation"]).To(Equal([]string{fmt.Sprint(int64(2))})) + Expect(req.URL.Query()["start"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["limit"]).To(Equal([]string{fmt.Sprint(int64(10))})) // 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", "health_reasons": [{"code": "missing_service_authorization_policies", "message": "One or more accounts are missing service authorization policies", "more_info": "https://cloud.ibm.com/docs/vpc?topic=vpc-backup-service-about&interface=ui"}], "health_state": "ok", "href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6", "id": "r134-076191ba-49c2-4763-94fd-c70de73ee2e6", "last_job_completed_at": "2019-01-01T12:00:00.000Z", "lifecycle_state": "stable", "match_user_tags": ["MatchUserTags"], "name": "my-backup-policy", "plans": [{"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6/plans/r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "id": "r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "name": "my-policy-plan", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "backup_policy_plan"}], "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "resource_type": "backup_policy", "scope": {"crn": "crn:v1:bluemix:public:enterprise::a/123456::enterprise:ebc2b430240943458b9e91e1432cfcce", "id": "fee82deba12e4c0fb69c3b09d1f12345", "resource_type": "enterprise"}, "included_content": ["data_volumes"], "match_resource_type": "instance"}`) + fmt.Fprintf(res, "%s", `{"first": {"href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/3b2669a2-4c2b-4003-bc91-1b81f1326267/network_attachments?limit=20"}, "limit": 20, "network_attachments": [{"created_at": "2019-01-01T12:00:00.000Z", "href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/2302-f7a2bf57-af7c-49d9-b599-b2c91293d30c/network_attachments/2302-da8c43ec-b6ca-4bd2-871e-72e288c66ee6", "id": "2302-da8c43ec-b6ca-4bd2-871e-72e288c66ee6", "lifecycle_state": "stable", "name": "my-bare-metal-server-network-attachment", "port_speed": 1000, "primary_ip": {"address": "192.168.3.4", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e/reserved_ips/6d353a0f-aeb1-4ae1-832e-1110d10981bb", "id": "6d353a0f-aeb1-4ae1-832e-1110d10981bb", "name": "my-reserved-ip", "resource_type": "subnet_reserved_ip"}, "resource_type": "bare_metal_server_network_attachment", "subnet": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "id": "7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "name": "my-subnet", "resource_type": "subnet"}, "type": "primary", "virtual_network_interface": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::virtual-network-interface:0767-fa41aecb-4f21-423d-8082-630bfba1e1d9", "href": "https://us-south.iaas.cloud.ibm.com/v1/virtual_network_interfaces/0767-fa41aecb-4f21-423d-8082-630bfba1e1d9", "id": "0767-fa41aecb-4f21-423d-8082-630bfba1e1d9", "name": "my-virtual-network-interface", "resource_type": "virtual_network_interface"}, "allowed_vlans": [4], "interface_type": "pci"}], "next": {"href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/3b2669a2-4c2b-4003-bc91-1b81f1326267/network_attachments?start=d3e721fd-c988-4670-9927-dbd5e7b07fc6&limit=20"}, "total_count": 132}`) })) }) - It(`Invoke GetBackupPolicy successfully with retries`, func() { + It(`Invoke ListBareMetalServerNetworkAttachments successfully with retries`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -44143,21 +44641,23 @@ var _ = Describe(`VpcV1`, func() { 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"} + // Construct an instance of the ListBareMetalServerNetworkAttachmentsOptions model + listBareMetalServerNetworkAttachmentsOptionsModel := new(vpcv1.ListBareMetalServerNetworkAttachmentsOptions) + listBareMetalServerNetworkAttachmentsOptionsModel.BareMetalServerID = core.StringPtr("testString") + listBareMetalServerNetworkAttachmentsOptionsModel.Start = core.StringPtr("testString") + listBareMetalServerNetworkAttachmentsOptionsModel.Limit = core.Int64Ptr(int64(10)) + listBareMetalServerNetworkAttachmentsOptionsModel.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) + _, _, operationErr := vpcService.ListBareMetalServerNetworkAttachmentsWithContext(ctx, listBareMetalServerNetworkAttachmentsOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) // Disable retries and test again vpcService.DisableRetries() - result, response, operationErr := vpcService.GetBackupPolicy(getBackupPolicyOptionsModel) + result, response, operationErr := vpcService.ListBareMetalServerNetworkAttachments(listBareMetalServerNetworkAttachmentsOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) @@ -44165,7 +44665,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.GetBackupPolicyWithContext(ctx, getBackupPolicyOptionsModel) + _, _, operationErr = vpcService.ListBareMetalServerNetworkAttachmentsWithContext(ctx, listBareMetalServerNetworkAttachmentsOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) }) @@ -44179,18 +44679,20 @@ var _ = Describe(`VpcV1`, func() { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(getBackupPolicyPath)) + Expect(req.URL.EscapedPath()).To(Equal(listBareMetalServerNetworkAttachmentsPath)) Expect(req.Method).To(Equal("GET")) Expect(req.URL.Query()["version"]).To(Equal([]string{"testString"})) Expect(req.URL.Query()["generation"]).To(Equal([]string{fmt.Sprint(int64(2))})) + Expect(req.URL.Query()["start"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["limit"]).To(Equal([]string{fmt.Sprint(int64(10))})) // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south:a/123456::backup-policy:r134-076191ba-49c2-4763-94fd-c70de73ee2e6", "health_reasons": [{"code": "missing_service_authorization_policies", "message": "One or more accounts are missing service authorization policies", "more_info": "https://cloud.ibm.com/docs/vpc?topic=vpc-backup-service-about&interface=ui"}], "health_state": "ok", "href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6", "id": "r134-076191ba-49c2-4763-94fd-c70de73ee2e6", "last_job_completed_at": "2019-01-01T12:00:00.000Z", "lifecycle_state": "stable", "match_user_tags": ["MatchUserTags"], "name": "my-backup-policy", "plans": [{"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6/plans/r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "id": "r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "name": "my-policy-plan", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "backup_policy_plan"}], "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "resource_type": "backup_policy", "scope": {"crn": "crn:v1:bluemix:public:enterprise::a/123456::enterprise:ebc2b430240943458b9e91e1432cfcce", "id": "fee82deba12e4c0fb69c3b09d1f12345", "resource_type": "enterprise"}, "included_content": ["data_volumes"], "match_resource_type": "instance"}`) + fmt.Fprintf(res, "%s", `{"first": {"href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/3b2669a2-4c2b-4003-bc91-1b81f1326267/network_attachments?limit=20"}, "limit": 20, "network_attachments": [{"created_at": "2019-01-01T12:00:00.000Z", "href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/2302-f7a2bf57-af7c-49d9-b599-b2c91293d30c/network_attachments/2302-da8c43ec-b6ca-4bd2-871e-72e288c66ee6", "id": "2302-da8c43ec-b6ca-4bd2-871e-72e288c66ee6", "lifecycle_state": "stable", "name": "my-bare-metal-server-network-attachment", "port_speed": 1000, "primary_ip": {"address": "192.168.3.4", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e/reserved_ips/6d353a0f-aeb1-4ae1-832e-1110d10981bb", "id": "6d353a0f-aeb1-4ae1-832e-1110d10981bb", "name": "my-reserved-ip", "resource_type": "subnet_reserved_ip"}, "resource_type": "bare_metal_server_network_attachment", "subnet": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "id": "7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "name": "my-subnet", "resource_type": "subnet"}, "type": "primary", "virtual_network_interface": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::virtual-network-interface:0767-fa41aecb-4f21-423d-8082-630bfba1e1d9", "href": "https://us-south.iaas.cloud.ibm.com/v1/virtual_network_interfaces/0767-fa41aecb-4f21-423d-8082-630bfba1e1d9", "id": "0767-fa41aecb-4f21-423d-8082-630bfba1e1d9", "name": "my-virtual-network-interface", "resource_type": "virtual_network_interface"}, "allowed_vlans": [4], "interface_type": "pci"}], "next": {"href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/3b2669a2-4c2b-4003-bc91-1b81f1326267/network_attachments?start=d3e721fd-c988-4670-9927-dbd5e7b07fc6&limit=20"}, "total_count": 132}`) })) }) - It(`Invoke GetBackupPolicy successfully`, func() { + It(`Invoke ListBareMetalServerNetworkAttachments successfully`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -44200,24 +44702,26 @@ var _ = Describe(`VpcV1`, func() { Expect(vpcService).ToNot(BeNil()) // Invoke operation with nil options model (negative test) - result, response, operationErr := vpcService.GetBackupPolicy(nil) + result, response, operationErr := vpcService.ListBareMetalServerNetworkAttachments(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"} + // Construct an instance of the ListBareMetalServerNetworkAttachmentsOptions model + listBareMetalServerNetworkAttachmentsOptionsModel := new(vpcv1.ListBareMetalServerNetworkAttachmentsOptions) + listBareMetalServerNetworkAttachmentsOptionsModel.BareMetalServerID = core.StringPtr("testString") + listBareMetalServerNetworkAttachmentsOptionsModel.Start = core.StringPtr("testString") + listBareMetalServerNetworkAttachmentsOptionsModel.Limit = core.Int64Ptr(int64(10)) + listBareMetalServerNetworkAttachmentsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with valid options model (positive test) - result, response, operationErr = vpcService.GetBackupPolicy(getBackupPolicyOptionsModel) + result, response, operationErr = vpcService.ListBareMetalServerNetworkAttachments(listBareMetalServerNetworkAttachmentsOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) }) - It(`Invoke GetBackupPolicy with error: Operation validation and request error`, func() { + It(`Invoke ListBareMetalServerNetworkAttachments with error: Operation validation and request error`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -44226,22 +44730,24 @@ var _ = Describe(`VpcV1`, func() { 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"} + // Construct an instance of the ListBareMetalServerNetworkAttachmentsOptions model + listBareMetalServerNetworkAttachmentsOptionsModel := new(vpcv1.ListBareMetalServerNetworkAttachmentsOptions) + listBareMetalServerNetworkAttachmentsOptionsModel.BareMetalServerID = core.StringPtr("testString") + listBareMetalServerNetworkAttachmentsOptionsModel.Start = core.StringPtr("testString") + listBareMetalServerNetworkAttachmentsOptionsModel.Limit = core.Int64Ptr(int64(10)) + listBareMetalServerNetworkAttachmentsOptionsModel.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) + result, response, operationErr := vpcService.ListBareMetalServerNetworkAttachments(listBareMetalServerNetworkAttachmentsOptionsModel) 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) + // Construct a second instance of the ListBareMetalServerNetworkAttachmentsOptions model with no property values + listBareMetalServerNetworkAttachmentsOptionsModelNew := new(vpcv1.ListBareMetalServerNetworkAttachmentsOptions) // Invoke operation with invalid model (negative test) - result, response, operationErr = vpcService.GetBackupPolicy(getBackupPolicyOptionsModelNew) + result, response, operationErr = vpcService.ListBareMetalServerNetworkAttachments(listBareMetalServerNetworkAttachmentsOptionsModelNew) Expect(operationErr).ToNot(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) @@ -44250,16 +44756,96 @@ var _ = Describe(`VpcV1`, func() { testServer.Close() }) }) - Context(`Using mock server endpoint with missing response body`, func() { + 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 ListBareMetalServerNetworkAttachments 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 ListBareMetalServerNetworkAttachmentsOptions model + listBareMetalServerNetworkAttachmentsOptionsModel := new(vpcv1.ListBareMetalServerNetworkAttachmentsOptions) + listBareMetalServerNetworkAttachmentsOptionsModel.BareMetalServerID = core.StringPtr("testString") + listBareMetalServerNetworkAttachmentsOptionsModel.Start = core.StringPtr("testString") + listBareMetalServerNetworkAttachmentsOptionsModel.Limit = core.Int64Ptr(int64(10)) + listBareMetalServerNetworkAttachmentsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation + result, response, operationErr := vpcService.ListBareMetalServerNetworkAttachments(listBareMetalServerNetworkAttachmentsOptionsModel) + 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.BareMetalServerNetworkAttachmentCollection) + nextObject := new(vpcv1.BareMetalServerNetworkAttachmentCollectionNext) + 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.BareMetalServerNetworkAttachmentCollection) + + 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.BareMetalServerNetworkAttachmentCollection) + nextObject := new(vpcv1.BareMetalServerNetworkAttachmentCollectionNext) + nextObject.Href = core.StringPtr("ibm.com") + responseObject.Next = nextObject + + value, err := responseObject.GetNextStart() + Expect(err).To(BeNil()) + Expect(value).To(BeNil()) + }) + }) + Context(`Using mock server endpoint - paginated response`, func() { BeforeEach(func() { + var requestNumber int = 0 testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { defer GinkgoRecover() - // Set success status code with no respoonse body + // Verify the contents of the request + Expect(req.URL.EscapedPath()).To(Equal(listBareMetalServerNetworkAttachmentsPath)) + Expect(req.Method).To(Equal("GET")) + + // Set mock response + res.Header().Set("Content-type", "application/json") res.WriteHeader(200) + requestNumber++ + if requestNumber == 1 { + fmt.Fprintf(res, "%s", `{"next":{"href":"https://myhost.com/somePath?start=1"},"total_count":2,"limit":1,"network_attachments":[{"created_at":"2019-01-01T12:00:00.000Z","href":"https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/2302-f7a2bf57-af7c-49d9-b599-b2c91293d30c/network_attachments/2302-da8c43ec-b6ca-4bd2-871e-72e288c66ee6","id":"2302-da8c43ec-b6ca-4bd2-871e-72e288c66ee6","lifecycle_state":"stable","name":"my-bare-metal-server-network-attachment","port_speed":1000,"primary_ip":{"address":"192.168.3.4","deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e/reserved_ips/6d353a0f-aeb1-4ae1-832e-1110d10981bb","id":"6d353a0f-aeb1-4ae1-832e-1110d10981bb","name":"my-reserved-ip","resource_type":"subnet_reserved_ip"},"resource_type":"bare_metal_server_network_attachment","subnet":{"crn":"crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e","deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e","id":"7ec86020-1c6e-4889-b3f0-a15f2e50f87e","name":"my-subnet","resource_type":"subnet"},"type":"primary","virtual_network_interface":{"crn":"crn:v1:bluemix:public:is:us-south-1:a/123456::virtual-network-interface:0767-fa41aecb-4f21-423d-8082-630bfba1e1d9","href":"https://us-south.iaas.cloud.ibm.com/v1/virtual_network_interfaces/0767-fa41aecb-4f21-423d-8082-630bfba1e1d9","id":"0767-fa41aecb-4f21-423d-8082-630bfba1e1d9","name":"my-virtual-network-interface","resource_type":"virtual_network_interface"},"allowed_vlans":[4],"interface_type":"pci"}]}`) + } else if requestNumber == 2 { + fmt.Fprintf(res, "%s", `{"total_count":2,"limit":1,"network_attachments":[{"created_at":"2019-01-01T12:00:00.000Z","href":"https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/2302-f7a2bf57-af7c-49d9-b599-b2c91293d30c/network_attachments/2302-da8c43ec-b6ca-4bd2-871e-72e288c66ee6","id":"2302-da8c43ec-b6ca-4bd2-871e-72e288c66ee6","lifecycle_state":"stable","name":"my-bare-metal-server-network-attachment","port_speed":1000,"primary_ip":{"address":"192.168.3.4","deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e/reserved_ips/6d353a0f-aeb1-4ae1-832e-1110d10981bb","id":"6d353a0f-aeb1-4ae1-832e-1110d10981bb","name":"my-reserved-ip","resource_type":"subnet_reserved_ip"},"resource_type":"bare_metal_server_network_attachment","subnet":{"crn":"crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e","deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e","id":"7ec86020-1c6e-4889-b3f0-a15f2e50f87e","name":"my-subnet","resource_type":"subnet"},"type":"primary","virtual_network_interface":{"crn":"crn:v1:bluemix:public:is:us-south-1:a/123456::virtual-network-interface:0767-fa41aecb-4f21-423d-8082-630bfba1e1d9","href":"https://us-south.iaas.cloud.ibm.com/v1/virtual_network_interfaces/0767-fa41aecb-4f21-423d-8082-630bfba1e1d9","id":"0767-fa41aecb-4f21-423d-8082-630bfba1e1d9","name":"my-virtual-network-interface","resource_type":"virtual_network_interface"},"allowed_vlans":[4],"interface_type":"pci"}]}`) + } else { + res.WriteHeader(400) + } })) }) - It(`Invoke GetBackupPolicy successfully`, func() { + It(`Use BareMetalServerNetworkAttachmentsPager.GetNext successfully`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -44268,45 +44854,68 @@ var _ = Describe(`VpcV1`, func() { 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"} + listBareMetalServerNetworkAttachmentsOptionsModel := &vpcv1.ListBareMetalServerNetworkAttachmentsOptions{ + BareMetalServerID: core.StringPtr("testString"), + Limit: core.Int64Ptr(int64(10)), + } - // Invoke operation - result, response, operationErr := vpcService.GetBackupPolicy(getBackupPolicyOptionsModel) - Expect(operationErr).To(BeNil()) - Expect(response).ToNot(BeNil()) + pager, err := vpcService.NewBareMetalServerNetworkAttachmentsPager(listBareMetalServerNetworkAttachmentsOptionsModel) + Expect(err).To(BeNil()) + Expect(pager).ToNot(BeNil()) - // Verify a nil result - Expect(result).To(BeNil()) + var allResults []vpcv1.BareMetalServerNetworkAttachmentIntf + for pager.HasNext() { + nextPage, err := pager.GetNext() + Expect(err).To(BeNil()) + Expect(nextPage).ToNot(BeNil()) + allResults = append(allResults, nextPage...) + } + Expect(len(allResults)).To(Equal(2)) }) - AfterEach(func() { - testServer.Close() + It(`Use BareMetalServerNetworkAttachmentsPager.GetAll successfully`, func() { + vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + Version: core.StringPtr(version), + }) + Expect(serviceErr).To(BeNil()) + Expect(vpcService).ToNot(BeNil()) + + listBareMetalServerNetworkAttachmentsOptionsModel := &vpcv1.ListBareMetalServerNetworkAttachmentsOptions{ + BareMetalServerID: core.StringPtr("testString"), + Limit: core.Int64Ptr(int64(10)), + } + + pager, err := vpcService.NewBareMetalServerNetworkAttachmentsPager(listBareMetalServerNetworkAttachmentsOptionsModel) + Expect(err).To(BeNil()) + Expect(pager).ToNot(BeNil()) + + allResults, err := pager.GetAll() + Expect(err).To(BeNil()) + Expect(allResults).ToNot(BeNil()) + Expect(len(allResults)).To(Equal(2)) }) }) }) - Describe(`UpdateBackupPolicy(updateBackupPolicyOptions *UpdateBackupPolicyOptions) - Operation response error`, func() { + Describe(`CreateBareMetalServerNetworkAttachment(createBareMetalServerNetworkAttachmentOptions *CreateBareMetalServerNetworkAttachmentOptions) - Operation response error`, func() { version := "testString" - updateBackupPolicyPath := "/backup_policies/testString" + createBareMetalServerNetworkAttachmentPath := "/bare_metal_servers/testString/network_attachments" 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.EscapedPath()).To(Equal(createBareMetalServerNetworkAttachmentPath)) + 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 UpdateBackupPolicy with error: Operation response processing error`, func() { + It(`Invoke CreateBareMetalServerNetworkAttachment with error: Operation response processing error`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -44315,29 +44924,63 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the BackupPolicyPatch model - backupPolicyPatchModel := new(vpcv1.BackupPolicyPatch) - backupPolicyPatchModel.IncludedContent = []string{"data_volumes"} - backupPolicyPatchModel.MatchUserTags = []string{"my-daily-backup-policy"} - backupPolicyPatchModel.Name = core.StringPtr("my-backup-policy") - backupPolicyPatchModelAsPatch, asPatchErr := backupPolicyPatchModel.AsPatch() - Expect(asPatchErr).To(BeNil()) + // Construct an instance of the VirtualNetworkInterfaceIPPrototypeReservedIPPrototypeVirtualNetworkInterfaceIPsContext model + virtualNetworkInterfaceIPPrototypeModel := new(vpcv1.VirtualNetworkInterfaceIPPrototypeReservedIPPrototypeVirtualNetworkInterfaceIPsContext) + virtualNetworkInterfaceIPPrototypeModel.Address = core.StringPtr("10.0.0.5") + virtualNetworkInterfaceIPPrototypeModel.AutoDelete = core.BoolPtr(false) + virtualNetworkInterfaceIPPrototypeModel.Name = core.StringPtr("my-reserved-ip") - // 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"} + // Construct an instance of the VirtualNetworkInterfacePrimaryIPPrototypeReservedIPPrototypeVirtualNetworkInterfacePrimaryIPContext model + virtualNetworkInterfacePrimaryIPPrototypeModel := new(vpcv1.VirtualNetworkInterfacePrimaryIPPrototypeReservedIPPrototypeVirtualNetworkInterfacePrimaryIPContext) + virtualNetworkInterfacePrimaryIPPrototypeModel.Address = core.StringPtr("10.0.0.5") + virtualNetworkInterfacePrimaryIPPrototypeModel.AutoDelete = core.BoolPtr(false) + virtualNetworkInterfacePrimaryIPPrototypeModel.Name = core.StringPtr("my-reserved-ip") + + // Construct an instance of the ResourceGroupIdentityByID model + resourceGroupIdentityModel := new(vpcv1.ResourceGroupIdentityByID) + resourceGroupIdentityModel.ID = core.StringPtr("fee82deba12e4c0fb69c3b09d1f12345") + + // Construct an instance of the SecurityGroupIdentityByID model + securityGroupIdentityModel := new(vpcv1.SecurityGroupIdentityByID) + securityGroupIdentityModel.ID = core.StringPtr("be5df5ca-12a0-494b-907e-aa6ec2bfa271") + + // Construct an instance of the SubnetIdentityByID model + subnetIdentityModel := new(vpcv1.SubnetIdentityByID) + subnetIdentityModel.ID = core.StringPtr("7ec86020-1c6e-4889-b3f0-a15f2e50f87e") + + // Construct an instance of the BareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceVirtualNetworkInterfacePrototypeBareMetalServerNetworkAttachmentContext model + bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel := new(vpcv1.BareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceVirtualNetworkInterfacePrototypeBareMetalServerNetworkAttachmentContext) + bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel.AllowIPSpoofing = core.BoolPtr(true) + bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel.AutoDelete = core.BoolPtr(false) + bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel.EnableInfrastructureNat = core.BoolPtr(true) + bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel.Ips = []vpcv1.VirtualNetworkInterfaceIPPrototypeIntf{virtualNetworkInterfaceIPPrototypeModel} + bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel.Name = core.StringPtr("my-virtual-network-interface") + bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel.PrimaryIP = virtualNetworkInterfacePrimaryIPPrototypeModel + bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel.ResourceGroup = resourceGroupIdentityModel + bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel.SecurityGroups = []vpcv1.SecurityGroupIdentityIntf{securityGroupIdentityModel} + bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel.Subnet = subnetIdentityModel + + // Construct an instance of the BareMetalServerNetworkAttachmentPrototypeBareMetalServerNetworkAttachmentByPciPrototype model + bareMetalServerNetworkAttachmentPrototypeModel := new(vpcv1.BareMetalServerNetworkAttachmentPrototypeBareMetalServerNetworkAttachmentByPciPrototype) + bareMetalServerNetworkAttachmentPrototypeModel.Name = core.StringPtr("my-bare-metal-server-network-attachment") + bareMetalServerNetworkAttachmentPrototypeModel.VirtualNetworkInterface = bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel + bareMetalServerNetworkAttachmentPrototypeModel.AllowedVlans = []int64{} + bareMetalServerNetworkAttachmentPrototypeModel.InterfaceType = core.StringPtr("pci") + + // Construct an instance of the CreateBareMetalServerNetworkAttachmentOptions model + createBareMetalServerNetworkAttachmentOptionsModel := new(vpcv1.CreateBareMetalServerNetworkAttachmentOptions) + createBareMetalServerNetworkAttachmentOptionsModel.BareMetalServerID = core.StringPtr("testString") + createBareMetalServerNetworkAttachmentOptionsModel.BareMetalServerNetworkAttachmentPrototype = bareMetalServerNetworkAttachmentPrototypeModel + createBareMetalServerNetworkAttachmentOptionsModel.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) + result, response, operationErr := vpcService.CreateBareMetalServerNetworkAttachment(createBareMetalServerNetworkAttachmentOptionsModel) 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) + result, response, operationErr = vpcService.CreateBareMetalServerNetworkAttachment(createBareMetalServerNetworkAttachmentOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).To(BeNil()) @@ -44347,17 +44990,17 @@ var _ = Describe(`VpcV1`, func() { }) }) }) - Describe(`UpdateBackupPolicy(updateBackupPolicyOptions *UpdateBackupPolicyOptions)`, func() { + Describe(`CreateBareMetalServerNetworkAttachment(createBareMetalServerNetworkAttachmentOptions *CreateBareMetalServerNetworkAttachmentOptions)`, func() { version := "testString" - updateBackupPolicyPath := "/backup_policies/testString" + createBareMetalServerNetworkAttachmentPath := "/bare_metal_servers/testString/network_attachments" 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")) + Expect(req.URL.EscapedPath()).To(Equal(createBareMetalServerNetworkAttachmentPath)) + Expect(req.Method).To(Equal("POST")) // For gzip-disabled operation, verify Content-Encoding is not set. Expect(req.Header.Get("Content-Encoding")).To(BeEmpty()) @@ -44375,8 +45018,6 @@ var _ = Describe(`VpcV1`, func() { } 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 @@ -44384,11 +45025,11 @@ var _ = Describe(`VpcV1`, func() { // Set mock response res.Header().Set("Content-type", "application/json") - res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south:a/123456::backup-policy:r134-076191ba-49c2-4763-94fd-c70de73ee2e6", "health_reasons": [{"code": "missing_service_authorization_policies", "message": "One or more accounts are missing service authorization policies", "more_info": "https://cloud.ibm.com/docs/vpc?topic=vpc-backup-service-about&interface=ui"}], "health_state": "ok", "href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6", "id": "r134-076191ba-49c2-4763-94fd-c70de73ee2e6", "last_job_completed_at": "2019-01-01T12:00:00.000Z", "lifecycle_state": "stable", "match_user_tags": ["MatchUserTags"], "name": "my-backup-policy", "plans": [{"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6/plans/r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "id": "r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "name": "my-policy-plan", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "backup_policy_plan"}], "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "resource_type": "backup_policy", "scope": {"crn": "crn:v1:bluemix:public:enterprise::a/123456::enterprise:ebc2b430240943458b9e91e1432cfcce", "id": "fee82deba12e4c0fb69c3b09d1f12345", "resource_type": "enterprise"}, "included_content": ["data_volumes"], "match_resource_type": "instance"}`) + res.WriteHeader(201) + fmt.Fprintf(res, "%s", `{"created_at": "2019-01-01T12:00:00.000Z", "href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/2302-f7a2bf57-af7c-49d9-b599-b2c91293d30c/network_attachments/2302-da8c43ec-b6ca-4bd2-871e-72e288c66ee6", "id": "2302-da8c43ec-b6ca-4bd2-871e-72e288c66ee6", "lifecycle_state": "stable", "name": "my-bare-metal-server-network-attachment", "port_speed": 1000, "primary_ip": {"address": "192.168.3.4", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e/reserved_ips/6d353a0f-aeb1-4ae1-832e-1110d10981bb", "id": "6d353a0f-aeb1-4ae1-832e-1110d10981bb", "name": "my-reserved-ip", "resource_type": "subnet_reserved_ip"}, "resource_type": "bare_metal_server_network_attachment", "subnet": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "id": "7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "name": "my-subnet", "resource_type": "subnet"}, "type": "primary", "virtual_network_interface": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::virtual-network-interface:0767-fa41aecb-4f21-423d-8082-630bfba1e1d9", "href": "https://us-south.iaas.cloud.ibm.com/v1/virtual_network_interfaces/0767-fa41aecb-4f21-423d-8082-630bfba1e1d9", "id": "0767-fa41aecb-4f21-423d-8082-630bfba1e1d9", "name": "my-virtual-network-interface", "resource_type": "virtual_network_interface"}, "allowed_vlans": [4], "interface_type": "pci"}`) })) }) - It(`Invoke UpdateBackupPolicy successfully with retries`, func() { + It(`Invoke CreateBareMetalServerNetworkAttachment successfully with retries`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -44398,31 +45039,65 @@ var _ = Describe(`VpcV1`, func() { Expect(vpcService).ToNot(BeNil()) vpcService.EnableRetries(0, 0) - // Construct an instance of the BackupPolicyPatch model - backupPolicyPatchModel := new(vpcv1.BackupPolicyPatch) - backupPolicyPatchModel.IncludedContent = []string{"data_volumes"} - backupPolicyPatchModel.MatchUserTags = []string{"my-daily-backup-policy"} - backupPolicyPatchModel.Name = core.StringPtr("my-backup-policy") - backupPolicyPatchModelAsPatch, asPatchErr := backupPolicyPatchModel.AsPatch() - Expect(asPatchErr).To(BeNil()) + // Construct an instance of the VirtualNetworkInterfaceIPPrototypeReservedIPPrototypeVirtualNetworkInterfaceIPsContext model + virtualNetworkInterfaceIPPrototypeModel := new(vpcv1.VirtualNetworkInterfaceIPPrototypeReservedIPPrototypeVirtualNetworkInterfaceIPsContext) + virtualNetworkInterfaceIPPrototypeModel.Address = core.StringPtr("10.0.0.5") + virtualNetworkInterfaceIPPrototypeModel.AutoDelete = core.BoolPtr(false) + virtualNetworkInterfaceIPPrototypeModel.Name = core.StringPtr("my-reserved-ip") - // 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"} + // Construct an instance of the VirtualNetworkInterfacePrimaryIPPrototypeReservedIPPrototypeVirtualNetworkInterfacePrimaryIPContext model + virtualNetworkInterfacePrimaryIPPrototypeModel := new(vpcv1.VirtualNetworkInterfacePrimaryIPPrototypeReservedIPPrototypeVirtualNetworkInterfacePrimaryIPContext) + virtualNetworkInterfacePrimaryIPPrototypeModel.Address = core.StringPtr("10.0.0.5") + virtualNetworkInterfacePrimaryIPPrototypeModel.AutoDelete = core.BoolPtr(false) + virtualNetworkInterfacePrimaryIPPrototypeModel.Name = core.StringPtr("my-reserved-ip") + + // Construct an instance of the ResourceGroupIdentityByID model + resourceGroupIdentityModel := new(vpcv1.ResourceGroupIdentityByID) + resourceGroupIdentityModel.ID = core.StringPtr("fee82deba12e4c0fb69c3b09d1f12345") + + // Construct an instance of the SecurityGroupIdentityByID model + securityGroupIdentityModel := new(vpcv1.SecurityGroupIdentityByID) + securityGroupIdentityModel.ID = core.StringPtr("be5df5ca-12a0-494b-907e-aa6ec2bfa271") + + // Construct an instance of the SubnetIdentityByID model + subnetIdentityModel := new(vpcv1.SubnetIdentityByID) + subnetIdentityModel.ID = core.StringPtr("7ec86020-1c6e-4889-b3f0-a15f2e50f87e") + + // Construct an instance of the BareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceVirtualNetworkInterfacePrototypeBareMetalServerNetworkAttachmentContext model + bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel := new(vpcv1.BareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceVirtualNetworkInterfacePrototypeBareMetalServerNetworkAttachmentContext) + bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel.AllowIPSpoofing = core.BoolPtr(true) + bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel.AutoDelete = core.BoolPtr(false) + bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel.EnableInfrastructureNat = core.BoolPtr(true) + bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel.Ips = []vpcv1.VirtualNetworkInterfaceIPPrototypeIntf{virtualNetworkInterfaceIPPrototypeModel} + bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel.Name = core.StringPtr("my-virtual-network-interface") + bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel.PrimaryIP = virtualNetworkInterfacePrimaryIPPrototypeModel + bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel.ResourceGroup = resourceGroupIdentityModel + bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel.SecurityGroups = []vpcv1.SecurityGroupIdentityIntf{securityGroupIdentityModel} + bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel.Subnet = subnetIdentityModel + + // Construct an instance of the BareMetalServerNetworkAttachmentPrototypeBareMetalServerNetworkAttachmentByPciPrototype model + bareMetalServerNetworkAttachmentPrototypeModel := new(vpcv1.BareMetalServerNetworkAttachmentPrototypeBareMetalServerNetworkAttachmentByPciPrototype) + bareMetalServerNetworkAttachmentPrototypeModel.Name = core.StringPtr("my-bare-metal-server-network-attachment") + bareMetalServerNetworkAttachmentPrototypeModel.VirtualNetworkInterface = bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel + bareMetalServerNetworkAttachmentPrototypeModel.AllowedVlans = []int64{} + bareMetalServerNetworkAttachmentPrototypeModel.InterfaceType = core.StringPtr("pci") + + // Construct an instance of the CreateBareMetalServerNetworkAttachmentOptions model + createBareMetalServerNetworkAttachmentOptionsModel := new(vpcv1.CreateBareMetalServerNetworkAttachmentOptions) + createBareMetalServerNetworkAttachmentOptionsModel.BareMetalServerID = core.StringPtr("testString") + createBareMetalServerNetworkAttachmentOptionsModel.BareMetalServerNetworkAttachmentPrototype = bareMetalServerNetworkAttachmentPrototypeModel + createBareMetalServerNetworkAttachmentOptionsModel.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) + _, _, operationErr := vpcService.CreateBareMetalServerNetworkAttachmentWithContext(ctx, createBareMetalServerNetworkAttachmentOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) // Disable retries and test again vpcService.DisableRetries() - result, response, operationErr := vpcService.UpdateBackupPolicy(updateBackupPolicyOptionsModel) + result, response, operationErr := vpcService.CreateBareMetalServerNetworkAttachment(createBareMetalServerNetworkAttachmentOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) @@ -44430,7 +45105,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.UpdateBackupPolicyWithContext(ctx, updateBackupPolicyOptionsModel) + _, _, operationErr = vpcService.CreateBareMetalServerNetworkAttachmentWithContext(ctx, createBareMetalServerNetworkAttachmentOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) }) @@ -44444,8 +45119,8 @@ var _ = Describe(`VpcV1`, func() { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(updateBackupPolicyPath)) - Expect(req.Method).To(Equal("PATCH")) + Expect(req.URL.EscapedPath()).To(Equal(createBareMetalServerNetworkAttachmentPath)) + Expect(req.Method).To(Equal("POST")) // For gzip-disabled operation, verify Content-Encoding is not set. Expect(req.Header.Get("Content-Encoding")).To(BeEmpty()) @@ -44463,17 +45138,15 @@ var _ = Describe(`VpcV1`, func() { } 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", "health_reasons": [{"code": "missing_service_authorization_policies", "message": "One or more accounts are missing service authorization policies", "more_info": "https://cloud.ibm.com/docs/vpc?topic=vpc-backup-service-about&interface=ui"}], "health_state": "ok", "href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6", "id": "r134-076191ba-49c2-4763-94fd-c70de73ee2e6", "last_job_completed_at": "2019-01-01T12:00:00.000Z", "lifecycle_state": "stable", "match_user_tags": ["MatchUserTags"], "name": "my-backup-policy", "plans": [{"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6/plans/r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "id": "r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "name": "my-policy-plan", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "backup_policy_plan"}], "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "resource_type": "backup_policy", "scope": {"crn": "crn:v1:bluemix:public:enterprise::a/123456::enterprise:ebc2b430240943458b9e91e1432cfcce", "id": "fee82deba12e4c0fb69c3b09d1f12345", "resource_type": "enterprise"}, "included_content": ["data_volumes"], "match_resource_type": "instance"}`) + res.WriteHeader(201) + fmt.Fprintf(res, "%s", `{"created_at": "2019-01-01T12:00:00.000Z", "href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/2302-f7a2bf57-af7c-49d9-b599-b2c91293d30c/network_attachments/2302-da8c43ec-b6ca-4bd2-871e-72e288c66ee6", "id": "2302-da8c43ec-b6ca-4bd2-871e-72e288c66ee6", "lifecycle_state": "stable", "name": "my-bare-metal-server-network-attachment", "port_speed": 1000, "primary_ip": {"address": "192.168.3.4", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e/reserved_ips/6d353a0f-aeb1-4ae1-832e-1110d10981bb", "id": "6d353a0f-aeb1-4ae1-832e-1110d10981bb", "name": "my-reserved-ip", "resource_type": "subnet_reserved_ip"}, "resource_type": "bare_metal_server_network_attachment", "subnet": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "id": "7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "name": "my-subnet", "resource_type": "subnet"}, "type": "primary", "virtual_network_interface": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::virtual-network-interface:0767-fa41aecb-4f21-423d-8082-630bfba1e1d9", "href": "https://us-south.iaas.cloud.ibm.com/v1/virtual_network_interfaces/0767-fa41aecb-4f21-423d-8082-630bfba1e1d9", "id": "0767-fa41aecb-4f21-423d-8082-630bfba1e1d9", "name": "my-virtual-network-interface", "resource_type": "virtual_network_interface"}, "allowed_vlans": [4], "interface_type": "pci"}`) })) }) - It(`Invoke UpdateBackupPolicy successfully`, func() { + It(`Invoke CreateBareMetalServerNetworkAttachment successfully`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -44483,34 +45156,68 @@ var _ = Describe(`VpcV1`, func() { Expect(vpcService).ToNot(BeNil()) // Invoke operation with nil options model (negative test) - result, response, operationErr := vpcService.UpdateBackupPolicy(nil) + result, response, operationErr := vpcService.CreateBareMetalServerNetworkAttachment(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.IncludedContent = []string{"data_volumes"} - 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 VirtualNetworkInterfaceIPPrototypeReservedIPPrototypeVirtualNetworkInterfaceIPsContext model + virtualNetworkInterfaceIPPrototypeModel := new(vpcv1.VirtualNetworkInterfaceIPPrototypeReservedIPPrototypeVirtualNetworkInterfaceIPsContext) + virtualNetworkInterfaceIPPrototypeModel.Address = core.StringPtr("10.0.0.5") + virtualNetworkInterfaceIPPrototypeModel.AutoDelete = core.BoolPtr(false) + virtualNetworkInterfaceIPPrototypeModel.Name = core.StringPtr("my-reserved-ip") - // 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"} + // Construct an instance of the VirtualNetworkInterfacePrimaryIPPrototypeReservedIPPrototypeVirtualNetworkInterfacePrimaryIPContext model + virtualNetworkInterfacePrimaryIPPrototypeModel := new(vpcv1.VirtualNetworkInterfacePrimaryIPPrototypeReservedIPPrototypeVirtualNetworkInterfacePrimaryIPContext) + virtualNetworkInterfacePrimaryIPPrototypeModel.Address = core.StringPtr("10.0.0.5") + virtualNetworkInterfacePrimaryIPPrototypeModel.AutoDelete = core.BoolPtr(false) + virtualNetworkInterfacePrimaryIPPrototypeModel.Name = core.StringPtr("my-reserved-ip") + + // Construct an instance of the ResourceGroupIdentityByID model + resourceGroupIdentityModel := new(vpcv1.ResourceGroupIdentityByID) + resourceGroupIdentityModel.ID = core.StringPtr("fee82deba12e4c0fb69c3b09d1f12345") + + // Construct an instance of the SecurityGroupIdentityByID model + securityGroupIdentityModel := new(vpcv1.SecurityGroupIdentityByID) + securityGroupIdentityModel.ID = core.StringPtr("be5df5ca-12a0-494b-907e-aa6ec2bfa271") + + // Construct an instance of the SubnetIdentityByID model + subnetIdentityModel := new(vpcv1.SubnetIdentityByID) + subnetIdentityModel.ID = core.StringPtr("7ec86020-1c6e-4889-b3f0-a15f2e50f87e") + + // Construct an instance of the BareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceVirtualNetworkInterfacePrototypeBareMetalServerNetworkAttachmentContext model + bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel := new(vpcv1.BareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceVirtualNetworkInterfacePrototypeBareMetalServerNetworkAttachmentContext) + bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel.AllowIPSpoofing = core.BoolPtr(true) + bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel.AutoDelete = core.BoolPtr(false) + bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel.EnableInfrastructureNat = core.BoolPtr(true) + bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel.Ips = []vpcv1.VirtualNetworkInterfaceIPPrototypeIntf{virtualNetworkInterfaceIPPrototypeModel} + bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel.Name = core.StringPtr("my-virtual-network-interface") + bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel.PrimaryIP = virtualNetworkInterfacePrimaryIPPrototypeModel + bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel.ResourceGroup = resourceGroupIdentityModel + bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel.SecurityGroups = []vpcv1.SecurityGroupIdentityIntf{securityGroupIdentityModel} + bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel.Subnet = subnetIdentityModel + + // Construct an instance of the BareMetalServerNetworkAttachmentPrototypeBareMetalServerNetworkAttachmentByPciPrototype model + bareMetalServerNetworkAttachmentPrototypeModel := new(vpcv1.BareMetalServerNetworkAttachmentPrototypeBareMetalServerNetworkAttachmentByPciPrototype) + bareMetalServerNetworkAttachmentPrototypeModel.Name = core.StringPtr("my-bare-metal-server-network-attachment") + bareMetalServerNetworkAttachmentPrototypeModel.VirtualNetworkInterface = bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel + bareMetalServerNetworkAttachmentPrototypeModel.AllowedVlans = []int64{} + bareMetalServerNetworkAttachmentPrototypeModel.InterfaceType = core.StringPtr("pci") + + // Construct an instance of the CreateBareMetalServerNetworkAttachmentOptions model + createBareMetalServerNetworkAttachmentOptionsModel := new(vpcv1.CreateBareMetalServerNetworkAttachmentOptions) + createBareMetalServerNetworkAttachmentOptionsModel.BareMetalServerID = core.StringPtr("testString") + createBareMetalServerNetworkAttachmentOptionsModel.BareMetalServerNetworkAttachmentPrototype = bareMetalServerNetworkAttachmentPrototypeModel + createBareMetalServerNetworkAttachmentOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with valid options model (positive test) - result, response, operationErr = vpcService.UpdateBackupPolicy(updateBackupPolicyOptionsModel) + result, response, operationErr = vpcService.CreateBareMetalServerNetworkAttachment(createBareMetalServerNetworkAttachmentOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) }) - It(`Invoke UpdateBackupPolicy with error: Operation validation and request error`, func() { + It(`Invoke CreateBareMetalServerNetworkAttachment with error: Operation validation and request error`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -44519,32 +45226,66 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the BackupPolicyPatch model - backupPolicyPatchModel := new(vpcv1.BackupPolicyPatch) - backupPolicyPatchModel.IncludedContent = []string{"data_volumes"} - backupPolicyPatchModel.MatchUserTags = []string{"my-daily-backup-policy"} - backupPolicyPatchModel.Name = core.StringPtr("my-backup-policy") - backupPolicyPatchModelAsPatch, asPatchErr := backupPolicyPatchModel.AsPatch() - Expect(asPatchErr).To(BeNil()) + // Construct an instance of the VirtualNetworkInterfaceIPPrototypeReservedIPPrototypeVirtualNetworkInterfaceIPsContext model + virtualNetworkInterfaceIPPrototypeModel := new(vpcv1.VirtualNetworkInterfaceIPPrototypeReservedIPPrototypeVirtualNetworkInterfaceIPsContext) + virtualNetworkInterfaceIPPrototypeModel.Address = core.StringPtr("10.0.0.5") + virtualNetworkInterfaceIPPrototypeModel.AutoDelete = core.BoolPtr(false) + virtualNetworkInterfaceIPPrototypeModel.Name = core.StringPtr("my-reserved-ip") - // 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"} + // Construct an instance of the VirtualNetworkInterfacePrimaryIPPrototypeReservedIPPrototypeVirtualNetworkInterfacePrimaryIPContext model + virtualNetworkInterfacePrimaryIPPrototypeModel := new(vpcv1.VirtualNetworkInterfacePrimaryIPPrototypeReservedIPPrototypeVirtualNetworkInterfacePrimaryIPContext) + virtualNetworkInterfacePrimaryIPPrototypeModel.Address = core.StringPtr("10.0.0.5") + virtualNetworkInterfacePrimaryIPPrototypeModel.AutoDelete = core.BoolPtr(false) + virtualNetworkInterfacePrimaryIPPrototypeModel.Name = core.StringPtr("my-reserved-ip") + + // Construct an instance of the ResourceGroupIdentityByID model + resourceGroupIdentityModel := new(vpcv1.ResourceGroupIdentityByID) + resourceGroupIdentityModel.ID = core.StringPtr("fee82deba12e4c0fb69c3b09d1f12345") + + // Construct an instance of the SecurityGroupIdentityByID model + securityGroupIdentityModel := new(vpcv1.SecurityGroupIdentityByID) + securityGroupIdentityModel.ID = core.StringPtr("be5df5ca-12a0-494b-907e-aa6ec2bfa271") + + // Construct an instance of the SubnetIdentityByID model + subnetIdentityModel := new(vpcv1.SubnetIdentityByID) + subnetIdentityModel.ID = core.StringPtr("7ec86020-1c6e-4889-b3f0-a15f2e50f87e") + + // Construct an instance of the BareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceVirtualNetworkInterfacePrototypeBareMetalServerNetworkAttachmentContext model + bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel := new(vpcv1.BareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceVirtualNetworkInterfacePrototypeBareMetalServerNetworkAttachmentContext) + bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel.AllowIPSpoofing = core.BoolPtr(true) + bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel.AutoDelete = core.BoolPtr(false) + bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel.EnableInfrastructureNat = core.BoolPtr(true) + bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel.Ips = []vpcv1.VirtualNetworkInterfaceIPPrototypeIntf{virtualNetworkInterfaceIPPrototypeModel} + bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel.Name = core.StringPtr("my-virtual-network-interface") + bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel.PrimaryIP = virtualNetworkInterfacePrimaryIPPrototypeModel + bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel.ResourceGroup = resourceGroupIdentityModel + bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel.SecurityGroups = []vpcv1.SecurityGroupIdentityIntf{securityGroupIdentityModel} + bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel.Subnet = subnetIdentityModel + + // Construct an instance of the BareMetalServerNetworkAttachmentPrototypeBareMetalServerNetworkAttachmentByPciPrototype model + bareMetalServerNetworkAttachmentPrototypeModel := new(vpcv1.BareMetalServerNetworkAttachmentPrototypeBareMetalServerNetworkAttachmentByPciPrototype) + bareMetalServerNetworkAttachmentPrototypeModel.Name = core.StringPtr("my-bare-metal-server-network-attachment") + bareMetalServerNetworkAttachmentPrototypeModel.VirtualNetworkInterface = bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel + bareMetalServerNetworkAttachmentPrototypeModel.AllowedVlans = []int64{} + bareMetalServerNetworkAttachmentPrototypeModel.InterfaceType = core.StringPtr("pci") + + // Construct an instance of the CreateBareMetalServerNetworkAttachmentOptions model + createBareMetalServerNetworkAttachmentOptionsModel := new(vpcv1.CreateBareMetalServerNetworkAttachmentOptions) + createBareMetalServerNetworkAttachmentOptionsModel.BareMetalServerID = core.StringPtr("testString") + createBareMetalServerNetworkAttachmentOptionsModel.BareMetalServerNetworkAttachmentPrototype = bareMetalServerNetworkAttachmentPrototypeModel + createBareMetalServerNetworkAttachmentOptionsModel.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) + result, response, operationErr := vpcService.CreateBareMetalServerNetworkAttachment(createBareMetalServerNetworkAttachmentOptionsModel) 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) + // Construct a second instance of the CreateBareMetalServerNetworkAttachmentOptions model with no property values + createBareMetalServerNetworkAttachmentOptionsModelNew := new(vpcv1.CreateBareMetalServerNetworkAttachmentOptions) // Invoke operation with invalid model (negative test) - result, response, operationErr = vpcService.UpdateBackupPolicy(updateBackupPolicyOptionsModelNew) + result, response, operationErr = vpcService.CreateBareMetalServerNetworkAttachment(createBareMetalServerNetworkAttachmentOptionsModelNew) Expect(operationErr).ToNot(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) @@ -44558,11 +45299,124 @@ var _ = Describe(`VpcV1`, 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) - })) + // Set success status code with no respoonse body + res.WriteHeader(201) + })) + }) + It(`Invoke CreateBareMetalServerNetworkAttachment 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 VirtualNetworkInterfaceIPPrototypeReservedIPPrototypeVirtualNetworkInterfaceIPsContext model + virtualNetworkInterfaceIPPrototypeModel := new(vpcv1.VirtualNetworkInterfaceIPPrototypeReservedIPPrototypeVirtualNetworkInterfaceIPsContext) + virtualNetworkInterfaceIPPrototypeModel.Address = core.StringPtr("10.0.0.5") + virtualNetworkInterfaceIPPrototypeModel.AutoDelete = core.BoolPtr(false) + virtualNetworkInterfaceIPPrototypeModel.Name = core.StringPtr("my-reserved-ip") + + // Construct an instance of the VirtualNetworkInterfacePrimaryIPPrototypeReservedIPPrototypeVirtualNetworkInterfacePrimaryIPContext model + virtualNetworkInterfacePrimaryIPPrototypeModel := new(vpcv1.VirtualNetworkInterfacePrimaryIPPrototypeReservedIPPrototypeVirtualNetworkInterfacePrimaryIPContext) + virtualNetworkInterfacePrimaryIPPrototypeModel.Address = core.StringPtr("10.0.0.5") + virtualNetworkInterfacePrimaryIPPrototypeModel.AutoDelete = core.BoolPtr(false) + virtualNetworkInterfacePrimaryIPPrototypeModel.Name = core.StringPtr("my-reserved-ip") + + // Construct an instance of the ResourceGroupIdentityByID model + resourceGroupIdentityModel := new(vpcv1.ResourceGroupIdentityByID) + resourceGroupIdentityModel.ID = core.StringPtr("fee82deba12e4c0fb69c3b09d1f12345") + + // Construct an instance of the SecurityGroupIdentityByID model + securityGroupIdentityModel := new(vpcv1.SecurityGroupIdentityByID) + securityGroupIdentityModel.ID = core.StringPtr("be5df5ca-12a0-494b-907e-aa6ec2bfa271") + + // Construct an instance of the SubnetIdentityByID model + subnetIdentityModel := new(vpcv1.SubnetIdentityByID) + subnetIdentityModel.ID = core.StringPtr("7ec86020-1c6e-4889-b3f0-a15f2e50f87e") + + // Construct an instance of the BareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceVirtualNetworkInterfacePrototypeBareMetalServerNetworkAttachmentContext model + bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel := new(vpcv1.BareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceVirtualNetworkInterfacePrototypeBareMetalServerNetworkAttachmentContext) + bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel.AllowIPSpoofing = core.BoolPtr(true) + bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel.AutoDelete = core.BoolPtr(false) + bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel.EnableInfrastructureNat = core.BoolPtr(true) + bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel.Ips = []vpcv1.VirtualNetworkInterfaceIPPrototypeIntf{virtualNetworkInterfaceIPPrototypeModel} + bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel.Name = core.StringPtr("my-virtual-network-interface") + bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel.PrimaryIP = virtualNetworkInterfacePrimaryIPPrototypeModel + bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel.ResourceGroup = resourceGroupIdentityModel + bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel.SecurityGroups = []vpcv1.SecurityGroupIdentityIntf{securityGroupIdentityModel} + bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel.Subnet = subnetIdentityModel + + // Construct an instance of the BareMetalServerNetworkAttachmentPrototypeBareMetalServerNetworkAttachmentByPciPrototype model + bareMetalServerNetworkAttachmentPrototypeModel := new(vpcv1.BareMetalServerNetworkAttachmentPrototypeBareMetalServerNetworkAttachmentByPciPrototype) + bareMetalServerNetworkAttachmentPrototypeModel.Name = core.StringPtr("my-bare-metal-server-network-attachment") + bareMetalServerNetworkAttachmentPrototypeModel.VirtualNetworkInterface = bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel + bareMetalServerNetworkAttachmentPrototypeModel.AllowedVlans = []int64{} + bareMetalServerNetworkAttachmentPrototypeModel.InterfaceType = core.StringPtr("pci") + + // Construct an instance of the CreateBareMetalServerNetworkAttachmentOptions model + createBareMetalServerNetworkAttachmentOptionsModel := new(vpcv1.CreateBareMetalServerNetworkAttachmentOptions) + createBareMetalServerNetworkAttachmentOptionsModel.BareMetalServerID = core.StringPtr("testString") + createBareMetalServerNetworkAttachmentOptionsModel.BareMetalServerNetworkAttachmentPrototype = bareMetalServerNetworkAttachmentPrototypeModel + createBareMetalServerNetworkAttachmentOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation + result, response, operationErr := vpcService.CreateBareMetalServerNetworkAttachment(createBareMetalServerNetworkAttachmentOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + + // Verify a nil result + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + }) + Describe(`DeleteBareMetalServerNetworkAttachment(deleteBareMetalServerNetworkAttachmentOptions *DeleteBareMetalServerNetworkAttachmentOptions)`, func() { + version := "testString" + deleteBareMetalServerNetworkAttachmentPath := "/bare_metal_servers/testString/network_attachments/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(deleteBareMetalServerNetworkAttachmentPath)) + 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 DeleteBareMetalServerNetworkAttachment 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.DeleteBareMetalServerNetworkAttachment(nil) + Expect(operationErr).NotTo(BeNil()) + Expect(response).To(BeNil()) + + // Construct an instance of the DeleteBareMetalServerNetworkAttachmentOptions model + deleteBareMetalServerNetworkAttachmentOptionsModel := new(vpcv1.DeleteBareMetalServerNetworkAttachmentOptions) + deleteBareMetalServerNetworkAttachmentOptionsModel.BareMetalServerID = core.StringPtr("testString") + deleteBareMetalServerNetworkAttachmentOptionsModel.ID = core.StringPtr("testString") + deleteBareMetalServerNetworkAttachmentOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation with valid options model (positive test) + response, operationErr = vpcService.DeleteBareMetalServerNetworkAttachment(deleteBareMetalServerNetworkAttachmentOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) }) - It(`Invoke UpdateBackupPolicy successfully`, func() { + It(`Invoke DeleteBareMetalServerNetworkAttachment with error: Operation validation and request error`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -44571,55 +45425,49 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the BackupPolicyPatch model - backupPolicyPatchModel := new(vpcv1.BackupPolicyPatch) - backupPolicyPatchModel.IncludedContent = []string{"data_volumes"} - backupPolicyPatchModel.MatchUserTags = []string{"my-daily-backup-policy"} - backupPolicyPatchModel.Name = core.StringPtr("my-backup-policy") - backupPolicyPatchModelAsPatch, asPatchErr := backupPolicyPatchModel.AsPatch() - 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()) + // Construct an instance of the DeleteBareMetalServerNetworkAttachmentOptions model + deleteBareMetalServerNetworkAttachmentOptionsModel := new(vpcv1.DeleteBareMetalServerNetworkAttachmentOptions) + deleteBareMetalServerNetworkAttachmentOptionsModel.BareMetalServerID = core.StringPtr("testString") + deleteBareMetalServerNetworkAttachmentOptionsModel.ID = core.StringPtr("testString") + deleteBareMetalServerNetworkAttachmentOptionsModel.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.DeleteBareMetalServerNetworkAttachment(deleteBareMetalServerNetworkAttachmentOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING)) + Expect(response).To(BeNil()) + // Construct a second instance of the DeleteBareMetalServerNetworkAttachmentOptions model with no property values + deleteBareMetalServerNetworkAttachmentOptionsModelNew := new(vpcv1.DeleteBareMetalServerNetworkAttachmentOptions) + // Invoke operation with invalid model (negative test) + response, operationErr = vpcService.DeleteBareMetalServerNetworkAttachment(deleteBareMetalServerNetworkAttachmentOptionsModelNew) + Expect(operationErr).ToNot(BeNil()) + Expect(response).To(BeNil()) }) AfterEach(func() { testServer.Close() }) }) }) - Describe(`ListPlacementGroups(listPlacementGroupsOptions *ListPlacementGroupsOptions) - Operation response error`, func() { + Describe(`GetBareMetalServerNetworkAttachment(getBareMetalServerNetworkAttachmentOptions *GetBareMetalServerNetworkAttachmentOptions) - Operation response error`, func() { version := "testString" - listPlacementGroupsPath := "/placement_groups" + getBareMetalServerNetworkAttachmentPath := "/bare_metal_servers/testString/network_attachments/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(listPlacementGroupsPath)) + Expect(req.URL.EscapedPath()).To(Equal(getBareMetalServerNetworkAttachmentPath)) Expect(req.Method).To(Equal("GET")) Expect(req.URL.Query()["version"]).To(Equal([]string{"testString"})) Expect(req.URL.Query()["generation"]).To(Equal([]string{fmt.Sprint(int64(2))})) - Expect(req.URL.Query()["start"]).To(Equal([]string{"testString"})) - Expect(req.URL.Query()["limit"]).To(Equal([]string{fmt.Sprint(int64(10))})) 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 GetBareMetalServerNetworkAttachment with error: Operation response processing error`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -44628,20 +45476,20 @@ 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(10)) - listPlacementGroupsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the GetBareMetalServerNetworkAttachmentOptions model + getBareMetalServerNetworkAttachmentOptionsModel := new(vpcv1.GetBareMetalServerNetworkAttachmentOptions) + getBareMetalServerNetworkAttachmentOptionsModel.BareMetalServerID = core.StringPtr("testString") + getBareMetalServerNetworkAttachmentOptionsModel.ID = core.StringPtr("testString") + getBareMetalServerNetworkAttachmentOptionsModel.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.GetBareMetalServerNetworkAttachment(getBareMetalServerNetworkAttachmentOptionsModel) 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.GetBareMetalServerNetworkAttachment(getBareMetalServerNetworkAttachmentOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).To(BeNil()) @@ -44651,32 +45499,30 @@ var _ = Describe(`VpcV1`, func() { }) }) }) - Describe(`ListPlacementGroups(listPlacementGroupsOptions *ListPlacementGroupsOptions)`, func() { + Describe(`GetBareMetalServerNetworkAttachment(getBareMetalServerNetworkAttachmentOptions *GetBareMetalServerNetworkAttachmentOptions)`, func() { version := "testString" - listPlacementGroupsPath := "/placement_groups" + getBareMetalServerNetworkAttachmentPath := "/bare_metal_servers/testString/network_attachments/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(listPlacementGroupsPath)) + Expect(req.URL.EscapedPath()).To(Equal(getBareMetalServerNetworkAttachmentPath)) Expect(req.Method).To(Equal("GET")) Expect(req.URL.Query()["version"]).To(Equal([]string{"testString"})) Expect(req.URL.Query()["generation"]).To(Equal([]string{fmt.Sprint(int64(2))})) - Expect(req.URL.Query()["start"]).To(Equal([]string{"testString"})) - Expect(req.URL.Query()["limit"]).To(Equal([]string{fmt.Sprint(int64(10))})) // 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", `{"created_at": "2019-01-01T12:00:00.000Z", "href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/2302-f7a2bf57-af7c-49d9-b599-b2c91293d30c/network_attachments/2302-da8c43ec-b6ca-4bd2-871e-72e288c66ee6", "id": "2302-da8c43ec-b6ca-4bd2-871e-72e288c66ee6", "lifecycle_state": "stable", "name": "my-bare-metal-server-network-attachment", "port_speed": 1000, "primary_ip": {"address": "192.168.3.4", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e/reserved_ips/6d353a0f-aeb1-4ae1-832e-1110d10981bb", "id": "6d353a0f-aeb1-4ae1-832e-1110d10981bb", "name": "my-reserved-ip", "resource_type": "subnet_reserved_ip"}, "resource_type": "bare_metal_server_network_attachment", "subnet": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "id": "7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "name": "my-subnet", "resource_type": "subnet"}, "type": "primary", "virtual_network_interface": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::virtual-network-interface:0767-fa41aecb-4f21-423d-8082-630bfba1e1d9", "href": "https://us-south.iaas.cloud.ibm.com/v1/virtual_network_interfaces/0767-fa41aecb-4f21-423d-8082-630bfba1e1d9", "id": "0767-fa41aecb-4f21-423d-8082-630bfba1e1d9", "name": "my-virtual-network-interface", "resource_type": "virtual_network_interface"}, "allowed_vlans": [4], "interface_type": "pci"}`) })) }) - It(`Invoke ListPlacementGroups successfully with retries`, func() { + It(`Invoke GetBareMetalServerNetworkAttachment successfully with retries`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -44686,22 +45532,22 @@ 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(10)) - listPlacementGroupsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the GetBareMetalServerNetworkAttachmentOptions model + getBareMetalServerNetworkAttachmentOptionsModel := new(vpcv1.GetBareMetalServerNetworkAttachmentOptions) + getBareMetalServerNetworkAttachmentOptionsModel.BareMetalServerID = core.StringPtr("testString") + getBareMetalServerNetworkAttachmentOptionsModel.ID = core.StringPtr("testString") + getBareMetalServerNetworkAttachmentOptionsModel.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.GetBareMetalServerNetworkAttachmentWithContext(ctx, getBareMetalServerNetworkAttachmentOptionsModel) 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.GetBareMetalServerNetworkAttachment(getBareMetalServerNetworkAttachmentOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) @@ -44709,7 +45555,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.GetBareMetalServerNetworkAttachmentWithContext(ctx, getBareMetalServerNetworkAttachmentOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) }) @@ -44723,20 +45569,18 @@ 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(getBareMetalServerNetworkAttachmentPath)) Expect(req.Method).To(Equal("GET")) Expect(req.URL.Query()["version"]).To(Equal([]string{"testString"})) Expect(req.URL.Query()["generation"]).To(Equal([]string{fmt.Sprint(int64(2))})) - Expect(req.URL.Query()["start"]).To(Equal([]string{"testString"})) - Expect(req.URL.Query()["limit"]).To(Equal([]string{fmt.Sprint(int64(10))})) // 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", `{"created_at": "2019-01-01T12:00:00.000Z", "href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/2302-f7a2bf57-af7c-49d9-b599-b2c91293d30c/network_attachments/2302-da8c43ec-b6ca-4bd2-871e-72e288c66ee6", "id": "2302-da8c43ec-b6ca-4bd2-871e-72e288c66ee6", "lifecycle_state": "stable", "name": "my-bare-metal-server-network-attachment", "port_speed": 1000, "primary_ip": {"address": "192.168.3.4", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e/reserved_ips/6d353a0f-aeb1-4ae1-832e-1110d10981bb", "id": "6d353a0f-aeb1-4ae1-832e-1110d10981bb", "name": "my-reserved-ip", "resource_type": "subnet_reserved_ip"}, "resource_type": "bare_metal_server_network_attachment", "subnet": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "id": "7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "name": "my-subnet", "resource_type": "subnet"}, "type": "primary", "virtual_network_interface": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::virtual-network-interface:0767-fa41aecb-4f21-423d-8082-630bfba1e1d9", "href": "https://us-south.iaas.cloud.ibm.com/v1/virtual_network_interfaces/0767-fa41aecb-4f21-423d-8082-630bfba1e1d9", "id": "0767-fa41aecb-4f21-423d-8082-630bfba1e1d9", "name": "my-virtual-network-interface", "resource_type": "virtual_network_interface"}, "allowed_vlans": [4], "interface_type": "pci"}`) })) }) - It(`Invoke ListPlacementGroups successfully`, func() { + It(`Invoke GetBareMetalServerNetworkAttachment successfully`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -44746,25 +45590,25 @@ 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.GetBareMetalServerNetworkAttachment(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(10)) - listPlacementGroupsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the GetBareMetalServerNetworkAttachmentOptions model + getBareMetalServerNetworkAttachmentOptionsModel := new(vpcv1.GetBareMetalServerNetworkAttachmentOptions) + getBareMetalServerNetworkAttachmentOptionsModel.BareMetalServerID = core.StringPtr("testString") + getBareMetalServerNetworkAttachmentOptionsModel.ID = core.StringPtr("testString") + getBareMetalServerNetworkAttachmentOptionsModel.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.GetBareMetalServerNetworkAttachment(getBareMetalServerNetworkAttachmentOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) }) - It(`Invoke ListPlacementGroups with error: Operation request error`, func() { + It(`Invoke GetBareMetalServerNetworkAttachment with error: Operation validation and request error`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -44773,19 +45617,26 @@ 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(10)) - listPlacementGroupsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the GetBareMetalServerNetworkAttachmentOptions model + getBareMetalServerNetworkAttachmentOptionsModel := new(vpcv1.GetBareMetalServerNetworkAttachmentOptions) + getBareMetalServerNetworkAttachmentOptionsModel.BareMetalServerID = core.StringPtr("testString") + getBareMetalServerNetworkAttachmentOptionsModel.ID = core.StringPtr("testString") + getBareMetalServerNetworkAttachmentOptionsModel.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.GetBareMetalServerNetworkAttachment(getBareMetalServerNetworkAttachmentOptionsModel) 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 GetBareMetalServerNetworkAttachmentOptions model with no property values + getBareMetalServerNetworkAttachmentOptionsModelNew := new(vpcv1.GetBareMetalServerNetworkAttachmentOptions) + // Invoke operation with invalid model (negative test) + result, response, operationErr = vpcService.GetBareMetalServerNetworkAttachment(getBareMetalServerNetworkAttachmentOptionsModelNew) + Expect(operationErr).ToNot(BeNil()) + Expect(response).To(BeNil()) + Expect(result).To(BeNil()) }) AfterEach(func() { testServer.Close() @@ -44800,7 +45651,7 @@ var _ = Describe(`VpcV1`, func() { res.WriteHeader(200) })) }) - It(`Invoke ListPlacementGroups successfully`, func() { + It(`Invoke GetBareMetalServerNetworkAttachment successfully`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -44809,14 +45660,14 @@ 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(10)) - listPlacementGroupsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the GetBareMetalServerNetworkAttachmentOptions model + getBareMetalServerNetworkAttachmentOptionsModel := new(vpcv1.GetBareMetalServerNetworkAttachmentOptions) + getBareMetalServerNetworkAttachmentOptionsModel.BareMetalServerID = core.StringPtr("testString") + getBareMetalServerNetworkAttachmentOptionsModel.ID = core.StringPtr("testString") + getBareMetalServerNetworkAttachmentOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation - result, response, operationErr := vpcService.ListPlacementGroups(listPlacementGroupsOptionsModel) + result, response, operationErr := vpcService.GetBareMetalServerNetworkAttachment(getBareMetalServerNetworkAttachmentOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) @@ -44827,127 +45678,26 @@ var _ = Describe(`VpcV1`, 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()) - }) - }) - Context(`Using mock server endpoint - paginated response`, func() { - BeforeEach(func() { - var requestNumber int = 0 - testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { - defer GinkgoRecover() - - // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(listPlacementGroupsPath)) - Expect(req.Method).To(Equal("GET")) - - // Set mock response - res.Header().Set("Content-type", "application/json") - res.WriteHeader(200) - requestNumber++ - if requestNumber == 1 { - fmt.Fprintf(res, "%s", `{"next":{"href":"https://myhost.com/somePath?start=1"},"total_count":2,"limit":1,"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"}]}`) - } else if requestNumber == 2 { - fmt.Fprintf(res, "%s", `{"total_count":2,"limit":1,"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"}]}`) - } else { - res.WriteHeader(400) - } - })) - }) - It(`Use PlacementGroupsPager.GetNext successfully`, func() { - vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ - URL: testServer.URL, - Authenticator: &core.NoAuthAuthenticator{}, - Version: core.StringPtr(version), - }) - Expect(serviceErr).To(BeNil()) - Expect(vpcService).ToNot(BeNil()) - - listPlacementGroupsOptionsModel := &vpcv1.ListPlacementGroupsOptions{ - Limit: core.Int64Ptr(int64(10)), - } - - pager, err := vpcService.NewPlacementGroupsPager(listPlacementGroupsOptionsModel) - Expect(err).To(BeNil()) - Expect(pager).ToNot(BeNil()) - - var allResults []vpcv1.PlacementGroup - for pager.HasNext() { - nextPage, err := pager.GetNext() - Expect(err).To(BeNil()) - Expect(nextPage).ToNot(BeNil()) - allResults = append(allResults, nextPage...) - } - Expect(len(allResults)).To(Equal(2)) - }) - It(`Use PlacementGroupsPager.GetAll successfully`, func() { - vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ - URL: testServer.URL, - Authenticator: &core.NoAuthAuthenticator{}, - Version: core.StringPtr(version), - }) - Expect(serviceErr).To(BeNil()) - Expect(vpcService).ToNot(BeNil()) - - listPlacementGroupsOptionsModel := &vpcv1.ListPlacementGroupsOptions{ - Limit: core.Int64Ptr(int64(10)), - } - - pager, err := vpcService.NewPlacementGroupsPager(listPlacementGroupsOptionsModel) - Expect(err).To(BeNil()) - Expect(pager).ToNot(BeNil()) - - allResults, err := pager.GetAll() - Expect(err).To(BeNil()) - Expect(allResults).ToNot(BeNil()) - Expect(len(allResults)).To(Equal(2)) - }) - }) }) - Describe(`CreatePlacementGroup(createPlacementGroupOptions *CreatePlacementGroupOptions) - Operation response error`, func() { + Describe(`UpdateBareMetalServerNetworkAttachment(updateBareMetalServerNetworkAttachmentOptions *UpdateBareMetalServerNetworkAttachmentOptions) - Operation response error`, func() { version := "testString" - createPlacementGroupPath := "/placement_groups" + updateBareMetalServerNetworkAttachmentPath := "/bare_metal_servers/testString/network_attachments/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(createPlacementGroupPath)) - Expect(req.Method).To(Equal("POST")) + Expect(req.URL.EscapedPath()).To(Equal(updateBareMetalServerNetworkAttachmentPath)) + 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(201) + res.WriteHeader(200) fmt.Fprint(res, `} this is not valid json {`) })) }) - It(`Invoke CreatePlacementGroup with error: Operation response processing error`, func() { + It(`Invoke UpdateBareMetalServerNetworkAttachment with error: Operation response processing error`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -44956,25 +45706,28 @@ var _ = Describe(`VpcV1`, func() { 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 BareMetalServerNetworkAttachmentPatch model + bareMetalServerNetworkAttachmentPatchModel := new(vpcv1.BareMetalServerNetworkAttachmentPatch) + bareMetalServerNetworkAttachmentPatchModel.AllowedVlans = []int64{int64(4)} + bareMetalServerNetworkAttachmentPatchModel.Name = core.StringPtr("my-bare-metal-server-network-attachment-updated") + bareMetalServerNetworkAttachmentPatchModelAsPatch, asPatchErr := bareMetalServerNetworkAttachmentPatchModel.AsPatch() + Expect(asPatchErr).To(BeNil()) - // 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 UpdateBareMetalServerNetworkAttachmentOptions model + updateBareMetalServerNetworkAttachmentOptionsModel := new(vpcv1.UpdateBareMetalServerNetworkAttachmentOptions) + updateBareMetalServerNetworkAttachmentOptionsModel.BareMetalServerID = core.StringPtr("testString") + updateBareMetalServerNetworkAttachmentOptionsModel.ID = core.StringPtr("testString") + updateBareMetalServerNetworkAttachmentOptionsModel.BareMetalServerNetworkAttachmentPatch = bareMetalServerNetworkAttachmentPatchModelAsPatch + updateBareMetalServerNetworkAttachmentOptionsModel.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.UpdateBareMetalServerNetworkAttachment(updateBareMetalServerNetworkAttachmentOptionsModel) 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.UpdateBareMetalServerNetworkAttachment(updateBareMetalServerNetworkAttachmentOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).To(BeNil()) @@ -44984,17 +45737,17 @@ var _ = Describe(`VpcV1`, func() { }) }) }) - Describe(`CreatePlacementGroup(createPlacementGroupOptions *CreatePlacementGroupOptions)`, func() { + Describe(`UpdateBareMetalServerNetworkAttachment(updateBareMetalServerNetworkAttachmentOptions *UpdateBareMetalServerNetworkAttachmentOptions)`, func() { version := "testString" - createPlacementGroupPath := "/placement_groups" + updateBareMetalServerNetworkAttachmentPath := "/bare_metal_servers/testString/network_attachments/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(createPlacementGroupPath)) - Expect(req.Method).To(Equal("POST")) + Expect(req.URL.EscapedPath()).To(Equal(updateBareMetalServerNetworkAttachmentPath)) + Expect(req.Method).To(Equal("PATCH")) // For gzip-disabled operation, verify Content-Encoding is not set. Expect(req.Header.Get("Content-Encoding")).To(BeEmpty()) @@ -45019,11 +45772,11 @@ 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"}`) + res.WriteHeader(200) + fmt.Fprintf(res, "%s", `{"created_at": "2019-01-01T12:00:00.000Z", "href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/2302-f7a2bf57-af7c-49d9-b599-b2c91293d30c/network_attachments/2302-da8c43ec-b6ca-4bd2-871e-72e288c66ee6", "id": "2302-da8c43ec-b6ca-4bd2-871e-72e288c66ee6", "lifecycle_state": "stable", "name": "my-bare-metal-server-network-attachment", "port_speed": 1000, "primary_ip": {"address": "192.168.3.4", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e/reserved_ips/6d353a0f-aeb1-4ae1-832e-1110d10981bb", "id": "6d353a0f-aeb1-4ae1-832e-1110d10981bb", "name": "my-reserved-ip", "resource_type": "subnet_reserved_ip"}, "resource_type": "bare_metal_server_network_attachment", "subnet": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "id": "7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "name": "my-subnet", "resource_type": "subnet"}, "type": "primary", "virtual_network_interface": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::virtual-network-interface:0767-fa41aecb-4f21-423d-8082-630bfba1e1d9", "href": "https://us-south.iaas.cloud.ibm.com/v1/virtual_network_interfaces/0767-fa41aecb-4f21-423d-8082-630bfba1e1d9", "id": "0767-fa41aecb-4f21-423d-8082-630bfba1e1d9", "name": "my-virtual-network-interface", "resource_type": "virtual_network_interface"}, "allowed_vlans": [4], "interface_type": "pci"}`) })) }) - It(`Invoke CreatePlacementGroup successfully with retries`, func() { + It(`Invoke UpdateBareMetalServerNetworkAttachment successfully with retries`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -45033,27 +45786,30 @@ var _ = Describe(`VpcV1`, func() { 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 BareMetalServerNetworkAttachmentPatch model + bareMetalServerNetworkAttachmentPatchModel := new(vpcv1.BareMetalServerNetworkAttachmentPatch) + bareMetalServerNetworkAttachmentPatchModel.AllowedVlans = []int64{int64(4)} + bareMetalServerNetworkAttachmentPatchModel.Name = core.StringPtr("my-bare-metal-server-network-attachment-updated") + bareMetalServerNetworkAttachmentPatchModelAsPatch, asPatchErr := bareMetalServerNetworkAttachmentPatchModel.AsPatch() + Expect(asPatchErr).To(BeNil()) - // 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 UpdateBareMetalServerNetworkAttachmentOptions model + updateBareMetalServerNetworkAttachmentOptionsModel := new(vpcv1.UpdateBareMetalServerNetworkAttachmentOptions) + updateBareMetalServerNetworkAttachmentOptionsModel.BareMetalServerID = core.StringPtr("testString") + updateBareMetalServerNetworkAttachmentOptionsModel.ID = core.StringPtr("testString") + updateBareMetalServerNetworkAttachmentOptionsModel.BareMetalServerNetworkAttachmentPatch = bareMetalServerNetworkAttachmentPatchModelAsPatch + updateBareMetalServerNetworkAttachmentOptionsModel.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.UpdateBareMetalServerNetworkAttachmentWithContext(ctx, updateBareMetalServerNetworkAttachmentOptionsModel) 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.UpdateBareMetalServerNetworkAttachment(updateBareMetalServerNetworkAttachmentOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) @@ -45061,7 +45817,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.UpdateBareMetalServerNetworkAttachmentWithContext(ctx, updateBareMetalServerNetworkAttachmentOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) }) @@ -45075,8 +45831,8 @@ var _ = Describe(`VpcV1`, func() { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(createPlacementGroupPath)) - Expect(req.Method).To(Equal("POST")) + Expect(req.URL.EscapedPath()).To(Equal(updateBareMetalServerNetworkAttachmentPath)) + Expect(req.Method).To(Equal("PATCH")) // For gzip-disabled operation, verify Content-Encoding is not set. Expect(req.Header.Get("Content-Encoding")).To(BeEmpty()) @@ -45098,11 +45854,11 @@ var _ = Describe(`VpcV1`, func() { 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"}`) + res.WriteHeader(200) + fmt.Fprintf(res, "%s", `{"created_at": "2019-01-01T12:00:00.000Z", "href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/2302-f7a2bf57-af7c-49d9-b599-b2c91293d30c/network_attachments/2302-da8c43ec-b6ca-4bd2-871e-72e288c66ee6", "id": "2302-da8c43ec-b6ca-4bd2-871e-72e288c66ee6", "lifecycle_state": "stable", "name": "my-bare-metal-server-network-attachment", "port_speed": 1000, "primary_ip": {"address": "192.168.3.4", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e/reserved_ips/6d353a0f-aeb1-4ae1-832e-1110d10981bb", "id": "6d353a0f-aeb1-4ae1-832e-1110d10981bb", "name": "my-reserved-ip", "resource_type": "subnet_reserved_ip"}, "resource_type": "bare_metal_server_network_attachment", "subnet": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "id": "7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "name": "my-subnet", "resource_type": "subnet"}, "type": "primary", "virtual_network_interface": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::virtual-network-interface:0767-fa41aecb-4f21-423d-8082-630bfba1e1d9", "href": "https://us-south.iaas.cloud.ibm.com/v1/virtual_network_interfaces/0767-fa41aecb-4f21-423d-8082-630bfba1e1d9", "id": "0767-fa41aecb-4f21-423d-8082-630bfba1e1d9", "name": "my-virtual-network-interface", "resource_type": "virtual_network_interface"}, "allowed_vlans": [4], "interface_type": "pci"}`) })) }) - It(`Invoke CreatePlacementGroup successfully`, func() { + It(`Invoke UpdateBareMetalServerNetworkAttachment successfully`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -45112,30 +45868,33 @@ 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.UpdateBareMetalServerNetworkAttachment(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 BareMetalServerNetworkAttachmentPatch model + bareMetalServerNetworkAttachmentPatchModel := new(vpcv1.BareMetalServerNetworkAttachmentPatch) + bareMetalServerNetworkAttachmentPatchModel.AllowedVlans = []int64{int64(4)} + bareMetalServerNetworkAttachmentPatchModel.Name = core.StringPtr("my-bare-metal-server-network-attachment-updated") + bareMetalServerNetworkAttachmentPatchModelAsPatch, asPatchErr := bareMetalServerNetworkAttachmentPatchModel.AsPatch() + Expect(asPatchErr).To(BeNil()) - // 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 UpdateBareMetalServerNetworkAttachmentOptions model + updateBareMetalServerNetworkAttachmentOptionsModel := new(vpcv1.UpdateBareMetalServerNetworkAttachmentOptions) + updateBareMetalServerNetworkAttachmentOptionsModel.BareMetalServerID = core.StringPtr("testString") + updateBareMetalServerNetworkAttachmentOptionsModel.ID = core.StringPtr("testString") + updateBareMetalServerNetworkAttachmentOptionsModel.BareMetalServerNetworkAttachmentPatch = bareMetalServerNetworkAttachmentPatchModelAsPatch + updateBareMetalServerNetworkAttachmentOptionsModel.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.UpdateBareMetalServerNetworkAttachment(updateBareMetalServerNetworkAttachmentOptionsModel) 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 UpdateBareMetalServerNetworkAttachment with error: Operation validation and request error`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -45144,28 +45903,31 @@ var _ = Describe(`VpcV1`, func() { 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 BareMetalServerNetworkAttachmentPatch model + bareMetalServerNetworkAttachmentPatchModel := new(vpcv1.BareMetalServerNetworkAttachmentPatch) + bareMetalServerNetworkAttachmentPatchModel.AllowedVlans = []int64{int64(4)} + bareMetalServerNetworkAttachmentPatchModel.Name = core.StringPtr("my-bare-metal-server-network-attachment-updated") + bareMetalServerNetworkAttachmentPatchModelAsPatch, asPatchErr := bareMetalServerNetworkAttachmentPatchModel.AsPatch() + Expect(asPatchErr).To(BeNil()) - // 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 UpdateBareMetalServerNetworkAttachmentOptions model + updateBareMetalServerNetworkAttachmentOptionsModel := new(vpcv1.UpdateBareMetalServerNetworkAttachmentOptions) + updateBareMetalServerNetworkAttachmentOptionsModel.BareMetalServerID = core.StringPtr("testString") + updateBareMetalServerNetworkAttachmentOptionsModel.ID = core.StringPtr("testString") + updateBareMetalServerNetworkAttachmentOptionsModel.BareMetalServerNetworkAttachmentPatch = bareMetalServerNetworkAttachmentPatchModelAsPatch + updateBareMetalServerNetworkAttachmentOptionsModel.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.UpdateBareMetalServerNetworkAttachment(updateBareMetalServerNetworkAttachmentOptionsModel) 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) + // Construct a second instance of the UpdateBareMetalServerNetworkAttachmentOptions model with no property values + updateBareMetalServerNetworkAttachmentOptionsModelNew := new(vpcv1.UpdateBareMetalServerNetworkAttachmentOptions) // Invoke operation with invalid model (negative test) - result, response, operationErr = vpcService.CreatePlacementGroup(createPlacementGroupOptionsModelNew) + result, response, operationErr = vpcService.UpdateBareMetalServerNetworkAttachment(updateBareMetalServerNetworkAttachmentOptionsModelNew) Expect(operationErr).ToNot(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) @@ -45180,10 +45942,10 @@ var _ = Describe(`VpcV1`, func() { defer GinkgoRecover() // Set success status code with no respoonse body - res.WriteHeader(201) + res.WriteHeader(200) })) }) - It(`Invoke CreatePlacementGroup successfully`, func() { + It(`Invoke UpdateBareMetalServerNetworkAttachment successfully`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -45192,19 +45954,22 @@ var _ = Describe(`VpcV1`, func() { 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 BareMetalServerNetworkAttachmentPatch model + bareMetalServerNetworkAttachmentPatchModel := new(vpcv1.BareMetalServerNetworkAttachmentPatch) + bareMetalServerNetworkAttachmentPatchModel.AllowedVlans = []int64{int64(4)} + bareMetalServerNetworkAttachmentPatchModel.Name = core.StringPtr("my-bare-metal-server-network-attachment-updated") + bareMetalServerNetworkAttachmentPatchModelAsPatch, asPatchErr := bareMetalServerNetworkAttachmentPatchModel.AsPatch() + Expect(asPatchErr).To(BeNil()) - // 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 UpdateBareMetalServerNetworkAttachmentOptions model + updateBareMetalServerNetworkAttachmentOptionsModel := new(vpcv1.UpdateBareMetalServerNetworkAttachmentOptions) + updateBareMetalServerNetworkAttachmentOptionsModel.BareMetalServerID = core.StringPtr("testString") + updateBareMetalServerNetworkAttachmentOptionsModel.ID = core.StringPtr("testString") + updateBareMetalServerNetworkAttachmentOptionsModel.BareMetalServerNetworkAttachmentPatch = bareMetalServerNetworkAttachmentPatchModelAsPatch + updateBareMetalServerNetworkAttachmentOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation - result, response, operationErr := vpcService.CreatePlacementGroup(createPlacementGroupOptionsModel) + result, response, operationErr := vpcService.UpdateBareMetalServerNetworkAttachment(updateBareMetalServerNetworkAttachmentOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) @@ -45216,98 +45981,27 @@ var _ = Describe(`VpcV1`, func() { }) }) }) - 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() { + Describe(`ListBareMetalServerNetworkInterfaces(listBareMetalServerNetworkInterfacesOptions *ListBareMetalServerNetworkInterfacesOptions) - Operation response error`, func() { version := "testString" - getPlacementGroupPath := "/placement_groups/testString" + listBareMetalServerNetworkInterfacesPath := "/bare_metal_servers/testString/network_interfaces" 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(listBareMetalServerNetworkInterfacesPath)) Expect(req.Method).To(Equal("GET")) Expect(req.URL.Query()["version"]).To(Equal([]string{"testString"})) Expect(req.URL.Query()["generation"]).To(Equal([]string{fmt.Sprint(int64(2))})) + Expect(req.URL.Query()["start"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["limit"]).To(Equal([]string{fmt.Sprint(int64(10))})) 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 ListBareMetalServerNetworkInterfaces with error: Operation response processing error`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -45316,19 +46010,21 @@ 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 ListBareMetalServerNetworkInterfacesOptions model + listBareMetalServerNetworkInterfacesOptionsModel := new(vpcv1.ListBareMetalServerNetworkInterfacesOptions) + listBareMetalServerNetworkInterfacesOptionsModel.BareMetalServerID = core.StringPtr("testString") + listBareMetalServerNetworkInterfacesOptionsModel.Start = core.StringPtr("testString") + listBareMetalServerNetworkInterfacesOptionsModel.Limit = core.Int64Ptr(int64(10)) + listBareMetalServerNetworkInterfacesOptionsModel.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.ListBareMetalServerNetworkInterfaces(listBareMetalServerNetworkInterfacesOptionsModel) 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.ListBareMetalServerNetworkInterfaces(listBareMetalServerNetworkInterfacesOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).To(BeNil()) @@ -45338,30 +46034,32 @@ var _ = Describe(`VpcV1`, func() { }) }) }) - Describe(`GetPlacementGroup(getPlacementGroupOptions *GetPlacementGroupOptions)`, func() { + Describe(`ListBareMetalServerNetworkInterfaces(listBareMetalServerNetworkInterfacesOptions *ListBareMetalServerNetworkInterfacesOptions)`, func() { version := "testString" - getPlacementGroupPath := "/placement_groups/testString" + listBareMetalServerNetworkInterfacesPath := "/bare_metal_servers/testString/network_interfaces" 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(listBareMetalServerNetworkInterfacesPath)) Expect(req.Method).To(Equal("GET")) Expect(req.URL.Query()["version"]).To(Equal([]string{"testString"})) Expect(req.URL.Query()["generation"]).To(Equal([]string{fmt.Sprint(int64(2))})) + Expect(req.URL.Query()["start"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["limit"]).To(Equal([]string{fmt.Sprint(int64(10))})) // 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", `{"first": {"href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/3b2669a2-4c2b-4003-bc91-1b81f1326267/network_interfaces?limit=20"}, "limit": 20, "network_interfaces": [{"allow_ip_spoofing": true, "created_at": "2019-01-01T12:00:00.000Z", "enable_infrastructure_nat": true, "floating_ips": [{"address": "203.0.113.1", "crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::floating-ip:39300233-9995-4806-89a5-3c1b6eb88689", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/floating_ips/39300233-9995-4806-89a5-3c1b6eb88689", "id": "39300233-9995-4806-89a5-3c1b6eb88689", "name": "my-floating-ip"}], "href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/1e09281b-f177-46fb-baf1-bc152b2e391a/network_interfaces/10c02d81-0ecb-4dc5-897d-28392913b81e", "id": "10c02d81-0ecb-4dc5-897d-28392913b81e", "mac_address": "02:00:04:00:C4:6A", "name": "my-bare-metal-server-network-interface", "port_speed": 1000, "primary_ip": {"address": "192.168.3.4", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e/reserved_ips/6d353a0f-aeb1-4ae1-832e-1110d10981bb", "id": "6d353a0f-aeb1-4ae1-832e-1110d10981bb", "name": "my-reserved-ip", "resource_type": "subnet_reserved_ip"}, "resource_type": "network_interface", "security_groups": [{"crn": "crn:v1:bluemix:public:is:us-south:a/123456::security-group:be5df5ca-12a0-494b-907e-aa6ec2bfa271", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/security_groups/be5df5ca-12a0-494b-907e-aa6ec2bfa271", "id": "be5df5ca-12a0-494b-907e-aa6ec2bfa271", "name": "my-security-group"}], "status": "available", "subnet": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "id": "7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "name": "my-subnet", "resource_type": "subnet"}, "type": "primary", "interface_type": "hipersocket"}], "next": {"href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/3b2669a2-4c2b-4003-bc91-1b81f1326267/network_interfaces?start=d3e721fd-c988-4670-9927-dbd5e7b07fc6&limit=20"}, "total_count": 132}`) })) }) - It(`Invoke GetPlacementGroup successfully with retries`, func() { + It(`Invoke ListBareMetalServerNetworkInterfaces successfully with retries`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -45371,21 +46069,23 @@ 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 ListBareMetalServerNetworkInterfacesOptions model + listBareMetalServerNetworkInterfacesOptionsModel := new(vpcv1.ListBareMetalServerNetworkInterfacesOptions) + listBareMetalServerNetworkInterfacesOptionsModel.BareMetalServerID = core.StringPtr("testString") + listBareMetalServerNetworkInterfacesOptionsModel.Start = core.StringPtr("testString") + listBareMetalServerNetworkInterfacesOptionsModel.Limit = core.Int64Ptr(int64(10)) + listBareMetalServerNetworkInterfacesOptionsModel.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.ListBareMetalServerNetworkInterfacesWithContext(ctx, listBareMetalServerNetworkInterfacesOptionsModel) 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.ListBareMetalServerNetworkInterfaces(listBareMetalServerNetworkInterfacesOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) @@ -45393,7 +46093,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.ListBareMetalServerNetworkInterfacesWithContext(ctx, listBareMetalServerNetworkInterfacesOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) }) @@ -45407,18 +46107,20 @@ 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(listBareMetalServerNetworkInterfacesPath)) Expect(req.Method).To(Equal("GET")) Expect(req.URL.Query()["version"]).To(Equal([]string{"testString"})) Expect(req.URL.Query()["generation"]).To(Equal([]string{fmt.Sprint(int64(2))})) + Expect(req.URL.Query()["start"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["limit"]).To(Equal([]string{fmt.Sprint(int64(10))})) // 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", `{"first": {"href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/3b2669a2-4c2b-4003-bc91-1b81f1326267/network_interfaces?limit=20"}, "limit": 20, "network_interfaces": [{"allow_ip_spoofing": true, "created_at": "2019-01-01T12:00:00.000Z", "enable_infrastructure_nat": true, "floating_ips": [{"address": "203.0.113.1", "crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::floating-ip:39300233-9995-4806-89a5-3c1b6eb88689", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/floating_ips/39300233-9995-4806-89a5-3c1b6eb88689", "id": "39300233-9995-4806-89a5-3c1b6eb88689", "name": "my-floating-ip"}], "href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/1e09281b-f177-46fb-baf1-bc152b2e391a/network_interfaces/10c02d81-0ecb-4dc5-897d-28392913b81e", "id": "10c02d81-0ecb-4dc5-897d-28392913b81e", "mac_address": "02:00:04:00:C4:6A", "name": "my-bare-metal-server-network-interface", "port_speed": 1000, "primary_ip": {"address": "192.168.3.4", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e/reserved_ips/6d353a0f-aeb1-4ae1-832e-1110d10981bb", "id": "6d353a0f-aeb1-4ae1-832e-1110d10981bb", "name": "my-reserved-ip", "resource_type": "subnet_reserved_ip"}, "resource_type": "network_interface", "security_groups": [{"crn": "crn:v1:bluemix:public:is:us-south:a/123456::security-group:be5df5ca-12a0-494b-907e-aa6ec2bfa271", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/security_groups/be5df5ca-12a0-494b-907e-aa6ec2bfa271", "id": "be5df5ca-12a0-494b-907e-aa6ec2bfa271", "name": "my-security-group"}], "status": "available", "subnet": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "id": "7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "name": "my-subnet", "resource_type": "subnet"}, "type": "primary", "interface_type": "hipersocket"}], "next": {"href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/3b2669a2-4c2b-4003-bc91-1b81f1326267/network_interfaces?start=d3e721fd-c988-4670-9927-dbd5e7b07fc6&limit=20"}, "total_count": 132}`) })) }) - It(`Invoke GetPlacementGroup successfully`, func() { + It(`Invoke ListBareMetalServerNetworkInterfaces successfully`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -45428,24 +46130,26 @@ 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.ListBareMetalServerNetworkInterfaces(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 ListBareMetalServerNetworkInterfacesOptions model + listBareMetalServerNetworkInterfacesOptionsModel := new(vpcv1.ListBareMetalServerNetworkInterfacesOptions) + listBareMetalServerNetworkInterfacesOptionsModel.BareMetalServerID = core.StringPtr("testString") + listBareMetalServerNetworkInterfacesOptionsModel.Start = core.StringPtr("testString") + listBareMetalServerNetworkInterfacesOptionsModel.Limit = core.Int64Ptr(int64(10)) + listBareMetalServerNetworkInterfacesOptionsModel.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.ListBareMetalServerNetworkInterfaces(listBareMetalServerNetworkInterfacesOptionsModel) 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 ListBareMetalServerNetworkInterfaces with error: Operation validation and request error`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -45454,22 +46158,24 @@ 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 ListBareMetalServerNetworkInterfacesOptions model + listBareMetalServerNetworkInterfacesOptionsModel := new(vpcv1.ListBareMetalServerNetworkInterfacesOptions) + listBareMetalServerNetworkInterfacesOptionsModel.BareMetalServerID = core.StringPtr("testString") + listBareMetalServerNetworkInterfacesOptionsModel.Start = core.StringPtr("testString") + listBareMetalServerNetworkInterfacesOptionsModel.Limit = core.Int64Ptr(int64(10)) + listBareMetalServerNetworkInterfacesOptionsModel.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.ListBareMetalServerNetworkInterfaces(listBareMetalServerNetworkInterfacesOptionsModel) 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 ListBareMetalServerNetworkInterfacesOptions model with no property values + listBareMetalServerNetworkInterfacesOptionsModelNew := new(vpcv1.ListBareMetalServerNetworkInterfacesOptions) // Invoke operation with invalid model (negative test) - result, response, operationErr = vpcService.GetPlacementGroup(getPlacementGroupOptionsModelNew) + result, response, operationErr = vpcService.ListBareMetalServerNetworkInterfaces(listBareMetalServerNetworkInterfacesOptionsModelNew) Expect(operationErr).ToNot(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) @@ -45487,7 +46193,7 @@ var _ = Describe(`VpcV1`, func() { res.WriteHeader(200) })) }) - It(`Invoke GetPlacementGroup successfully`, func() { + It(`Invoke ListBareMetalServerNetworkInterfaces successfully`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -45496,13 +46202,15 @@ 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 ListBareMetalServerNetworkInterfacesOptions model + listBareMetalServerNetworkInterfacesOptionsModel := new(vpcv1.ListBareMetalServerNetworkInterfacesOptions) + listBareMetalServerNetworkInterfacesOptionsModel.BareMetalServerID = core.StringPtr("testString") + listBareMetalServerNetworkInterfacesOptionsModel.Start = core.StringPtr("testString") + listBareMetalServerNetworkInterfacesOptionsModel.Limit = core.Int64Ptr(int64(10)) + listBareMetalServerNetworkInterfacesOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation - result, response, operationErr := vpcService.GetPlacementGroup(getPlacementGroupOptionsModel) + result, response, operationErr := vpcService.ListBareMetalServerNetworkInterfaces(listBareMetalServerNetworkInterfacesOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) @@ -45513,26 +46221,129 @@ var _ = Describe(`VpcV1`, func() { testServer.Close() }) }) + Context(`Test pagination helper method on response`, func() { + It(`Invoke GetNextStart successfully`, func() { + responseObject := new(vpcv1.BareMetalServerNetworkInterfaceCollection) + nextObject := new(vpcv1.BareMetalServerNetworkInterfaceCollectionNext) + 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.BareMetalServerNetworkInterfaceCollection) + + 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.BareMetalServerNetworkInterfaceCollection) + nextObject := new(vpcv1.BareMetalServerNetworkInterfaceCollectionNext) + nextObject.Href = core.StringPtr("ibm.com") + responseObject.Next = nextObject + + value, err := responseObject.GetNextStart() + Expect(err).To(BeNil()) + Expect(value).To(BeNil()) + }) + }) + Context(`Using mock server endpoint - paginated response`, func() { + BeforeEach(func() { + var requestNumber int = 0 + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Verify the contents of the request + Expect(req.URL.EscapedPath()).To(Equal(listBareMetalServerNetworkInterfacesPath)) + Expect(req.Method).To(Equal("GET")) + + // Set mock response + res.Header().Set("Content-type", "application/json") + res.WriteHeader(200) + requestNumber++ + if requestNumber == 1 { + fmt.Fprintf(res, "%s", `{"next":{"href":"https://myhost.com/somePath?start=1"},"total_count":2,"limit":1,"network_interfaces":[{"allow_ip_spoofing":true,"created_at":"2019-01-01T12:00:00.000Z","enable_infrastructure_nat":true,"floating_ips":[{"address":"203.0.113.1","crn":"crn:v1:bluemix:public:is:us-south-1:a/123456::floating-ip:39300233-9995-4806-89a5-3c1b6eb88689","deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/floating_ips/39300233-9995-4806-89a5-3c1b6eb88689","id":"39300233-9995-4806-89a5-3c1b6eb88689","name":"my-floating-ip"}],"href":"https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/1e09281b-f177-46fb-baf1-bc152b2e391a/network_interfaces/10c02d81-0ecb-4dc5-897d-28392913b81e","id":"10c02d81-0ecb-4dc5-897d-28392913b81e","mac_address":"02:00:04:00:C4:6A","name":"my-bare-metal-server-network-interface","port_speed":1000,"primary_ip":{"address":"192.168.3.4","deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e/reserved_ips/6d353a0f-aeb1-4ae1-832e-1110d10981bb","id":"6d353a0f-aeb1-4ae1-832e-1110d10981bb","name":"my-reserved-ip","resource_type":"subnet_reserved_ip"},"resource_type":"network_interface","security_groups":[{"crn":"crn:v1:bluemix:public:is:us-south:a/123456::security-group:be5df5ca-12a0-494b-907e-aa6ec2bfa271","deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/security_groups/be5df5ca-12a0-494b-907e-aa6ec2bfa271","id":"be5df5ca-12a0-494b-907e-aa6ec2bfa271","name":"my-security-group"}],"status":"available","subnet":{"crn":"crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e","deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e","id":"7ec86020-1c6e-4889-b3f0-a15f2e50f87e","name":"my-subnet","resource_type":"subnet"},"type":"primary","interface_type":"hipersocket"}]}`) + } else if requestNumber == 2 { + fmt.Fprintf(res, "%s", `{"total_count":2,"limit":1,"network_interfaces":[{"allow_ip_spoofing":true,"created_at":"2019-01-01T12:00:00.000Z","enable_infrastructure_nat":true,"floating_ips":[{"address":"203.0.113.1","crn":"crn:v1:bluemix:public:is:us-south-1:a/123456::floating-ip:39300233-9995-4806-89a5-3c1b6eb88689","deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/floating_ips/39300233-9995-4806-89a5-3c1b6eb88689","id":"39300233-9995-4806-89a5-3c1b6eb88689","name":"my-floating-ip"}],"href":"https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/1e09281b-f177-46fb-baf1-bc152b2e391a/network_interfaces/10c02d81-0ecb-4dc5-897d-28392913b81e","id":"10c02d81-0ecb-4dc5-897d-28392913b81e","mac_address":"02:00:04:00:C4:6A","name":"my-bare-metal-server-network-interface","port_speed":1000,"primary_ip":{"address":"192.168.3.4","deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e/reserved_ips/6d353a0f-aeb1-4ae1-832e-1110d10981bb","id":"6d353a0f-aeb1-4ae1-832e-1110d10981bb","name":"my-reserved-ip","resource_type":"subnet_reserved_ip"},"resource_type":"network_interface","security_groups":[{"crn":"crn:v1:bluemix:public:is:us-south:a/123456::security-group:be5df5ca-12a0-494b-907e-aa6ec2bfa271","deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/security_groups/be5df5ca-12a0-494b-907e-aa6ec2bfa271","id":"be5df5ca-12a0-494b-907e-aa6ec2bfa271","name":"my-security-group"}],"status":"available","subnet":{"crn":"crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e","deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e","id":"7ec86020-1c6e-4889-b3f0-a15f2e50f87e","name":"my-subnet","resource_type":"subnet"},"type":"primary","interface_type":"hipersocket"}]}`) + } else { + res.WriteHeader(400) + } + })) + }) + It(`Use BareMetalServerNetworkInterfacesPager.GetNext successfully`, func() { + vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + Version: core.StringPtr(version), + }) + Expect(serviceErr).To(BeNil()) + Expect(vpcService).ToNot(BeNil()) + + listBareMetalServerNetworkInterfacesOptionsModel := &vpcv1.ListBareMetalServerNetworkInterfacesOptions{ + BareMetalServerID: core.StringPtr("testString"), + Limit: core.Int64Ptr(int64(10)), + } + + pager, err := vpcService.NewBareMetalServerNetworkInterfacesPager(listBareMetalServerNetworkInterfacesOptionsModel) + Expect(err).To(BeNil()) + Expect(pager).ToNot(BeNil()) + + var allResults []vpcv1.BareMetalServerNetworkInterfaceIntf + for pager.HasNext() { + nextPage, err := pager.GetNext() + Expect(err).To(BeNil()) + Expect(nextPage).ToNot(BeNil()) + allResults = append(allResults, nextPage...) + } + Expect(len(allResults)).To(Equal(2)) + }) + It(`Use BareMetalServerNetworkInterfacesPager.GetAll successfully`, func() { + vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + Version: core.StringPtr(version), + }) + Expect(serviceErr).To(BeNil()) + Expect(vpcService).ToNot(BeNil()) + + listBareMetalServerNetworkInterfacesOptionsModel := &vpcv1.ListBareMetalServerNetworkInterfacesOptions{ + BareMetalServerID: core.StringPtr("testString"), + Limit: core.Int64Ptr(int64(10)), + } + + pager, err := vpcService.NewBareMetalServerNetworkInterfacesPager(listBareMetalServerNetworkInterfacesOptionsModel) + Expect(err).To(BeNil()) + Expect(pager).ToNot(BeNil()) + + allResults, err := pager.GetAll() + Expect(err).To(BeNil()) + Expect(allResults).ToNot(BeNil()) + Expect(len(allResults)).To(Equal(2)) + }) + }) }) - Describe(`UpdatePlacementGroup(updatePlacementGroupOptions *UpdatePlacementGroupOptions) - Operation response error`, func() { + Describe(`CreateBareMetalServerNetworkInterface(createBareMetalServerNetworkInterfaceOptions *CreateBareMetalServerNetworkInterfaceOptions) - Operation response error`, func() { version := "testString" - updatePlacementGroupPath := "/placement_groups/testString" + createBareMetalServerNetworkInterfacePath := "/bare_metal_servers/testString/network_interfaces" 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(createBareMetalServerNetworkInterfacePath)) + 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 CreateBareMetalServerNetworkInterface with error: Operation response processing error`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -45541,26 +46352,44 @@ 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 NetworkInterfaceIPPrototypeReservedIPPrototypeNetworkInterfaceContext model + networkInterfaceIPPrototypeModel := new(vpcv1.NetworkInterfaceIPPrototypeReservedIPPrototypeNetworkInterfaceContext) + networkInterfaceIPPrototypeModel.Address = core.StringPtr("10.0.0.5") + networkInterfaceIPPrototypeModel.AutoDelete = core.BoolPtr(false) + networkInterfaceIPPrototypeModel.Name = core.StringPtr("my-reserved-ip") - // 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 SecurityGroupIdentityByID model + securityGroupIdentityModel := new(vpcv1.SecurityGroupIdentityByID) + securityGroupIdentityModel.ID = core.StringPtr("be5df5ca-12a0-494b-907e-aa6ec2bfa271") + + // Construct an instance of the SubnetIdentityByID model + subnetIdentityModel := new(vpcv1.SubnetIdentityByID) + subnetIdentityModel.ID = core.StringPtr("7ec86020-1c6e-4889-b3f0-a15f2e50f87e") + + // Construct an instance of the BareMetalServerNetworkInterfacePrototypeBareMetalServerNetworkInterfaceByHiperSocketPrototype model + bareMetalServerNetworkInterfacePrototypeModel := new(vpcv1.BareMetalServerNetworkInterfacePrototypeBareMetalServerNetworkInterfaceByHiperSocketPrototype) + bareMetalServerNetworkInterfacePrototypeModel.AllowIPSpoofing = core.BoolPtr(true) + bareMetalServerNetworkInterfacePrototypeModel.EnableInfrastructureNat = core.BoolPtr(true) + bareMetalServerNetworkInterfacePrototypeModel.Name = core.StringPtr("my-bare-metal-server-network-interface") + bareMetalServerNetworkInterfacePrototypeModel.PrimaryIP = networkInterfaceIPPrototypeModel + bareMetalServerNetworkInterfacePrototypeModel.SecurityGroups = []vpcv1.SecurityGroupIdentityIntf{securityGroupIdentityModel} + bareMetalServerNetworkInterfacePrototypeModel.Subnet = subnetIdentityModel + bareMetalServerNetworkInterfacePrototypeModel.InterfaceType = core.StringPtr("hipersocket") + + // Construct an instance of the CreateBareMetalServerNetworkInterfaceOptions model + createBareMetalServerNetworkInterfaceOptionsModel := new(vpcv1.CreateBareMetalServerNetworkInterfaceOptions) + createBareMetalServerNetworkInterfaceOptionsModel.BareMetalServerID = core.StringPtr("testString") + createBareMetalServerNetworkInterfaceOptionsModel.BareMetalServerNetworkInterfacePrototype = bareMetalServerNetworkInterfacePrototypeModel + createBareMetalServerNetworkInterfaceOptionsModel.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.CreateBareMetalServerNetworkInterface(createBareMetalServerNetworkInterfaceOptionsModel) 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.CreateBareMetalServerNetworkInterface(createBareMetalServerNetworkInterfaceOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).To(BeNil()) @@ -45570,17 +46399,17 @@ var _ = Describe(`VpcV1`, func() { }) }) }) - Describe(`UpdatePlacementGroup(updatePlacementGroupOptions *UpdatePlacementGroupOptions)`, func() { + Describe(`CreateBareMetalServerNetworkInterface(createBareMetalServerNetworkInterfaceOptions *CreateBareMetalServerNetworkInterfaceOptions)`, func() { version := "testString" - updatePlacementGroupPath := "/placement_groups/testString" + createBareMetalServerNetworkInterfacePath := "/bare_metal_servers/testString/network_interfaces" 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(createBareMetalServerNetworkInterfacePath)) + Expect(req.Method).To(Equal("POST")) // For gzip-disabled operation, verify Content-Encoding is not set. Expect(req.Header.Get("Content-Encoding")).To(BeEmpty()) @@ -45605,11 +46434,11 @@ var _ = Describe(`VpcV1`, func() { // Set mock response res.Header().Set("Content-type", "application/json") - res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south:a/123456::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"}`) + res.WriteHeader(201) + fmt.Fprintf(res, "%s", `{"allow_ip_spoofing": true, "created_at": "2019-01-01T12:00:00.000Z", "enable_infrastructure_nat": true, "floating_ips": [{"address": "203.0.113.1", "crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::floating-ip:39300233-9995-4806-89a5-3c1b6eb88689", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/floating_ips/39300233-9995-4806-89a5-3c1b6eb88689", "id": "39300233-9995-4806-89a5-3c1b6eb88689", "name": "my-floating-ip"}], "href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/1e09281b-f177-46fb-baf1-bc152b2e391a/network_interfaces/10c02d81-0ecb-4dc5-897d-28392913b81e", "id": "10c02d81-0ecb-4dc5-897d-28392913b81e", "mac_address": "02:00:04:00:C4:6A", "name": "my-bare-metal-server-network-interface", "port_speed": 1000, "primary_ip": {"address": "192.168.3.4", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e/reserved_ips/6d353a0f-aeb1-4ae1-832e-1110d10981bb", "id": "6d353a0f-aeb1-4ae1-832e-1110d10981bb", "name": "my-reserved-ip", "resource_type": "subnet_reserved_ip"}, "resource_type": "network_interface", "security_groups": [{"crn": "crn:v1:bluemix:public:is:us-south:a/123456::security-group:be5df5ca-12a0-494b-907e-aa6ec2bfa271", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/security_groups/be5df5ca-12a0-494b-907e-aa6ec2bfa271", "id": "be5df5ca-12a0-494b-907e-aa6ec2bfa271", "name": "my-security-group"}], "status": "available", "subnet": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "id": "7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "name": "my-subnet", "resource_type": "subnet"}, "type": "primary", "interface_type": "hipersocket"}`) })) }) - It(`Invoke UpdatePlacementGroup successfully with retries`, func() { + It(`Invoke CreateBareMetalServerNetworkInterface successfully with retries`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -45619,28 +46448,46 @@ var _ = Describe(`VpcV1`, func() { Expect(vpcService).ToNot(BeNil()) vpcService.EnableRetries(0, 0) - // 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 NetworkInterfaceIPPrototypeReservedIPPrototypeNetworkInterfaceContext model + networkInterfaceIPPrototypeModel := new(vpcv1.NetworkInterfaceIPPrototypeReservedIPPrototypeNetworkInterfaceContext) + networkInterfaceIPPrototypeModel.Address = core.StringPtr("10.0.0.5") + networkInterfaceIPPrototypeModel.AutoDelete = core.BoolPtr(false) + networkInterfaceIPPrototypeModel.Name = core.StringPtr("my-reserved-ip") - // 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 SecurityGroupIdentityByID model + securityGroupIdentityModel := new(vpcv1.SecurityGroupIdentityByID) + securityGroupIdentityModel.ID = core.StringPtr("be5df5ca-12a0-494b-907e-aa6ec2bfa271") + + // Construct an instance of the SubnetIdentityByID model + subnetIdentityModel := new(vpcv1.SubnetIdentityByID) + subnetIdentityModel.ID = core.StringPtr("7ec86020-1c6e-4889-b3f0-a15f2e50f87e") + + // Construct an instance of the BareMetalServerNetworkInterfacePrototypeBareMetalServerNetworkInterfaceByHiperSocketPrototype model + bareMetalServerNetworkInterfacePrototypeModel := new(vpcv1.BareMetalServerNetworkInterfacePrototypeBareMetalServerNetworkInterfaceByHiperSocketPrototype) + bareMetalServerNetworkInterfacePrototypeModel.AllowIPSpoofing = core.BoolPtr(true) + bareMetalServerNetworkInterfacePrototypeModel.EnableInfrastructureNat = core.BoolPtr(true) + bareMetalServerNetworkInterfacePrototypeModel.Name = core.StringPtr("my-bare-metal-server-network-interface") + bareMetalServerNetworkInterfacePrototypeModel.PrimaryIP = networkInterfaceIPPrototypeModel + bareMetalServerNetworkInterfacePrototypeModel.SecurityGroups = []vpcv1.SecurityGroupIdentityIntf{securityGroupIdentityModel} + bareMetalServerNetworkInterfacePrototypeModel.Subnet = subnetIdentityModel + bareMetalServerNetworkInterfacePrototypeModel.InterfaceType = core.StringPtr("hipersocket") + + // Construct an instance of the CreateBareMetalServerNetworkInterfaceOptions model + createBareMetalServerNetworkInterfaceOptionsModel := new(vpcv1.CreateBareMetalServerNetworkInterfaceOptions) + createBareMetalServerNetworkInterfaceOptionsModel.BareMetalServerID = core.StringPtr("testString") + createBareMetalServerNetworkInterfaceOptionsModel.BareMetalServerNetworkInterfacePrototype = bareMetalServerNetworkInterfacePrototypeModel + createBareMetalServerNetworkInterfaceOptionsModel.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.UpdatePlacementGroupWithContext(ctx, updatePlacementGroupOptionsModel) + _, _, operationErr := vpcService.CreateBareMetalServerNetworkInterfaceWithContext(ctx, createBareMetalServerNetworkInterfaceOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) // Disable retries and test again vpcService.DisableRetries() - result, response, operationErr := vpcService.UpdatePlacementGroup(updatePlacementGroupOptionsModel) + result, response, operationErr := vpcService.CreateBareMetalServerNetworkInterface(createBareMetalServerNetworkInterfaceOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) @@ -45648,7 +46495,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.UpdatePlacementGroupWithContext(ctx, updatePlacementGroupOptionsModel) + _, _, operationErr = vpcService.CreateBareMetalServerNetworkInterfaceWithContext(ctx, createBareMetalServerNetworkInterfaceOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) }) @@ -45662,34 +46509,222 @@ var _ = Describe(`VpcV1`, func() { 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()) - - // 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.EscapedPath()).To(Equal(createBareMetalServerNetworkInterfacePath)) + 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", `{"allow_ip_spoofing": true, "created_at": "2019-01-01T12:00:00.000Z", "enable_infrastructure_nat": true, "floating_ips": [{"address": "203.0.113.1", "crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::floating-ip:39300233-9995-4806-89a5-3c1b6eb88689", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/floating_ips/39300233-9995-4806-89a5-3c1b6eb88689", "id": "39300233-9995-4806-89a5-3c1b6eb88689", "name": "my-floating-ip"}], "href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/1e09281b-f177-46fb-baf1-bc152b2e391a/network_interfaces/10c02d81-0ecb-4dc5-897d-28392913b81e", "id": "10c02d81-0ecb-4dc5-897d-28392913b81e", "mac_address": "02:00:04:00:C4:6A", "name": "my-bare-metal-server-network-interface", "port_speed": 1000, "primary_ip": {"address": "192.168.3.4", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e/reserved_ips/6d353a0f-aeb1-4ae1-832e-1110d10981bb", "id": "6d353a0f-aeb1-4ae1-832e-1110d10981bb", "name": "my-reserved-ip", "resource_type": "subnet_reserved_ip"}, "resource_type": "network_interface", "security_groups": [{"crn": "crn:v1:bluemix:public:is:us-south:a/123456::security-group:be5df5ca-12a0-494b-907e-aa6ec2bfa271", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/security_groups/be5df5ca-12a0-494b-907e-aa6ec2bfa271", "id": "be5df5ca-12a0-494b-907e-aa6ec2bfa271", "name": "my-security-group"}], "status": "available", "subnet": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "id": "7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "name": "my-subnet", "resource_type": "subnet"}, "type": "primary", "interface_type": "hipersocket"}`) + })) + }) + It(`Invoke CreateBareMetalServerNetworkInterface 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.CreateBareMetalServerNetworkInterface(nil) + Expect(operationErr).NotTo(BeNil()) + Expect(response).To(BeNil()) + Expect(result).To(BeNil()) + + // Construct an instance of the NetworkInterfaceIPPrototypeReservedIPPrototypeNetworkInterfaceContext model + networkInterfaceIPPrototypeModel := new(vpcv1.NetworkInterfaceIPPrototypeReservedIPPrototypeNetworkInterfaceContext) + networkInterfaceIPPrototypeModel.Address = core.StringPtr("10.0.0.5") + networkInterfaceIPPrototypeModel.AutoDelete = core.BoolPtr(false) + networkInterfaceIPPrototypeModel.Name = core.StringPtr("my-reserved-ip") + + // Construct an instance of the SecurityGroupIdentityByID model + securityGroupIdentityModel := new(vpcv1.SecurityGroupIdentityByID) + securityGroupIdentityModel.ID = core.StringPtr("be5df5ca-12a0-494b-907e-aa6ec2bfa271") + + // Construct an instance of the SubnetIdentityByID model + subnetIdentityModel := new(vpcv1.SubnetIdentityByID) + subnetIdentityModel.ID = core.StringPtr("7ec86020-1c6e-4889-b3f0-a15f2e50f87e") + + // Construct an instance of the BareMetalServerNetworkInterfacePrototypeBareMetalServerNetworkInterfaceByHiperSocketPrototype model + bareMetalServerNetworkInterfacePrototypeModel := new(vpcv1.BareMetalServerNetworkInterfacePrototypeBareMetalServerNetworkInterfaceByHiperSocketPrototype) + bareMetalServerNetworkInterfacePrototypeModel.AllowIPSpoofing = core.BoolPtr(true) + bareMetalServerNetworkInterfacePrototypeModel.EnableInfrastructureNat = core.BoolPtr(true) + bareMetalServerNetworkInterfacePrototypeModel.Name = core.StringPtr("my-bare-metal-server-network-interface") + bareMetalServerNetworkInterfacePrototypeModel.PrimaryIP = networkInterfaceIPPrototypeModel + bareMetalServerNetworkInterfacePrototypeModel.SecurityGroups = []vpcv1.SecurityGroupIdentityIntf{securityGroupIdentityModel} + bareMetalServerNetworkInterfacePrototypeModel.Subnet = subnetIdentityModel + bareMetalServerNetworkInterfacePrototypeModel.InterfaceType = core.StringPtr("hipersocket") + + // Construct an instance of the CreateBareMetalServerNetworkInterfaceOptions model + createBareMetalServerNetworkInterfaceOptionsModel := new(vpcv1.CreateBareMetalServerNetworkInterfaceOptions) + createBareMetalServerNetworkInterfaceOptionsModel.BareMetalServerID = core.StringPtr("testString") + createBareMetalServerNetworkInterfaceOptionsModel.BareMetalServerNetworkInterfacePrototype = bareMetalServerNetworkInterfacePrototypeModel + createBareMetalServerNetworkInterfaceOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation with valid options model (positive test) + result, response, operationErr = vpcService.CreateBareMetalServerNetworkInterface(createBareMetalServerNetworkInterfaceOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).ToNot(BeNil()) + + }) + It(`Invoke CreateBareMetalServerNetworkInterface 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 NetworkInterfaceIPPrototypeReservedIPPrototypeNetworkInterfaceContext model + networkInterfaceIPPrototypeModel := new(vpcv1.NetworkInterfaceIPPrototypeReservedIPPrototypeNetworkInterfaceContext) + networkInterfaceIPPrototypeModel.Address = core.StringPtr("10.0.0.5") + networkInterfaceIPPrototypeModel.AutoDelete = core.BoolPtr(false) + networkInterfaceIPPrototypeModel.Name = core.StringPtr("my-reserved-ip") + + // Construct an instance of the SecurityGroupIdentityByID model + securityGroupIdentityModel := new(vpcv1.SecurityGroupIdentityByID) + securityGroupIdentityModel.ID = core.StringPtr("be5df5ca-12a0-494b-907e-aa6ec2bfa271") + + // Construct an instance of the SubnetIdentityByID model + subnetIdentityModel := new(vpcv1.SubnetIdentityByID) + subnetIdentityModel.ID = core.StringPtr("7ec86020-1c6e-4889-b3f0-a15f2e50f87e") + + // Construct an instance of the BareMetalServerNetworkInterfacePrototypeBareMetalServerNetworkInterfaceByHiperSocketPrototype model + bareMetalServerNetworkInterfacePrototypeModel := new(vpcv1.BareMetalServerNetworkInterfacePrototypeBareMetalServerNetworkInterfaceByHiperSocketPrototype) + bareMetalServerNetworkInterfacePrototypeModel.AllowIPSpoofing = core.BoolPtr(true) + bareMetalServerNetworkInterfacePrototypeModel.EnableInfrastructureNat = core.BoolPtr(true) + bareMetalServerNetworkInterfacePrototypeModel.Name = core.StringPtr("my-bare-metal-server-network-interface") + bareMetalServerNetworkInterfacePrototypeModel.PrimaryIP = networkInterfaceIPPrototypeModel + bareMetalServerNetworkInterfacePrototypeModel.SecurityGroups = []vpcv1.SecurityGroupIdentityIntf{securityGroupIdentityModel} + bareMetalServerNetworkInterfacePrototypeModel.Subnet = subnetIdentityModel + bareMetalServerNetworkInterfacePrototypeModel.InterfaceType = core.StringPtr("hipersocket") + + // Construct an instance of the CreateBareMetalServerNetworkInterfaceOptions model + createBareMetalServerNetworkInterfaceOptionsModel := new(vpcv1.CreateBareMetalServerNetworkInterfaceOptions) + createBareMetalServerNetworkInterfaceOptionsModel.BareMetalServerID = core.StringPtr("testString") + createBareMetalServerNetworkInterfaceOptionsModel.BareMetalServerNetworkInterfacePrototype = bareMetalServerNetworkInterfacePrototypeModel + createBareMetalServerNetworkInterfaceOptionsModel.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.CreateBareMetalServerNetworkInterface(createBareMetalServerNetworkInterfaceOptionsModel) + 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 CreateBareMetalServerNetworkInterfaceOptions model with no property values + createBareMetalServerNetworkInterfaceOptionsModelNew := new(vpcv1.CreateBareMetalServerNetworkInterfaceOptions) + // Invoke operation with invalid model (negative test) + result, response, operationErr = vpcService.CreateBareMetalServerNetworkInterface(createBareMetalServerNetworkInterfaceOptionsModelNew) + 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 CreateBareMetalServerNetworkInterface 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 NetworkInterfaceIPPrototypeReservedIPPrototypeNetworkInterfaceContext model + networkInterfaceIPPrototypeModel := new(vpcv1.NetworkInterfaceIPPrototypeReservedIPPrototypeNetworkInterfaceContext) + networkInterfaceIPPrototypeModel.Address = core.StringPtr("10.0.0.5") + networkInterfaceIPPrototypeModel.AutoDelete = core.BoolPtr(false) + networkInterfaceIPPrototypeModel.Name = core.StringPtr("my-reserved-ip") + + // Construct an instance of the SecurityGroupIdentityByID model + securityGroupIdentityModel := new(vpcv1.SecurityGroupIdentityByID) + securityGroupIdentityModel.ID = core.StringPtr("be5df5ca-12a0-494b-907e-aa6ec2bfa271") + + // Construct an instance of the SubnetIdentityByID model + subnetIdentityModel := new(vpcv1.SubnetIdentityByID) + subnetIdentityModel.ID = core.StringPtr("7ec86020-1c6e-4889-b3f0-a15f2e50f87e") + + // Construct an instance of the BareMetalServerNetworkInterfacePrototypeBareMetalServerNetworkInterfaceByHiperSocketPrototype model + bareMetalServerNetworkInterfacePrototypeModel := new(vpcv1.BareMetalServerNetworkInterfacePrototypeBareMetalServerNetworkInterfaceByHiperSocketPrototype) + bareMetalServerNetworkInterfacePrototypeModel.AllowIPSpoofing = core.BoolPtr(true) + bareMetalServerNetworkInterfacePrototypeModel.EnableInfrastructureNat = core.BoolPtr(true) + bareMetalServerNetworkInterfacePrototypeModel.Name = core.StringPtr("my-bare-metal-server-network-interface") + bareMetalServerNetworkInterfacePrototypeModel.PrimaryIP = networkInterfaceIPPrototypeModel + bareMetalServerNetworkInterfacePrototypeModel.SecurityGroups = []vpcv1.SecurityGroupIdentityIntf{securityGroupIdentityModel} + bareMetalServerNetworkInterfacePrototypeModel.Subnet = subnetIdentityModel + bareMetalServerNetworkInterfacePrototypeModel.InterfaceType = core.StringPtr("hipersocket") + + // Construct an instance of the CreateBareMetalServerNetworkInterfaceOptions model + createBareMetalServerNetworkInterfaceOptionsModel := new(vpcv1.CreateBareMetalServerNetworkInterfaceOptions) + createBareMetalServerNetworkInterfaceOptionsModel.BareMetalServerID = core.StringPtr("testString") + createBareMetalServerNetworkInterfaceOptionsModel.BareMetalServerNetworkInterfacePrototype = bareMetalServerNetworkInterfacePrototypeModel + createBareMetalServerNetworkInterfaceOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation + result, response, operationErr := vpcService.CreateBareMetalServerNetworkInterface(createBareMetalServerNetworkInterfaceOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + + // Verify a nil result + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + }) + Describe(`DeleteBareMetalServerNetworkInterface(deleteBareMetalServerNetworkInterfaceOptions *DeleteBareMetalServerNetworkInterfaceOptions)`, func() { + version := "testString" + deleteBareMetalServerNetworkInterfacePath := "/bare_metal_servers/testString/network_interfaces/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(deleteBareMetalServerNetworkInterfacePath)) + 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))})) - // 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"}`) + res.WriteHeader(204) })) }) - It(`Invoke UpdatePlacementGroup successfully`, func() { + It(`Invoke DeleteBareMetalServerNetworkInterface successfully`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -45699,31 +46734,22 @@ var _ = Describe(`VpcV1`, func() { Expect(vpcService).ToNot(BeNil()) // Invoke operation with nil options model (negative test) - result, response, operationErr := vpcService.UpdatePlacementGroup(nil) + response, operationErr := vpcService.DeleteBareMetalServerNetworkInterface(nil) Expect(operationErr).NotTo(BeNil()) Expect(response).To(BeNil()) - Expect(result).To(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"} + // Construct an instance of the DeleteBareMetalServerNetworkInterfaceOptions model + deleteBareMetalServerNetworkInterfaceOptionsModel := new(vpcv1.DeleteBareMetalServerNetworkInterfaceOptions) + deleteBareMetalServerNetworkInterfaceOptionsModel.BareMetalServerID = core.StringPtr("testString") + deleteBareMetalServerNetworkInterfaceOptionsModel.ID = core.StringPtr("testString") + deleteBareMetalServerNetworkInterfaceOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with valid options model (positive test) - result, response, operationErr = vpcService.UpdatePlacementGroup(updatePlacementGroupOptionsModel) + response, operationErr = vpcService.DeleteBareMetalServerNetworkInterface(deleteBareMetalServerNetworkInterfaceOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) - Expect(result).ToNot(BeNil()) - }) - It(`Invoke UpdatePlacementGroup with error: Operation validation and request error`, func() { + It(`Invoke DeleteBareMetalServerNetworkInterface with error: Operation validation and request error`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -45732,101 +46758,49 @@ 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 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 DeleteBareMetalServerNetworkInterfaceOptions model + deleteBareMetalServerNetworkInterfaceOptionsModel := new(vpcv1.DeleteBareMetalServerNetworkInterfaceOptions) + deleteBareMetalServerNetworkInterfaceOptionsModel.BareMetalServerID = core.StringPtr("testString") + deleteBareMetalServerNetworkInterfaceOptionsModel.ID = core.StringPtr("testString") + deleteBareMetalServerNetworkInterfaceOptionsModel.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.UpdatePlacementGroup(updatePlacementGroupOptionsModel) + response, operationErr := vpcService.DeleteBareMetalServerNetworkInterface(deleteBareMetalServerNetworkInterfaceOptionsModel) 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 UpdatePlacementGroupOptions model with no property values - updatePlacementGroupOptionsModelNew := new(vpcv1.UpdatePlacementGroupOptions) + // Construct a second instance of the DeleteBareMetalServerNetworkInterfaceOptions model with no property values + deleteBareMetalServerNetworkInterfaceOptionsModelNew := new(vpcv1.DeleteBareMetalServerNetworkInterfaceOptions) // Invoke operation with invalid model (negative test) - result, response, operationErr = vpcService.UpdatePlacementGroup(updatePlacementGroupOptionsModelNew) + response, operationErr = vpcService.DeleteBareMetalServerNetworkInterface(deleteBareMetalServerNetworkInterfaceOptionsModelNew) 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 UpdatePlacementGroup 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 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"} - - // Invoke operation - result, response, operationErr := vpcService.UpdatePlacementGroup(updatePlacementGroupOptionsModel) - Expect(operationErr).To(BeNil()) - Expect(response).ToNot(BeNil()) - - // Verify a nil result - Expect(result).To(BeNil()) }) AfterEach(func() { testServer.Close() }) }) }) - Describe(`ListBareMetalServerProfiles(listBareMetalServerProfilesOptions *ListBareMetalServerProfilesOptions) - Operation response error`, func() { + Describe(`GetBareMetalServerNetworkInterface(getBareMetalServerNetworkInterfaceOptions *GetBareMetalServerNetworkInterfaceOptions) - Operation response error`, func() { version := "testString" - listBareMetalServerProfilesPath := "/bare_metal_server/profiles" + getBareMetalServerNetworkInterfacePath := "/bare_metal_servers/testString/network_interfaces/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(listBareMetalServerProfilesPath)) + Expect(req.URL.EscapedPath()).To(Equal(getBareMetalServerNetworkInterfacePath)) Expect(req.Method).To(Equal("GET")) Expect(req.URL.Query()["version"]).To(Equal([]string{"testString"})) Expect(req.URL.Query()["generation"]).To(Equal([]string{fmt.Sprint(int64(2))})) - Expect(req.URL.Query()["start"]).To(Equal([]string{"testString"})) - Expect(req.URL.Query()["limit"]).To(Equal([]string{fmt.Sprint(int64(10))})) res.Header().Set("Content-type", "application/json") res.WriteHeader(200) fmt.Fprint(res, `} this is not valid json {`) })) }) - It(`Invoke ListBareMetalServerProfiles with error: Operation response processing error`, func() { + It(`Invoke GetBareMetalServerNetworkInterface with error: Operation response processing error`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -45835,20 +46809,20 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the ListBareMetalServerProfilesOptions model - listBareMetalServerProfilesOptionsModel := new(vpcv1.ListBareMetalServerProfilesOptions) - listBareMetalServerProfilesOptionsModel.Start = core.StringPtr("testString") - listBareMetalServerProfilesOptionsModel.Limit = core.Int64Ptr(int64(10)) - listBareMetalServerProfilesOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the GetBareMetalServerNetworkInterfaceOptions model + getBareMetalServerNetworkInterfaceOptionsModel := new(vpcv1.GetBareMetalServerNetworkInterfaceOptions) + getBareMetalServerNetworkInterfaceOptionsModel.BareMetalServerID = core.StringPtr("testString") + getBareMetalServerNetworkInterfaceOptionsModel.ID = core.StringPtr("testString") + getBareMetalServerNetworkInterfaceOptionsModel.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.ListBareMetalServerProfiles(listBareMetalServerProfilesOptionsModel) + result, response, operationErr := vpcService.GetBareMetalServerNetworkInterface(getBareMetalServerNetworkInterfaceOptionsModel) 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.ListBareMetalServerProfiles(listBareMetalServerProfilesOptionsModel) + result, response, operationErr = vpcService.GetBareMetalServerNetworkInterface(getBareMetalServerNetworkInterfaceOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).To(BeNil()) @@ -45858,32 +46832,30 @@ var _ = Describe(`VpcV1`, func() { }) }) }) - Describe(`ListBareMetalServerProfiles(listBareMetalServerProfilesOptions *ListBareMetalServerProfilesOptions)`, func() { + Describe(`GetBareMetalServerNetworkInterface(getBareMetalServerNetworkInterfaceOptions *GetBareMetalServerNetworkInterfaceOptions)`, func() { version := "testString" - listBareMetalServerProfilesPath := "/bare_metal_server/profiles" + getBareMetalServerNetworkInterfacePath := "/bare_metal_servers/testString/network_interfaces/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(listBareMetalServerProfilesPath)) + Expect(req.URL.EscapedPath()).To(Equal(getBareMetalServerNetworkInterfacePath)) Expect(req.Method).To(Equal("GET")) Expect(req.URL.Query()["version"]).To(Equal([]string{"testString"})) Expect(req.URL.Query()["generation"]).To(Equal([]string{fmt.Sprint(int64(2))})) - Expect(req.URL.Query()["start"]).To(Equal([]string{"testString"})) - Expect(req.URL.Query()["limit"]).To(Equal([]string{fmt.Sprint(int64(10))})) // 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/bare_metal_servers/profiles?limit=20"}, "limit": 20, "next": {"href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/profiles?start=9d5a91a3e2cbd233b5a5b33436855ed1&limit=20"}, "profiles": [{"bandwidth": {"type": "fixed", "value": 20000}, "console_types": {"type": "enum", "values": ["serial"]}, "cpu_architecture": {"default": "amd64", "type": "fixed", "value": "amd64"}, "cpu_core_count": {"type": "fixed", "value": 80}, "cpu_socket_count": {"type": "fixed", "value": 4}, "disks": [{"quantity": {"type": "fixed", "value": 4}, "size": {"type": "fixed", "value": 100}, "supported_interface_types": {"default": "fcp", "type": "enum", "values": ["fcp"]}}], "family": "balanced", "href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/profiles/bx2-metal-192x768", "memory": {"type": "fixed", "value": 16}, "name": "bx2-metal-192x768", "network_attachment_count": {"max": 128, "min": 1, "type": "range"}, "network_interface_count": {"max": 128, "min": 1, "type": "range"}, "os_architecture": {"default": "amd64", "type": "enum", "values": ["amd64"]}, "resource_type": "bare_metal_server_profile", "supported_trusted_platform_module_modes": {"type": "enum", "values": ["disabled"]}, "virtual_network_interfaces_supported": {"type": "fixed", "value": false}}], "total_count": 132}`) + fmt.Fprintf(res, "%s", `{"allow_ip_spoofing": true, "created_at": "2019-01-01T12:00:00.000Z", "enable_infrastructure_nat": true, "floating_ips": [{"address": "203.0.113.1", "crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::floating-ip:39300233-9995-4806-89a5-3c1b6eb88689", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/floating_ips/39300233-9995-4806-89a5-3c1b6eb88689", "id": "39300233-9995-4806-89a5-3c1b6eb88689", "name": "my-floating-ip"}], "href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/1e09281b-f177-46fb-baf1-bc152b2e391a/network_interfaces/10c02d81-0ecb-4dc5-897d-28392913b81e", "id": "10c02d81-0ecb-4dc5-897d-28392913b81e", "mac_address": "02:00:04:00:C4:6A", "name": "my-bare-metal-server-network-interface", "port_speed": 1000, "primary_ip": {"address": "192.168.3.4", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e/reserved_ips/6d353a0f-aeb1-4ae1-832e-1110d10981bb", "id": "6d353a0f-aeb1-4ae1-832e-1110d10981bb", "name": "my-reserved-ip", "resource_type": "subnet_reserved_ip"}, "resource_type": "network_interface", "security_groups": [{"crn": "crn:v1:bluemix:public:is:us-south:a/123456::security-group:be5df5ca-12a0-494b-907e-aa6ec2bfa271", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/security_groups/be5df5ca-12a0-494b-907e-aa6ec2bfa271", "id": "be5df5ca-12a0-494b-907e-aa6ec2bfa271", "name": "my-security-group"}], "status": "available", "subnet": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "id": "7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "name": "my-subnet", "resource_type": "subnet"}, "type": "primary", "interface_type": "hipersocket"}`) })) }) - It(`Invoke ListBareMetalServerProfiles successfully with retries`, func() { + It(`Invoke GetBareMetalServerNetworkInterface successfully with retries`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -45893,22 +46865,22 @@ var _ = Describe(`VpcV1`, func() { Expect(vpcService).ToNot(BeNil()) vpcService.EnableRetries(0, 0) - // Construct an instance of the ListBareMetalServerProfilesOptions model - listBareMetalServerProfilesOptionsModel := new(vpcv1.ListBareMetalServerProfilesOptions) - listBareMetalServerProfilesOptionsModel.Start = core.StringPtr("testString") - listBareMetalServerProfilesOptionsModel.Limit = core.Int64Ptr(int64(10)) - listBareMetalServerProfilesOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the GetBareMetalServerNetworkInterfaceOptions model + getBareMetalServerNetworkInterfaceOptionsModel := new(vpcv1.GetBareMetalServerNetworkInterfaceOptions) + getBareMetalServerNetworkInterfaceOptionsModel.BareMetalServerID = core.StringPtr("testString") + getBareMetalServerNetworkInterfaceOptionsModel.ID = core.StringPtr("testString") + getBareMetalServerNetworkInterfaceOptionsModel.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.ListBareMetalServerProfilesWithContext(ctx, listBareMetalServerProfilesOptionsModel) + _, _, operationErr := vpcService.GetBareMetalServerNetworkInterfaceWithContext(ctx, getBareMetalServerNetworkInterfaceOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) // Disable retries and test again vpcService.DisableRetries() - result, response, operationErr := vpcService.ListBareMetalServerProfiles(listBareMetalServerProfilesOptionsModel) + result, response, operationErr := vpcService.GetBareMetalServerNetworkInterface(getBareMetalServerNetworkInterfaceOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) @@ -45916,7 +46888,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.ListBareMetalServerProfilesWithContext(ctx, listBareMetalServerProfilesOptionsModel) + _, _, operationErr = vpcService.GetBareMetalServerNetworkInterfaceWithContext(ctx, getBareMetalServerNetworkInterfaceOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) }) @@ -45930,20 +46902,18 @@ var _ = Describe(`VpcV1`, func() { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(listBareMetalServerProfilesPath)) + Expect(req.URL.EscapedPath()).To(Equal(getBareMetalServerNetworkInterfacePath)) Expect(req.Method).To(Equal("GET")) Expect(req.URL.Query()["version"]).To(Equal([]string{"testString"})) Expect(req.URL.Query()["generation"]).To(Equal([]string{fmt.Sprint(int64(2))})) - Expect(req.URL.Query()["start"]).To(Equal([]string{"testString"})) - Expect(req.URL.Query()["limit"]).To(Equal([]string{fmt.Sprint(int64(10))})) // 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/bare_metal_servers/profiles?limit=20"}, "limit": 20, "next": {"href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/profiles?start=9d5a91a3e2cbd233b5a5b33436855ed1&limit=20"}, "profiles": [{"bandwidth": {"type": "fixed", "value": 20000}, "console_types": {"type": "enum", "values": ["serial"]}, "cpu_architecture": {"default": "amd64", "type": "fixed", "value": "amd64"}, "cpu_core_count": {"type": "fixed", "value": 80}, "cpu_socket_count": {"type": "fixed", "value": 4}, "disks": [{"quantity": {"type": "fixed", "value": 4}, "size": {"type": "fixed", "value": 100}, "supported_interface_types": {"default": "fcp", "type": "enum", "values": ["fcp"]}}], "family": "balanced", "href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/profiles/bx2-metal-192x768", "memory": {"type": "fixed", "value": 16}, "name": "bx2-metal-192x768", "network_attachment_count": {"max": 128, "min": 1, "type": "range"}, "network_interface_count": {"max": 128, "min": 1, "type": "range"}, "os_architecture": {"default": "amd64", "type": "enum", "values": ["amd64"]}, "resource_type": "bare_metal_server_profile", "supported_trusted_platform_module_modes": {"type": "enum", "values": ["disabled"]}, "virtual_network_interfaces_supported": {"type": "fixed", "value": false}}], "total_count": 132}`) + fmt.Fprintf(res, "%s", `{"allow_ip_spoofing": true, "created_at": "2019-01-01T12:00:00.000Z", "enable_infrastructure_nat": true, "floating_ips": [{"address": "203.0.113.1", "crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::floating-ip:39300233-9995-4806-89a5-3c1b6eb88689", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/floating_ips/39300233-9995-4806-89a5-3c1b6eb88689", "id": "39300233-9995-4806-89a5-3c1b6eb88689", "name": "my-floating-ip"}], "href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/1e09281b-f177-46fb-baf1-bc152b2e391a/network_interfaces/10c02d81-0ecb-4dc5-897d-28392913b81e", "id": "10c02d81-0ecb-4dc5-897d-28392913b81e", "mac_address": "02:00:04:00:C4:6A", "name": "my-bare-metal-server-network-interface", "port_speed": 1000, "primary_ip": {"address": "192.168.3.4", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e/reserved_ips/6d353a0f-aeb1-4ae1-832e-1110d10981bb", "id": "6d353a0f-aeb1-4ae1-832e-1110d10981bb", "name": "my-reserved-ip", "resource_type": "subnet_reserved_ip"}, "resource_type": "network_interface", "security_groups": [{"crn": "crn:v1:bluemix:public:is:us-south:a/123456::security-group:be5df5ca-12a0-494b-907e-aa6ec2bfa271", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/security_groups/be5df5ca-12a0-494b-907e-aa6ec2bfa271", "id": "be5df5ca-12a0-494b-907e-aa6ec2bfa271", "name": "my-security-group"}], "status": "available", "subnet": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "id": "7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "name": "my-subnet", "resource_type": "subnet"}, "type": "primary", "interface_type": "hipersocket"}`) })) }) - It(`Invoke ListBareMetalServerProfiles successfully`, func() { + It(`Invoke GetBareMetalServerNetworkInterface successfully`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -45953,25 +46923,25 @@ var _ = Describe(`VpcV1`, func() { Expect(vpcService).ToNot(BeNil()) // Invoke operation with nil options model (negative test) - result, response, operationErr := vpcService.ListBareMetalServerProfiles(nil) + result, response, operationErr := vpcService.GetBareMetalServerNetworkInterface(nil) Expect(operationErr).NotTo(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) - // Construct an instance of the ListBareMetalServerProfilesOptions model - listBareMetalServerProfilesOptionsModel := new(vpcv1.ListBareMetalServerProfilesOptions) - listBareMetalServerProfilesOptionsModel.Start = core.StringPtr("testString") - listBareMetalServerProfilesOptionsModel.Limit = core.Int64Ptr(int64(10)) - listBareMetalServerProfilesOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the GetBareMetalServerNetworkInterfaceOptions model + getBareMetalServerNetworkInterfaceOptionsModel := new(vpcv1.GetBareMetalServerNetworkInterfaceOptions) + getBareMetalServerNetworkInterfaceOptionsModel.BareMetalServerID = core.StringPtr("testString") + getBareMetalServerNetworkInterfaceOptionsModel.ID = core.StringPtr("testString") + getBareMetalServerNetworkInterfaceOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with valid options model (positive test) - result, response, operationErr = vpcService.ListBareMetalServerProfiles(listBareMetalServerProfilesOptionsModel) + result, response, operationErr = vpcService.GetBareMetalServerNetworkInterface(getBareMetalServerNetworkInterfaceOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) }) - It(`Invoke ListBareMetalServerProfiles with error: Operation request error`, func() { + It(`Invoke GetBareMetalServerNetworkInterface with error: Operation validation and request error`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -45980,19 +46950,26 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the ListBareMetalServerProfilesOptions model - listBareMetalServerProfilesOptionsModel := new(vpcv1.ListBareMetalServerProfilesOptions) - listBareMetalServerProfilesOptionsModel.Start = core.StringPtr("testString") - listBareMetalServerProfilesOptionsModel.Limit = core.Int64Ptr(int64(10)) - listBareMetalServerProfilesOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the GetBareMetalServerNetworkInterfaceOptions model + getBareMetalServerNetworkInterfaceOptionsModel := new(vpcv1.GetBareMetalServerNetworkInterfaceOptions) + getBareMetalServerNetworkInterfaceOptionsModel.BareMetalServerID = core.StringPtr("testString") + getBareMetalServerNetworkInterfaceOptionsModel.ID = core.StringPtr("testString") + getBareMetalServerNetworkInterfaceOptionsModel.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.ListBareMetalServerProfiles(listBareMetalServerProfilesOptionsModel) + result, response, operationErr := vpcService.GetBareMetalServerNetworkInterface(getBareMetalServerNetworkInterfaceOptionsModel) 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 GetBareMetalServerNetworkInterfaceOptions model with no property values + getBareMetalServerNetworkInterfaceOptionsModelNew := new(vpcv1.GetBareMetalServerNetworkInterfaceOptions) + // Invoke operation with invalid model (negative test) + result, response, operationErr = vpcService.GetBareMetalServerNetworkInterface(getBareMetalServerNetworkInterfaceOptionsModelNew) + Expect(operationErr).ToNot(BeNil()) + Expect(response).To(BeNil()) + Expect(result).To(BeNil()) }) AfterEach(func() { testServer.Close() @@ -46007,7 +46984,7 @@ var _ = Describe(`VpcV1`, func() { res.WriteHeader(200) })) }) - It(`Invoke ListBareMetalServerProfiles successfully`, func() { + It(`Invoke GetBareMetalServerNetworkInterface successfully`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -46016,14 +46993,14 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the ListBareMetalServerProfilesOptions model - listBareMetalServerProfilesOptionsModel := new(vpcv1.ListBareMetalServerProfilesOptions) - listBareMetalServerProfilesOptionsModel.Start = core.StringPtr("testString") - listBareMetalServerProfilesOptionsModel.Limit = core.Int64Ptr(int64(10)) - listBareMetalServerProfilesOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the GetBareMetalServerNetworkInterfaceOptions model + getBareMetalServerNetworkInterfaceOptionsModel := new(vpcv1.GetBareMetalServerNetworkInterfaceOptions) + getBareMetalServerNetworkInterfaceOptionsModel.BareMetalServerID = core.StringPtr("testString") + getBareMetalServerNetworkInterfaceOptionsModel.ID = core.StringPtr("testString") + getBareMetalServerNetworkInterfaceOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation - result, response, operationErr := vpcService.ListBareMetalServerProfiles(listBareMetalServerProfilesOptionsModel) + result, response, operationErr := vpcService.GetBareMetalServerNetworkInterface(getBareMetalServerNetworkInterfaceOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) @@ -46034,119 +47011,18 @@ var _ = Describe(`VpcV1`, func() { testServer.Close() }) }) - Context(`Test pagination helper method on response`, func() { - It(`Invoke GetNextStart successfully`, func() { - responseObject := new(vpcv1.BareMetalServerProfileCollection) - nextObject := new(vpcv1.BareMetalServerProfileCollectionNext) - 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.BareMetalServerProfileCollection) - - 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.BareMetalServerProfileCollection) - nextObject := new(vpcv1.BareMetalServerProfileCollectionNext) - nextObject.Href = core.StringPtr("ibm.com") - responseObject.Next = nextObject - - value, err := responseObject.GetNextStart() - Expect(err).To(BeNil()) - Expect(value).To(BeNil()) - }) - }) - Context(`Using mock server endpoint - paginated response`, func() { - BeforeEach(func() { - var requestNumber int = 0 - testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { - defer GinkgoRecover() - - // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(listBareMetalServerProfilesPath)) - Expect(req.Method).To(Equal("GET")) - - // Set mock response - res.Header().Set("Content-type", "application/json") - res.WriteHeader(200) - requestNumber++ - if requestNumber == 1 { - fmt.Fprintf(res, "%s", `{"next":{"href":"https://myhost.com/somePath?start=1"},"total_count":2,"limit":1,"profiles":[{"bandwidth":{"type":"fixed","value":20000},"console_types":{"type":"enum","values":["serial"]},"cpu_architecture":{"default":"amd64","type":"fixed","value":"amd64"},"cpu_core_count":{"type":"fixed","value":80},"cpu_socket_count":{"type":"fixed","value":4},"disks":[{"quantity":{"type":"fixed","value":4},"size":{"type":"fixed","value":100},"supported_interface_types":{"default":"fcp","type":"enum","values":["fcp"]}}],"family":"balanced","href":"https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/profiles/bx2-metal-192x768","memory":{"type":"fixed","value":16},"name":"bx2-metal-192x768","network_attachment_count":{"max":128,"min":1,"type":"range"},"network_interface_count":{"max":128,"min":1,"type":"range"},"os_architecture":{"default":"amd64","type":"enum","values":["amd64"]},"resource_type":"bare_metal_server_profile","supported_trusted_platform_module_modes":{"type":"enum","values":["disabled"]},"virtual_network_interfaces_supported":{"type":"fixed","value":false}}]}`) - } else if requestNumber == 2 { - fmt.Fprintf(res, "%s", `{"total_count":2,"limit":1,"profiles":[{"bandwidth":{"type":"fixed","value":20000},"console_types":{"type":"enum","values":["serial"]},"cpu_architecture":{"default":"amd64","type":"fixed","value":"amd64"},"cpu_core_count":{"type":"fixed","value":80},"cpu_socket_count":{"type":"fixed","value":4},"disks":[{"quantity":{"type":"fixed","value":4},"size":{"type":"fixed","value":100},"supported_interface_types":{"default":"fcp","type":"enum","values":["fcp"]}}],"family":"balanced","href":"https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/profiles/bx2-metal-192x768","memory":{"type":"fixed","value":16},"name":"bx2-metal-192x768","network_attachment_count":{"max":128,"min":1,"type":"range"},"network_interface_count":{"max":128,"min":1,"type":"range"},"os_architecture":{"default":"amd64","type":"enum","values":["amd64"]},"resource_type":"bare_metal_server_profile","supported_trusted_platform_module_modes":{"type":"enum","values":["disabled"]},"virtual_network_interfaces_supported":{"type":"fixed","value":false}}]}`) - } else { - res.WriteHeader(400) - } - })) - }) - It(`Use BareMetalServerProfilesPager.GetNext successfully`, func() { - vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ - URL: testServer.URL, - Authenticator: &core.NoAuthAuthenticator{}, - Version: core.StringPtr(version), - }) - Expect(serviceErr).To(BeNil()) - Expect(vpcService).ToNot(BeNil()) - - listBareMetalServerProfilesOptionsModel := &vpcv1.ListBareMetalServerProfilesOptions{ - Limit: core.Int64Ptr(int64(10)), - } - - pager, err := vpcService.NewBareMetalServerProfilesPager(listBareMetalServerProfilesOptionsModel) - Expect(err).To(BeNil()) - Expect(pager).ToNot(BeNil()) - - var allResults []vpcv1.BareMetalServerProfile - for pager.HasNext() { - nextPage, err := pager.GetNext() - Expect(err).To(BeNil()) - Expect(nextPage).ToNot(BeNil()) - allResults = append(allResults, nextPage...) - } - Expect(len(allResults)).To(Equal(2)) - }) - It(`Use BareMetalServerProfilesPager.GetAll successfully`, func() { - vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ - URL: testServer.URL, - Authenticator: &core.NoAuthAuthenticator{}, - Version: core.StringPtr(version), - }) - Expect(serviceErr).To(BeNil()) - Expect(vpcService).ToNot(BeNil()) - - listBareMetalServerProfilesOptionsModel := &vpcv1.ListBareMetalServerProfilesOptions{ - Limit: core.Int64Ptr(int64(10)), - } - - pager, err := vpcService.NewBareMetalServerProfilesPager(listBareMetalServerProfilesOptionsModel) - Expect(err).To(BeNil()) - Expect(pager).ToNot(BeNil()) - - allResults, err := pager.GetAll() - Expect(err).To(BeNil()) - Expect(allResults).ToNot(BeNil()) - Expect(len(allResults)).To(Equal(2)) - }) - }) }) - Describe(`GetBareMetalServerProfile(getBareMetalServerProfileOptions *GetBareMetalServerProfileOptions) - Operation response error`, func() { + Describe(`UpdateBareMetalServerNetworkInterface(updateBareMetalServerNetworkInterfaceOptions *UpdateBareMetalServerNetworkInterfaceOptions) - Operation response error`, func() { version := "testString" - getBareMetalServerProfilePath := "/bare_metal_server/profiles/testString" + updateBareMetalServerNetworkInterfacePath := "/bare_metal_servers/testString/network_interfaces/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(getBareMetalServerProfilePath)) - Expect(req.Method).To(Equal("GET")) + Expect(req.URL.EscapedPath()).To(Equal(updateBareMetalServerNetworkInterfacePath)) + 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") @@ -46154,7 +47030,7 @@ var _ = Describe(`VpcV1`, func() { fmt.Fprint(res, `} this is not valid json {`) })) }) - It(`Invoke GetBareMetalServerProfile with error: Operation response processing error`, func() { + It(`Invoke UpdateBareMetalServerNetworkInterface with error: Operation response processing error`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -46163,19 +47039,30 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the GetBareMetalServerProfileOptions model - getBareMetalServerProfileOptionsModel := new(vpcv1.GetBareMetalServerProfileOptions) - getBareMetalServerProfileOptionsModel.Name = core.StringPtr("testString") - getBareMetalServerProfileOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the BareMetalServerNetworkInterfacePatch model + bareMetalServerNetworkInterfacePatchModel := new(vpcv1.BareMetalServerNetworkInterfacePatch) + bareMetalServerNetworkInterfacePatchModel.AllowIPSpoofing = core.BoolPtr(true) + bareMetalServerNetworkInterfacePatchModel.AllowedVlans = []int64{int64(4)} + bareMetalServerNetworkInterfacePatchModel.EnableInfrastructureNat = core.BoolPtr(true) + bareMetalServerNetworkInterfacePatchModel.Name = core.StringPtr("my-bare-metal-server-network-interface") + bareMetalServerNetworkInterfacePatchModelAsPatch, asPatchErr := bareMetalServerNetworkInterfacePatchModel.AsPatch() + Expect(asPatchErr).To(BeNil()) + + // Construct an instance of the UpdateBareMetalServerNetworkInterfaceOptions model + updateBareMetalServerNetworkInterfaceOptionsModel := new(vpcv1.UpdateBareMetalServerNetworkInterfaceOptions) + updateBareMetalServerNetworkInterfaceOptionsModel.BareMetalServerID = core.StringPtr("testString") + updateBareMetalServerNetworkInterfaceOptionsModel.ID = core.StringPtr("testString") + updateBareMetalServerNetworkInterfaceOptionsModel.BareMetalServerNetworkInterfacePatch = bareMetalServerNetworkInterfacePatchModelAsPatch + updateBareMetalServerNetworkInterfaceOptionsModel.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.GetBareMetalServerProfile(getBareMetalServerProfileOptionsModel) + result, response, operationErr := vpcService.UpdateBareMetalServerNetworkInterface(updateBareMetalServerNetworkInterfaceOptionsModel) 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.GetBareMetalServerProfile(getBareMetalServerProfileOptionsModel) + result, response, operationErr = vpcService.UpdateBareMetalServerNetworkInterface(updateBareMetalServerNetworkInterfaceOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).To(BeNil()) @@ -46185,17 +47072,33 @@ var _ = Describe(`VpcV1`, func() { }) }) }) - Describe(`GetBareMetalServerProfile(getBareMetalServerProfileOptions *GetBareMetalServerProfileOptions)`, func() { + Describe(`UpdateBareMetalServerNetworkInterface(updateBareMetalServerNetworkInterfaceOptions *UpdateBareMetalServerNetworkInterfaceOptions)`, func() { version := "testString" - getBareMetalServerProfilePath := "/bare_metal_server/profiles/testString" + updateBareMetalServerNetworkInterfacePath := "/bare_metal_servers/testString/network_interfaces/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(getBareMetalServerProfilePath)) - Expect(req.Method).To(Equal("GET")) + Expect(req.URL.EscapedPath()).To(Equal(updateBareMetalServerNetworkInterfacePath)) + 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.URL.Query()["version"]).To(Equal([]string{"testString"})) Expect(req.URL.Query()["generation"]).To(Equal([]string{fmt.Sprint(int64(2))})) @@ -46205,10 +47108,10 @@ var _ = Describe(`VpcV1`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"bandwidth": {"type": "fixed", "value": 20000}, "console_types": {"type": "enum", "values": ["serial"]}, "cpu_architecture": {"default": "amd64", "type": "fixed", "value": "amd64"}, "cpu_core_count": {"type": "fixed", "value": 80}, "cpu_socket_count": {"type": "fixed", "value": 4}, "disks": [{"quantity": {"type": "fixed", "value": 4}, "size": {"type": "fixed", "value": 100}, "supported_interface_types": {"default": "fcp", "type": "enum", "values": ["fcp"]}}], "family": "balanced", "href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/profiles/bx2-metal-192x768", "memory": {"type": "fixed", "value": 16}, "name": "bx2-metal-192x768", "network_attachment_count": {"max": 128, "min": 1, "type": "range"}, "network_interface_count": {"max": 128, "min": 1, "type": "range"}, "os_architecture": {"default": "amd64", "type": "enum", "values": ["amd64"]}, "resource_type": "bare_metal_server_profile", "supported_trusted_platform_module_modes": {"type": "enum", "values": ["disabled"]}, "virtual_network_interfaces_supported": {"type": "fixed", "value": false}}`) + fmt.Fprintf(res, "%s", `{"allow_ip_spoofing": true, "created_at": "2019-01-01T12:00:00.000Z", "enable_infrastructure_nat": true, "floating_ips": [{"address": "203.0.113.1", "crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::floating-ip:39300233-9995-4806-89a5-3c1b6eb88689", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/floating_ips/39300233-9995-4806-89a5-3c1b6eb88689", "id": "39300233-9995-4806-89a5-3c1b6eb88689", "name": "my-floating-ip"}], "href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/1e09281b-f177-46fb-baf1-bc152b2e391a/network_interfaces/10c02d81-0ecb-4dc5-897d-28392913b81e", "id": "10c02d81-0ecb-4dc5-897d-28392913b81e", "mac_address": "02:00:04:00:C4:6A", "name": "my-bare-metal-server-network-interface", "port_speed": 1000, "primary_ip": {"address": "192.168.3.4", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e/reserved_ips/6d353a0f-aeb1-4ae1-832e-1110d10981bb", "id": "6d353a0f-aeb1-4ae1-832e-1110d10981bb", "name": "my-reserved-ip", "resource_type": "subnet_reserved_ip"}, "resource_type": "network_interface", "security_groups": [{"crn": "crn:v1:bluemix:public:is:us-south:a/123456::security-group:be5df5ca-12a0-494b-907e-aa6ec2bfa271", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/security_groups/be5df5ca-12a0-494b-907e-aa6ec2bfa271", "id": "be5df5ca-12a0-494b-907e-aa6ec2bfa271", "name": "my-security-group"}], "status": "available", "subnet": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "id": "7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "name": "my-subnet", "resource_type": "subnet"}, "type": "primary", "interface_type": "hipersocket"}`) })) }) - It(`Invoke GetBareMetalServerProfile successfully with retries`, func() { + It(`Invoke UpdateBareMetalServerNetworkInterface successfully with retries`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -46218,21 +47121,32 @@ var _ = Describe(`VpcV1`, func() { Expect(vpcService).ToNot(BeNil()) vpcService.EnableRetries(0, 0) - // Construct an instance of the GetBareMetalServerProfileOptions model - getBareMetalServerProfileOptionsModel := new(vpcv1.GetBareMetalServerProfileOptions) - getBareMetalServerProfileOptionsModel.Name = core.StringPtr("testString") - getBareMetalServerProfileOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the BareMetalServerNetworkInterfacePatch model + bareMetalServerNetworkInterfacePatchModel := new(vpcv1.BareMetalServerNetworkInterfacePatch) + bareMetalServerNetworkInterfacePatchModel.AllowIPSpoofing = core.BoolPtr(true) + bareMetalServerNetworkInterfacePatchModel.AllowedVlans = []int64{int64(4)} + bareMetalServerNetworkInterfacePatchModel.EnableInfrastructureNat = core.BoolPtr(true) + bareMetalServerNetworkInterfacePatchModel.Name = core.StringPtr("my-bare-metal-server-network-interface") + bareMetalServerNetworkInterfacePatchModelAsPatch, asPatchErr := bareMetalServerNetworkInterfacePatchModel.AsPatch() + Expect(asPatchErr).To(BeNil()) + + // Construct an instance of the UpdateBareMetalServerNetworkInterfaceOptions model + updateBareMetalServerNetworkInterfaceOptionsModel := new(vpcv1.UpdateBareMetalServerNetworkInterfaceOptions) + updateBareMetalServerNetworkInterfaceOptionsModel.BareMetalServerID = core.StringPtr("testString") + updateBareMetalServerNetworkInterfaceOptionsModel.ID = core.StringPtr("testString") + updateBareMetalServerNetworkInterfaceOptionsModel.BareMetalServerNetworkInterfacePatch = bareMetalServerNetworkInterfacePatchModelAsPatch + updateBareMetalServerNetworkInterfaceOptionsModel.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.GetBareMetalServerProfileWithContext(ctx, getBareMetalServerProfileOptionsModel) + _, _, operationErr := vpcService.UpdateBareMetalServerNetworkInterfaceWithContext(ctx, updateBareMetalServerNetworkInterfaceOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) // Disable retries and test again vpcService.DisableRetries() - result, response, operationErr := vpcService.GetBareMetalServerProfile(getBareMetalServerProfileOptionsModel) + result, response, operationErr := vpcService.UpdateBareMetalServerNetworkInterface(updateBareMetalServerNetworkInterfaceOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) @@ -46240,7 +47154,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.GetBareMetalServerProfileWithContext(ctx, getBareMetalServerProfileOptionsModel) + _, _, operationErr = vpcService.UpdateBareMetalServerNetworkInterfaceWithContext(ctx, updateBareMetalServerNetworkInterfaceOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) }) @@ -46254,18 +47168,34 @@ var _ = Describe(`VpcV1`, func() { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(getBareMetalServerProfilePath)) - Expect(req.Method).To(Equal("GET")) + Expect(req.URL.EscapedPath()).To(Equal(updateBareMetalServerNetworkInterfacePath)) + 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.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", `{"bandwidth": {"type": "fixed", "value": 20000}, "console_types": {"type": "enum", "values": ["serial"]}, "cpu_architecture": {"default": "amd64", "type": "fixed", "value": "amd64"}, "cpu_core_count": {"type": "fixed", "value": 80}, "cpu_socket_count": {"type": "fixed", "value": 4}, "disks": [{"quantity": {"type": "fixed", "value": 4}, "size": {"type": "fixed", "value": 100}, "supported_interface_types": {"default": "fcp", "type": "enum", "values": ["fcp"]}}], "family": "balanced", "href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/profiles/bx2-metal-192x768", "memory": {"type": "fixed", "value": 16}, "name": "bx2-metal-192x768", "network_attachment_count": {"max": 128, "min": 1, "type": "range"}, "network_interface_count": {"max": 128, "min": 1, "type": "range"}, "os_architecture": {"default": "amd64", "type": "enum", "values": ["amd64"]}, "resource_type": "bare_metal_server_profile", "supported_trusted_platform_module_modes": {"type": "enum", "values": ["disabled"]}, "virtual_network_interfaces_supported": {"type": "fixed", "value": false}}`) + fmt.Fprintf(res, "%s", `{"allow_ip_spoofing": true, "created_at": "2019-01-01T12:00:00.000Z", "enable_infrastructure_nat": true, "floating_ips": [{"address": "203.0.113.1", "crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::floating-ip:39300233-9995-4806-89a5-3c1b6eb88689", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/floating_ips/39300233-9995-4806-89a5-3c1b6eb88689", "id": "39300233-9995-4806-89a5-3c1b6eb88689", "name": "my-floating-ip"}], "href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/1e09281b-f177-46fb-baf1-bc152b2e391a/network_interfaces/10c02d81-0ecb-4dc5-897d-28392913b81e", "id": "10c02d81-0ecb-4dc5-897d-28392913b81e", "mac_address": "02:00:04:00:C4:6A", "name": "my-bare-metal-server-network-interface", "port_speed": 1000, "primary_ip": {"address": "192.168.3.4", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e/reserved_ips/6d353a0f-aeb1-4ae1-832e-1110d10981bb", "id": "6d353a0f-aeb1-4ae1-832e-1110d10981bb", "name": "my-reserved-ip", "resource_type": "subnet_reserved_ip"}, "resource_type": "network_interface", "security_groups": [{"crn": "crn:v1:bluemix:public:is:us-south:a/123456::security-group:be5df5ca-12a0-494b-907e-aa6ec2bfa271", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/security_groups/be5df5ca-12a0-494b-907e-aa6ec2bfa271", "id": "be5df5ca-12a0-494b-907e-aa6ec2bfa271", "name": "my-security-group"}], "status": "available", "subnet": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "id": "7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "name": "my-subnet", "resource_type": "subnet"}, "type": "primary", "interface_type": "hipersocket"}`) })) }) - It(`Invoke GetBareMetalServerProfile successfully`, func() { + It(`Invoke UpdateBareMetalServerNetworkInterface successfully`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -46275,24 +47205,35 @@ var _ = Describe(`VpcV1`, func() { Expect(vpcService).ToNot(BeNil()) // Invoke operation with nil options model (negative test) - result, response, operationErr := vpcService.GetBareMetalServerProfile(nil) + result, response, operationErr := vpcService.UpdateBareMetalServerNetworkInterface(nil) Expect(operationErr).NotTo(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) - // Construct an instance of the GetBareMetalServerProfileOptions model - getBareMetalServerProfileOptionsModel := new(vpcv1.GetBareMetalServerProfileOptions) - getBareMetalServerProfileOptionsModel.Name = core.StringPtr("testString") - getBareMetalServerProfileOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the BareMetalServerNetworkInterfacePatch model + bareMetalServerNetworkInterfacePatchModel := new(vpcv1.BareMetalServerNetworkInterfacePatch) + bareMetalServerNetworkInterfacePatchModel.AllowIPSpoofing = core.BoolPtr(true) + bareMetalServerNetworkInterfacePatchModel.AllowedVlans = []int64{int64(4)} + bareMetalServerNetworkInterfacePatchModel.EnableInfrastructureNat = core.BoolPtr(true) + bareMetalServerNetworkInterfacePatchModel.Name = core.StringPtr("my-bare-metal-server-network-interface") + bareMetalServerNetworkInterfacePatchModelAsPatch, asPatchErr := bareMetalServerNetworkInterfacePatchModel.AsPatch() + Expect(asPatchErr).To(BeNil()) + + // Construct an instance of the UpdateBareMetalServerNetworkInterfaceOptions model + updateBareMetalServerNetworkInterfaceOptionsModel := new(vpcv1.UpdateBareMetalServerNetworkInterfaceOptions) + updateBareMetalServerNetworkInterfaceOptionsModel.BareMetalServerID = core.StringPtr("testString") + updateBareMetalServerNetworkInterfaceOptionsModel.ID = core.StringPtr("testString") + updateBareMetalServerNetworkInterfaceOptionsModel.BareMetalServerNetworkInterfacePatch = bareMetalServerNetworkInterfacePatchModelAsPatch + updateBareMetalServerNetworkInterfaceOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with valid options model (positive test) - result, response, operationErr = vpcService.GetBareMetalServerProfile(getBareMetalServerProfileOptionsModel) + result, response, operationErr = vpcService.UpdateBareMetalServerNetworkInterface(updateBareMetalServerNetworkInterfaceOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) }) - It(`Invoke GetBareMetalServerProfile with error: Operation validation and request error`, func() { + It(`Invoke UpdateBareMetalServerNetworkInterface with error: Operation validation and request error`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -46301,22 +47242,33 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the GetBareMetalServerProfileOptions model - getBareMetalServerProfileOptionsModel := new(vpcv1.GetBareMetalServerProfileOptions) - getBareMetalServerProfileOptionsModel.Name = core.StringPtr("testString") - getBareMetalServerProfileOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the BareMetalServerNetworkInterfacePatch model + bareMetalServerNetworkInterfacePatchModel := new(vpcv1.BareMetalServerNetworkInterfacePatch) + bareMetalServerNetworkInterfacePatchModel.AllowIPSpoofing = core.BoolPtr(true) + bareMetalServerNetworkInterfacePatchModel.AllowedVlans = []int64{int64(4)} + bareMetalServerNetworkInterfacePatchModel.EnableInfrastructureNat = core.BoolPtr(true) + bareMetalServerNetworkInterfacePatchModel.Name = core.StringPtr("my-bare-metal-server-network-interface") + bareMetalServerNetworkInterfacePatchModelAsPatch, asPatchErr := bareMetalServerNetworkInterfacePatchModel.AsPatch() + Expect(asPatchErr).To(BeNil()) + + // Construct an instance of the UpdateBareMetalServerNetworkInterfaceOptions model + updateBareMetalServerNetworkInterfaceOptionsModel := new(vpcv1.UpdateBareMetalServerNetworkInterfaceOptions) + updateBareMetalServerNetworkInterfaceOptionsModel.BareMetalServerID = core.StringPtr("testString") + updateBareMetalServerNetworkInterfaceOptionsModel.ID = core.StringPtr("testString") + updateBareMetalServerNetworkInterfaceOptionsModel.BareMetalServerNetworkInterfacePatch = bareMetalServerNetworkInterfacePatchModelAsPatch + updateBareMetalServerNetworkInterfaceOptionsModel.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.GetBareMetalServerProfile(getBareMetalServerProfileOptionsModel) + result, response, operationErr := vpcService.UpdateBareMetalServerNetworkInterface(updateBareMetalServerNetworkInterfaceOptionsModel) 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 GetBareMetalServerProfileOptions model with no property values - getBareMetalServerProfileOptionsModelNew := new(vpcv1.GetBareMetalServerProfileOptions) + // Construct a second instance of the UpdateBareMetalServerNetworkInterfaceOptions model with no property values + updateBareMetalServerNetworkInterfaceOptionsModelNew := new(vpcv1.UpdateBareMetalServerNetworkInterfaceOptions) // Invoke operation with invalid model (negative test) - result, response, operationErr = vpcService.GetBareMetalServerProfile(getBareMetalServerProfileOptionsModelNew) + result, response, operationErr = vpcService.UpdateBareMetalServerNetworkInterface(updateBareMetalServerNetworkInterfaceOptionsModelNew) Expect(operationErr).ToNot(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) @@ -46334,7 +47286,7 @@ var _ = Describe(`VpcV1`, func() { res.WriteHeader(200) })) }) - It(`Invoke GetBareMetalServerProfile successfully`, func() { + It(`Invoke UpdateBareMetalServerNetworkInterface successfully`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -46343,13 +47295,24 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the GetBareMetalServerProfileOptions model - getBareMetalServerProfileOptionsModel := new(vpcv1.GetBareMetalServerProfileOptions) - getBareMetalServerProfileOptionsModel.Name = core.StringPtr("testString") - getBareMetalServerProfileOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the BareMetalServerNetworkInterfacePatch model + bareMetalServerNetworkInterfacePatchModel := new(vpcv1.BareMetalServerNetworkInterfacePatch) + bareMetalServerNetworkInterfacePatchModel.AllowIPSpoofing = core.BoolPtr(true) + bareMetalServerNetworkInterfacePatchModel.AllowedVlans = []int64{int64(4)} + bareMetalServerNetworkInterfacePatchModel.EnableInfrastructureNat = core.BoolPtr(true) + bareMetalServerNetworkInterfacePatchModel.Name = core.StringPtr("my-bare-metal-server-network-interface") + bareMetalServerNetworkInterfacePatchModelAsPatch, asPatchErr := bareMetalServerNetworkInterfacePatchModel.AsPatch() + Expect(asPatchErr).To(BeNil()) + + // Construct an instance of the UpdateBareMetalServerNetworkInterfaceOptions model + updateBareMetalServerNetworkInterfaceOptionsModel := new(vpcv1.UpdateBareMetalServerNetworkInterfaceOptions) + updateBareMetalServerNetworkInterfaceOptionsModel.BareMetalServerID = core.StringPtr("testString") + updateBareMetalServerNetworkInterfaceOptionsModel.ID = core.StringPtr("testString") + updateBareMetalServerNetworkInterfaceOptionsModel.BareMetalServerNetworkInterfacePatch = bareMetalServerNetworkInterfacePatchModelAsPatch + updateBareMetalServerNetworkInterfaceOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation - result, response, operationErr := vpcService.GetBareMetalServerProfile(getBareMetalServerProfileOptionsModel) + result, response, operationErr := vpcService.UpdateBareMetalServerNetworkInterface(updateBareMetalServerNetworkInterfaceOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) @@ -46361,32 +47324,25 @@ var _ = Describe(`VpcV1`, func() { }) }) }) - Describe(`ListBareMetalServers(listBareMetalServersOptions *ListBareMetalServersOptions) - Operation response error`, func() { + Describe(`ListBareMetalServerNetworkInterfaceFloatingIps(listBareMetalServerNetworkInterfaceFloatingIpsOptions *ListBareMetalServerNetworkInterfaceFloatingIpsOptions) - Operation response error`, func() { version := "testString" - listBareMetalServersPath := "/bare_metal_servers" + listBareMetalServerNetworkInterfaceFloatingIpsPath := "/bare_metal_servers/testString/network_interfaces/testString/floating_ips" 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(listBareMetalServersPath)) + Expect(req.URL.EscapedPath()).To(Equal(listBareMetalServerNetworkInterfaceFloatingIpsPath)) Expect(req.Method).To(Equal("GET")) Expect(req.URL.Query()["version"]).To(Equal([]string{"testString"})) Expect(req.URL.Query()["generation"]).To(Equal([]string{fmt.Sprint(int64(2))})) - Expect(req.URL.Query()["start"]).To(Equal([]string{"testString"})) - Expect(req.URL.Query()["limit"]).To(Equal([]string{fmt.Sprint(int64(10))})) - Expect(req.URL.Query()["resource_group.id"]).To(Equal([]string{"testString"})) - Expect(req.URL.Query()["name"]).To(Equal([]string{"testString"})) - Expect(req.URL.Query()["vpc.id"]).To(Equal([]string{"testString"})) - Expect(req.URL.Query()["vpc.crn"]).To(Equal([]string{"crn:v1:bluemix:public:is:us-south:a/123456::vpc:4727d842-f94f-4a2d-824a-9bc9b02c523b"})) - Expect(req.URL.Query()["vpc.name"]).To(Equal([]string{"my-vpc"})) res.Header().Set("Content-type", "application/json") res.WriteHeader(200) fmt.Fprint(res, `} this is not valid json {`) })) }) - It(`Invoke ListBareMetalServers with error: Operation response processing error`, func() { + It(`Invoke ListBareMetalServerNetworkInterfaceFloatingIps with error: Operation response processing error`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -46395,25 +47351,20 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the ListBareMetalServersOptions model - listBareMetalServersOptionsModel := new(vpcv1.ListBareMetalServersOptions) - listBareMetalServersOptionsModel.Start = core.StringPtr("testString") - listBareMetalServersOptionsModel.Limit = core.Int64Ptr(int64(10)) - listBareMetalServersOptionsModel.ResourceGroupID = core.StringPtr("testString") - listBareMetalServersOptionsModel.Name = core.StringPtr("testString") - listBareMetalServersOptionsModel.VPCID = core.StringPtr("testString") - listBareMetalServersOptionsModel.VPCCRN = core.StringPtr("crn:v1:bluemix:public:is:us-south:a/123456::vpc:4727d842-f94f-4a2d-824a-9bc9b02c523b") - listBareMetalServersOptionsModel.VPCName = core.StringPtr("my-vpc") - listBareMetalServersOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the ListBareMetalServerNetworkInterfaceFloatingIpsOptions model + listBareMetalServerNetworkInterfaceFloatingIpsOptionsModel := new(vpcv1.ListBareMetalServerNetworkInterfaceFloatingIpsOptions) + listBareMetalServerNetworkInterfaceFloatingIpsOptionsModel.BareMetalServerID = core.StringPtr("testString") + listBareMetalServerNetworkInterfaceFloatingIpsOptionsModel.NetworkInterfaceID = core.StringPtr("testString") + listBareMetalServerNetworkInterfaceFloatingIpsOptionsModel.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.ListBareMetalServers(listBareMetalServersOptionsModel) + result, response, operationErr := vpcService.ListBareMetalServerNetworkInterfaceFloatingIps(listBareMetalServerNetworkInterfaceFloatingIpsOptionsModel) 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.ListBareMetalServers(listBareMetalServersOptionsModel) + result, response, operationErr = vpcService.ListBareMetalServerNetworkInterfaceFloatingIps(listBareMetalServerNetworkInterfaceFloatingIpsOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).To(BeNil()) @@ -46423,37 +47374,30 @@ var _ = Describe(`VpcV1`, func() { }) }) }) - Describe(`ListBareMetalServers(listBareMetalServersOptions *ListBareMetalServersOptions)`, func() { + Describe(`ListBareMetalServerNetworkInterfaceFloatingIps(listBareMetalServerNetworkInterfaceFloatingIpsOptions *ListBareMetalServerNetworkInterfaceFloatingIpsOptions)`, func() { version := "testString" - listBareMetalServersPath := "/bare_metal_servers" + listBareMetalServerNetworkInterfaceFloatingIpsPath := "/bare_metal_servers/testString/network_interfaces/testString/floating_ips" 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(listBareMetalServersPath)) + Expect(req.URL.EscapedPath()).To(Equal(listBareMetalServerNetworkInterfaceFloatingIpsPath)) Expect(req.Method).To(Equal("GET")) Expect(req.URL.Query()["version"]).To(Equal([]string{"testString"})) Expect(req.URL.Query()["generation"]).To(Equal([]string{fmt.Sprint(int64(2))})) - Expect(req.URL.Query()["start"]).To(Equal([]string{"testString"})) - Expect(req.URL.Query()["limit"]).To(Equal([]string{fmt.Sprint(int64(10))})) - Expect(req.URL.Query()["resource_group.id"]).To(Equal([]string{"testString"})) - Expect(req.URL.Query()["name"]).To(Equal([]string{"testString"})) - Expect(req.URL.Query()["vpc.id"]).To(Equal([]string{"testString"})) - Expect(req.URL.Query()["vpc.crn"]).To(Equal([]string{"crn:v1:bluemix:public:is:us-south:a/123456::vpc:4727d842-f94f-4a2d-824a-9bc9b02c523b"})) - Expect(req.URL.Query()["vpc.name"]).To(Equal([]string{"my-vpc"})) // 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", `{"bare_metal_servers": [{"bandwidth": 20000, "boot_target": {"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/1e09281b-f177-46fb-baf1-bc152b2e391a/disks/10c02d81-0ecb-4dc5-897d-28392913b81e", "id": "10c02d81-0ecb-4dc5-897d-28392913b81e", "name": "my-bare-metal-server-disk", "resource_type": "bare_metal_server_disk"}, "cpu": {"architecture": "amd64", "core_count": 80, "socket_count": 4, "threads_per_core": 2}, "created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::bare-metal-server:1e09281b-f177-46fb-baf1-bc152b2e391a", "disks": [{"created_at": "2019-01-01T12:00:00.000Z", "href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/1e09281b-f177-46fb-baf1-bc152b2e391a/disks/10c02d81-0ecb-4dc5-897d-28392913b81e", "id": "10c02d81-0ecb-4dc5-897d-28392913b81e", "interface_type": "fcp", "name": "my-bare-metal-server-disk", "resource_type": "bare_metal_server_disk", "size": 100}], "enable_secure_boot": false, "href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/1e09281b-f177-46fb-baf1-bc152b2e391a", "id": "1e09281b-f177-46fb-baf1-bc152b2e391a", "lifecycle_reasons": [{"code": "resource_suspended_by_provider", "message": "The resource has been suspended. Contact IBM support with the CRN for next steps.", "more_info": "https://cloud.ibm.com/apidocs/vpc#resource-suspension"}], "lifecycle_state": "stable", "memory": 1536, "name": "my-bare-metal-server", "network_attachments": [{"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/2302-f7a2bf57-af7c-49d9-b599-b2c91293d30c/network_attachments/2302-da8c43ec-b6ca-4bd2-871e-72e288c66ee6", "id": "2302-da8c43ec-b6ca-4bd2-871e-72e288c66ee6", "name": "my-bare-metal-server-network-attachment", "primary_ip": {"address": "192.168.3.4", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e/reserved_ips/6d353a0f-aeb1-4ae1-832e-1110d10981bb", "id": "6d353a0f-aeb1-4ae1-832e-1110d10981bb", "name": "my-reserved-ip", "resource_type": "subnet_reserved_ip"}, "resource_type": "bare_metal_server_network_attachment", "subnet": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "id": "7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "name": "my-subnet", "resource_type": "subnet"}}], "network_interfaces": [{"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/1e09281b-f177-46fb-baf1-bc152b2e391a/network_interfaces/10c02d81-0ecb-4dc5-897d-28392913b81e", "id": "10c02d81-0ecb-4dc5-897d-28392913b81e", "name": "my-bare-metal-server-network-interface", "primary_ip": {"address": "192.168.3.4", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e/reserved_ips/6d353a0f-aeb1-4ae1-832e-1110d10981bb", "id": "6d353a0f-aeb1-4ae1-832e-1110d10981bb", "name": "my-reserved-ip", "resource_type": "subnet_reserved_ip"}, "resource_type": "network_interface", "subnet": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "id": "7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "name": "my-subnet", "resource_type": "subnet"}}], "primary_network_attachment": {"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/2302-f7a2bf57-af7c-49d9-b599-b2c91293d30c/network_attachments/2302-da8c43ec-b6ca-4bd2-871e-72e288c66ee6", "id": "2302-da8c43ec-b6ca-4bd2-871e-72e288c66ee6", "name": "my-bare-metal-server-network-attachment", "primary_ip": {"address": "192.168.3.4", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e/reserved_ips/6d353a0f-aeb1-4ae1-832e-1110d10981bb", "id": "6d353a0f-aeb1-4ae1-832e-1110d10981bb", "name": "my-reserved-ip", "resource_type": "subnet_reserved_ip"}, "resource_type": "bare_metal_server_network_attachment", "subnet": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "id": "7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "name": "my-subnet", "resource_type": "subnet"}}, "primary_network_interface": {"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/1e09281b-f177-46fb-baf1-bc152b2e391a/network_interfaces/10c02d81-0ecb-4dc5-897d-28392913b81e", "id": "10c02d81-0ecb-4dc5-897d-28392913b81e", "name": "my-bare-metal-server-network-interface", "primary_ip": {"address": "192.168.3.4", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e/reserved_ips/6d353a0f-aeb1-4ae1-832e-1110d10981bb", "id": "6d353a0f-aeb1-4ae1-832e-1110d10981bb", "name": "my-reserved-ip", "resource_type": "subnet_reserved_ip"}, "resource_type": "network_interface", "subnet": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "id": "7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "name": "my-subnet", "resource_type": "subnet"}}, "profile": {"href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/profiles/bx2-metal-192x768", "name": "bx2-metal-192x768", "resource_type": "bare_metal_server_profile"}, "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "resource_type": "bare_metal_server", "status": "deleting", "status_reasons": [{"code": "cannot_start_capacity", "message": "The bare metal server cannot start as there is no more capacity in this\nzone for a bare metal server with the requested profile.", "more_info": "https://console.bluemix.net/docs/iaas/bare_metal_server.html"}], "trusted_platform_module": {"enabled": true, "mode": "disabled", "supported_modes": ["disabled"]}, "vpc": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::vpc:4727d842-f94f-4a2d-824a-9bc9b02c523b", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/vpcs/4727d842-f94f-4a2d-824a-9bc9b02c523b", "id": "4727d842-f94f-4a2d-824a-9bc9b02c523b", "name": "my-vpc", "resource_type": "vpc"}, "zone": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south/zones/us-south-1", "name": "us-south-1"}}], "first": {"href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers?limit=20"}, "limit": 20, "next": {"href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers?start=9d5a91a3e2cbd233b5a5b33436855ed1&limit=20"}, "total_count": 132}`) + fmt.Fprintf(res, "%s", `{"floating_ips": [{"address": "203.0.113.1", "created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::floating-ip:39300233-9995-4806-89a5-3c1b6eb88689", "href": "https://us-south.iaas.cloud.ibm.com/v1/floating_ips/39300233-9995-4806-89a5-3c1b6eb88689", "id": "39300233-9995-4806-89a5-3c1b6eb88689", "name": "my-floating-ip", "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "status": "available", "target": {"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/instances/1e09281b-f177-46fb-baf1-bc152b2e391a/network_interfaces/10c02d81-0ecb-4dc5-897d-28392913b81e", "id": "10c02d81-0ecb-4dc5-897d-28392913b81e", "name": "my-instance-network-interface", "primary_ip": {"address": "192.168.3.4", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e/reserved_ips/6d353a0f-aeb1-4ae1-832e-1110d10981bb", "id": "6d353a0f-aeb1-4ae1-832e-1110d10981bb", "name": "my-reserved-ip", "resource_type": "subnet_reserved_ip"}, "resource_type": "network_interface"}, "zone": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south/zones/us-south-1", "name": "us-south-1"}}]}`) })) }) - It(`Invoke ListBareMetalServers successfully with retries`, func() { + It(`Invoke ListBareMetalServerNetworkInterfaceFloatingIps successfully with retries`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -46463,27 +47407,22 @@ var _ = Describe(`VpcV1`, func() { Expect(vpcService).ToNot(BeNil()) vpcService.EnableRetries(0, 0) - // Construct an instance of the ListBareMetalServersOptions model - listBareMetalServersOptionsModel := new(vpcv1.ListBareMetalServersOptions) - listBareMetalServersOptionsModel.Start = core.StringPtr("testString") - listBareMetalServersOptionsModel.Limit = core.Int64Ptr(int64(10)) - listBareMetalServersOptionsModel.ResourceGroupID = core.StringPtr("testString") - listBareMetalServersOptionsModel.Name = core.StringPtr("testString") - listBareMetalServersOptionsModel.VPCID = core.StringPtr("testString") - listBareMetalServersOptionsModel.VPCCRN = core.StringPtr("crn:v1:bluemix:public:is:us-south:a/123456::vpc:4727d842-f94f-4a2d-824a-9bc9b02c523b") - listBareMetalServersOptionsModel.VPCName = core.StringPtr("my-vpc") - listBareMetalServersOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the ListBareMetalServerNetworkInterfaceFloatingIpsOptions model + listBareMetalServerNetworkInterfaceFloatingIpsOptionsModel := new(vpcv1.ListBareMetalServerNetworkInterfaceFloatingIpsOptions) + listBareMetalServerNetworkInterfaceFloatingIpsOptionsModel.BareMetalServerID = core.StringPtr("testString") + listBareMetalServerNetworkInterfaceFloatingIpsOptionsModel.NetworkInterfaceID = core.StringPtr("testString") + listBareMetalServerNetworkInterfaceFloatingIpsOptionsModel.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.ListBareMetalServersWithContext(ctx, listBareMetalServersOptionsModel) + _, _, operationErr := vpcService.ListBareMetalServerNetworkInterfaceFloatingIpsWithContext(ctx, listBareMetalServerNetworkInterfaceFloatingIpsOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) // Disable retries and test again vpcService.DisableRetries() - result, response, operationErr := vpcService.ListBareMetalServers(listBareMetalServersOptionsModel) + result, response, operationErr := vpcService.ListBareMetalServerNetworkInterfaceFloatingIps(listBareMetalServerNetworkInterfaceFloatingIpsOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) @@ -46491,7 +47430,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.ListBareMetalServersWithContext(ctx, listBareMetalServersOptionsModel) + _, _, operationErr = vpcService.ListBareMetalServerNetworkInterfaceFloatingIpsWithContext(ctx, listBareMetalServerNetworkInterfaceFloatingIpsOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) }) @@ -46505,25 +47444,18 @@ var _ = Describe(`VpcV1`, func() { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(listBareMetalServersPath)) + Expect(req.URL.EscapedPath()).To(Equal(listBareMetalServerNetworkInterfaceFloatingIpsPath)) Expect(req.Method).To(Equal("GET")) Expect(req.URL.Query()["version"]).To(Equal([]string{"testString"})) Expect(req.URL.Query()["generation"]).To(Equal([]string{fmt.Sprint(int64(2))})) - Expect(req.URL.Query()["start"]).To(Equal([]string{"testString"})) - Expect(req.URL.Query()["limit"]).To(Equal([]string{fmt.Sprint(int64(10))})) - Expect(req.URL.Query()["resource_group.id"]).To(Equal([]string{"testString"})) - Expect(req.URL.Query()["name"]).To(Equal([]string{"testString"})) - Expect(req.URL.Query()["vpc.id"]).To(Equal([]string{"testString"})) - Expect(req.URL.Query()["vpc.crn"]).To(Equal([]string{"crn:v1:bluemix:public:is:us-south:a/123456::vpc:4727d842-f94f-4a2d-824a-9bc9b02c523b"})) - Expect(req.URL.Query()["vpc.name"]).To(Equal([]string{"my-vpc"})) // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"bare_metal_servers": [{"bandwidth": 20000, "boot_target": {"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/1e09281b-f177-46fb-baf1-bc152b2e391a/disks/10c02d81-0ecb-4dc5-897d-28392913b81e", "id": "10c02d81-0ecb-4dc5-897d-28392913b81e", "name": "my-bare-metal-server-disk", "resource_type": "bare_metal_server_disk"}, "cpu": {"architecture": "amd64", "core_count": 80, "socket_count": 4, "threads_per_core": 2}, "created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::bare-metal-server:1e09281b-f177-46fb-baf1-bc152b2e391a", "disks": [{"created_at": "2019-01-01T12:00:00.000Z", "href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/1e09281b-f177-46fb-baf1-bc152b2e391a/disks/10c02d81-0ecb-4dc5-897d-28392913b81e", "id": "10c02d81-0ecb-4dc5-897d-28392913b81e", "interface_type": "fcp", "name": "my-bare-metal-server-disk", "resource_type": "bare_metal_server_disk", "size": 100}], "enable_secure_boot": false, "href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/1e09281b-f177-46fb-baf1-bc152b2e391a", "id": "1e09281b-f177-46fb-baf1-bc152b2e391a", "lifecycle_reasons": [{"code": "resource_suspended_by_provider", "message": "The resource has been suspended. Contact IBM support with the CRN for next steps.", "more_info": "https://cloud.ibm.com/apidocs/vpc#resource-suspension"}], "lifecycle_state": "stable", "memory": 1536, "name": "my-bare-metal-server", "network_attachments": [{"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/2302-f7a2bf57-af7c-49d9-b599-b2c91293d30c/network_attachments/2302-da8c43ec-b6ca-4bd2-871e-72e288c66ee6", "id": "2302-da8c43ec-b6ca-4bd2-871e-72e288c66ee6", "name": "my-bare-metal-server-network-attachment", "primary_ip": {"address": "192.168.3.4", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e/reserved_ips/6d353a0f-aeb1-4ae1-832e-1110d10981bb", "id": "6d353a0f-aeb1-4ae1-832e-1110d10981bb", "name": "my-reserved-ip", "resource_type": "subnet_reserved_ip"}, "resource_type": "bare_metal_server_network_attachment", "subnet": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "id": "7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "name": "my-subnet", "resource_type": "subnet"}}], "network_interfaces": [{"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/1e09281b-f177-46fb-baf1-bc152b2e391a/network_interfaces/10c02d81-0ecb-4dc5-897d-28392913b81e", "id": "10c02d81-0ecb-4dc5-897d-28392913b81e", "name": "my-bare-metal-server-network-interface", "primary_ip": {"address": "192.168.3.4", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e/reserved_ips/6d353a0f-aeb1-4ae1-832e-1110d10981bb", "id": "6d353a0f-aeb1-4ae1-832e-1110d10981bb", "name": "my-reserved-ip", "resource_type": "subnet_reserved_ip"}, "resource_type": "network_interface", "subnet": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "id": "7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "name": "my-subnet", "resource_type": "subnet"}}], "primary_network_attachment": {"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/2302-f7a2bf57-af7c-49d9-b599-b2c91293d30c/network_attachments/2302-da8c43ec-b6ca-4bd2-871e-72e288c66ee6", "id": "2302-da8c43ec-b6ca-4bd2-871e-72e288c66ee6", "name": "my-bare-metal-server-network-attachment", "primary_ip": {"address": "192.168.3.4", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e/reserved_ips/6d353a0f-aeb1-4ae1-832e-1110d10981bb", "id": "6d353a0f-aeb1-4ae1-832e-1110d10981bb", "name": "my-reserved-ip", "resource_type": "subnet_reserved_ip"}, "resource_type": "bare_metal_server_network_attachment", "subnet": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "id": "7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "name": "my-subnet", "resource_type": "subnet"}}, "primary_network_interface": {"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/1e09281b-f177-46fb-baf1-bc152b2e391a/network_interfaces/10c02d81-0ecb-4dc5-897d-28392913b81e", "id": "10c02d81-0ecb-4dc5-897d-28392913b81e", "name": "my-bare-metal-server-network-interface", "primary_ip": {"address": "192.168.3.4", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e/reserved_ips/6d353a0f-aeb1-4ae1-832e-1110d10981bb", "id": "6d353a0f-aeb1-4ae1-832e-1110d10981bb", "name": "my-reserved-ip", "resource_type": "subnet_reserved_ip"}, "resource_type": "network_interface", "subnet": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "id": "7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "name": "my-subnet", "resource_type": "subnet"}}, "profile": {"href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/profiles/bx2-metal-192x768", "name": "bx2-metal-192x768", "resource_type": "bare_metal_server_profile"}, "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "resource_type": "bare_metal_server", "status": "deleting", "status_reasons": [{"code": "cannot_start_capacity", "message": "The bare metal server cannot start as there is no more capacity in this\nzone for a bare metal server with the requested profile.", "more_info": "https://console.bluemix.net/docs/iaas/bare_metal_server.html"}], "trusted_platform_module": {"enabled": true, "mode": "disabled", "supported_modes": ["disabled"]}, "vpc": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::vpc:4727d842-f94f-4a2d-824a-9bc9b02c523b", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/vpcs/4727d842-f94f-4a2d-824a-9bc9b02c523b", "id": "4727d842-f94f-4a2d-824a-9bc9b02c523b", "name": "my-vpc", "resource_type": "vpc"}, "zone": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south/zones/us-south-1", "name": "us-south-1"}}], "first": {"href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers?limit=20"}, "limit": 20, "next": {"href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers?start=9d5a91a3e2cbd233b5a5b33436855ed1&limit=20"}, "total_count": 132}`) + fmt.Fprintf(res, "%s", `{"floating_ips": [{"address": "203.0.113.1", "created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::floating-ip:39300233-9995-4806-89a5-3c1b6eb88689", "href": "https://us-south.iaas.cloud.ibm.com/v1/floating_ips/39300233-9995-4806-89a5-3c1b6eb88689", "id": "39300233-9995-4806-89a5-3c1b6eb88689", "name": "my-floating-ip", "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "status": "available", "target": {"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/instances/1e09281b-f177-46fb-baf1-bc152b2e391a/network_interfaces/10c02d81-0ecb-4dc5-897d-28392913b81e", "id": "10c02d81-0ecb-4dc5-897d-28392913b81e", "name": "my-instance-network-interface", "primary_ip": {"address": "192.168.3.4", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e/reserved_ips/6d353a0f-aeb1-4ae1-832e-1110d10981bb", "id": "6d353a0f-aeb1-4ae1-832e-1110d10981bb", "name": "my-reserved-ip", "resource_type": "subnet_reserved_ip"}, "resource_type": "network_interface"}, "zone": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south/zones/us-south-1", "name": "us-south-1"}}]}`) })) }) - It(`Invoke ListBareMetalServers successfully`, func() { + It(`Invoke ListBareMetalServerNetworkInterfaceFloatingIps successfully`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -46533,30 +47465,25 @@ var _ = Describe(`VpcV1`, func() { Expect(vpcService).ToNot(BeNil()) // Invoke operation with nil options model (negative test) - result, response, operationErr := vpcService.ListBareMetalServers(nil) + result, response, operationErr := vpcService.ListBareMetalServerNetworkInterfaceFloatingIps(nil) Expect(operationErr).NotTo(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) - // Construct an instance of the ListBareMetalServersOptions model - listBareMetalServersOptionsModel := new(vpcv1.ListBareMetalServersOptions) - listBareMetalServersOptionsModel.Start = core.StringPtr("testString") - listBareMetalServersOptionsModel.Limit = core.Int64Ptr(int64(10)) - listBareMetalServersOptionsModel.ResourceGroupID = core.StringPtr("testString") - listBareMetalServersOptionsModel.Name = core.StringPtr("testString") - listBareMetalServersOptionsModel.VPCID = core.StringPtr("testString") - listBareMetalServersOptionsModel.VPCCRN = core.StringPtr("crn:v1:bluemix:public:is:us-south:a/123456::vpc:4727d842-f94f-4a2d-824a-9bc9b02c523b") - listBareMetalServersOptionsModel.VPCName = core.StringPtr("my-vpc") - listBareMetalServersOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the ListBareMetalServerNetworkInterfaceFloatingIpsOptions model + listBareMetalServerNetworkInterfaceFloatingIpsOptionsModel := new(vpcv1.ListBareMetalServerNetworkInterfaceFloatingIpsOptions) + listBareMetalServerNetworkInterfaceFloatingIpsOptionsModel.BareMetalServerID = core.StringPtr("testString") + listBareMetalServerNetworkInterfaceFloatingIpsOptionsModel.NetworkInterfaceID = core.StringPtr("testString") + listBareMetalServerNetworkInterfaceFloatingIpsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with valid options model (positive test) - result, response, operationErr = vpcService.ListBareMetalServers(listBareMetalServersOptionsModel) + result, response, operationErr = vpcService.ListBareMetalServerNetworkInterfaceFloatingIps(listBareMetalServerNetworkInterfaceFloatingIpsOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) }) - It(`Invoke ListBareMetalServers with error: Operation request error`, func() { + It(`Invoke ListBareMetalServerNetworkInterfaceFloatingIps with error: Operation validation and request error`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -46565,24 +47492,26 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the ListBareMetalServersOptions model - listBareMetalServersOptionsModel := new(vpcv1.ListBareMetalServersOptions) - listBareMetalServersOptionsModel.Start = core.StringPtr("testString") - listBareMetalServersOptionsModel.Limit = core.Int64Ptr(int64(10)) - listBareMetalServersOptionsModel.ResourceGroupID = core.StringPtr("testString") - listBareMetalServersOptionsModel.Name = core.StringPtr("testString") - listBareMetalServersOptionsModel.VPCID = core.StringPtr("testString") - listBareMetalServersOptionsModel.VPCCRN = core.StringPtr("crn:v1:bluemix:public:is:us-south:a/123456::vpc:4727d842-f94f-4a2d-824a-9bc9b02c523b") - listBareMetalServersOptionsModel.VPCName = core.StringPtr("my-vpc") - listBareMetalServersOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the ListBareMetalServerNetworkInterfaceFloatingIpsOptions model + listBareMetalServerNetworkInterfaceFloatingIpsOptionsModel := new(vpcv1.ListBareMetalServerNetworkInterfaceFloatingIpsOptions) + listBareMetalServerNetworkInterfaceFloatingIpsOptionsModel.BareMetalServerID = core.StringPtr("testString") + listBareMetalServerNetworkInterfaceFloatingIpsOptionsModel.NetworkInterfaceID = core.StringPtr("testString") + listBareMetalServerNetworkInterfaceFloatingIpsOptionsModel.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.ListBareMetalServers(listBareMetalServersOptionsModel) + result, response, operationErr := vpcService.ListBareMetalServerNetworkInterfaceFloatingIps(listBareMetalServerNetworkInterfaceFloatingIpsOptionsModel) 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 ListBareMetalServerNetworkInterfaceFloatingIpsOptions model with no property values + listBareMetalServerNetworkInterfaceFloatingIpsOptionsModelNew := new(vpcv1.ListBareMetalServerNetworkInterfaceFloatingIpsOptions) + // Invoke operation with invalid model (negative test) + result, response, operationErr = vpcService.ListBareMetalServerNetworkInterfaceFloatingIps(listBareMetalServerNetworkInterfaceFloatingIpsOptionsModelNew) + Expect(operationErr).ToNot(BeNil()) + Expect(response).To(BeNil()) + Expect(result).To(BeNil()) }) AfterEach(func() { testServer.Close() @@ -46597,7 +47526,7 @@ var _ = Describe(`VpcV1`, func() { res.WriteHeader(200) })) }) - It(`Invoke ListBareMetalServers successfully`, func() { + It(`Invoke ListBareMetalServerNetworkInterfaceFloatingIps successfully`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -46606,19 +47535,14 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the ListBareMetalServersOptions model - listBareMetalServersOptionsModel := new(vpcv1.ListBareMetalServersOptions) - listBareMetalServersOptionsModel.Start = core.StringPtr("testString") - listBareMetalServersOptionsModel.Limit = core.Int64Ptr(int64(10)) - listBareMetalServersOptionsModel.ResourceGroupID = core.StringPtr("testString") - listBareMetalServersOptionsModel.Name = core.StringPtr("testString") - listBareMetalServersOptionsModel.VPCID = core.StringPtr("testString") - listBareMetalServersOptionsModel.VPCCRN = core.StringPtr("crn:v1:bluemix:public:is:us-south:a/123456::vpc:4727d842-f94f-4a2d-824a-9bc9b02c523b") - listBareMetalServersOptionsModel.VPCName = core.StringPtr("my-vpc") - listBareMetalServersOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the ListBareMetalServerNetworkInterfaceFloatingIpsOptions model + listBareMetalServerNetworkInterfaceFloatingIpsOptionsModel := new(vpcv1.ListBareMetalServerNetworkInterfaceFloatingIpsOptions) + listBareMetalServerNetworkInterfaceFloatingIpsOptionsModel.BareMetalServerID = core.StringPtr("testString") + listBareMetalServerNetworkInterfaceFloatingIpsOptionsModel.NetworkInterfaceID = core.StringPtr("testString") + listBareMetalServerNetworkInterfaceFloatingIpsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation - result, response, operationErr := vpcService.ListBareMetalServers(listBareMetalServersOptionsModel) + result, response, operationErr := vpcService.ListBareMetalServerNetworkInterfaceFloatingIps(listBareMetalServerNetworkInterfaceFloatingIpsOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) @@ -46629,59 +47553,25 @@ var _ = Describe(`VpcV1`, func() { testServer.Close() }) }) - Context(`Test pagination helper method on response`, func() { - It(`Invoke GetNextStart successfully`, func() { - responseObject := new(vpcv1.BareMetalServerCollection) - nextObject := new(vpcv1.BareMetalServerCollectionNext) - 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.BareMetalServerCollection) - - 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.BareMetalServerCollection) - nextObject := new(vpcv1.BareMetalServerCollectionNext) - nextObject.Href = core.StringPtr("ibm.com") - responseObject.Next = nextObject - - value, err := responseObject.GetNextStart() - Expect(err).To(BeNil()) - Expect(value).To(BeNil()) - }) - }) - Context(`Using mock server endpoint - paginated response`, func() { + }) + Describe(`RemoveBareMetalServerNetworkInterfaceFloatingIP(removeBareMetalServerNetworkInterfaceFloatingIPOptions *RemoveBareMetalServerNetworkInterfaceFloatingIPOptions)`, func() { + version := "testString" + removeBareMetalServerNetworkInterfaceFloatingIPPath := "/bare_metal_servers/testString/network_interfaces/testString/floating_ips/testString" + Context(`Using mock server endpoint`, func() { BeforeEach(func() { - var requestNumber int = 0 testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(listBareMetalServersPath)) - Expect(req.Method).To(Equal("GET")) + Expect(req.URL.EscapedPath()).To(Equal(removeBareMetalServerNetworkInterfaceFloatingIPPath)) + Expect(req.Method).To(Equal("DELETE")) - // Set mock response - res.Header().Set("Content-type", "application/json") - res.WriteHeader(200) - requestNumber++ - if requestNumber == 1 { - fmt.Fprintf(res, "%s", `{"next":{"href":"https://myhost.com/somePath?start=1"},"total_count":2,"limit":1,"bare_metal_servers":[{"bandwidth":20000,"boot_target":{"deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/1e09281b-f177-46fb-baf1-bc152b2e391a/disks/10c02d81-0ecb-4dc5-897d-28392913b81e","id":"10c02d81-0ecb-4dc5-897d-28392913b81e","name":"my-bare-metal-server-disk","resource_type":"bare_metal_server_disk"},"cpu":{"architecture":"amd64","core_count":80,"socket_count":4,"threads_per_core":2},"created_at":"2019-01-01T12:00:00.000Z","crn":"crn:v1:bluemix:public:is:us-south-1:a/123456::bare-metal-server:1e09281b-f177-46fb-baf1-bc152b2e391a","disks":[{"created_at":"2019-01-01T12:00:00.000Z","href":"https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/1e09281b-f177-46fb-baf1-bc152b2e391a/disks/10c02d81-0ecb-4dc5-897d-28392913b81e","id":"10c02d81-0ecb-4dc5-897d-28392913b81e","interface_type":"fcp","name":"my-bare-metal-server-disk","resource_type":"bare_metal_server_disk","size":100}],"enable_secure_boot":false,"href":"https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/1e09281b-f177-46fb-baf1-bc152b2e391a","id":"1e09281b-f177-46fb-baf1-bc152b2e391a","lifecycle_reasons":[{"code":"resource_suspended_by_provider","message":"The resource has been suspended. Contact IBM support with the CRN for next steps.","more_info":"https://cloud.ibm.com/apidocs/vpc#resource-suspension"}],"lifecycle_state":"stable","memory":1536,"name":"my-bare-metal-server","network_attachments":[{"deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/2302-f7a2bf57-af7c-49d9-b599-b2c91293d30c/network_attachments/2302-da8c43ec-b6ca-4bd2-871e-72e288c66ee6","id":"2302-da8c43ec-b6ca-4bd2-871e-72e288c66ee6","name":"my-bare-metal-server-network-attachment","primary_ip":{"address":"192.168.3.4","deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e/reserved_ips/6d353a0f-aeb1-4ae1-832e-1110d10981bb","id":"6d353a0f-aeb1-4ae1-832e-1110d10981bb","name":"my-reserved-ip","resource_type":"subnet_reserved_ip"},"resource_type":"bare_metal_server_network_attachment","subnet":{"crn":"crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e","deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e","id":"7ec86020-1c6e-4889-b3f0-a15f2e50f87e","name":"my-subnet","resource_type":"subnet"}}],"network_interfaces":[{"deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/1e09281b-f177-46fb-baf1-bc152b2e391a/network_interfaces/10c02d81-0ecb-4dc5-897d-28392913b81e","id":"10c02d81-0ecb-4dc5-897d-28392913b81e","name":"my-bare-metal-server-network-interface","primary_ip":{"address":"192.168.3.4","deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e/reserved_ips/6d353a0f-aeb1-4ae1-832e-1110d10981bb","id":"6d353a0f-aeb1-4ae1-832e-1110d10981bb","name":"my-reserved-ip","resource_type":"subnet_reserved_ip"},"resource_type":"network_interface","subnet":{"crn":"crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e","deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e","id":"7ec86020-1c6e-4889-b3f0-a15f2e50f87e","name":"my-subnet","resource_type":"subnet"}}],"primary_network_attachment":{"deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/2302-f7a2bf57-af7c-49d9-b599-b2c91293d30c/network_attachments/2302-da8c43ec-b6ca-4bd2-871e-72e288c66ee6","id":"2302-da8c43ec-b6ca-4bd2-871e-72e288c66ee6","name":"my-bare-metal-server-network-attachment","primary_ip":{"address":"192.168.3.4","deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e/reserved_ips/6d353a0f-aeb1-4ae1-832e-1110d10981bb","id":"6d353a0f-aeb1-4ae1-832e-1110d10981bb","name":"my-reserved-ip","resource_type":"subnet_reserved_ip"},"resource_type":"bare_metal_server_network_attachment","subnet":{"crn":"crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e","deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e","id":"7ec86020-1c6e-4889-b3f0-a15f2e50f87e","name":"my-subnet","resource_type":"subnet"}},"primary_network_interface":{"deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/1e09281b-f177-46fb-baf1-bc152b2e391a/network_interfaces/10c02d81-0ecb-4dc5-897d-28392913b81e","id":"10c02d81-0ecb-4dc5-897d-28392913b81e","name":"my-bare-metal-server-network-interface","primary_ip":{"address":"192.168.3.4","deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e/reserved_ips/6d353a0f-aeb1-4ae1-832e-1110d10981bb","id":"6d353a0f-aeb1-4ae1-832e-1110d10981bb","name":"my-reserved-ip","resource_type":"subnet_reserved_ip"},"resource_type":"network_interface","subnet":{"crn":"crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e","deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e","id":"7ec86020-1c6e-4889-b3f0-a15f2e50f87e","name":"my-subnet","resource_type":"subnet"}},"profile":{"href":"https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/profiles/bx2-metal-192x768","name":"bx2-metal-192x768","resource_type":"bare_metal_server_profile"},"resource_group":{"href":"https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345","id":"fee82deba12e4c0fb69c3b09d1f12345","name":"my-resource-group"},"resource_type":"bare_metal_server","status":"deleting","status_reasons":[{"code":"cannot_start_capacity","message":"The bare metal server cannot start as there is no more capacity in this\\nzone for a bare metal server with the requested profile.","more_info":"https://console.bluemix.net/docs/iaas/bare_metal_server.html"}],"trusted_platform_module":{"enabled":true,"mode":"disabled","supported_modes":["disabled"]},"vpc":{"crn":"crn:v1:bluemix:public:is:us-south:a/123456::vpc:4727d842-f94f-4a2d-824a-9bc9b02c523b","deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/vpcs/4727d842-f94f-4a2d-824a-9bc9b02c523b","id":"4727d842-f94f-4a2d-824a-9bc9b02c523b","name":"my-vpc","resource_type":"vpc"},"zone":{"href":"https://us-south.iaas.cloud.ibm.com/v1/regions/us-south/zones/us-south-1","name":"us-south-1"}}]}`) - } else if requestNumber == 2 { - fmt.Fprintf(res, "%s", `{"total_count":2,"limit":1,"bare_metal_servers":[{"bandwidth":20000,"boot_target":{"deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/1e09281b-f177-46fb-baf1-bc152b2e391a/disks/10c02d81-0ecb-4dc5-897d-28392913b81e","id":"10c02d81-0ecb-4dc5-897d-28392913b81e","name":"my-bare-metal-server-disk","resource_type":"bare_metal_server_disk"},"cpu":{"architecture":"amd64","core_count":80,"socket_count":4,"threads_per_core":2},"created_at":"2019-01-01T12:00:00.000Z","crn":"crn:v1:bluemix:public:is:us-south-1:a/123456::bare-metal-server:1e09281b-f177-46fb-baf1-bc152b2e391a","disks":[{"created_at":"2019-01-01T12:00:00.000Z","href":"https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/1e09281b-f177-46fb-baf1-bc152b2e391a/disks/10c02d81-0ecb-4dc5-897d-28392913b81e","id":"10c02d81-0ecb-4dc5-897d-28392913b81e","interface_type":"fcp","name":"my-bare-metal-server-disk","resource_type":"bare_metal_server_disk","size":100}],"enable_secure_boot":false,"href":"https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/1e09281b-f177-46fb-baf1-bc152b2e391a","id":"1e09281b-f177-46fb-baf1-bc152b2e391a","lifecycle_reasons":[{"code":"resource_suspended_by_provider","message":"The resource has been suspended. Contact IBM support with the CRN for next steps.","more_info":"https://cloud.ibm.com/apidocs/vpc#resource-suspension"}],"lifecycle_state":"stable","memory":1536,"name":"my-bare-metal-server","network_attachments":[{"deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/2302-f7a2bf57-af7c-49d9-b599-b2c91293d30c/network_attachments/2302-da8c43ec-b6ca-4bd2-871e-72e288c66ee6","id":"2302-da8c43ec-b6ca-4bd2-871e-72e288c66ee6","name":"my-bare-metal-server-network-attachment","primary_ip":{"address":"192.168.3.4","deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e/reserved_ips/6d353a0f-aeb1-4ae1-832e-1110d10981bb","id":"6d353a0f-aeb1-4ae1-832e-1110d10981bb","name":"my-reserved-ip","resource_type":"subnet_reserved_ip"},"resource_type":"bare_metal_server_network_attachment","subnet":{"crn":"crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e","deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e","id":"7ec86020-1c6e-4889-b3f0-a15f2e50f87e","name":"my-subnet","resource_type":"subnet"}}],"network_interfaces":[{"deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/1e09281b-f177-46fb-baf1-bc152b2e391a/network_interfaces/10c02d81-0ecb-4dc5-897d-28392913b81e","id":"10c02d81-0ecb-4dc5-897d-28392913b81e","name":"my-bare-metal-server-network-interface","primary_ip":{"address":"192.168.3.4","deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e/reserved_ips/6d353a0f-aeb1-4ae1-832e-1110d10981bb","id":"6d353a0f-aeb1-4ae1-832e-1110d10981bb","name":"my-reserved-ip","resource_type":"subnet_reserved_ip"},"resource_type":"network_interface","subnet":{"crn":"crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e","deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e","id":"7ec86020-1c6e-4889-b3f0-a15f2e50f87e","name":"my-subnet","resource_type":"subnet"}}],"primary_network_attachment":{"deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/2302-f7a2bf57-af7c-49d9-b599-b2c91293d30c/network_attachments/2302-da8c43ec-b6ca-4bd2-871e-72e288c66ee6","id":"2302-da8c43ec-b6ca-4bd2-871e-72e288c66ee6","name":"my-bare-metal-server-network-attachment","primary_ip":{"address":"192.168.3.4","deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e/reserved_ips/6d353a0f-aeb1-4ae1-832e-1110d10981bb","id":"6d353a0f-aeb1-4ae1-832e-1110d10981bb","name":"my-reserved-ip","resource_type":"subnet_reserved_ip"},"resource_type":"bare_metal_server_network_attachment","subnet":{"crn":"crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e","deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e","id":"7ec86020-1c6e-4889-b3f0-a15f2e50f87e","name":"my-subnet","resource_type":"subnet"}},"primary_network_interface":{"deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/1e09281b-f177-46fb-baf1-bc152b2e391a/network_interfaces/10c02d81-0ecb-4dc5-897d-28392913b81e","id":"10c02d81-0ecb-4dc5-897d-28392913b81e","name":"my-bare-metal-server-network-interface","primary_ip":{"address":"192.168.3.4","deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e/reserved_ips/6d353a0f-aeb1-4ae1-832e-1110d10981bb","id":"6d353a0f-aeb1-4ae1-832e-1110d10981bb","name":"my-reserved-ip","resource_type":"subnet_reserved_ip"},"resource_type":"network_interface","subnet":{"crn":"crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e","deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e","id":"7ec86020-1c6e-4889-b3f0-a15f2e50f87e","name":"my-subnet","resource_type":"subnet"}},"profile":{"href":"https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/profiles/bx2-metal-192x768","name":"bx2-metal-192x768","resource_type":"bare_metal_server_profile"},"resource_group":{"href":"https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345","id":"fee82deba12e4c0fb69c3b09d1f12345","name":"my-resource-group"},"resource_type":"bare_metal_server","status":"deleting","status_reasons":[{"code":"cannot_start_capacity","message":"The bare metal server cannot start as there is no more capacity in this\\nzone for a bare metal server with the requested profile.","more_info":"https://console.bluemix.net/docs/iaas/bare_metal_server.html"}],"trusted_platform_module":{"enabled":true,"mode":"disabled","supported_modes":["disabled"]},"vpc":{"crn":"crn:v1:bluemix:public:is:us-south:a/123456::vpc:4727d842-f94f-4a2d-824a-9bc9b02c523b","deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/vpcs/4727d842-f94f-4a2d-824a-9bc9b02c523b","id":"4727d842-f94f-4a2d-824a-9bc9b02c523b","name":"my-vpc","resource_type":"vpc"},"zone":{"href":"https://us-south.iaas.cloud.ibm.com/v1/regions/us-south/zones/us-south-1","name":"us-south-1"}}]}`) - } else { - res.WriteHeader(400) - } + Expect(req.URL.Query()["version"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["generation"]).To(Equal([]string{fmt.Sprint(int64(2))})) + res.WriteHeader(204) })) }) - It(`Use BareMetalServersPager.GetNext successfully`, func() { + It(`Invoke RemoveBareMetalServerNetworkInterfaceFloatingIP successfully`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -46690,29 +47580,24 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - listBareMetalServersOptionsModel := &vpcv1.ListBareMetalServersOptions{ - Limit: core.Int64Ptr(int64(10)), - ResourceGroupID: core.StringPtr("testString"), - Name: core.StringPtr("testString"), - VPCID: core.StringPtr("testString"), - VPCCRN: core.StringPtr("crn:v1:bluemix:public:is:us-south:a/123456::vpc:4727d842-f94f-4a2d-824a-9bc9b02c523b"), - VPCName: core.StringPtr("my-vpc"), - } + // Invoke operation with nil options model (negative test) + response, operationErr := vpcService.RemoveBareMetalServerNetworkInterfaceFloatingIP(nil) + Expect(operationErr).NotTo(BeNil()) + Expect(response).To(BeNil()) - pager, err := vpcService.NewBareMetalServersPager(listBareMetalServersOptionsModel) - Expect(err).To(BeNil()) - Expect(pager).ToNot(BeNil()) + // Construct an instance of the RemoveBareMetalServerNetworkInterfaceFloatingIPOptions model + removeBareMetalServerNetworkInterfaceFloatingIPOptionsModel := new(vpcv1.RemoveBareMetalServerNetworkInterfaceFloatingIPOptions) + removeBareMetalServerNetworkInterfaceFloatingIPOptionsModel.BareMetalServerID = core.StringPtr("testString") + removeBareMetalServerNetworkInterfaceFloatingIPOptionsModel.NetworkInterfaceID = core.StringPtr("testString") + removeBareMetalServerNetworkInterfaceFloatingIPOptionsModel.ID = core.StringPtr("testString") + removeBareMetalServerNetworkInterfaceFloatingIPOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} - var allResults []vpcv1.BareMetalServer - for pager.HasNext() { - nextPage, err := pager.GetNext() - Expect(err).To(BeNil()) - Expect(nextPage).ToNot(BeNil()) - allResults = append(allResults, nextPage...) - } - Expect(len(allResults)).To(Equal(2)) + // Invoke operation with valid options model (positive test) + response, operationErr = vpcService.RemoveBareMetalServerNetworkInterfaceFloatingIP(removeBareMetalServerNetworkInterfaceFloatingIPOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) }) - It(`Use BareMetalServersPager.GetAll successfully`, func() { + It(`Invoke RemoveBareMetalServerNetworkInterfaceFloatingIP with error: Operation validation and request error`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -46721,208 +47606,50 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - listBareMetalServersOptionsModel := &vpcv1.ListBareMetalServersOptions{ - Limit: core.Int64Ptr(int64(10)), - ResourceGroupID: core.StringPtr("testString"), - Name: core.StringPtr("testString"), - VPCID: core.StringPtr("testString"), - VPCCRN: core.StringPtr("crn:v1:bluemix:public:is:us-south:a/123456::vpc:4727d842-f94f-4a2d-824a-9bc9b02c523b"), - VPCName: core.StringPtr("my-vpc"), - } - - pager, err := vpcService.NewBareMetalServersPager(listBareMetalServersOptionsModel) - Expect(err).To(BeNil()) - Expect(pager).ToNot(BeNil()) - - allResults, err := pager.GetAll() + // Construct an instance of the RemoveBareMetalServerNetworkInterfaceFloatingIPOptions model + removeBareMetalServerNetworkInterfaceFloatingIPOptionsModel := new(vpcv1.RemoveBareMetalServerNetworkInterfaceFloatingIPOptions) + removeBareMetalServerNetworkInterfaceFloatingIPOptionsModel.BareMetalServerID = core.StringPtr("testString") + removeBareMetalServerNetworkInterfaceFloatingIPOptionsModel.NetworkInterfaceID = core.StringPtr("testString") + removeBareMetalServerNetworkInterfaceFloatingIPOptionsModel.ID = core.StringPtr("testString") + removeBareMetalServerNetworkInterfaceFloatingIPOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Invoke operation with empty URL (negative test) + err := vpcService.SetServiceURL("") Expect(err).To(BeNil()) - Expect(allResults).ToNot(BeNil()) - Expect(len(allResults)).To(Equal(2)) - }) - }) - }) - Describe(`CreateBareMetalServer(createBareMetalServerOptions *CreateBareMetalServerOptions) - Operation response error`, func() { - version := "testString" - createBareMetalServerPath := "/bare_metal_servers" - 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(createBareMetalServerPath)) - 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 CreateBareMetalServer 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 ImageIdentityByID model - imageIdentityModel := new(vpcv1.ImageIdentityByID) - imageIdentityModel.ID = core.StringPtr("72b27b5c-f4b0-48bb-b954-5becc7c1dcb8") - - // Construct an instance of the KeyIdentityByID model - keyIdentityModel := new(vpcv1.KeyIdentityByID) - keyIdentityModel.ID = core.StringPtr("a6b1a881-2ce8-41a3-80fc-36316a73f803") - - // Construct an instance of the BareMetalServerInitializationPrototype model - bareMetalServerInitializationPrototypeModel := new(vpcv1.BareMetalServerInitializationPrototype) - bareMetalServerInitializationPrototypeModel.Image = imageIdentityModel - bareMetalServerInitializationPrototypeModel.Keys = []vpcv1.KeyIdentityIntf{keyIdentityModel} - bareMetalServerInitializationPrototypeModel.UserData = core.StringPtr("testString") - - // Construct an instance of the BareMetalServerProfileIdentityByName model - bareMetalServerProfileIdentityModel := new(vpcv1.BareMetalServerProfileIdentityByName) - bareMetalServerProfileIdentityModel.Name = core.StringPtr("bx2-metal-192x768") - - // Construct an instance of the ResourceGroupIdentityByID model - resourceGroupIdentityModel := new(vpcv1.ResourceGroupIdentityByID) - resourceGroupIdentityModel.ID = core.StringPtr("fee82deba12e4c0fb69c3b09d1f12345") - - // Construct an instance of the BareMetalServerTrustedPlatformModulePrototype model - bareMetalServerTrustedPlatformModulePrototypeModel := new(vpcv1.BareMetalServerTrustedPlatformModulePrototype) - bareMetalServerTrustedPlatformModulePrototypeModel.Mode = core.StringPtr("disabled") - - // Construct an instance of the VPCIdentityByID model - vpcIdentityModel := new(vpcv1.VPCIdentityByID) - vpcIdentityModel.ID = core.StringPtr("4727d842-f94f-4a2d-824a-9bc9b02c523b") - - // Construct an instance of the ZoneIdentityByName model - zoneIdentityModel := new(vpcv1.ZoneIdentityByName) - zoneIdentityModel.Name = core.StringPtr("us-south-1") - - // Construct an instance of the VirtualNetworkInterfaceIPPrototypeReservedIPPrototypeVirtualNetworkInterfaceIPsContext model - virtualNetworkInterfaceIPPrototypeModel := new(vpcv1.VirtualNetworkInterfaceIPPrototypeReservedIPPrototypeVirtualNetworkInterfaceIPsContext) - virtualNetworkInterfaceIPPrototypeModel.Address = core.StringPtr("10.0.0.5") - virtualNetworkInterfaceIPPrototypeModel.AutoDelete = core.BoolPtr(false) - virtualNetworkInterfaceIPPrototypeModel.Name = core.StringPtr("my-reserved-ip") - - // Construct an instance of the VirtualNetworkInterfacePrimaryIPPrototypeReservedIPPrototypeVirtualNetworkInterfacePrimaryIPContext model - virtualNetworkInterfacePrimaryIPPrototypeModel := new(vpcv1.VirtualNetworkInterfacePrimaryIPPrototypeReservedIPPrototypeVirtualNetworkInterfacePrimaryIPContext) - virtualNetworkInterfacePrimaryIPPrototypeModel.Address = core.StringPtr("10.0.0.5") - virtualNetworkInterfacePrimaryIPPrototypeModel.AutoDelete = core.BoolPtr(false) - virtualNetworkInterfacePrimaryIPPrototypeModel.Name = core.StringPtr("my-reserved-ip") - - // Construct an instance of the SecurityGroupIdentityByID model - securityGroupIdentityModel := new(vpcv1.SecurityGroupIdentityByID) - securityGroupIdentityModel.ID = core.StringPtr("be5df5ca-12a0-494b-907e-aa6ec2bfa271") - - // Construct an instance of the SubnetIdentityByID model - subnetIdentityModel := new(vpcv1.SubnetIdentityByID) - subnetIdentityModel.ID = core.StringPtr("7ec86020-1c6e-4889-b3f0-a15f2e50f87e") - - // Construct an instance of the BareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceVirtualNetworkInterfacePrototypeBareMetalServerNetworkAttachmentContext model - bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel := new(vpcv1.BareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceVirtualNetworkInterfacePrototypeBareMetalServerNetworkAttachmentContext) - bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel.AllowIPSpoofing = core.BoolPtr(true) - bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel.AutoDelete = core.BoolPtr(false) - bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel.EnableInfrastructureNat = core.BoolPtr(true) - bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel.Ips = []vpcv1.VirtualNetworkInterfaceIPPrototypeIntf{virtualNetworkInterfaceIPPrototypeModel} - bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel.Name = core.StringPtr("my-virtual-network-interface") - bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel.PrimaryIP = virtualNetworkInterfacePrimaryIPPrototypeModel - bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel.ResourceGroup = resourceGroupIdentityModel - bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel.SecurityGroups = []vpcv1.SecurityGroupIdentityIntf{securityGroupIdentityModel} - bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel.Subnet = subnetIdentityModel - - // Construct an instance of the BareMetalServerNetworkAttachmentPrototypeBareMetalServerNetworkAttachmentByPciPrototype model - bareMetalServerNetworkAttachmentPrototypeModel := new(vpcv1.BareMetalServerNetworkAttachmentPrototypeBareMetalServerNetworkAttachmentByPciPrototype) - bareMetalServerNetworkAttachmentPrototypeModel.Name = core.StringPtr("my-bare-metal-server-network-attachment") - bareMetalServerNetworkAttachmentPrototypeModel.VirtualNetworkInterface = bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel - bareMetalServerNetworkAttachmentPrototypeModel.AllowedVlans = []int64{} - bareMetalServerNetworkAttachmentPrototypeModel.InterfaceType = core.StringPtr("pci") - - // Construct an instance of the BareMetalServerPrimaryNetworkAttachmentPrototypeBareMetalServerPrimaryNetworkAttachmentByPciPrototype model - bareMetalServerPrimaryNetworkAttachmentPrototypeModel := new(vpcv1.BareMetalServerPrimaryNetworkAttachmentPrototypeBareMetalServerPrimaryNetworkAttachmentByPciPrototype) - bareMetalServerPrimaryNetworkAttachmentPrototypeModel.Name = core.StringPtr("my-bare-metal-server-network-attachment") - bareMetalServerPrimaryNetworkAttachmentPrototypeModel.VirtualNetworkInterface = bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel - bareMetalServerPrimaryNetworkAttachmentPrototypeModel.AllowedVlans = []int64{} - bareMetalServerPrimaryNetworkAttachmentPrototypeModel.InterfaceType = core.StringPtr("pci") - - // Construct an instance of the BareMetalServerPrototypeBareMetalServerByNetworkAttachment model - bareMetalServerPrototypeModel := new(vpcv1.BareMetalServerPrototypeBareMetalServerByNetworkAttachment) - bareMetalServerPrototypeModel.EnableSecureBoot = core.BoolPtr(false) - bareMetalServerPrototypeModel.Initialization = bareMetalServerInitializationPrototypeModel - bareMetalServerPrototypeModel.Name = core.StringPtr("my-bare-metal-server") - bareMetalServerPrototypeModel.Profile = bareMetalServerProfileIdentityModel - bareMetalServerPrototypeModel.ResourceGroup = resourceGroupIdentityModel - bareMetalServerPrototypeModel.TrustedPlatformModule = bareMetalServerTrustedPlatformModulePrototypeModel - bareMetalServerPrototypeModel.VPC = vpcIdentityModel - bareMetalServerPrototypeModel.Zone = zoneIdentityModel - bareMetalServerPrototypeModel.NetworkAttachments = []vpcv1.BareMetalServerNetworkAttachmentPrototypeIntf{bareMetalServerNetworkAttachmentPrototypeModel} - bareMetalServerPrototypeModel.PrimaryNetworkAttachment = bareMetalServerPrimaryNetworkAttachmentPrototypeModel - - // Construct an instance of the CreateBareMetalServerOptions model - createBareMetalServerOptionsModel := new(vpcv1.CreateBareMetalServerOptions) - createBareMetalServerOptionsModel.BareMetalServerPrototype = bareMetalServerPrototypeModel - createBareMetalServerOptionsModel.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.CreateBareMetalServer(createBareMetalServerOptionsModel) + response, operationErr := vpcService.RemoveBareMetalServerNetworkInterfaceFloatingIP(removeBareMetalServerNetworkInterfaceFloatingIPOptionsModel) 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.CreateBareMetalServer(createBareMetalServerOptionsModel) + Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING)) + Expect(response).To(BeNil()) + // Construct a second instance of the RemoveBareMetalServerNetworkInterfaceFloatingIPOptions model with no property values + removeBareMetalServerNetworkInterfaceFloatingIPOptionsModelNew := new(vpcv1.RemoveBareMetalServerNetworkInterfaceFloatingIPOptions) + // Invoke operation with invalid model (negative test) + response, operationErr = vpcService.RemoveBareMetalServerNetworkInterfaceFloatingIP(removeBareMetalServerNetworkInterfaceFloatingIPOptionsModelNew) Expect(operationErr).ToNot(BeNil()) - Expect(response).ToNot(BeNil()) - Expect(result).To(BeNil()) + Expect(response).To(BeNil()) }) AfterEach(func() { testServer.Close() }) }) }) - Describe(`CreateBareMetalServer(createBareMetalServerOptions *CreateBareMetalServerOptions)`, func() { + Describe(`GetBareMetalServerNetworkInterfaceFloatingIP(getBareMetalServerNetworkInterfaceFloatingIPOptions *GetBareMetalServerNetworkInterfaceFloatingIPOptions) - Operation response error`, func() { version := "testString" - createBareMetalServerPath := "/bare_metal_servers" - Context(`Using mock server endpoint with timeout`, func() { + getBareMetalServerNetworkInterfaceFloatingIPPath := "/bare_metal_servers/testString/network_interfaces/testString/floating_ips/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(createBareMetalServerPath)) - 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.EscapedPath()).To(Equal(getBareMetalServerNetworkInterfaceFloatingIPPath)) + 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(201) - fmt.Fprintf(res, "%s", `{"bandwidth": 20000, "boot_target": {"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/1e09281b-f177-46fb-baf1-bc152b2e391a/disks/10c02d81-0ecb-4dc5-897d-28392913b81e", "id": "10c02d81-0ecb-4dc5-897d-28392913b81e", "name": "my-bare-metal-server-disk", "resource_type": "bare_metal_server_disk"}, "cpu": {"architecture": "amd64", "core_count": 80, "socket_count": 4, "threads_per_core": 2}, "created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::bare-metal-server:1e09281b-f177-46fb-baf1-bc152b2e391a", "disks": [{"created_at": "2019-01-01T12:00:00.000Z", "href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/1e09281b-f177-46fb-baf1-bc152b2e391a/disks/10c02d81-0ecb-4dc5-897d-28392913b81e", "id": "10c02d81-0ecb-4dc5-897d-28392913b81e", "interface_type": "fcp", "name": "my-bare-metal-server-disk", "resource_type": "bare_metal_server_disk", "size": 100}], "enable_secure_boot": false, "href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/1e09281b-f177-46fb-baf1-bc152b2e391a", "id": "1e09281b-f177-46fb-baf1-bc152b2e391a", "lifecycle_reasons": [{"code": "resource_suspended_by_provider", "message": "The resource has been suspended. Contact IBM support with the CRN for next steps.", "more_info": "https://cloud.ibm.com/apidocs/vpc#resource-suspension"}], "lifecycle_state": "stable", "memory": 1536, "name": "my-bare-metal-server", "network_attachments": [{"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/2302-f7a2bf57-af7c-49d9-b599-b2c91293d30c/network_attachments/2302-da8c43ec-b6ca-4bd2-871e-72e288c66ee6", "id": "2302-da8c43ec-b6ca-4bd2-871e-72e288c66ee6", "name": "my-bare-metal-server-network-attachment", "primary_ip": {"address": "192.168.3.4", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e/reserved_ips/6d353a0f-aeb1-4ae1-832e-1110d10981bb", "id": "6d353a0f-aeb1-4ae1-832e-1110d10981bb", "name": "my-reserved-ip", "resource_type": "subnet_reserved_ip"}, "resource_type": "bare_metal_server_network_attachment", "subnet": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "id": "7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "name": "my-subnet", "resource_type": "subnet"}}], "network_interfaces": [{"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/1e09281b-f177-46fb-baf1-bc152b2e391a/network_interfaces/10c02d81-0ecb-4dc5-897d-28392913b81e", "id": "10c02d81-0ecb-4dc5-897d-28392913b81e", "name": "my-bare-metal-server-network-interface", "primary_ip": {"address": "192.168.3.4", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e/reserved_ips/6d353a0f-aeb1-4ae1-832e-1110d10981bb", "id": "6d353a0f-aeb1-4ae1-832e-1110d10981bb", "name": "my-reserved-ip", "resource_type": "subnet_reserved_ip"}, "resource_type": "network_interface", "subnet": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "id": "7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "name": "my-subnet", "resource_type": "subnet"}}], "primary_network_attachment": {"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/2302-f7a2bf57-af7c-49d9-b599-b2c91293d30c/network_attachments/2302-da8c43ec-b6ca-4bd2-871e-72e288c66ee6", "id": "2302-da8c43ec-b6ca-4bd2-871e-72e288c66ee6", "name": "my-bare-metal-server-network-attachment", "primary_ip": {"address": "192.168.3.4", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e/reserved_ips/6d353a0f-aeb1-4ae1-832e-1110d10981bb", "id": "6d353a0f-aeb1-4ae1-832e-1110d10981bb", "name": "my-reserved-ip", "resource_type": "subnet_reserved_ip"}, "resource_type": "bare_metal_server_network_attachment", "subnet": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "id": "7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "name": "my-subnet", "resource_type": "subnet"}}, "primary_network_interface": {"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/1e09281b-f177-46fb-baf1-bc152b2e391a/network_interfaces/10c02d81-0ecb-4dc5-897d-28392913b81e", "id": "10c02d81-0ecb-4dc5-897d-28392913b81e", "name": "my-bare-metal-server-network-interface", "primary_ip": {"address": "192.168.3.4", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e/reserved_ips/6d353a0f-aeb1-4ae1-832e-1110d10981bb", "id": "6d353a0f-aeb1-4ae1-832e-1110d10981bb", "name": "my-reserved-ip", "resource_type": "subnet_reserved_ip"}, "resource_type": "network_interface", "subnet": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "id": "7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "name": "my-subnet", "resource_type": "subnet"}}, "profile": {"href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/profiles/bx2-metal-192x768", "name": "bx2-metal-192x768", "resource_type": "bare_metal_server_profile"}, "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "resource_type": "bare_metal_server", "status": "deleting", "status_reasons": [{"code": "cannot_start_capacity", "message": "The bare metal server cannot start as there is no more capacity in this\nzone for a bare metal server with the requested profile.", "more_info": "https://console.bluemix.net/docs/iaas/bare_metal_server.html"}], "trusted_platform_module": {"enabled": true, "mode": "disabled", "supported_modes": ["disabled"]}, "vpc": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::vpc:4727d842-f94f-4a2d-824a-9bc9b02c523b", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/vpcs/4727d842-f94f-4a2d-824a-9bc9b02c523b", "id": "4727d842-f94f-4a2d-824a-9bc9b02c523b", "name": "my-vpc", "resource_type": "vpc"}, "zone": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south/zones/us-south-1", "name": "us-south-1"}}`) + res.WriteHeader(200) + fmt.Fprint(res, `} this is not valid json {`) })) }) - It(`Invoke CreateBareMetalServer successfully with retries`, func() { + It(`Invoke GetBareMetalServerNetworkInterfaceFloatingIP with error: Operation response processing error`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -46930,116 +47657,81 @@ var _ = Describe(`VpcV1`, func() { }) Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - vpcService.EnableRetries(0, 0) - - // Construct an instance of the ImageIdentityByID model - imageIdentityModel := new(vpcv1.ImageIdentityByID) - imageIdentityModel.ID = core.StringPtr("72b27b5c-f4b0-48bb-b954-5becc7c1dcb8") - - // Construct an instance of the KeyIdentityByID model - keyIdentityModel := new(vpcv1.KeyIdentityByID) - keyIdentityModel.ID = core.StringPtr("a6b1a881-2ce8-41a3-80fc-36316a73f803") - - // Construct an instance of the BareMetalServerInitializationPrototype model - bareMetalServerInitializationPrototypeModel := new(vpcv1.BareMetalServerInitializationPrototype) - bareMetalServerInitializationPrototypeModel.Image = imageIdentityModel - bareMetalServerInitializationPrototypeModel.Keys = []vpcv1.KeyIdentityIntf{keyIdentityModel} - bareMetalServerInitializationPrototypeModel.UserData = core.StringPtr("testString") - - // Construct an instance of the BareMetalServerProfileIdentityByName model - bareMetalServerProfileIdentityModel := new(vpcv1.BareMetalServerProfileIdentityByName) - bareMetalServerProfileIdentityModel.Name = core.StringPtr("bx2-metal-192x768") - - // Construct an instance of the ResourceGroupIdentityByID model - resourceGroupIdentityModel := new(vpcv1.ResourceGroupIdentityByID) - resourceGroupIdentityModel.ID = core.StringPtr("fee82deba12e4c0fb69c3b09d1f12345") - // Construct an instance of the BareMetalServerTrustedPlatformModulePrototype model - bareMetalServerTrustedPlatformModulePrototypeModel := new(vpcv1.BareMetalServerTrustedPlatformModulePrototype) - bareMetalServerTrustedPlatformModulePrototypeModel.Mode = core.StringPtr("disabled") - - // Construct an instance of the VPCIdentityByID model - vpcIdentityModel := new(vpcv1.VPCIdentityByID) - vpcIdentityModel.ID = core.StringPtr("4727d842-f94f-4a2d-824a-9bc9b02c523b") - - // Construct an instance of the ZoneIdentityByName model - zoneIdentityModel := new(vpcv1.ZoneIdentityByName) - zoneIdentityModel.Name = core.StringPtr("us-south-1") - - // Construct an instance of the VirtualNetworkInterfaceIPPrototypeReservedIPPrototypeVirtualNetworkInterfaceIPsContext model - virtualNetworkInterfaceIPPrototypeModel := new(vpcv1.VirtualNetworkInterfaceIPPrototypeReservedIPPrototypeVirtualNetworkInterfaceIPsContext) - virtualNetworkInterfaceIPPrototypeModel.Address = core.StringPtr("10.0.0.5") - virtualNetworkInterfaceIPPrototypeModel.AutoDelete = core.BoolPtr(false) - virtualNetworkInterfaceIPPrototypeModel.Name = core.StringPtr("my-reserved-ip") - - // Construct an instance of the VirtualNetworkInterfacePrimaryIPPrototypeReservedIPPrototypeVirtualNetworkInterfacePrimaryIPContext model - virtualNetworkInterfacePrimaryIPPrototypeModel := new(vpcv1.VirtualNetworkInterfacePrimaryIPPrototypeReservedIPPrototypeVirtualNetworkInterfacePrimaryIPContext) - virtualNetworkInterfacePrimaryIPPrototypeModel.Address = core.StringPtr("10.0.0.5") - virtualNetworkInterfacePrimaryIPPrototypeModel.AutoDelete = core.BoolPtr(false) - virtualNetworkInterfacePrimaryIPPrototypeModel.Name = core.StringPtr("my-reserved-ip") - - // Construct an instance of the SecurityGroupIdentityByID model - securityGroupIdentityModel := new(vpcv1.SecurityGroupIdentityByID) - securityGroupIdentityModel.ID = core.StringPtr("be5df5ca-12a0-494b-907e-aa6ec2bfa271") - - // Construct an instance of the SubnetIdentityByID model - subnetIdentityModel := new(vpcv1.SubnetIdentityByID) - subnetIdentityModel.ID = core.StringPtr("7ec86020-1c6e-4889-b3f0-a15f2e50f87e") + // Construct an instance of the GetBareMetalServerNetworkInterfaceFloatingIPOptions model + getBareMetalServerNetworkInterfaceFloatingIPOptionsModel := new(vpcv1.GetBareMetalServerNetworkInterfaceFloatingIPOptions) + getBareMetalServerNetworkInterfaceFloatingIPOptionsModel.BareMetalServerID = core.StringPtr("testString") + getBareMetalServerNetworkInterfaceFloatingIPOptionsModel.NetworkInterfaceID = core.StringPtr("testString") + getBareMetalServerNetworkInterfaceFloatingIPOptionsModel.ID = core.StringPtr("testString") + getBareMetalServerNetworkInterfaceFloatingIPOptionsModel.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.GetBareMetalServerNetworkInterfaceFloatingIP(getBareMetalServerNetworkInterfaceFloatingIPOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).To(BeNil()) - // Construct an instance of the BareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceVirtualNetworkInterfacePrototypeBareMetalServerNetworkAttachmentContext model - bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel := new(vpcv1.BareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceVirtualNetworkInterfacePrototypeBareMetalServerNetworkAttachmentContext) - bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel.AllowIPSpoofing = core.BoolPtr(true) - bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel.AutoDelete = core.BoolPtr(false) - bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel.EnableInfrastructureNat = core.BoolPtr(true) - bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel.Ips = []vpcv1.VirtualNetworkInterfaceIPPrototypeIntf{virtualNetworkInterfaceIPPrototypeModel} - bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel.Name = core.StringPtr("my-virtual-network-interface") - bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel.PrimaryIP = virtualNetworkInterfacePrimaryIPPrototypeModel - bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel.ResourceGroup = resourceGroupIdentityModel - bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel.SecurityGroups = []vpcv1.SecurityGroupIdentityIntf{securityGroupIdentityModel} - bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel.Subnet = subnetIdentityModel + // Enable retries and test again + vpcService.EnableRetries(0, 0) + result, response, operationErr = vpcService.GetBareMetalServerNetworkInterfaceFloatingIP(getBareMetalServerNetworkInterfaceFloatingIPOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + }) + Describe(`GetBareMetalServerNetworkInterfaceFloatingIP(getBareMetalServerNetworkInterfaceFloatingIPOptions *GetBareMetalServerNetworkInterfaceFloatingIPOptions)`, func() { + version := "testString" + getBareMetalServerNetworkInterfaceFloatingIPPath := "/bare_metal_servers/testString/network_interfaces/testString/floating_ips/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() - // Construct an instance of the BareMetalServerNetworkAttachmentPrototypeBareMetalServerNetworkAttachmentByPciPrototype model - bareMetalServerNetworkAttachmentPrototypeModel := new(vpcv1.BareMetalServerNetworkAttachmentPrototypeBareMetalServerNetworkAttachmentByPciPrototype) - bareMetalServerNetworkAttachmentPrototypeModel.Name = core.StringPtr("my-bare-metal-server-network-attachment") - bareMetalServerNetworkAttachmentPrototypeModel.VirtualNetworkInterface = bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel - bareMetalServerNetworkAttachmentPrototypeModel.AllowedVlans = []int64{} - bareMetalServerNetworkAttachmentPrototypeModel.InterfaceType = core.StringPtr("pci") + // Verify the contents of the request + Expect(req.URL.EscapedPath()).To(Equal(getBareMetalServerNetworkInterfaceFloatingIPPath)) + Expect(req.Method).To(Equal("GET")) - // Construct an instance of the BareMetalServerPrimaryNetworkAttachmentPrototypeBareMetalServerPrimaryNetworkAttachmentByPciPrototype model - bareMetalServerPrimaryNetworkAttachmentPrototypeModel := new(vpcv1.BareMetalServerPrimaryNetworkAttachmentPrototypeBareMetalServerPrimaryNetworkAttachmentByPciPrototype) - bareMetalServerPrimaryNetworkAttachmentPrototypeModel.Name = core.StringPtr("my-bare-metal-server-network-attachment") - bareMetalServerPrimaryNetworkAttachmentPrototypeModel.VirtualNetworkInterface = bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel - bareMetalServerPrimaryNetworkAttachmentPrototypeModel.AllowedVlans = []int64{} - bareMetalServerPrimaryNetworkAttachmentPrototypeModel.InterfaceType = core.StringPtr("pci") + 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) - // Construct an instance of the BareMetalServerPrototypeBareMetalServerByNetworkAttachment model - bareMetalServerPrototypeModel := new(vpcv1.BareMetalServerPrototypeBareMetalServerByNetworkAttachment) - bareMetalServerPrototypeModel.EnableSecureBoot = core.BoolPtr(false) - bareMetalServerPrototypeModel.Initialization = bareMetalServerInitializationPrototypeModel - bareMetalServerPrototypeModel.Name = core.StringPtr("my-bare-metal-server") - bareMetalServerPrototypeModel.Profile = bareMetalServerProfileIdentityModel - bareMetalServerPrototypeModel.ResourceGroup = resourceGroupIdentityModel - bareMetalServerPrototypeModel.TrustedPlatformModule = bareMetalServerTrustedPlatformModulePrototypeModel - bareMetalServerPrototypeModel.VPC = vpcIdentityModel - bareMetalServerPrototypeModel.Zone = zoneIdentityModel - bareMetalServerPrototypeModel.NetworkAttachments = []vpcv1.BareMetalServerNetworkAttachmentPrototypeIntf{bareMetalServerNetworkAttachmentPrototypeModel} - bareMetalServerPrototypeModel.PrimaryNetworkAttachment = bareMetalServerPrimaryNetworkAttachmentPrototypeModel + // Set mock response + res.Header().Set("Content-type", "application/json") + res.WriteHeader(200) + fmt.Fprintf(res, "%s", `{"address": "203.0.113.1", "created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::floating-ip:39300233-9995-4806-89a5-3c1b6eb88689", "href": "https://us-south.iaas.cloud.ibm.com/v1/floating_ips/39300233-9995-4806-89a5-3c1b6eb88689", "id": "39300233-9995-4806-89a5-3c1b6eb88689", "name": "my-floating-ip", "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "status": "available", "target": {"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/instances/1e09281b-f177-46fb-baf1-bc152b2e391a/network_interfaces/10c02d81-0ecb-4dc5-897d-28392913b81e", "id": "10c02d81-0ecb-4dc5-897d-28392913b81e", "name": "my-instance-network-interface", "primary_ip": {"address": "192.168.3.4", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e/reserved_ips/6d353a0f-aeb1-4ae1-832e-1110d10981bb", "id": "6d353a0f-aeb1-4ae1-832e-1110d10981bb", "name": "my-reserved-ip", "resource_type": "subnet_reserved_ip"}, "resource_type": "network_interface"}, "zone": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south/zones/us-south-1", "name": "us-south-1"}}`) + })) + }) + It(`Invoke GetBareMetalServerNetworkInterfaceFloatingIP 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 CreateBareMetalServerOptions model - createBareMetalServerOptionsModel := new(vpcv1.CreateBareMetalServerOptions) - createBareMetalServerOptionsModel.BareMetalServerPrototype = bareMetalServerPrototypeModel - createBareMetalServerOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the GetBareMetalServerNetworkInterfaceFloatingIPOptions model + getBareMetalServerNetworkInterfaceFloatingIPOptionsModel := new(vpcv1.GetBareMetalServerNetworkInterfaceFloatingIPOptions) + getBareMetalServerNetworkInterfaceFloatingIPOptionsModel.BareMetalServerID = core.StringPtr("testString") + getBareMetalServerNetworkInterfaceFloatingIPOptionsModel.NetworkInterfaceID = core.StringPtr("testString") + getBareMetalServerNetworkInterfaceFloatingIPOptionsModel.ID = core.StringPtr("testString") + getBareMetalServerNetworkInterfaceFloatingIPOptionsModel.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.CreateBareMetalServerWithContext(ctx, createBareMetalServerOptionsModel) + _, _, operationErr := vpcService.GetBareMetalServerNetworkInterfaceFloatingIPWithContext(ctx, getBareMetalServerNetworkInterfaceFloatingIPOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) // Disable retries and test again vpcService.DisableRetries() - result, response, operationErr := vpcService.CreateBareMetalServer(createBareMetalServerOptionsModel) + result, response, operationErr := vpcService.GetBareMetalServerNetworkInterfaceFloatingIP(getBareMetalServerNetworkInterfaceFloatingIPOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) @@ -47047,7 +47739,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.CreateBareMetalServerWithContext(ctx, createBareMetalServerOptionsModel) + _, _, operationErr = vpcService.GetBareMetalServerNetworkInterfaceFloatingIPWithContext(ctx, getBareMetalServerNetworkInterfaceFloatingIPOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) }) @@ -47061,34 +47753,18 @@ var _ = Describe(`VpcV1`, func() { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(createBareMetalServerPath)) - 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.EscapedPath()).To(Equal(getBareMetalServerNetworkInterfaceFloatingIPPath)) + 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(201) - fmt.Fprintf(res, "%s", `{"bandwidth": 20000, "boot_target": {"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/1e09281b-f177-46fb-baf1-bc152b2e391a/disks/10c02d81-0ecb-4dc5-897d-28392913b81e", "id": "10c02d81-0ecb-4dc5-897d-28392913b81e", "name": "my-bare-metal-server-disk", "resource_type": "bare_metal_server_disk"}, "cpu": {"architecture": "amd64", "core_count": 80, "socket_count": 4, "threads_per_core": 2}, "created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::bare-metal-server:1e09281b-f177-46fb-baf1-bc152b2e391a", "disks": [{"created_at": "2019-01-01T12:00:00.000Z", "href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/1e09281b-f177-46fb-baf1-bc152b2e391a/disks/10c02d81-0ecb-4dc5-897d-28392913b81e", "id": "10c02d81-0ecb-4dc5-897d-28392913b81e", "interface_type": "fcp", "name": "my-bare-metal-server-disk", "resource_type": "bare_metal_server_disk", "size": 100}], "enable_secure_boot": false, "href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/1e09281b-f177-46fb-baf1-bc152b2e391a", "id": "1e09281b-f177-46fb-baf1-bc152b2e391a", "lifecycle_reasons": [{"code": "resource_suspended_by_provider", "message": "The resource has been suspended. Contact IBM support with the CRN for next steps.", "more_info": "https://cloud.ibm.com/apidocs/vpc#resource-suspension"}], "lifecycle_state": "stable", "memory": 1536, "name": "my-bare-metal-server", "network_attachments": [{"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/2302-f7a2bf57-af7c-49d9-b599-b2c91293d30c/network_attachments/2302-da8c43ec-b6ca-4bd2-871e-72e288c66ee6", "id": "2302-da8c43ec-b6ca-4bd2-871e-72e288c66ee6", "name": "my-bare-metal-server-network-attachment", "primary_ip": {"address": "192.168.3.4", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e/reserved_ips/6d353a0f-aeb1-4ae1-832e-1110d10981bb", "id": "6d353a0f-aeb1-4ae1-832e-1110d10981bb", "name": "my-reserved-ip", "resource_type": "subnet_reserved_ip"}, "resource_type": "bare_metal_server_network_attachment", "subnet": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "id": "7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "name": "my-subnet", "resource_type": "subnet"}}], "network_interfaces": [{"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/1e09281b-f177-46fb-baf1-bc152b2e391a/network_interfaces/10c02d81-0ecb-4dc5-897d-28392913b81e", "id": "10c02d81-0ecb-4dc5-897d-28392913b81e", "name": "my-bare-metal-server-network-interface", "primary_ip": {"address": "192.168.3.4", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e/reserved_ips/6d353a0f-aeb1-4ae1-832e-1110d10981bb", "id": "6d353a0f-aeb1-4ae1-832e-1110d10981bb", "name": "my-reserved-ip", "resource_type": "subnet_reserved_ip"}, "resource_type": "network_interface", "subnet": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "id": "7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "name": "my-subnet", "resource_type": "subnet"}}], "primary_network_attachment": {"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/2302-f7a2bf57-af7c-49d9-b599-b2c91293d30c/network_attachments/2302-da8c43ec-b6ca-4bd2-871e-72e288c66ee6", "id": "2302-da8c43ec-b6ca-4bd2-871e-72e288c66ee6", "name": "my-bare-metal-server-network-attachment", "primary_ip": {"address": "192.168.3.4", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e/reserved_ips/6d353a0f-aeb1-4ae1-832e-1110d10981bb", "id": "6d353a0f-aeb1-4ae1-832e-1110d10981bb", "name": "my-reserved-ip", "resource_type": "subnet_reserved_ip"}, "resource_type": "bare_metal_server_network_attachment", "subnet": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "id": "7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "name": "my-subnet", "resource_type": "subnet"}}, "primary_network_interface": {"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/1e09281b-f177-46fb-baf1-bc152b2e391a/network_interfaces/10c02d81-0ecb-4dc5-897d-28392913b81e", "id": "10c02d81-0ecb-4dc5-897d-28392913b81e", "name": "my-bare-metal-server-network-interface", "primary_ip": {"address": "192.168.3.4", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e/reserved_ips/6d353a0f-aeb1-4ae1-832e-1110d10981bb", "id": "6d353a0f-aeb1-4ae1-832e-1110d10981bb", "name": "my-reserved-ip", "resource_type": "subnet_reserved_ip"}, "resource_type": "network_interface", "subnet": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "id": "7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "name": "my-subnet", "resource_type": "subnet"}}, "profile": {"href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/profiles/bx2-metal-192x768", "name": "bx2-metal-192x768", "resource_type": "bare_metal_server_profile"}, "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "resource_type": "bare_metal_server", "status": "deleting", "status_reasons": [{"code": "cannot_start_capacity", "message": "The bare metal server cannot start as there is no more capacity in this\nzone for a bare metal server with the requested profile.", "more_info": "https://console.bluemix.net/docs/iaas/bare_metal_server.html"}], "trusted_platform_module": {"enabled": true, "mode": "disabled", "supported_modes": ["disabled"]}, "vpc": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::vpc:4727d842-f94f-4a2d-824a-9bc9b02c523b", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/vpcs/4727d842-f94f-4a2d-824a-9bc9b02c523b", "id": "4727d842-f94f-4a2d-824a-9bc9b02c523b", "name": "my-vpc", "resource_type": "vpc"}, "zone": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south/zones/us-south-1", "name": "us-south-1"}}`) + res.WriteHeader(200) + fmt.Fprintf(res, "%s", `{"address": "203.0.113.1", "created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::floating-ip:39300233-9995-4806-89a5-3c1b6eb88689", "href": "https://us-south.iaas.cloud.ibm.com/v1/floating_ips/39300233-9995-4806-89a5-3c1b6eb88689", "id": "39300233-9995-4806-89a5-3c1b6eb88689", "name": "my-floating-ip", "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "status": "available", "target": {"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/instances/1e09281b-f177-46fb-baf1-bc152b2e391a/network_interfaces/10c02d81-0ecb-4dc5-897d-28392913b81e", "id": "10c02d81-0ecb-4dc5-897d-28392913b81e", "name": "my-instance-network-interface", "primary_ip": {"address": "192.168.3.4", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e/reserved_ips/6d353a0f-aeb1-4ae1-832e-1110d10981bb", "id": "6d353a0f-aeb1-4ae1-832e-1110d10981bb", "name": "my-reserved-ip", "resource_type": "subnet_reserved_ip"}, "resource_type": "network_interface"}, "zone": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south/zones/us-south-1", "name": "us-south-1"}}`) })) }) - It(`Invoke CreateBareMetalServer successfully`, func() { + It(`Invoke GetBareMetalServerNetworkInterfaceFloatingIP successfully`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -47098,117 +47774,26 @@ var _ = Describe(`VpcV1`, func() { Expect(vpcService).ToNot(BeNil()) // Invoke operation with nil options model (negative test) - result, response, operationErr := vpcService.CreateBareMetalServer(nil) + result, response, operationErr := vpcService.GetBareMetalServerNetworkInterfaceFloatingIP(nil) Expect(operationErr).NotTo(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) - // Construct an instance of the ImageIdentityByID model - imageIdentityModel := new(vpcv1.ImageIdentityByID) - imageIdentityModel.ID = core.StringPtr("72b27b5c-f4b0-48bb-b954-5becc7c1dcb8") - - // Construct an instance of the KeyIdentityByID model - keyIdentityModel := new(vpcv1.KeyIdentityByID) - keyIdentityModel.ID = core.StringPtr("a6b1a881-2ce8-41a3-80fc-36316a73f803") - - // Construct an instance of the BareMetalServerInitializationPrototype model - bareMetalServerInitializationPrototypeModel := new(vpcv1.BareMetalServerInitializationPrototype) - bareMetalServerInitializationPrototypeModel.Image = imageIdentityModel - bareMetalServerInitializationPrototypeModel.Keys = []vpcv1.KeyIdentityIntf{keyIdentityModel} - bareMetalServerInitializationPrototypeModel.UserData = core.StringPtr("testString") - - // Construct an instance of the BareMetalServerProfileIdentityByName model - bareMetalServerProfileIdentityModel := new(vpcv1.BareMetalServerProfileIdentityByName) - bareMetalServerProfileIdentityModel.Name = core.StringPtr("bx2-metal-192x768") - - // Construct an instance of the ResourceGroupIdentityByID model - resourceGroupIdentityModel := new(vpcv1.ResourceGroupIdentityByID) - resourceGroupIdentityModel.ID = core.StringPtr("fee82deba12e4c0fb69c3b09d1f12345") - - // Construct an instance of the BareMetalServerTrustedPlatformModulePrototype model - bareMetalServerTrustedPlatformModulePrototypeModel := new(vpcv1.BareMetalServerTrustedPlatformModulePrototype) - bareMetalServerTrustedPlatformModulePrototypeModel.Mode = core.StringPtr("disabled") - - // Construct an instance of the VPCIdentityByID model - vpcIdentityModel := new(vpcv1.VPCIdentityByID) - vpcIdentityModel.ID = core.StringPtr("4727d842-f94f-4a2d-824a-9bc9b02c523b") - - // Construct an instance of the ZoneIdentityByName model - zoneIdentityModel := new(vpcv1.ZoneIdentityByName) - zoneIdentityModel.Name = core.StringPtr("us-south-1") - - // Construct an instance of the VirtualNetworkInterfaceIPPrototypeReservedIPPrototypeVirtualNetworkInterfaceIPsContext model - virtualNetworkInterfaceIPPrototypeModel := new(vpcv1.VirtualNetworkInterfaceIPPrototypeReservedIPPrototypeVirtualNetworkInterfaceIPsContext) - virtualNetworkInterfaceIPPrototypeModel.Address = core.StringPtr("10.0.0.5") - virtualNetworkInterfaceIPPrototypeModel.AutoDelete = core.BoolPtr(false) - virtualNetworkInterfaceIPPrototypeModel.Name = core.StringPtr("my-reserved-ip") - - // Construct an instance of the VirtualNetworkInterfacePrimaryIPPrototypeReservedIPPrototypeVirtualNetworkInterfacePrimaryIPContext model - virtualNetworkInterfacePrimaryIPPrototypeModel := new(vpcv1.VirtualNetworkInterfacePrimaryIPPrototypeReservedIPPrototypeVirtualNetworkInterfacePrimaryIPContext) - virtualNetworkInterfacePrimaryIPPrototypeModel.Address = core.StringPtr("10.0.0.5") - virtualNetworkInterfacePrimaryIPPrototypeModel.AutoDelete = core.BoolPtr(false) - virtualNetworkInterfacePrimaryIPPrototypeModel.Name = core.StringPtr("my-reserved-ip") - - // Construct an instance of the SecurityGroupIdentityByID model - securityGroupIdentityModel := new(vpcv1.SecurityGroupIdentityByID) - securityGroupIdentityModel.ID = core.StringPtr("be5df5ca-12a0-494b-907e-aa6ec2bfa271") - - // Construct an instance of the SubnetIdentityByID model - subnetIdentityModel := new(vpcv1.SubnetIdentityByID) - subnetIdentityModel.ID = core.StringPtr("7ec86020-1c6e-4889-b3f0-a15f2e50f87e") - - // Construct an instance of the BareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceVirtualNetworkInterfacePrototypeBareMetalServerNetworkAttachmentContext model - bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel := new(vpcv1.BareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceVirtualNetworkInterfacePrototypeBareMetalServerNetworkAttachmentContext) - bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel.AllowIPSpoofing = core.BoolPtr(true) - bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel.AutoDelete = core.BoolPtr(false) - bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel.EnableInfrastructureNat = core.BoolPtr(true) - bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel.Ips = []vpcv1.VirtualNetworkInterfaceIPPrototypeIntf{virtualNetworkInterfaceIPPrototypeModel} - bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel.Name = core.StringPtr("my-virtual-network-interface") - bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel.PrimaryIP = virtualNetworkInterfacePrimaryIPPrototypeModel - bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel.ResourceGroup = resourceGroupIdentityModel - bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel.SecurityGroups = []vpcv1.SecurityGroupIdentityIntf{securityGroupIdentityModel} - bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel.Subnet = subnetIdentityModel - - // Construct an instance of the BareMetalServerNetworkAttachmentPrototypeBareMetalServerNetworkAttachmentByPciPrototype model - bareMetalServerNetworkAttachmentPrototypeModel := new(vpcv1.BareMetalServerNetworkAttachmentPrototypeBareMetalServerNetworkAttachmentByPciPrototype) - bareMetalServerNetworkAttachmentPrototypeModel.Name = core.StringPtr("my-bare-metal-server-network-attachment") - bareMetalServerNetworkAttachmentPrototypeModel.VirtualNetworkInterface = bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel - bareMetalServerNetworkAttachmentPrototypeModel.AllowedVlans = []int64{} - bareMetalServerNetworkAttachmentPrototypeModel.InterfaceType = core.StringPtr("pci") - - // Construct an instance of the BareMetalServerPrimaryNetworkAttachmentPrototypeBareMetalServerPrimaryNetworkAttachmentByPciPrototype model - bareMetalServerPrimaryNetworkAttachmentPrototypeModel := new(vpcv1.BareMetalServerPrimaryNetworkAttachmentPrototypeBareMetalServerPrimaryNetworkAttachmentByPciPrototype) - bareMetalServerPrimaryNetworkAttachmentPrototypeModel.Name = core.StringPtr("my-bare-metal-server-network-attachment") - bareMetalServerPrimaryNetworkAttachmentPrototypeModel.VirtualNetworkInterface = bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel - bareMetalServerPrimaryNetworkAttachmentPrototypeModel.AllowedVlans = []int64{} - bareMetalServerPrimaryNetworkAttachmentPrototypeModel.InterfaceType = core.StringPtr("pci") - - // Construct an instance of the BareMetalServerPrototypeBareMetalServerByNetworkAttachment model - bareMetalServerPrototypeModel := new(vpcv1.BareMetalServerPrototypeBareMetalServerByNetworkAttachment) - bareMetalServerPrototypeModel.EnableSecureBoot = core.BoolPtr(false) - bareMetalServerPrototypeModel.Initialization = bareMetalServerInitializationPrototypeModel - bareMetalServerPrototypeModel.Name = core.StringPtr("my-bare-metal-server") - bareMetalServerPrototypeModel.Profile = bareMetalServerProfileIdentityModel - bareMetalServerPrototypeModel.ResourceGroup = resourceGroupIdentityModel - bareMetalServerPrototypeModel.TrustedPlatformModule = bareMetalServerTrustedPlatformModulePrototypeModel - bareMetalServerPrototypeModel.VPC = vpcIdentityModel - bareMetalServerPrototypeModel.Zone = zoneIdentityModel - bareMetalServerPrototypeModel.NetworkAttachments = []vpcv1.BareMetalServerNetworkAttachmentPrototypeIntf{bareMetalServerNetworkAttachmentPrototypeModel} - bareMetalServerPrototypeModel.PrimaryNetworkAttachment = bareMetalServerPrimaryNetworkAttachmentPrototypeModel - - // Construct an instance of the CreateBareMetalServerOptions model - createBareMetalServerOptionsModel := new(vpcv1.CreateBareMetalServerOptions) - createBareMetalServerOptionsModel.BareMetalServerPrototype = bareMetalServerPrototypeModel - createBareMetalServerOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the GetBareMetalServerNetworkInterfaceFloatingIPOptions model + getBareMetalServerNetworkInterfaceFloatingIPOptionsModel := new(vpcv1.GetBareMetalServerNetworkInterfaceFloatingIPOptions) + getBareMetalServerNetworkInterfaceFloatingIPOptionsModel.BareMetalServerID = core.StringPtr("testString") + getBareMetalServerNetworkInterfaceFloatingIPOptionsModel.NetworkInterfaceID = core.StringPtr("testString") + getBareMetalServerNetworkInterfaceFloatingIPOptionsModel.ID = core.StringPtr("testString") + getBareMetalServerNetworkInterfaceFloatingIPOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with valid options model (positive test) - result, response, operationErr = vpcService.CreateBareMetalServer(createBareMetalServerOptionsModel) + result, response, operationErr = vpcService.GetBareMetalServerNetworkInterfaceFloatingIP(getBareMetalServerNetworkInterfaceFloatingIPOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) }) - It(`Invoke CreateBareMetalServer with error: Operation validation and request error`, func() { + It(`Invoke GetBareMetalServerNetworkInterfaceFloatingIP with error: Operation validation and request error`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -47217,115 +47802,24 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the ImageIdentityByID model - imageIdentityModel := new(vpcv1.ImageIdentityByID) - imageIdentityModel.ID = core.StringPtr("72b27b5c-f4b0-48bb-b954-5becc7c1dcb8") - - // Construct an instance of the KeyIdentityByID model - keyIdentityModel := new(vpcv1.KeyIdentityByID) - keyIdentityModel.ID = core.StringPtr("a6b1a881-2ce8-41a3-80fc-36316a73f803") - - // Construct an instance of the BareMetalServerInitializationPrototype model - bareMetalServerInitializationPrototypeModel := new(vpcv1.BareMetalServerInitializationPrototype) - bareMetalServerInitializationPrototypeModel.Image = imageIdentityModel - bareMetalServerInitializationPrototypeModel.Keys = []vpcv1.KeyIdentityIntf{keyIdentityModel} - bareMetalServerInitializationPrototypeModel.UserData = core.StringPtr("testString") - - // Construct an instance of the BareMetalServerProfileIdentityByName model - bareMetalServerProfileIdentityModel := new(vpcv1.BareMetalServerProfileIdentityByName) - bareMetalServerProfileIdentityModel.Name = core.StringPtr("bx2-metal-192x768") - - // Construct an instance of the ResourceGroupIdentityByID model - resourceGroupIdentityModel := new(vpcv1.ResourceGroupIdentityByID) - resourceGroupIdentityModel.ID = core.StringPtr("fee82deba12e4c0fb69c3b09d1f12345") - - // Construct an instance of the BareMetalServerTrustedPlatformModulePrototype model - bareMetalServerTrustedPlatformModulePrototypeModel := new(vpcv1.BareMetalServerTrustedPlatformModulePrototype) - bareMetalServerTrustedPlatformModulePrototypeModel.Mode = core.StringPtr("disabled") - - // Construct an instance of the VPCIdentityByID model - vpcIdentityModel := new(vpcv1.VPCIdentityByID) - vpcIdentityModel.ID = core.StringPtr("4727d842-f94f-4a2d-824a-9bc9b02c523b") - - // Construct an instance of the ZoneIdentityByName model - zoneIdentityModel := new(vpcv1.ZoneIdentityByName) - zoneIdentityModel.Name = core.StringPtr("us-south-1") - - // Construct an instance of the VirtualNetworkInterfaceIPPrototypeReservedIPPrototypeVirtualNetworkInterfaceIPsContext model - virtualNetworkInterfaceIPPrototypeModel := new(vpcv1.VirtualNetworkInterfaceIPPrototypeReservedIPPrototypeVirtualNetworkInterfaceIPsContext) - virtualNetworkInterfaceIPPrototypeModel.Address = core.StringPtr("10.0.0.5") - virtualNetworkInterfaceIPPrototypeModel.AutoDelete = core.BoolPtr(false) - virtualNetworkInterfaceIPPrototypeModel.Name = core.StringPtr("my-reserved-ip") - - // Construct an instance of the VirtualNetworkInterfacePrimaryIPPrototypeReservedIPPrototypeVirtualNetworkInterfacePrimaryIPContext model - virtualNetworkInterfacePrimaryIPPrototypeModel := new(vpcv1.VirtualNetworkInterfacePrimaryIPPrototypeReservedIPPrototypeVirtualNetworkInterfacePrimaryIPContext) - virtualNetworkInterfacePrimaryIPPrototypeModel.Address = core.StringPtr("10.0.0.5") - virtualNetworkInterfacePrimaryIPPrototypeModel.AutoDelete = core.BoolPtr(false) - virtualNetworkInterfacePrimaryIPPrototypeModel.Name = core.StringPtr("my-reserved-ip") - - // Construct an instance of the SecurityGroupIdentityByID model - securityGroupIdentityModel := new(vpcv1.SecurityGroupIdentityByID) - securityGroupIdentityModel.ID = core.StringPtr("be5df5ca-12a0-494b-907e-aa6ec2bfa271") - - // Construct an instance of the SubnetIdentityByID model - subnetIdentityModel := new(vpcv1.SubnetIdentityByID) - subnetIdentityModel.ID = core.StringPtr("7ec86020-1c6e-4889-b3f0-a15f2e50f87e") - - // Construct an instance of the BareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceVirtualNetworkInterfacePrototypeBareMetalServerNetworkAttachmentContext model - bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel := new(vpcv1.BareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceVirtualNetworkInterfacePrototypeBareMetalServerNetworkAttachmentContext) - bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel.AllowIPSpoofing = core.BoolPtr(true) - bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel.AutoDelete = core.BoolPtr(false) - bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel.EnableInfrastructureNat = core.BoolPtr(true) - bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel.Ips = []vpcv1.VirtualNetworkInterfaceIPPrototypeIntf{virtualNetworkInterfaceIPPrototypeModel} - bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel.Name = core.StringPtr("my-virtual-network-interface") - bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel.PrimaryIP = virtualNetworkInterfacePrimaryIPPrototypeModel - bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel.ResourceGroup = resourceGroupIdentityModel - bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel.SecurityGroups = []vpcv1.SecurityGroupIdentityIntf{securityGroupIdentityModel} - bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel.Subnet = subnetIdentityModel - - // Construct an instance of the BareMetalServerNetworkAttachmentPrototypeBareMetalServerNetworkAttachmentByPciPrototype model - bareMetalServerNetworkAttachmentPrototypeModel := new(vpcv1.BareMetalServerNetworkAttachmentPrototypeBareMetalServerNetworkAttachmentByPciPrototype) - bareMetalServerNetworkAttachmentPrototypeModel.Name = core.StringPtr("my-bare-metal-server-network-attachment") - bareMetalServerNetworkAttachmentPrototypeModel.VirtualNetworkInterface = bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel - bareMetalServerNetworkAttachmentPrototypeModel.AllowedVlans = []int64{} - bareMetalServerNetworkAttachmentPrototypeModel.InterfaceType = core.StringPtr("pci") - - // Construct an instance of the BareMetalServerPrimaryNetworkAttachmentPrototypeBareMetalServerPrimaryNetworkAttachmentByPciPrototype model - bareMetalServerPrimaryNetworkAttachmentPrototypeModel := new(vpcv1.BareMetalServerPrimaryNetworkAttachmentPrototypeBareMetalServerPrimaryNetworkAttachmentByPciPrototype) - bareMetalServerPrimaryNetworkAttachmentPrototypeModel.Name = core.StringPtr("my-bare-metal-server-network-attachment") - bareMetalServerPrimaryNetworkAttachmentPrototypeModel.VirtualNetworkInterface = bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel - bareMetalServerPrimaryNetworkAttachmentPrototypeModel.AllowedVlans = []int64{} - bareMetalServerPrimaryNetworkAttachmentPrototypeModel.InterfaceType = core.StringPtr("pci") - - // Construct an instance of the BareMetalServerPrototypeBareMetalServerByNetworkAttachment model - bareMetalServerPrototypeModel := new(vpcv1.BareMetalServerPrototypeBareMetalServerByNetworkAttachment) - bareMetalServerPrototypeModel.EnableSecureBoot = core.BoolPtr(false) - bareMetalServerPrototypeModel.Initialization = bareMetalServerInitializationPrototypeModel - bareMetalServerPrototypeModel.Name = core.StringPtr("my-bare-metal-server") - bareMetalServerPrototypeModel.Profile = bareMetalServerProfileIdentityModel - bareMetalServerPrototypeModel.ResourceGroup = resourceGroupIdentityModel - bareMetalServerPrototypeModel.TrustedPlatformModule = bareMetalServerTrustedPlatformModulePrototypeModel - bareMetalServerPrototypeModel.VPC = vpcIdentityModel - bareMetalServerPrototypeModel.Zone = zoneIdentityModel - bareMetalServerPrototypeModel.NetworkAttachments = []vpcv1.BareMetalServerNetworkAttachmentPrototypeIntf{bareMetalServerNetworkAttachmentPrototypeModel} - bareMetalServerPrototypeModel.PrimaryNetworkAttachment = bareMetalServerPrimaryNetworkAttachmentPrototypeModel - - // Construct an instance of the CreateBareMetalServerOptions model - createBareMetalServerOptionsModel := new(vpcv1.CreateBareMetalServerOptions) - createBareMetalServerOptionsModel.BareMetalServerPrototype = bareMetalServerPrototypeModel - createBareMetalServerOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the GetBareMetalServerNetworkInterfaceFloatingIPOptions model + getBareMetalServerNetworkInterfaceFloatingIPOptionsModel := new(vpcv1.GetBareMetalServerNetworkInterfaceFloatingIPOptions) + getBareMetalServerNetworkInterfaceFloatingIPOptionsModel.BareMetalServerID = core.StringPtr("testString") + getBareMetalServerNetworkInterfaceFloatingIPOptionsModel.NetworkInterfaceID = core.StringPtr("testString") + getBareMetalServerNetworkInterfaceFloatingIPOptionsModel.ID = core.StringPtr("testString") + getBareMetalServerNetworkInterfaceFloatingIPOptionsModel.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.CreateBareMetalServer(createBareMetalServerOptionsModel) + result, response, operationErr := vpcService.GetBareMetalServerNetworkInterfaceFloatingIP(getBareMetalServerNetworkInterfaceFloatingIPOptionsModel) 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 CreateBareMetalServerOptions model with no property values - createBareMetalServerOptionsModelNew := new(vpcv1.CreateBareMetalServerOptions) + // Construct a second instance of the GetBareMetalServerNetworkInterfaceFloatingIPOptions model with no property values + getBareMetalServerNetworkInterfaceFloatingIPOptionsModelNew := new(vpcv1.GetBareMetalServerNetworkInterfaceFloatingIPOptions) // Invoke operation with invalid model (negative test) - result, response, operationErr = vpcService.CreateBareMetalServer(createBareMetalServerOptionsModelNew) + result, response, operationErr = vpcService.GetBareMetalServerNetworkInterfaceFloatingIP(getBareMetalServerNetworkInterfaceFloatingIPOptionsModelNew) Expect(operationErr).ToNot(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) @@ -47340,10 +47834,10 @@ var _ = Describe(`VpcV1`, func() { defer GinkgoRecover() // Set success status code with no respoonse body - res.WriteHeader(201) + res.WriteHeader(200) })) }) - It(`Invoke CreateBareMetalServer successfully`, func() { + It(`Invoke GetBareMetalServerNetworkInterfaceFloatingIP successfully`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -47352,106 +47846,15 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the ImageIdentityByID model - imageIdentityModel := new(vpcv1.ImageIdentityByID) - imageIdentityModel.ID = core.StringPtr("72b27b5c-f4b0-48bb-b954-5becc7c1dcb8") - - // Construct an instance of the KeyIdentityByID model - keyIdentityModel := new(vpcv1.KeyIdentityByID) - keyIdentityModel.ID = core.StringPtr("a6b1a881-2ce8-41a3-80fc-36316a73f803") - - // Construct an instance of the BareMetalServerInitializationPrototype model - bareMetalServerInitializationPrototypeModel := new(vpcv1.BareMetalServerInitializationPrototype) - bareMetalServerInitializationPrototypeModel.Image = imageIdentityModel - bareMetalServerInitializationPrototypeModel.Keys = []vpcv1.KeyIdentityIntf{keyIdentityModel} - bareMetalServerInitializationPrototypeModel.UserData = core.StringPtr("testString") - - // Construct an instance of the BareMetalServerProfileIdentityByName model - bareMetalServerProfileIdentityModel := new(vpcv1.BareMetalServerProfileIdentityByName) - bareMetalServerProfileIdentityModel.Name = core.StringPtr("bx2-metal-192x768") - - // Construct an instance of the ResourceGroupIdentityByID model - resourceGroupIdentityModel := new(vpcv1.ResourceGroupIdentityByID) - resourceGroupIdentityModel.ID = core.StringPtr("fee82deba12e4c0fb69c3b09d1f12345") - - // Construct an instance of the BareMetalServerTrustedPlatformModulePrototype model - bareMetalServerTrustedPlatformModulePrototypeModel := new(vpcv1.BareMetalServerTrustedPlatformModulePrototype) - bareMetalServerTrustedPlatformModulePrototypeModel.Mode = core.StringPtr("disabled") - - // Construct an instance of the VPCIdentityByID model - vpcIdentityModel := new(vpcv1.VPCIdentityByID) - vpcIdentityModel.ID = core.StringPtr("4727d842-f94f-4a2d-824a-9bc9b02c523b") - - // Construct an instance of the ZoneIdentityByName model - zoneIdentityModel := new(vpcv1.ZoneIdentityByName) - zoneIdentityModel.Name = core.StringPtr("us-south-1") - - // Construct an instance of the VirtualNetworkInterfaceIPPrototypeReservedIPPrototypeVirtualNetworkInterfaceIPsContext model - virtualNetworkInterfaceIPPrototypeModel := new(vpcv1.VirtualNetworkInterfaceIPPrototypeReservedIPPrototypeVirtualNetworkInterfaceIPsContext) - virtualNetworkInterfaceIPPrototypeModel.Address = core.StringPtr("10.0.0.5") - virtualNetworkInterfaceIPPrototypeModel.AutoDelete = core.BoolPtr(false) - virtualNetworkInterfaceIPPrototypeModel.Name = core.StringPtr("my-reserved-ip") - - // Construct an instance of the VirtualNetworkInterfacePrimaryIPPrototypeReservedIPPrototypeVirtualNetworkInterfacePrimaryIPContext model - virtualNetworkInterfacePrimaryIPPrototypeModel := new(vpcv1.VirtualNetworkInterfacePrimaryIPPrototypeReservedIPPrototypeVirtualNetworkInterfacePrimaryIPContext) - virtualNetworkInterfacePrimaryIPPrototypeModel.Address = core.StringPtr("10.0.0.5") - virtualNetworkInterfacePrimaryIPPrototypeModel.AutoDelete = core.BoolPtr(false) - virtualNetworkInterfacePrimaryIPPrototypeModel.Name = core.StringPtr("my-reserved-ip") - - // Construct an instance of the SecurityGroupIdentityByID model - securityGroupIdentityModel := new(vpcv1.SecurityGroupIdentityByID) - securityGroupIdentityModel.ID = core.StringPtr("be5df5ca-12a0-494b-907e-aa6ec2bfa271") - - // Construct an instance of the SubnetIdentityByID model - subnetIdentityModel := new(vpcv1.SubnetIdentityByID) - subnetIdentityModel.ID = core.StringPtr("7ec86020-1c6e-4889-b3f0-a15f2e50f87e") - - // Construct an instance of the BareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceVirtualNetworkInterfacePrototypeBareMetalServerNetworkAttachmentContext model - bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel := new(vpcv1.BareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceVirtualNetworkInterfacePrototypeBareMetalServerNetworkAttachmentContext) - bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel.AllowIPSpoofing = core.BoolPtr(true) - bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel.AutoDelete = core.BoolPtr(false) - bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel.EnableInfrastructureNat = core.BoolPtr(true) - bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel.Ips = []vpcv1.VirtualNetworkInterfaceIPPrototypeIntf{virtualNetworkInterfaceIPPrototypeModel} - bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel.Name = core.StringPtr("my-virtual-network-interface") - bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel.PrimaryIP = virtualNetworkInterfacePrimaryIPPrototypeModel - bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel.ResourceGroup = resourceGroupIdentityModel - bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel.SecurityGroups = []vpcv1.SecurityGroupIdentityIntf{securityGroupIdentityModel} - bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel.Subnet = subnetIdentityModel - - // Construct an instance of the BareMetalServerNetworkAttachmentPrototypeBareMetalServerNetworkAttachmentByPciPrototype model - bareMetalServerNetworkAttachmentPrototypeModel := new(vpcv1.BareMetalServerNetworkAttachmentPrototypeBareMetalServerNetworkAttachmentByPciPrototype) - bareMetalServerNetworkAttachmentPrototypeModel.Name = core.StringPtr("my-bare-metal-server-network-attachment") - bareMetalServerNetworkAttachmentPrototypeModel.VirtualNetworkInterface = bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel - bareMetalServerNetworkAttachmentPrototypeModel.AllowedVlans = []int64{} - bareMetalServerNetworkAttachmentPrototypeModel.InterfaceType = core.StringPtr("pci") - - // Construct an instance of the BareMetalServerPrimaryNetworkAttachmentPrototypeBareMetalServerPrimaryNetworkAttachmentByPciPrototype model - bareMetalServerPrimaryNetworkAttachmentPrototypeModel := new(vpcv1.BareMetalServerPrimaryNetworkAttachmentPrototypeBareMetalServerPrimaryNetworkAttachmentByPciPrototype) - bareMetalServerPrimaryNetworkAttachmentPrototypeModel.Name = core.StringPtr("my-bare-metal-server-network-attachment") - bareMetalServerPrimaryNetworkAttachmentPrototypeModel.VirtualNetworkInterface = bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel - bareMetalServerPrimaryNetworkAttachmentPrototypeModel.AllowedVlans = []int64{} - bareMetalServerPrimaryNetworkAttachmentPrototypeModel.InterfaceType = core.StringPtr("pci") - - // Construct an instance of the BareMetalServerPrototypeBareMetalServerByNetworkAttachment model - bareMetalServerPrototypeModel := new(vpcv1.BareMetalServerPrototypeBareMetalServerByNetworkAttachment) - bareMetalServerPrototypeModel.EnableSecureBoot = core.BoolPtr(false) - bareMetalServerPrototypeModel.Initialization = bareMetalServerInitializationPrototypeModel - bareMetalServerPrototypeModel.Name = core.StringPtr("my-bare-metal-server") - bareMetalServerPrototypeModel.Profile = bareMetalServerProfileIdentityModel - bareMetalServerPrototypeModel.ResourceGroup = resourceGroupIdentityModel - bareMetalServerPrototypeModel.TrustedPlatformModule = bareMetalServerTrustedPlatformModulePrototypeModel - bareMetalServerPrototypeModel.VPC = vpcIdentityModel - bareMetalServerPrototypeModel.Zone = zoneIdentityModel - bareMetalServerPrototypeModel.NetworkAttachments = []vpcv1.BareMetalServerNetworkAttachmentPrototypeIntf{bareMetalServerNetworkAttachmentPrototypeModel} - bareMetalServerPrototypeModel.PrimaryNetworkAttachment = bareMetalServerPrimaryNetworkAttachmentPrototypeModel - - // Construct an instance of the CreateBareMetalServerOptions model - createBareMetalServerOptionsModel := new(vpcv1.CreateBareMetalServerOptions) - createBareMetalServerOptionsModel.BareMetalServerPrototype = bareMetalServerPrototypeModel - createBareMetalServerOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the GetBareMetalServerNetworkInterfaceFloatingIPOptions model + getBareMetalServerNetworkInterfaceFloatingIPOptionsModel := new(vpcv1.GetBareMetalServerNetworkInterfaceFloatingIPOptions) + getBareMetalServerNetworkInterfaceFloatingIPOptionsModel.BareMetalServerID = core.StringPtr("testString") + getBareMetalServerNetworkInterfaceFloatingIPOptionsModel.NetworkInterfaceID = core.StringPtr("testString") + getBareMetalServerNetworkInterfaceFloatingIPOptionsModel.ID = core.StringPtr("testString") + getBareMetalServerNetworkInterfaceFloatingIPOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation - result, response, operationErr := vpcService.CreateBareMetalServer(createBareMetalServerOptionsModel) + result, response, operationErr := vpcService.GetBareMetalServerNetworkInterfaceFloatingIP(getBareMetalServerNetworkInterfaceFloatingIPOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) @@ -47463,25 +47866,25 @@ var _ = Describe(`VpcV1`, func() { }) }) }) - Describe(`CreateBareMetalServerConsoleAccessToken(createBareMetalServerConsoleAccessTokenOptions *CreateBareMetalServerConsoleAccessTokenOptions) - Operation response error`, func() { + Describe(`AddBareMetalServerNetworkInterfaceFloatingIP(addBareMetalServerNetworkInterfaceFloatingIPOptions *AddBareMetalServerNetworkInterfaceFloatingIPOptions) - Operation response error`, func() { version := "testString" - createBareMetalServerConsoleAccessTokenPath := "/bare_metal_servers/testString/console_access_token" + addBareMetalServerNetworkInterfaceFloatingIPPath := "/bare_metal_servers/testString/network_interfaces/testString/floating_ips/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(createBareMetalServerConsoleAccessTokenPath)) - Expect(req.Method).To(Equal("POST")) + Expect(req.URL.EscapedPath()).To(Equal(addBareMetalServerNetworkInterfaceFloatingIPPath)) + Expect(req.Method).To(Equal("PUT")) 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 CreateBareMetalServerConsoleAccessToken with error: Operation response processing error`, func() { + It(`Invoke AddBareMetalServerNetworkInterfaceFloatingIP with error: Operation response processing error`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -47490,21 +47893,21 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the CreateBareMetalServerConsoleAccessTokenOptions model - createBareMetalServerConsoleAccessTokenOptionsModel := new(vpcv1.CreateBareMetalServerConsoleAccessTokenOptions) - createBareMetalServerConsoleAccessTokenOptionsModel.BareMetalServerID = core.StringPtr("testString") - createBareMetalServerConsoleAccessTokenOptionsModel.ConsoleType = core.StringPtr("serial") - createBareMetalServerConsoleAccessTokenOptionsModel.Force = core.BoolPtr(false) - createBareMetalServerConsoleAccessTokenOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the AddBareMetalServerNetworkInterfaceFloatingIPOptions model + addBareMetalServerNetworkInterfaceFloatingIPOptionsModel := new(vpcv1.AddBareMetalServerNetworkInterfaceFloatingIPOptions) + addBareMetalServerNetworkInterfaceFloatingIPOptionsModel.BareMetalServerID = core.StringPtr("testString") + addBareMetalServerNetworkInterfaceFloatingIPOptionsModel.NetworkInterfaceID = core.StringPtr("testString") + addBareMetalServerNetworkInterfaceFloatingIPOptionsModel.ID = core.StringPtr("testString") + addBareMetalServerNetworkInterfaceFloatingIPOptionsModel.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.CreateBareMetalServerConsoleAccessToken(createBareMetalServerConsoleAccessTokenOptionsModel) + result, response, operationErr := vpcService.AddBareMetalServerNetworkInterfaceFloatingIP(addBareMetalServerNetworkInterfaceFloatingIPOptionsModel) 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.CreateBareMetalServerConsoleAccessToken(createBareMetalServerConsoleAccessTokenOptionsModel) + result, response, operationErr = vpcService.AddBareMetalServerNetworkInterfaceFloatingIP(addBareMetalServerNetworkInterfaceFloatingIPOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).To(BeNil()) @@ -47514,33 +47917,17 @@ var _ = Describe(`VpcV1`, func() { }) }) }) - Describe(`CreateBareMetalServerConsoleAccessToken(createBareMetalServerConsoleAccessTokenOptions *CreateBareMetalServerConsoleAccessTokenOptions)`, func() { + Describe(`AddBareMetalServerNetworkInterfaceFloatingIP(addBareMetalServerNetworkInterfaceFloatingIPOptions *AddBareMetalServerNetworkInterfaceFloatingIPOptions)`, func() { version := "testString" - createBareMetalServerConsoleAccessTokenPath := "/bare_metal_servers/testString/console_access_token" - 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(createBareMetalServerConsoleAccessTokenPath)) - 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()) + addBareMetalServerNetworkInterfaceFloatingIPPath := "/bare_metal_servers/testString/network_interfaces/testString/floating_ips/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(addBareMetalServerNetworkInterfaceFloatingIPPath)) + Expect(req.Method).To(Equal("PUT")) Expect(req.URL.Query()["version"]).To(Equal([]string{"testString"})) Expect(req.URL.Query()["generation"]).To(Equal([]string{fmt.Sprint(int64(2))})) @@ -47549,11 +47936,11 @@ var _ = Describe(`VpcV1`, func() { // Set mock response res.Header().Set("Content-type", "application/json") - res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"access_token": "VGhpcyBJcyBhIHRva2Vu", "console_type": "serial", "created_at": "2020-07-27T21:50:14.000Z", "expires_at": "2020-07-27T21:51:14.000Z", "force": false, "href": "wss://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/1e09281b-f177-46fb-baf1-bc152b2e391a/console?access_token=VGhpcyBJcyBhIHRva2Vu"}`) + res.WriteHeader(201) + fmt.Fprintf(res, "%s", `{"address": "203.0.113.1", "created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::floating-ip:39300233-9995-4806-89a5-3c1b6eb88689", "href": "https://us-south.iaas.cloud.ibm.com/v1/floating_ips/39300233-9995-4806-89a5-3c1b6eb88689", "id": "39300233-9995-4806-89a5-3c1b6eb88689", "name": "my-floating-ip", "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "status": "available", "target": {"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/instances/1e09281b-f177-46fb-baf1-bc152b2e391a/network_interfaces/10c02d81-0ecb-4dc5-897d-28392913b81e", "id": "10c02d81-0ecb-4dc5-897d-28392913b81e", "name": "my-instance-network-interface", "primary_ip": {"address": "192.168.3.4", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e/reserved_ips/6d353a0f-aeb1-4ae1-832e-1110d10981bb", "id": "6d353a0f-aeb1-4ae1-832e-1110d10981bb", "name": "my-reserved-ip", "resource_type": "subnet_reserved_ip"}, "resource_type": "network_interface"}, "zone": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south/zones/us-south-1", "name": "us-south-1"}}`) })) }) - It(`Invoke CreateBareMetalServerConsoleAccessToken successfully with retries`, func() { + It(`Invoke AddBareMetalServerNetworkInterfaceFloatingIP successfully with retries`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -47563,23 +47950,23 @@ var _ = Describe(`VpcV1`, func() { Expect(vpcService).ToNot(BeNil()) vpcService.EnableRetries(0, 0) - // Construct an instance of the CreateBareMetalServerConsoleAccessTokenOptions model - createBareMetalServerConsoleAccessTokenOptionsModel := new(vpcv1.CreateBareMetalServerConsoleAccessTokenOptions) - createBareMetalServerConsoleAccessTokenOptionsModel.BareMetalServerID = core.StringPtr("testString") - createBareMetalServerConsoleAccessTokenOptionsModel.ConsoleType = core.StringPtr("serial") - createBareMetalServerConsoleAccessTokenOptionsModel.Force = core.BoolPtr(false) - createBareMetalServerConsoleAccessTokenOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the AddBareMetalServerNetworkInterfaceFloatingIPOptions model + addBareMetalServerNetworkInterfaceFloatingIPOptionsModel := new(vpcv1.AddBareMetalServerNetworkInterfaceFloatingIPOptions) + addBareMetalServerNetworkInterfaceFloatingIPOptionsModel.BareMetalServerID = core.StringPtr("testString") + addBareMetalServerNetworkInterfaceFloatingIPOptionsModel.NetworkInterfaceID = core.StringPtr("testString") + addBareMetalServerNetworkInterfaceFloatingIPOptionsModel.ID = core.StringPtr("testString") + addBareMetalServerNetworkInterfaceFloatingIPOptionsModel.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.CreateBareMetalServerConsoleAccessTokenWithContext(ctx, createBareMetalServerConsoleAccessTokenOptionsModel) + _, _, operationErr := vpcService.AddBareMetalServerNetworkInterfaceFloatingIPWithContext(ctx, addBareMetalServerNetworkInterfaceFloatingIPOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) // Disable retries and test again vpcService.DisableRetries() - result, response, operationErr := vpcService.CreateBareMetalServerConsoleAccessToken(createBareMetalServerConsoleAccessTokenOptionsModel) + result, response, operationErr := vpcService.AddBareMetalServerNetworkInterfaceFloatingIP(addBareMetalServerNetworkInterfaceFloatingIPOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) @@ -47587,7 +47974,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.CreateBareMetalServerConsoleAccessTokenWithContext(ctx, createBareMetalServerConsoleAccessTokenOptionsModel) + _, _, operationErr = vpcService.AddBareMetalServerNetworkInterfaceFloatingIPWithContext(ctx, addBareMetalServerNetworkInterfaceFloatingIPOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) }) @@ -47601,34 +47988,18 @@ var _ = Describe(`VpcV1`, func() { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(createBareMetalServerConsoleAccessTokenPath)) - 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.EscapedPath()).To(Equal(addBareMetalServerNetworkInterfaceFloatingIPPath)) + Expect(req.Method).To(Equal("PUT")) 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", `{"access_token": "VGhpcyBJcyBhIHRva2Vu", "console_type": "serial", "created_at": "2020-07-27T21:50:14.000Z", "expires_at": "2020-07-27T21:51:14.000Z", "force": false, "href": "wss://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/1e09281b-f177-46fb-baf1-bc152b2e391a/console?access_token=VGhpcyBJcyBhIHRva2Vu"}`) + res.WriteHeader(201) + fmt.Fprintf(res, "%s", `{"address": "203.0.113.1", "created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::floating-ip:39300233-9995-4806-89a5-3c1b6eb88689", "href": "https://us-south.iaas.cloud.ibm.com/v1/floating_ips/39300233-9995-4806-89a5-3c1b6eb88689", "id": "39300233-9995-4806-89a5-3c1b6eb88689", "name": "my-floating-ip", "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "status": "available", "target": {"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/instances/1e09281b-f177-46fb-baf1-bc152b2e391a/network_interfaces/10c02d81-0ecb-4dc5-897d-28392913b81e", "id": "10c02d81-0ecb-4dc5-897d-28392913b81e", "name": "my-instance-network-interface", "primary_ip": {"address": "192.168.3.4", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e/reserved_ips/6d353a0f-aeb1-4ae1-832e-1110d10981bb", "id": "6d353a0f-aeb1-4ae1-832e-1110d10981bb", "name": "my-reserved-ip", "resource_type": "subnet_reserved_ip"}, "resource_type": "network_interface"}, "zone": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south/zones/us-south-1", "name": "us-south-1"}}`) })) }) - It(`Invoke CreateBareMetalServerConsoleAccessToken successfully`, func() { + It(`Invoke AddBareMetalServerNetworkInterfaceFloatingIP successfully`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -47638,26 +48009,26 @@ var _ = Describe(`VpcV1`, func() { Expect(vpcService).ToNot(BeNil()) // Invoke operation with nil options model (negative test) - result, response, operationErr := vpcService.CreateBareMetalServerConsoleAccessToken(nil) + result, response, operationErr := vpcService.AddBareMetalServerNetworkInterfaceFloatingIP(nil) Expect(operationErr).NotTo(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) - // Construct an instance of the CreateBareMetalServerConsoleAccessTokenOptions model - createBareMetalServerConsoleAccessTokenOptionsModel := new(vpcv1.CreateBareMetalServerConsoleAccessTokenOptions) - createBareMetalServerConsoleAccessTokenOptionsModel.BareMetalServerID = core.StringPtr("testString") - createBareMetalServerConsoleAccessTokenOptionsModel.ConsoleType = core.StringPtr("serial") - createBareMetalServerConsoleAccessTokenOptionsModel.Force = core.BoolPtr(false) - createBareMetalServerConsoleAccessTokenOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the AddBareMetalServerNetworkInterfaceFloatingIPOptions model + addBareMetalServerNetworkInterfaceFloatingIPOptionsModel := new(vpcv1.AddBareMetalServerNetworkInterfaceFloatingIPOptions) + addBareMetalServerNetworkInterfaceFloatingIPOptionsModel.BareMetalServerID = core.StringPtr("testString") + addBareMetalServerNetworkInterfaceFloatingIPOptionsModel.NetworkInterfaceID = core.StringPtr("testString") + addBareMetalServerNetworkInterfaceFloatingIPOptionsModel.ID = core.StringPtr("testString") + addBareMetalServerNetworkInterfaceFloatingIPOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with valid options model (positive test) - result, response, operationErr = vpcService.CreateBareMetalServerConsoleAccessToken(createBareMetalServerConsoleAccessTokenOptionsModel) + result, response, operationErr = vpcService.AddBareMetalServerNetworkInterfaceFloatingIP(addBareMetalServerNetworkInterfaceFloatingIPOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) }) - It(`Invoke CreateBareMetalServerConsoleAccessToken with error: Operation validation and request error`, func() { + It(`Invoke AddBareMetalServerNetworkInterfaceFloatingIP with error: Operation validation and request error`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -47666,24 +48037,24 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the CreateBareMetalServerConsoleAccessTokenOptions model - createBareMetalServerConsoleAccessTokenOptionsModel := new(vpcv1.CreateBareMetalServerConsoleAccessTokenOptions) - createBareMetalServerConsoleAccessTokenOptionsModel.BareMetalServerID = core.StringPtr("testString") - createBareMetalServerConsoleAccessTokenOptionsModel.ConsoleType = core.StringPtr("serial") - createBareMetalServerConsoleAccessTokenOptionsModel.Force = core.BoolPtr(false) - createBareMetalServerConsoleAccessTokenOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the AddBareMetalServerNetworkInterfaceFloatingIPOptions model + addBareMetalServerNetworkInterfaceFloatingIPOptionsModel := new(vpcv1.AddBareMetalServerNetworkInterfaceFloatingIPOptions) + addBareMetalServerNetworkInterfaceFloatingIPOptionsModel.BareMetalServerID = core.StringPtr("testString") + addBareMetalServerNetworkInterfaceFloatingIPOptionsModel.NetworkInterfaceID = core.StringPtr("testString") + addBareMetalServerNetworkInterfaceFloatingIPOptionsModel.ID = core.StringPtr("testString") + addBareMetalServerNetworkInterfaceFloatingIPOptionsModel.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.CreateBareMetalServerConsoleAccessToken(createBareMetalServerConsoleAccessTokenOptionsModel) + result, response, operationErr := vpcService.AddBareMetalServerNetworkInterfaceFloatingIP(addBareMetalServerNetworkInterfaceFloatingIPOptionsModel) 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 CreateBareMetalServerConsoleAccessTokenOptions model with no property values - createBareMetalServerConsoleAccessTokenOptionsModelNew := new(vpcv1.CreateBareMetalServerConsoleAccessTokenOptions) + // Construct a second instance of the AddBareMetalServerNetworkInterfaceFloatingIPOptions model with no property values + addBareMetalServerNetworkInterfaceFloatingIPOptionsModelNew := new(vpcv1.AddBareMetalServerNetworkInterfaceFloatingIPOptions) // Invoke operation with invalid model (negative test) - result, response, operationErr = vpcService.CreateBareMetalServerConsoleAccessToken(createBareMetalServerConsoleAccessTokenOptionsModelNew) + result, response, operationErr = vpcService.AddBareMetalServerNetworkInterfaceFloatingIP(addBareMetalServerNetworkInterfaceFloatingIPOptionsModelNew) Expect(operationErr).ToNot(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) @@ -47698,10 +48069,10 @@ var _ = Describe(`VpcV1`, func() { defer GinkgoRecover() // Set success status code with no respoonse body - res.WriteHeader(200) + res.WriteHeader(201) })) }) - It(`Invoke CreateBareMetalServerConsoleAccessToken successfully`, func() { + It(`Invoke AddBareMetalServerNetworkInterfaceFloatingIP successfully`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -47710,15 +48081,15 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the CreateBareMetalServerConsoleAccessTokenOptions model - createBareMetalServerConsoleAccessTokenOptionsModel := new(vpcv1.CreateBareMetalServerConsoleAccessTokenOptions) - createBareMetalServerConsoleAccessTokenOptionsModel.BareMetalServerID = core.StringPtr("testString") - createBareMetalServerConsoleAccessTokenOptionsModel.ConsoleType = core.StringPtr("serial") - createBareMetalServerConsoleAccessTokenOptionsModel.Force = core.BoolPtr(false) - createBareMetalServerConsoleAccessTokenOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the AddBareMetalServerNetworkInterfaceFloatingIPOptions model + addBareMetalServerNetworkInterfaceFloatingIPOptionsModel := new(vpcv1.AddBareMetalServerNetworkInterfaceFloatingIPOptions) + addBareMetalServerNetworkInterfaceFloatingIPOptionsModel.BareMetalServerID = core.StringPtr("testString") + addBareMetalServerNetworkInterfaceFloatingIPOptionsModel.NetworkInterfaceID = core.StringPtr("testString") + addBareMetalServerNetworkInterfaceFloatingIPOptionsModel.ID = core.StringPtr("testString") + addBareMetalServerNetworkInterfaceFloatingIPOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation - result, response, operationErr := vpcService.CreateBareMetalServerConsoleAccessToken(createBareMetalServerConsoleAccessTokenOptionsModel) + result, response, operationErr := vpcService.AddBareMetalServerNetworkInterfaceFloatingIP(addBareMetalServerNetworkInterfaceFloatingIPOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) @@ -47730,16 +48101,16 @@ var _ = Describe(`VpcV1`, func() { }) }) }) - Describe(`ListBareMetalServerDisks(listBareMetalServerDisksOptions *ListBareMetalServerDisksOptions) - Operation response error`, func() { + Describe(`ListBareMetalServerNetworkInterfaceIps(listBareMetalServerNetworkInterfaceIpsOptions *ListBareMetalServerNetworkInterfaceIpsOptions) - Operation response error`, func() { version := "testString" - listBareMetalServerDisksPath := "/bare_metal_servers/testString/disks" + listBareMetalServerNetworkInterfaceIpsPath := "/bare_metal_servers/testString/network_interfaces/testString/ips" 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(listBareMetalServerDisksPath)) + Expect(req.URL.EscapedPath()).To(Equal(listBareMetalServerNetworkInterfaceIpsPath)) 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))})) @@ -47748,7 +48119,7 @@ var _ = Describe(`VpcV1`, func() { fmt.Fprint(res, `} this is not valid json {`) })) }) - It(`Invoke ListBareMetalServerDisks with error: Operation response processing error`, func() { + It(`Invoke ListBareMetalServerNetworkInterfaceIps with error: Operation response processing error`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -47757,19 +48128,20 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the ListBareMetalServerDisksOptions model - listBareMetalServerDisksOptionsModel := new(vpcv1.ListBareMetalServerDisksOptions) - listBareMetalServerDisksOptionsModel.BareMetalServerID = core.StringPtr("testString") - listBareMetalServerDisksOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the ListBareMetalServerNetworkInterfaceIpsOptions model + listBareMetalServerNetworkInterfaceIpsOptionsModel := new(vpcv1.ListBareMetalServerNetworkInterfaceIpsOptions) + listBareMetalServerNetworkInterfaceIpsOptionsModel.BareMetalServerID = core.StringPtr("testString") + listBareMetalServerNetworkInterfaceIpsOptionsModel.NetworkInterfaceID = core.StringPtr("testString") + listBareMetalServerNetworkInterfaceIpsOptionsModel.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.ListBareMetalServerDisks(listBareMetalServerDisksOptionsModel) + result, response, operationErr := vpcService.ListBareMetalServerNetworkInterfaceIps(listBareMetalServerNetworkInterfaceIpsOptionsModel) 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.ListBareMetalServerDisks(listBareMetalServerDisksOptionsModel) + result, response, operationErr = vpcService.ListBareMetalServerNetworkInterfaceIps(listBareMetalServerNetworkInterfaceIpsOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).To(BeNil()) @@ -47779,16 +48151,16 @@ var _ = Describe(`VpcV1`, func() { }) }) }) - Describe(`ListBareMetalServerDisks(listBareMetalServerDisksOptions *ListBareMetalServerDisksOptions)`, func() { + Describe(`ListBareMetalServerNetworkInterfaceIps(listBareMetalServerNetworkInterfaceIpsOptions *ListBareMetalServerNetworkInterfaceIpsOptions)`, func() { version := "testString" - listBareMetalServerDisksPath := "/bare_metal_servers/testString/disks" + listBareMetalServerNetworkInterfaceIpsPath := "/bare_metal_servers/testString/network_interfaces/testString/ips" 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(listBareMetalServerDisksPath)) + Expect(req.URL.EscapedPath()).To(Equal(listBareMetalServerNetworkInterfaceIpsPath)) Expect(req.Method).To(Equal("GET")) Expect(req.URL.Query()["version"]).To(Equal([]string{"testString"})) @@ -47799,10 +48171,10 @@ var _ = Describe(`VpcV1`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"disks": [{"created_at": "2019-01-01T12:00:00.000Z", "href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/1e09281b-f177-46fb-baf1-bc152b2e391a/disks/10c02d81-0ecb-4dc5-897d-28392913b81e", "id": "10c02d81-0ecb-4dc5-897d-28392913b81e", "interface_type": "fcp", "name": "my-bare-metal-server-disk", "resource_type": "bare_metal_server_disk", "size": 100}]}`) + fmt.Fprintf(res, "%s", `{"first": {"href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/1e09281b-f177-46fb-baf1-bc152b2e391a/network_interfaces/10c02d81-0ecb-4dc5-897d-28392913b81e/ips?limit=20"}, "ips": [{"address": "192.168.3.4", "auto_delete": false, "created_at": "2019-01-01T12:00:00.000Z", "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e/reserved_ips/6d353a0f-aeb1-4ae1-832e-1110d10981bb", "id": "6d353a0f-aeb1-4ae1-832e-1110d10981bb", "lifecycle_state": "stable", "name": "my-reserved-ip", "owner": "user", "resource_type": "subnet_reserved_ip", "target": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::endpoint-gateway:r134-d7cc5196-9864-48c4-82d8-3f30da41fcc5", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/endpoint_gateways/r134-d7cc5196-9864-48c4-82d8-3f30da41fcc5", "id": "r134-d7cc5196-9864-48c4-82d8-3f30da41fcc5", "name": "my-endpoint-gateway", "resource_type": "endpoint_gateway"}}], "limit": 20, "next": {"href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/1e09281b-f177-46fb-baf1-bc152b2e391a/network_interfaces/10c02d81-0ecb-4dc5-897d-28392913b81e/ips?start=a404e343444b4e1095c9edba76672d67&limit=20"}, "total_count": 132}`) })) }) - It(`Invoke ListBareMetalServerDisks successfully with retries`, func() { + It(`Invoke ListBareMetalServerNetworkInterfaceIps successfully with retries`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -47812,21 +48184,22 @@ var _ = Describe(`VpcV1`, func() { Expect(vpcService).ToNot(BeNil()) vpcService.EnableRetries(0, 0) - // Construct an instance of the ListBareMetalServerDisksOptions model - listBareMetalServerDisksOptionsModel := new(vpcv1.ListBareMetalServerDisksOptions) - listBareMetalServerDisksOptionsModel.BareMetalServerID = core.StringPtr("testString") - listBareMetalServerDisksOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the ListBareMetalServerNetworkInterfaceIpsOptions model + listBareMetalServerNetworkInterfaceIpsOptionsModel := new(vpcv1.ListBareMetalServerNetworkInterfaceIpsOptions) + listBareMetalServerNetworkInterfaceIpsOptionsModel.BareMetalServerID = core.StringPtr("testString") + listBareMetalServerNetworkInterfaceIpsOptionsModel.NetworkInterfaceID = core.StringPtr("testString") + listBareMetalServerNetworkInterfaceIpsOptionsModel.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.ListBareMetalServerDisksWithContext(ctx, listBareMetalServerDisksOptionsModel) + _, _, operationErr := vpcService.ListBareMetalServerNetworkInterfaceIpsWithContext(ctx, listBareMetalServerNetworkInterfaceIpsOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) // Disable retries and test again vpcService.DisableRetries() - result, response, operationErr := vpcService.ListBareMetalServerDisks(listBareMetalServerDisksOptionsModel) + result, response, operationErr := vpcService.ListBareMetalServerNetworkInterfaceIps(listBareMetalServerNetworkInterfaceIpsOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) @@ -47834,7 +48207,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.ListBareMetalServerDisksWithContext(ctx, listBareMetalServerDisksOptionsModel) + _, _, operationErr = vpcService.ListBareMetalServerNetworkInterfaceIpsWithContext(ctx, listBareMetalServerNetworkInterfaceIpsOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) }) @@ -47848,7 +48221,7 @@ var _ = Describe(`VpcV1`, func() { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(listBareMetalServerDisksPath)) + Expect(req.URL.EscapedPath()).To(Equal(listBareMetalServerNetworkInterfaceIpsPath)) Expect(req.Method).To(Equal("GET")) Expect(req.URL.Query()["version"]).To(Equal([]string{"testString"})) @@ -47856,10 +48229,10 @@ var _ = Describe(`VpcV1`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"disks": [{"created_at": "2019-01-01T12:00:00.000Z", "href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/1e09281b-f177-46fb-baf1-bc152b2e391a/disks/10c02d81-0ecb-4dc5-897d-28392913b81e", "id": "10c02d81-0ecb-4dc5-897d-28392913b81e", "interface_type": "fcp", "name": "my-bare-metal-server-disk", "resource_type": "bare_metal_server_disk", "size": 100}]}`) + fmt.Fprintf(res, "%s", `{"first": {"href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/1e09281b-f177-46fb-baf1-bc152b2e391a/network_interfaces/10c02d81-0ecb-4dc5-897d-28392913b81e/ips?limit=20"}, "ips": [{"address": "192.168.3.4", "auto_delete": false, "created_at": "2019-01-01T12:00:00.000Z", "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e/reserved_ips/6d353a0f-aeb1-4ae1-832e-1110d10981bb", "id": "6d353a0f-aeb1-4ae1-832e-1110d10981bb", "lifecycle_state": "stable", "name": "my-reserved-ip", "owner": "user", "resource_type": "subnet_reserved_ip", "target": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::endpoint-gateway:r134-d7cc5196-9864-48c4-82d8-3f30da41fcc5", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/endpoint_gateways/r134-d7cc5196-9864-48c4-82d8-3f30da41fcc5", "id": "r134-d7cc5196-9864-48c4-82d8-3f30da41fcc5", "name": "my-endpoint-gateway", "resource_type": "endpoint_gateway"}}], "limit": 20, "next": {"href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/1e09281b-f177-46fb-baf1-bc152b2e391a/network_interfaces/10c02d81-0ecb-4dc5-897d-28392913b81e/ips?start=a404e343444b4e1095c9edba76672d67&limit=20"}, "total_count": 132}`) })) }) - It(`Invoke ListBareMetalServerDisks successfully`, func() { + It(`Invoke ListBareMetalServerNetworkInterfaceIps successfully`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -47869,24 +48242,25 @@ var _ = Describe(`VpcV1`, func() { Expect(vpcService).ToNot(BeNil()) // Invoke operation with nil options model (negative test) - result, response, operationErr := vpcService.ListBareMetalServerDisks(nil) + result, response, operationErr := vpcService.ListBareMetalServerNetworkInterfaceIps(nil) Expect(operationErr).NotTo(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) - // Construct an instance of the ListBareMetalServerDisksOptions model - listBareMetalServerDisksOptionsModel := new(vpcv1.ListBareMetalServerDisksOptions) - listBareMetalServerDisksOptionsModel.BareMetalServerID = core.StringPtr("testString") - listBareMetalServerDisksOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the ListBareMetalServerNetworkInterfaceIpsOptions model + listBareMetalServerNetworkInterfaceIpsOptionsModel := new(vpcv1.ListBareMetalServerNetworkInterfaceIpsOptions) + listBareMetalServerNetworkInterfaceIpsOptionsModel.BareMetalServerID = core.StringPtr("testString") + listBareMetalServerNetworkInterfaceIpsOptionsModel.NetworkInterfaceID = core.StringPtr("testString") + listBareMetalServerNetworkInterfaceIpsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with valid options model (positive test) - result, response, operationErr = vpcService.ListBareMetalServerDisks(listBareMetalServerDisksOptionsModel) + result, response, operationErr = vpcService.ListBareMetalServerNetworkInterfaceIps(listBareMetalServerNetworkInterfaceIpsOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) }) - It(`Invoke ListBareMetalServerDisks with error: Operation validation and request error`, func() { + It(`Invoke ListBareMetalServerNetworkInterfaceIps with error: Operation validation and request error`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -47895,22 +48269,23 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the ListBareMetalServerDisksOptions model - listBareMetalServerDisksOptionsModel := new(vpcv1.ListBareMetalServerDisksOptions) - listBareMetalServerDisksOptionsModel.BareMetalServerID = core.StringPtr("testString") - listBareMetalServerDisksOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the ListBareMetalServerNetworkInterfaceIpsOptions model + listBareMetalServerNetworkInterfaceIpsOptionsModel := new(vpcv1.ListBareMetalServerNetworkInterfaceIpsOptions) + listBareMetalServerNetworkInterfaceIpsOptionsModel.BareMetalServerID = core.StringPtr("testString") + listBareMetalServerNetworkInterfaceIpsOptionsModel.NetworkInterfaceID = core.StringPtr("testString") + listBareMetalServerNetworkInterfaceIpsOptionsModel.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.ListBareMetalServerDisks(listBareMetalServerDisksOptionsModel) + result, response, operationErr := vpcService.ListBareMetalServerNetworkInterfaceIps(listBareMetalServerNetworkInterfaceIpsOptionsModel) 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 ListBareMetalServerDisksOptions model with no property values - listBareMetalServerDisksOptionsModelNew := new(vpcv1.ListBareMetalServerDisksOptions) + // Construct a second instance of the ListBareMetalServerNetworkInterfaceIpsOptions model with no property values + listBareMetalServerNetworkInterfaceIpsOptionsModelNew := new(vpcv1.ListBareMetalServerNetworkInterfaceIpsOptions) // Invoke operation with invalid model (negative test) - result, response, operationErr = vpcService.ListBareMetalServerDisks(listBareMetalServerDisksOptionsModelNew) + result, response, operationErr = vpcService.ListBareMetalServerNetworkInterfaceIps(listBareMetalServerNetworkInterfaceIpsOptionsModelNew) Expect(operationErr).ToNot(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) @@ -47928,7 +48303,7 @@ var _ = Describe(`VpcV1`, func() { res.WriteHeader(200) })) }) - It(`Invoke ListBareMetalServerDisks successfully`, func() { + It(`Invoke ListBareMetalServerNetworkInterfaceIps successfully`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -47937,13 +48312,14 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the ListBareMetalServerDisksOptions model - listBareMetalServerDisksOptionsModel := new(vpcv1.ListBareMetalServerDisksOptions) - listBareMetalServerDisksOptionsModel.BareMetalServerID = core.StringPtr("testString") - listBareMetalServerDisksOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the ListBareMetalServerNetworkInterfaceIpsOptions model + listBareMetalServerNetworkInterfaceIpsOptionsModel := new(vpcv1.ListBareMetalServerNetworkInterfaceIpsOptions) + listBareMetalServerNetworkInterfaceIpsOptionsModel.BareMetalServerID = core.StringPtr("testString") + listBareMetalServerNetworkInterfaceIpsOptionsModel.NetworkInterfaceID = core.StringPtr("testString") + listBareMetalServerNetworkInterfaceIpsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation - result, response, operationErr := vpcService.ListBareMetalServerDisks(listBareMetalServerDisksOptionsModel) + result, response, operationErr := vpcService.ListBareMetalServerNetworkInterfaceIps(listBareMetalServerNetworkInterfaceIpsOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) @@ -47955,16 +48331,16 @@ var _ = Describe(`VpcV1`, func() { }) }) }) - Describe(`GetBareMetalServerDisk(getBareMetalServerDiskOptions *GetBareMetalServerDiskOptions) - Operation response error`, func() { + Describe(`GetBareMetalServerNetworkInterfaceIP(getBareMetalServerNetworkInterfaceIPOptions *GetBareMetalServerNetworkInterfaceIPOptions) - Operation response error`, func() { version := "testString" - getBareMetalServerDiskPath := "/bare_metal_servers/testString/disks/testString" + getBareMetalServerNetworkInterfaceIPPath := "/bare_metal_servers/testString/network_interfaces/testString/ips/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(getBareMetalServerDiskPath)) + Expect(req.URL.EscapedPath()).To(Equal(getBareMetalServerNetworkInterfaceIPPath)) 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))})) @@ -47973,7 +48349,7 @@ var _ = Describe(`VpcV1`, func() { fmt.Fprint(res, `} this is not valid json {`) })) }) - It(`Invoke GetBareMetalServerDisk with error: Operation response processing error`, func() { + It(`Invoke GetBareMetalServerNetworkInterfaceIP with error: Operation response processing error`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -47982,20 +48358,21 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the GetBareMetalServerDiskOptions model - getBareMetalServerDiskOptionsModel := new(vpcv1.GetBareMetalServerDiskOptions) - getBareMetalServerDiskOptionsModel.BareMetalServerID = core.StringPtr("testString") - getBareMetalServerDiskOptionsModel.ID = core.StringPtr("testString") - getBareMetalServerDiskOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the GetBareMetalServerNetworkInterfaceIPOptions model + getBareMetalServerNetworkInterfaceIPOptionsModel := new(vpcv1.GetBareMetalServerNetworkInterfaceIPOptions) + getBareMetalServerNetworkInterfaceIPOptionsModel.BareMetalServerID = core.StringPtr("testString") + getBareMetalServerNetworkInterfaceIPOptionsModel.NetworkInterfaceID = core.StringPtr("testString") + getBareMetalServerNetworkInterfaceIPOptionsModel.ID = core.StringPtr("testString") + getBareMetalServerNetworkInterfaceIPOptionsModel.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.GetBareMetalServerDisk(getBareMetalServerDiskOptionsModel) + result, response, operationErr := vpcService.GetBareMetalServerNetworkInterfaceIP(getBareMetalServerNetworkInterfaceIPOptionsModel) 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.GetBareMetalServerDisk(getBareMetalServerDiskOptionsModel) + result, response, operationErr = vpcService.GetBareMetalServerNetworkInterfaceIP(getBareMetalServerNetworkInterfaceIPOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).To(BeNil()) @@ -48005,16 +48382,16 @@ var _ = Describe(`VpcV1`, func() { }) }) }) - Describe(`GetBareMetalServerDisk(getBareMetalServerDiskOptions *GetBareMetalServerDiskOptions)`, func() { + Describe(`GetBareMetalServerNetworkInterfaceIP(getBareMetalServerNetworkInterfaceIPOptions *GetBareMetalServerNetworkInterfaceIPOptions)`, func() { version := "testString" - getBareMetalServerDiskPath := "/bare_metal_servers/testString/disks/testString" + getBareMetalServerNetworkInterfaceIPPath := "/bare_metal_servers/testString/network_interfaces/testString/ips/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(getBareMetalServerDiskPath)) + Expect(req.URL.EscapedPath()).To(Equal(getBareMetalServerNetworkInterfaceIPPath)) Expect(req.Method).To(Equal("GET")) Expect(req.URL.Query()["version"]).To(Equal([]string{"testString"})) @@ -48025,10 +48402,10 @@ var _ = Describe(`VpcV1`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"created_at": "2019-01-01T12:00:00.000Z", "href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/1e09281b-f177-46fb-baf1-bc152b2e391a/disks/10c02d81-0ecb-4dc5-897d-28392913b81e", "id": "10c02d81-0ecb-4dc5-897d-28392913b81e", "interface_type": "fcp", "name": "my-bare-metal-server-disk", "resource_type": "bare_metal_server_disk", "size": 100}`) + fmt.Fprintf(res, "%s", `{"address": "192.168.3.4", "auto_delete": false, "created_at": "2019-01-01T12:00:00.000Z", "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e/reserved_ips/6d353a0f-aeb1-4ae1-832e-1110d10981bb", "id": "6d353a0f-aeb1-4ae1-832e-1110d10981bb", "lifecycle_state": "stable", "name": "my-reserved-ip", "owner": "user", "resource_type": "subnet_reserved_ip", "target": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::endpoint-gateway:r134-d7cc5196-9864-48c4-82d8-3f30da41fcc5", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/endpoint_gateways/r134-d7cc5196-9864-48c4-82d8-3f30da41fcc5", "id": "r134-d7cc5196-9864-48c4-82d8-3f30da41fcc5", "name": "my-endpoint-gateway", "resource_type": "endpoint_gateway"}}`) })) }) - It(`Invoke GetBareMetalServerDisk successfully with retries`, func() { + It(`Invoke GetBareMetalServerNetworkInterfaceIP successfully with retries`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -48038,22 +48415,23 @@ var _ = Describe(`VpcV1`, func() { Expect(vpcService).ToNot(BeNil()) vpcService.EnableRetries(0, 0) - // Construct an instance of the GetBareMetalServerDiskOptions model - getBareMetalServerDiskOptionsModel := new(vpcv1.GetBareMetalServerDiskOptions) - getBareMetalServerDiskOptionsModel.BareMetalServerID = core.StringPtr("testString") - getBareMetalServerDiskOptionsModel.ID = core.StringPtr("testString") - getBareMetalServerDiskOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the GetBareMetalServerNetworkInterfaceIPOptions model + getBareMetalServerNetworkInterfaceIPOptionsModel := new(vpcv1.GetBareMetalServerNetworkInterfaceIPOptions) + getBareMetalServerNetworkInterfaceIPOptionsModel.BareMetalServerID = core.StringPtr("testString") + getBareMetalServerNetworkInterfaceIPOptionsModel.NetworkInterfaceID = core.StringPtr("testString") + getBareMetalServerNetworkInterfaceIPOptionsModel.ID = core.StringPtr("testString") + getBareMetalServerNetworkInterfaceIPOptionsModel.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.GetBareMetalServerDiskWithContext(ctx, getBareMetalServerDiskOptionsModel) + _, _, operationErr := vpcService.GetBareMetalServerNetworkInterfaceIPWithContext(ctx, getBareMetalServerNetworkInterfaceIPOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) // Disable retries and test again vpcService.DisableRetries() - result, response, operationErr := vpcService.GetBareMetalServerDisk(getBareMetalServerDiskOptionsModel) + result, response, operationErr := vpcService.GetBareMetalServerNetworkInterfaceIP(getBareMetalServerNetworkInterfaceIPOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) @@ -48061,7 +48439,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.GetBareMetalServerDiskWithContext(ctx, getBareMetalServerDiskOptionsModel) + _, _, operationErr = vpcService.GetBareMetalServerNetworkInterfaceIPWithContext(ctx, getBareMetalServerNetworkInterfaceIPOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) }) @@ -48075,7 +48453,7 @@ var _ = Describe(`VpcV1`, func() { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(getBareMetalServerDiskPath)) + Expect(req.URL.EscapedPath()).To(Equal(getBareMetalServerNetworkInterfaceIPPath)) Expect(req.Method).To(Equal("GET")) Expect(req.URL.Query()["version"]).To(Equal([]string{"testString"})) @@ -48083,10 +48461,10 @@ var _ = Describe(`VpcV1`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"created_at": "2019-01-01T12:00:00.000Z", "href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/1e09281b-f177-46fb-baf1-bc152b2e391a/disks/10c02d81-0ecb-4dc5-897d-28392913b81e", "id": "10c02d81-0ecb-4dc5-897d-28392913b81e", "interface_type": "fcp", "name": "my-bare-metal-server-disk", "resource_type": "bare_metal_server_disk", "size": 100}`) + fmt.Fprintf(res, "%s", `{"address": "192.168.3.4", "auto_delete": false, "created_at": "2019-01-01T12:00:00.000Z", "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e/reserved_ips/6d353a0f-aeb1-4ae1-832e-1110d10981bb", "id": "6d353a0f-aeb1-4ae1-832e-1110d10981bb", "lifecycle_state": "stable", "name": "my-reserved-ip", "owner": "user", "resource_type": "subnet_reserved_ip", "target": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::endpoint-gateway:r134-d7cc5196-9864-48c4-82d8-3f30da41fcc5", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/endpoint_gateways/r134-d7cc5196-9864-48c4-82d8-3f30da41fcc5", "id": "r134-d7cc5196-9864-48c4-82d8-3f30da41fcc5", "name": "my-endpoint-gateway", "resource_type": "endpoint_gateway"}}`) })) }) - It(`Invoke GetBareMetalServerDisk successfully`, func() { + It(`Invoke GetBareMetalServerNetworkInterfaceIP successfully`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -48096,25 +48474,26 @@ var _ = Describe(`VpcV1`, func() { Expect(vpcService).ToNot(BeNil()) // Invoke operation with nil options model (negative test) - result, response, operationErr := vpcService.GetBareMetalServerDisk(nil) + result, response, operationErr := vpcService.GetBareMetalServerNetworkInterfaceIP(nil) Expect(operationErr).NotTo(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) - // Construct an instance of the GetBareMetalServerDiskOptions model - getBareMetalServerDiskOptionsModel := new(vpcv1.GetBareMetalServerDiskOptions) - getBareMetalServerDiskOptionsModel.BareMetalServerID = core.StringPtr("testString") - getBareMetalServerDiskOptionsModel.ID = core.StringPtr("testString") - getBareMetalServerDiskOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the GetBareMetalServerNetworkInterfaceIPOptions model + getBareMetalServerNetworkInterfaceIPOptionsModel := new(vpcv1.GetBareMetalServerNetworkInterfaceIPOptions) + getBareMetalServerNetworkInterfaceIPOptionsModel.BareMetalServerID = core.StringPtr("testString") + getBareMetalServerNetworkInterfaceIPOptionsModel.NetworkInterfaceID = core.StringPtr("testString") + getBareMetalServerNetworkInterfaceIPOptionsModel.ID = core.StringPtr("testString") + getBareMetalServerNetworkInterfaceIPOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with valid options model (positive test) - result, response, operationErr = vpcService.GetBareMetalServerDisk(getBareMetalServerDiskOptionsModel) + result, response, operationErr = vpcService.GetBareMetalServerNetworkInterfaceIP(getBareMetalServerNetworkInterfaceIPOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) }) - It(`Invoke GetBareMetalServerDisk with error: Operation validation and request error`, func() { + It(`Invoke GetBareMetalServerNetworkInterfaceIP with error: Operation validation and request error`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -48123,23 +48502,24 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the GetBareMetalServerDiskOptions model - getBareMetalServerDiskOptionsModel := new(vpcv1.GetBareMetalServerDiskOptions) - getBareMetalServerDiskOptionsModel.BareMetalServerID = core.StringPtr("testString") - getBareMetalServerDiskOptionsModel.ID = core.StringPtr("testString") - getBareMetalServerDiskOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the GetBareMetalServerNetworkInterfaceIPOptions model + getBareMetalServerNetworkInterfaceIPOptionsModel := new(vpcv1.GetBareMetalServerNetworkInterfaceIPOptions) + getBareMetalServerNetworkInterfaceIPOptionsModel.BareMetalServerID = core.StringPtr("testString") + getBareMetalServerNetworkInterfaceIPOptionsModel.NetworkInterfaceID = core.StringPtr("testString") + getBareMetalServerNetworkInterfaceIPOptionsModel.ID = core.StringPtr("testString") + getBareMetalServerNetworkInterfaceIPOptionsModel.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.GetBareMetalServerDisk(getBareMetalServerDiskOptionsModel) + result, response, operationErr := vpcService.GetBareMetalServerNetworkInterfaceIP(getBareMetalServerNetworkInterfaceIPOptionsModel) 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 GetBareMetalServerDiskOptions model with no property values - getBareMetalServerDiskOptionsModelNew := new(vpcv1.GetBareMetalServerDiskOptions) + // Construct a second instance of the GetBareMetalServerNetworkInterfaceIPOptions model with no property values + getBareMetalServerNetworkInterfaceIPOptionsModelNew := new(vpcv1.GetBareMetalServerNetworkInterfaceIPOptions) // Invoke operation with invalid model (negative test) - result, response, operationErr = vpcService.GetBareMetalServerDisk(getBareMetalServerDiskOptionsModelNew) + result, response, operationErr = vpcService.GetBareMetalServerNetworkInterfaceIP(getBareMetalServerNetworkInterfaceIPOptionsModelNew) Expect(operationErr).ToNot(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) @@ -48157,7 +48537,7 @@ var _ = Describe(`VpcV1`, func() { res.WriteHeader(200) })) }) - It(`Invoke GetBareMetalServerDisk successfully`, func() { + It(`Invoke GetBareMetalServerNetworkInterfaceIP successfully`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -48166,14 +48546,15 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the GetBareMetalServerDiskOptions model - getBareMetalServerDiskOptionsModel := new(vpcv1.GetBareMetalServerDiskOptions) - getBareMetalServerDiskOptionsModel.BareMetalServerID = core.StringPtr("testString") - getBareMetalServerDiskOptionsModel.ID = core.StringPtr("testString") - getBareMetalServerDiskOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the GetBareMetalServerNetworkInterfaceIPOptions model + getBareMetalServerNetworkInterfaceIPOptionsModel := new(vpcv1.GetBareMetalServerNetworkInterfaceIPOptions) + getBareMetalServerNetworkInterfaceIPOptionsModel.BareMetalServerID = core.StringPtr("testString") + getBareMetalServerNetworkInterfaceIPOptionsModel.NetworkInterfaceID = core.StringPtr("testString") + getBareMetalServerNetworkInterfaceIPOptionsModel.ID = core.StringPtr("testString") + getBareMetalServerNetworkInterfaceIPOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation - result, response, operationErr := vpcService.GetBareMetalServerDisk(getBareMetalServerDiskOptionsModel) + result, response, operationErr := vpcService.GetBareMetalServerNetworkInterfaceIP(getBareMetalServerNetworkInterfaceIPOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) @@ -48185,17 +48566,90 @@ var _ = Describe(`VpcV1`, func() { }) }) }) - Describe(`UpdateBareMetalServerDisk(updateBareMetalServerDiskOptions *UpdateBareMetalServerDiskOptions) - Operation response error`, func() { + Describe(`DeleteBareMetalServer(deleteBareMetalServerOptions *DeleteBareMetalServerOptions)`, func() { version := "testString" - updateBareMetalServerDiskPath := "/bare_metal_servers/testString/disks/testString" + deleteBareMetalServerPath := "/bare_metal_servers/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(deleteBareMetalServerPath)) + 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 DeleteBareMetalServer 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.DeleteBareMetalServer(nil) + Expect(operationErr).NotTo(BeNil()) + Expect(response).To(BeNil()) + + // Construct an instance of the DeleteBareMetalServerOptions model + deleteBareMetalServerOptionsModel := new(vpcv1.DeleteBareMetalServerOptions) + deleteBareMetalServerOptionsModel.ID = core.StringPtr("testString") + deleteBareMetalServerOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation with valid options model (positive test) + response, operationErr = vpcService.DeleteBareMetalServer(deleteBareMetalServerOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + }) + It(`Invoke DeleteBareMetalServer 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 DeleteBareMetalServerOptions model + deleteBareMetalServerOptionsModel := new(vpcv1.DeleteBareMetalServerOptions) + deleteBareMetalServerOptionsModel.ID = core.StringPtr("testString") + deleteBareMetalServerOptionsModel.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.DeleteBareMetalServer(deleteBareMetalServerOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING)) + Expect(response).To(BeNil()) + // Construct a second instance of the DeleteBareMetalServerOptions model with no property values + deleteBareMetalServerOptionsModelNew := new(vpcv1.DeleteBareMetalServerOptions) + // Invoke operation with invalid model (negative test) + response, operationErr = vpcService.DeleteBareMetalServer(deleteBareMetalServerOptionsModelNew) + Expect(operationErr).ToNot(BeNil()) + Expect(response).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + }) + Describe(`GetBareMetalServer(getBareMetalServerOptions *GetBareMetalServerOptions) - Operation response error`, func() { + version := "testString" + getBareMetalServerPath := "/bare_metal_servers/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(updateBareMetalServerDiskPath)) - Expect(req.Method).To(Equal("PATCH")) + Expect(req.URL.EscapedPath()).To(Equal(getBareMetalServerPath)) + 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") @@ -48203,7 +48657,7 @@ var _ = Describe(`VpcV1`, func() { fmt.Fprint(res, `} this is not valid json {`) })) }) - It(`Invoke UpdateBareMetalServerDisk with error: Operation response processing error`, func() { + It(`Invoke GetBareMetalServer with error: Operation response processing error`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -48212,27 +48666,19 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the BareMetalServerDiskPatch model - bareMetalServerDiskPatchModel := new(vpcv1.BareMetalServerDiskPatch) - bareMetalServerDiskPatchModel.Name = core.StringPtr("my-bare-metal-server-disk-updated") - bareMetalServerDiskPatchModelAsPatch, asPatchErr := bareMetalServerDiskPatchModel.AsPatch() - Expect(asPatchErr).To(BeNil()) - - // Construct an instance of the UpdateBareMetalServerDiskOptions model - updateBareMetalServerDiskOptionsModel := new(vpcv1.UpdateBareMetalServerDiskOptions) - updateBareMetalServerDiskOptionsModel.BareMetalServerID = core.StringPtr("testString") - updateBareMetalServerDiskOptionsModel.ID = core.StringPtr("testString") - updateBareMetalServerDiskOptionsModel.BareMetalServerDiskPatch = bareMetalServerDiskPatchModelAsPatch - updateBareMetalServerDiskOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the GetBareMetalServerOptions model + getBareMetalServerOptionsModel := new(vpcv1.GetBareMetalServerOptions) + getBareMetalServerOptionsModel.ID = core.StringPtr("testString") + getBareMetalServerOptionsModel.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.UpdateBareMetalServerDisk(updateBareMetalServerDiskOptionsModel) + result, response, operationErr := vpcService.GetBareMetalServer(getBareMetalServerOptionsModel) 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.UpdateBareMetalServerDisk(updateBareMetalServerDiskOptionsModel) + result, response, operationErr = vpcService.GetBareMetalServer(getBareMetalServerOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).To(BeNil()) @@ -48242,33 +48688,17 @@ var _ = Describe(`VpcV1`, func() { }) }) }) - Describe(`UpdateBareMetalServerDisk(updateBareMetalServerDiskOptions *UpdateBareMetalServerDiskOptions)`, func() { + Describe(`GetBareMetalServer(getBareMetalServerOptions *GetBareMetalServerOptions)`, func() { version := "testString" - updateBareMetalServerDiskPath := "/bare_metal_servers/testString/disks/testString" + getBareMetalServerPath := "/bare_metal_servers/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(updateBareMetalServerDiskPath)) - 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.URL.EscapedPath()).To(Equal(getBareMetalServerPath)) + 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))})) @@ -48278,10 +48708,10 @@ var _ = Describe(`VpcV1`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"created_at": "2019-01-01T12:00:00.000Z", "href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/1e09281b-f177-46fb-baf1-bc152b2e391a/disks/10c02d81-0ecb-4dc5-897d-28392913b81e", "id": "10c02d81-0ecb-4dc5-897d-28392913b81e", "interface_type": "fcp", "name": "my-bare-metal-server-disk", "resource_type": "bare_metal_server_disk", "size": 100}`) + fmt.Fprintf(res, "%s", `{"bandwidth": 20000, "boot_target": {"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/1e09281b-f177-46fb-baf1-bc152b2e391a/disks/10c02d81-0ecb-4dc5-897d-28392913b81e", "id": "10c02d81-0ecb-4dc5-897d-28392913b81e", "name": "my-bare-metal-server-disk", "resource_type": "bare_metal_server_disk"}, "cpu": {"architecture": "amd64", "core_count": 80, "socket_count": 4, "threads_per_core": 2}, "created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::bare-metal-server:1e09281b-f177-46fb-baf1-bc152b2e391a", "disks": [{"created_at": "2019-01-01T12:00:00.000Z", "href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/1e09281b-f177-46fb-baf1-bc152b2e391a/disks/10c02d81-0ecb-4dc5-897d-28392913b81e", "id": "10c02d81-0ecb-4dc5-897d-28392913b81e", "interface_type": "fcp", "name": "my-bare-metal-server-disk", "resource_type": "bare_metal_server_disk", "size": 100}], "enable_secure_boot": false, "href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/1e09281b-f177-46fb-baf1-bc152b2e391a", "id": "1e09281b-f177-46fb-baf1-bc152b2e391a", "lifecycle_reasons": [{"code": "resource_suspended_by_provider", "message": "The resource has been suspended. Contact IBM support with the CRN for next steps.", "more_info": "https://cloud.ibm.com/apidocs/vpc#resource-suspension"}], "lifecycle_state": "stable", "memory": 1536, "name": "my-bare-metal-server", "network_attachments": [{"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/2302-f7a2bf57-af7c-49d9-b599-b2c91293d30c/network_attachments/2302-da8c43ec-b6ca-4bd2-871e-72e288c66ee6", "id": "2302-da8c43ec-b6ca-4bd2-871e-72e288c66ee6", "name": "my-bare-metal-server-network-attachment", "primary_ip": {"address": "192.168.3.4", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e/reserved_ips/6d353a0f-aeb1-4ae1-832e-1110d10981bb", "id": "6d353a0f-aeb1-4ae1-832e-1110d10981bb", "name": "my-reserved-ip", "resource_type": "subnet_reserved_ip"}, "resource_type": "bare_metal_server_network_attachment", "subnet": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "id": "7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "name": "my-subnet", "resource_type": "subnet"}}], "network_interfaces": [{"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/1e09281b-f177-46fb-baf1-bc152b2e391a/network_interfaces/10c02d81-0ecb-4dc5-897d-28392913b81e", "id": "10c02d81-0ecb-4dc5-897d-28392913b81e", "name": "my-bare-metal-server-network-interface", "primary_ip": {"address": "192.168.3.4", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e/reserved_ips/6d353a0f-aeb1-4ae1-832e-1110d10981bb", "id": "6d353a0f-aeb1-4ae1-832e-1110d10981bb", "name": "my-reserved-ip", "resource_type": "subnet_reserved_ip"}, "resource_type": "network_interface", "subnet": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "id": "7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "name": "my-subnet", "resource_type": "subnet"}}], "primary_network_attachment": {"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/2302-f7a2bf57-af7c-49d9-b599-b2c91293d30c/network_attachments/2302-da8c43ec-b6ca-4bd2-871e-72e288c66ee6", "id": "2302-da8c43ec-b6ca-4bd2-871e-72e288c66ee6", "name": "my-bare-metal-server-network-attachment", "primary_ip": {"address": "192.168.3.4", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e/reserved_ips/6d353a0f-aeb1-4ae1-832e-1110d10981bb", "id": "6d353a0f-aeb1-4ae1-832e-1110d10981bb", "name": "my-reserved-ip", "resource_type": "subnet_reserved_ip"}, "resource_type": "bare_metal_server_network_attachment", "subnet": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "id": "7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "name": "my-subnet", "resource_type": "subnet"}}, "primary_network_interface": {"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/1e09281b-f177-46fb-baf1-bc152b2e391a/network_interfaces/10c02d81-0ecb-4dc5-897d-28392913b81e", "id": "10c02d81-0ecb-4dc5-897d-28392913b81e", "name": "my-bare-metal-server-network-interface", "primary_ip": {"address": "192.168.3.4", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e/reserved_ips/6d353a0f-aeb1-4ae1-832e-1110d10981bb", "id": "6d353a0f-aeb1-4ae1-832e-1110d10981bb", "name": "my-reserved-ip", "resource_type": "subnet_reserved_ip"}, "resource_type": "network_interface", "subnet": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "id": "7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "name": "my-subnet", "resource_type": "subnet"}}, "profile": {"href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/profiles/bx2-metal-192x768", "name": "bx2-metal-192x768", "resource_type": "bare_metal_server_profile"}, "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "resource_type": "bare_metal_server", "status": "deleting", "status_reasons": [{"code": "cannot_start_capacity", "message": "The bare metal server cannot start as there is no more capacity in this\nzone for a bare metal server with the requested profile.", "more_info": "https://console.bluemix.net/docs/iaas/bare_metal_server.html"}], "trusted_platform_module": {"enabled": true, "mode": "disabled", "supported_modes": ["disabled"]}, "vpc": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::vpc:4727d842-f94f-4a2d-824a-9bc9b02c523b", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/vpcs/4727d842-f94f-4a2d-824a-9bc9b02c523b", "id": "4727d842-f94f-4a2d-824a-9bc9b02c523b", "name": "my-vpc", "resource_type": "vpc"}, "zone": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south/zones/us-south-1", "name": "us-south-1"}}`) })) }) - It(`Invoke UpdateBareMetalServerDisk successfully with retries`, func() { + It(`Invoke GetBareMetalServer successfully with retries`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -48291,29 +48721,21 @@ var _ = Describe(`VpcV1`, func() { Expect(vpcService).ToNot(BeNil()) vpcService.EnableRetries(0, 0) - // Construct an instance of the BareMetalServerDiskPatch model - bareMetalServerDiskPatchModel := new(vpcv1.BareMetalServerDiskPatch) - bareMetalServerDiskPatchModel.Name = core.StringPtr("my-bare-metal-server-disk-updated") - bareMetalServerDiskPatchModelAsPatch, asPatchErr := bareMetalServerDiskPatchModel.AsPatch() - Expect(asPatchErr).To(BeNil()) - - // Construct an instance of the UpdateBareMetalServerDiskOptions model - updateBareMetalServerDiskOptionsModel := new(vpcv1.UpdateBareMetalServerDiskOptions) - updateBareMetalServerDiskOptionsModel.BareMetalServerID = core.StringPtr("testString") - updateBareMetalServerDiskOptionsModel.ID = core.StringPtr("testString") - updateBareMetalServerDiskOptionsModel.BareMetalServerDiskPatch = bareMetalServerDiskPatchModelAsPatch - updateBareMetalServerDiskOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the GetBareMetalServerOptions model + getBareMetalServerOptionsModel := new(vpcv1.GetBareMetalServerOptions) + getBareMetalServerOptionsModel.ID = core.StringPtr("testString") + getBareMetalServerOptionsModel.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.UpdateBareMetalServerDiskWithContext(ctx, updateBareMetalServerDiskOptionsModel) + _, _, operationErr := vpcService.GetBareMetalServerWithContext(ctx, getBareMetalServerOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) // Disable retries and test again vpcService.DisableRetries() - result, response, operationErr := vpcService.UpdateBareMetalServerDisk(updateBareMetalServerDiskOptionsModel) + result, response, operationErr := vpcService.GetBareMetalServer(getBareMetalServerOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) @@ -48321,7 +48743,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.UpdateBareMetalServerDiskWithContext(ctx, updateBareMetalServerDiskOptionsModel) + _, _, operationErr = vpcService.GetBareMetalServerWithContext(ctx, getBareMetalServerOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) }) @@ -48335,34 +48757,18 @@ var _ = Describe(`VpcV1`, func() { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(updateBareMetalServerDiskPath)) - 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.URL.EscapedPath()).To(Equal(getBareMetalServerPath)) + 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", "href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/1e09281b-f177-46fb-baf1-bc152b2e391a/disks/10c02d81-0ecb-4dc5-897d-28392913b81e", "id": "10c02d81-0ecb-4dc5-897d-28392913b81e", "interface_type": "fcp", "name": "my-bare-metal-server-disk", "resource_type": "bare_metal_server_disk", "size": 100}`) + fmt.Fprintf(res, "%s", `{"bandwidth": 20000, "boot_target": {"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/1e09281b-f177-46fb-baf1-bc152b2e391a/disks/10c02d81-0ecb-4dc5-897d-28392913b81e", "id": "10c02d81-0ecb-4dc5-897d-28392913b81e", "name": "my-bare-metal-server-disk", "resource_type": "bare_metal_server_disk"}, "cpu": {"architecture": "amd64", "core_count": 80, "socket_count": 4, "threads_per_core": 2}, "created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::bare-metal-server:1e09281b-f177-46fb-baf1-bc152b2e391a", "disks": [{"created_at": "2019-01-01T12:00:00.000Z", "href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/1e09281b-f177-46fb-baf1-bc152b2e391a/disks/10c02d81-0ecb-4dc5-897d-28392913b81e", "id": "10c02d81-0ecb-4dc5-897d-28392913b81e", "interface_type": "fcp", "name": "my-bare-metal-server-disk", "resource_type": "bare_metal_server_disk", "size": 100}], "enable_secure_boot": false, "href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/1e09281b-f177-46fb-baf1-bc152b2e391a", "id": "1e09281b-f177-46fb-baf1-bc152b2e391a", "lifecycle_reasons": [{"code": "resource_suspended_by_provider", "message": "The resource has been suspended. Contact IBM support with the CRN for next steps.", "more_info": "https://cloud.ibm.com/apidocs/vpc#resource-suspension"}], "lifecycle_state": "stable", "memory": 1536, "name": "my-bare-metal-server", "network_attachments": [{"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/2302-f7a2bf57-af7c-49d9-b599-b2c91293d30c/network_attachments/2302-da8c43ec-b6ca-4bd2-871e-72e288c66ee6", "id": "2302-da8c43ec-b6ca-4bd2-871e-72e288c66ee6", "name": "my-bare-metal-server-network-attachment", "primary_ip": {"address": "192.168.3.4", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e/reserved_ips/6d353a0f-aeb1-4ae1-832e-1110d10981bb", "id": "6d353a0f-aeb1-4ae1-832e-1110d10981bb", "name": "my-reserved-ip", "resource_type": "subnet_reserved_ip"}, "resource_type": "bare_metal_server_network_attachment", "subnet": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "id": "7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "name": "my-subnet", "resource_type": "subnet"}}], "network_interfaces": [{"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/1e09281b-f177-46fb-baf1-bc152b2e391a/network_interfaces/10c02d81-0ecb-4dc5-897d-28392913b81e", "id": "10c02d81-0ecb-4dc5-897d-28392913b81e", "name": "my-bare-metal-server-network-interface", "primary_ip": {"address": "192.168.3.4", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e/reserved_ips/6d353a0f-aeb1-4ae1-832e-1110d10981bb", "id": "6d353a0f-aeb1-4ae1-832e-1110d10981bb", "name": "my-reserved-ip", "resource_type": "subnet_reserved_ip"}, "resource_type": "network_interface", "subnet": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "id": "7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "name": "my-subnet", "resource_type": "subnet"}}], "primary_network_attachment": {"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/2302-f7a2bf57-af7c-49d9-b599-b2c91293d30c/network_attachments/2302-da8c43ec-b6ca-4bd2-871e-72e288c66ee6", "id": "2302-da8c43ec-b6ca-4bd2-871e-72e288c66ee6", "name": "my-bare-metal-server-network-attachment", "primary_ip": {"address": "192.168.3.4", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e/reserved_ips/6d353a0f-aeb1-4ae1-832e-1110d10981bb", "id": "6d353a0f-aeb1-4ae1-832e-1110d10981bb", "name": "my-reserved-ip", "resource_type": "subnet_reserved_ip"}, "resource_type": "bare_metal_server_network_attachment", "subnet": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "id": "7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "name": "my-subnet", "resource_type": "subnet"}}, "primary_network_interface": {"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/1e09281b-f177-46fb-baf1-bc152b2e391a/network_interfaces/10c02d81-0ecb-4dc5-897d-28392913b81e", "id": "10c02d81-0ecb-4dc5-897d-28392913b81e", "name": "my-bare-metal-server-network-interface", "primary_ip": {"address": "192.168.3.4", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e/reserved_ips/6d353a0f-aeb1-4ae1-832e-1110d10981bb", "id": "6d353a0f-aeb1-4ae1-832e-1110d10981bb", "name": "my-reserved-ip", "resource_type": "subnet_reserved_ip"}, "resource_type": "network_interface", "subnet": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "id": "7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "name": "my-subnet", "resource_type": "subnet"}}, "profile": {"href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/profiles/bx2-metal-192x768", "name": "bx2-metal-192x768", "resource_type": "bare_metal_server_profile"}, "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "resource_type": "bare_metal_server", "status": "deleting", "status_reasons": [{"code": "cannot_start_capacity", "message": "The bare metal server cannot start as there is no more capacity in this\nzone for a bare metal server with the requested profile.", "more_info": "https://console.bluemix.net/docs/iaas/bare_metal_server.html"}], "trusted_platform_module": {"enabled": true, "mode": "disabled", "supported_modes": ["disabled"]}, "vpc": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::vpc:4727d842-f94f-4a2d-824a-9bc9b02c523b", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/vpcs/4727d842-f94f-4a2d-824a-9bc9b02c523b", "id": "4727d842-f94f-4a2d-824a-9bc9b02c523b", "name": "my-vpc", "resource_type": "vpc"}, "zone": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south/zones/us-south-1", "name": "us-south-1"}}`) })) }) - It(`Invoke UpdateBareMetalServerDisk successfully`, func() { + It(`Invoke GetBareMetalServer successfully`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -48372,32 +48778,24 @@ var _ = Describe(`VpcV1`, func() { Expect(vpcService).ToNot(BeNil()) // Invoke operation with nil options model (negative test) - result, response, operationErr := vpcService.UpdateBareMetalServerDisk(nil) + result, response, operationErr := vpcService.GetBareMetalServer(nil) Expect(operationErr).NotTo(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) - // Construct an instance of the BareMetalServerDiskPatch model - bareMetalServerDiskPatchModel := new(vpcv1.BareMetalServerDiskPatch) - bareMetalServerDiskPatchModel.Name = core.StringPtr("my-bare-metal-server-disk-updated") - bareMetalServerDiskPatchModelAsPatch, asPatchErr := bareMetalServerDiskPatchModel.AsPatch() - Expect(asPatchErr).To(BeNil()) - - // Construct an instance of the UpdateBareMetalServerDiskOptions model - updateBareMetalServerDiskOptionsModel := new(vpcv1.UpdateBareMetalServerDiskOptions) - updateBareMetalServerDiskOptionsModel.BareMetalServerID = core.StringPtr("testString") - updateBareMetalServerDiskOptionsModel.ID = core.StringPtr("testString") - updateBareMetalServerDiskOptionsModel.BareMetalServerDiskPatch = bareMetalServerDiskPatchModelAsPatch - updateBareMetalServerDiskOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the GetBareMetalServerOptions model + getBareMetalServerOptionsModel := new(vpcv1.GetBareMetalServerOptions) + getBareMetalServerOptionsModel.ID = core.StringPtr("testString") + getBareMetalServerOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with valid options model (positive test) - result, response, operationErr = vpcService.UpdateBareMetalServerDisk(updateBareMetalServerDiskOptionsModel) + result, response, operationErr = vpcService.GetBareMetalServer(getBareMetalServerOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) }) - It(`Invoke UpdateBareMetalServerDisk with error: Operation validation and request error`, func() { + It(`Invoke GetBareMetalServer with error: Operation validation and request error`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -48406,30 +48804,22 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the BareMetalServerDiskPatch model - bareMetalServerDiskPatchModel := new(vpcv1.BareMetalServerDiskPatch) - bareMetalServerDiskPatchModel.Name = core.StringPtr("my-bare-metal-server-disk-updated") - bareMetalServerDiskPatchModelAsPatch, asPatchErr := bareMetalServerDiskPatchModel.AsPatch() - Expect(asPatchErr).To(BeNil()) - - // Construct an instance of the UpdateBareMetalServerDiskOptions model - updateBareMetalServerDiskOptionsModel := new(vpcv1.UpdateBareMetalServerDiskOptions) - updateBareMetalServerDiskOptionsModel.BareMetalServerID = core.StringPtr("testString") - updateBareMetalServerDiskOptionsModel.ID = core.StringPtr("testString") - updateBareMetalServerDiskOptionsModel.BareMetalServerDiskPatch = bareMetalServerDiskPatchModelAsPatch - updateBareMetalServerDiskOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the GetBareMetalServerOptions model + getBareMetalServerOptionsModel := new(vpcv1.GetBareMetalServerOptions) + getBareMetalServerOptionsModel.ID = core.StringPtr("testString") + getBareMetalServerOptionsModel.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.UpdateBareMetalServerDisk(updateBareMetalServerDiskOptionsModel) + result, response, operationErr := vpcService.GetBareMetalServer(getBareMetalServerOptionsModel) 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 UpdateBareMetalServerDiskOptions model with no property values - updateBareMetalServerDiskOptionsModelNew := new(vpcv1.UpdateBareMetalServerDiskOptions) + // Construct a second instance of the GetBareMetalServerOptions model with no property values + getBareMetalServerOptionsModelNew := new(vpcv1.GetBareMetalServerOptions) // Invoke operation with invalid model (negative test) - result, response, operationErr = vpcService.UpdateBareMetalServerDisk(updateBareMetalServerDiskOptionsModelNew) + result, response, operationErr = vpcService.GetBareMetalServer(getBareMetalServerOptionsModelNew) Expect(operationErr).ToNot(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) @@ -48447,7 +48837,7 @@ var _ = Describe(`VpcV1`, func() { res.WriteHeader(200) })) }) - It(`Invoke UpdateBareMetalServerDisk successfully`, func() { + It(`Invoke GetBareMetalServer successfully`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -48456,21 +48846,13 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the BareMetalServerDiskPatch model - bareMetalServerDiskPatchModel := new(vpcv1.BareMetalServerDiskPatch) - bareMetalServerDiskPatchModel.Name = core.StringPtr("my-bare-metal-server-disk-updated") - bareMetalServerDiskPatchModelAsPatch, asPatchErr := bareMetalServerDiskPatchModel.AsPatch() - Expect(asPatchErr).To(BeNil()) - - // Construct an instance of the UpdateBareMetalServerDiskOptions model - updateBareMetalServerDiskOptionsModel := new(vpcv1.UpdateBareMetalServerDiskOptions) - updateBareMetalServerDiskOptionsModel.BareMetalServerID = core.StringPtr("testString") - updateBareMetalServerDiskOptionsModel.ID = core.StringPtr("testString") - updateBareMetalServerDiskOptionsModel.BareMetalServerDiskPatch = bareMetalServerDiskPatchModelAsPatch - updateBareMetalServerDiskOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the GetBareMetalServerOptions model + getBareMetalServerOptionsModel := new(vpcv1.GetBareMetalServerOptions) + getBareMetalServerOptionsModel.ID = core.StringPtr("testString") + getBareMetalServerOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation - result, response, operationErr := vpcService.UpdateBareMetalServerDisk(updateBareMetalServerDiskOptionsModel) + result, response, operationErr := vpcService.GetBareMetalServer(getBareMetalServerOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) @@ -48482,27 +48864,25 @@ var _ = Describe(`VpcV1`, func() { }) }) }) - Describe(`ListBareMetalServerNetworkAttachments(listBareMetalServerNetworkAttachmentsOptions *ListBareMetalServerNetworkAttachmentsOptions) - Operation response error`, func() { + Describe(`UpdateBareMetalServer(updateBareMetalServerOptions *UpdateBareMetalServerOptions) - Operation response error`, func() { version := "testString" - listBareMetalServerNetworkAttachmentsPath := "/bare_metal_servers/testString/network_attachments" + updateBareMetalServerPath := "/bare_metal_servers/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(listBareMetalServerNetworkAttachmentsPath)) - Expect(req.Method).To(Equal("GET")) + Expect(req.URL.EscapedPath()).To(Equal(updateBareMetalServerPath)) + 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))})) - Expect(req.URL.Query()["start"]).To(Equal([]string{"testString"})) - Expect(req.URL.Query()["limit"]).To(Equal([]string{fmt.Sprint(int64(10))})) res.Header().Set("Content-type", "application/json") res.WriteHeader(200) fmt.Fprint(res, `} this is not valid json {`) })) }) - It(`Invoke ListBareMetalServerNetworkAttachments with error: Operation response processing error`, func() { + It(`Invoke UpdateBareMetalServer with error: Operation response processing error`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -48511,21 +48891,32 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the ListBareMetalServerNetworkAttachmentsOptions model - listBareMetalServerNetworkAttachmentsOptionsModel := new(vpcv1.ListBareMetalServerNetworkAttachmentsOptions) - listBareMetalServerNetworkAttachmentsOptionsModel.BareMetalServerID = core.StringPtr("testString") - listBareMetalServerNetworkAttachmentsOptionsModel.Start = core.StringPtr("testString") - listBareMetalServerNetworkAttachmentsOptionsModel.Limit = core.Int64Ptr(int64(10)) - listBareMetalServerNetworkAttachmentsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the BareMetalServerTrustedPlatformModulePatch model + bareMetalServerTrustedPlatformModulePatchModel := new(vpcv1.BareMetalServerTrustedPlatformModulePatch) + bareMetalServerTrustedPlatformModulePatchModel.Mode = core.StringPtr("disabled") + + // Construct an instance of the BareMetalServerPatch model + bareMetalServerPatchModel := new(vpcv1.BareMetalServerPatch) + bareMetalServerPatchModel.EnableSecureBoot = core.BoolPtr(false) + bareMetalServerPatchModel.Name = core.StringPtr("my-bare-metal-server") + bareMetalServerPatchModel.TrustedPlatformModule = bareMetalServerTrustedPlatformModulePatchModel + bareMetalServerPatchModelAsPatch, asPatchErr := bareMetalServerPatchModel.AsPatch() + Expect(asPatchErr).To(BeNil()) + + // Construct an instance of the UpdateBareMetalServerOptions model + updateBareMetalServerOptionsModel := new(vpcv1.UpdateBareMetalServerOptions) + updateBareMetalServerOptionsModel.ID = core.StringPtr("testString") + updateBareMetalServerOptionsModel.BareMetalServerPatch = bareMetalServerPatchModelAsPatch + updateBareMetalServerOptionsModel.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.ListBareMetalServerNetworkAttachments(listBareMetalServerNetworkAttachmentsOptionsModel) + result, response, operationErr := vpcService.UpdateBareMetalServer(updateBareMetalServerOptionsModel) 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.ListBareMetalServerNetworkAttachments(listBareMetalServerNetworkAttachmentsOptionsModel) + result, response, operationErr = vpcService.UpdateBareMetalServer(updateBareMetalServerOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).To(BeNil()) @@ -48535,32 +48926,46 @@ var _ = Describe(`VpcV1`, func() { }) }) }) - Describe(`ListBareMetalServerNetworkAttachments(listBareMetalServerNetworkAttachmentsOptions *ListBareMetalServerNetworkAttachmentsOptions)`, func() { + Describe(`UpdateBareMetalServer(updateBareMetalServerOptions *UpdateBareMetalServerOptions)`, func() { version := "testString" - listBareMetalServerNetworkAttachmentsPath := "/bare_metal_servers/testString/network_attachments" + updateBareMetalServerPath := "/bare_metal_servers/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(listBareMetalServerNetworkAttachmentsPath)) - Expect(req.Method).To(Equal("GET")) + Expect(req.URL.EscapedPath()).To(Equal(updateBareMetalServerPath)) + 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.URL.Query()["version"]).To(Equal([]string{"testString"})) Expect(req.URL.Query()["generation"]).To(Equal([]string{fmt.Sprint(int64(2))})) - Expect(req.URL.Query()["start"]).To(Equal([]string{"testString"})) - Expect(req.URL.Query()["limit"]).To(Equal([]string{fmt.Sprint(int64(10))})) // 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/bare_metal_servers/3b2669a2-4c2b-4003-bc91-1b81f1326267/network_attachments?limit=20"}, "limit": 20, "network_attachments": [{"created_at": "2019-01-01T12:00:00.000Z", "href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/2302-f7a2bf57-af7c-49d9-b599-b2c91293d30c/network_attachments/2302-da8c43ec-b6ca-4bd2-871e-72e288c66ee6", "id": "2302-da8c43ec-b6ca-4bd2-871e-72e288c66ee6", "lifecycle_state": "stable", "name": "my-bare-metal-server-network-attachment", "port_speed": 1000, "primary_ip": {"address": "192.168.3.4", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e/reserved_ips/6d353a0f-aeb1-4ae1-832e-1110d10981bb", "id": "6d353a0f-aeb1-4ae1-832e-1110d10981bb", "name": "my-reserved-ip", "resource_type": "subnet_reserved_ip"}, "resource_type": "bare_metal_server_network_attachment", "subnet": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "id": "7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "name": "my-subnet", "resource_type": "subnet"}, "type": "primary", "virtual_network_interface": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::virtual-network-interface:0767-fa41aecb-4f21-423d-8082-630bfba1e1d9", "href": "https://us-south.iaas.cloud.ibm.com/v1/virtual_network_interfaces/0767-fa41aecb-4f21-423d-8082-630bfba1e1d9", "id": "0767-fa41aecb-4f21-423d-8082-630bfba1e1d9", "name": "my-virtual-network-interface", "resource_type": "virtual_network_interface"}, "allowed_vlans": [4], "interface_type": "pci"}], "next": {"href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/3b2669a2-4c2b-4003-bc91-1b81f1326267/network_attachments?start=d3e721fd-c988-4670-9927-dbd5e7b07fc6&limit=20"}, "total_count": 132}`) + fmt.Fprintf(res, "%s", `{"bandwidth": 20000, "boot_target": {"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/1e09281b-f177-46fb-baf1-bc152b2e391a/disks/10c02d81-0ecb-4dc5-897d-28392913b81e", "id": "10c02d81-0ecb-4dc5-897d-28392913b81e", "name": "my-bare-metal-server-disk", "resource_type": "bare_metal_server_disk"}, "cpu": {"architecture": "amd64", "core_count": 80, "socket_count": 4, "threads_per_core": 2}, "created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::bare-metal-server:1e09281b-f177-46fb-baf1-bc152b2e391a", "disks": [{"created_at": "2019-01-01T12:00:00.000Z", "href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/1e09281b-f177-46fb-baf1-bc152b2e391a/disks/10c02d81-0ecb-4dc5-897d-28392913b81e", "id": "10c02d81-0ecb-4dc5-897d-28392913b81e", "interface_type": "fcp", "name": "my-bare-metal-server-disk", "resource_type": "bare_metal_server_disk", "size": 100}], "enable_secure_boot": false, "href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/1e09281b-f177-46fb-baf1-bc152b2e391a", "id": "1e09281b-f177-46fb-baf1-bc152b2e391a", "lifecycle_reasons": [{"code": "resource_suspended_by_provider", "message": "The resource has been suspended. Contact IBM support with the CRN for next steps.", "more_info": "https://cloud.ibm.com/apidocs/vpc#resource-suspension"}], "lifecycle_state": "stable", "memory": 1536, "name": "my-bare-metal-server", "network_attachments": [{"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/2302-f7a2bf57-af7c-49d9-b599-b2c91293d30c/network_attachments/2302-da8c43ec-b6ca-4bd2-871e-72e288c66ee6", "id": "2302-da8c43ec-b6ca-4bd2-871e-72e288c66ee6", "name": "my-bare-metal-server-network-attachment", "primary_ip": {"address": "192.168.3.4", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e/reserved_ips/6d353a0f-aeb1-4ae1-832e-1110d10981bb", "id": "6d353a0f-aeb1-4ae1-832e-1110d10981bb", "name": "my-reserved-ip", "resource_type": "subnet_reserved_ip"}, "resource_type": "bare_metal_server_network_attachment", "subnet": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "id": "7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "name": "my-subnet", "resource_type": "subnet"}}], "network_interfaces": [{"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/1e09281b-f177-46fb-baf1-bc152b2e391a/network_interfaces/10c02d81-0ecb-4dc5-897d-28392913b81e", "id": "10c02d81-0ecb-4dc5-897d-28392913b81e", "name": "my-bare-metal-server-network-interface", "primary_ip": {"address": "192.168.3.4", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e/reserved_ips/6d353a0f-aeb1-4ae1-832e-1110d10981bb", "id": "6d353a0f-aeb1-4ae1-832e-1110d10981bb", "name": "my-reserved-ip", "resource_type": "subnet_reserved_ip"}, "resource_type": "network_interface", "subnet": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "id": "7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "name": "my-subnet", "resource_type": "subnet"}}], "primary_network_attachment": {"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/2302-f7a2bf57-af7c-49d9-b599-b2c91293d30c/network_attachments/2302-da8c43ec-b6ca-4bd2-871e-72e288c66ee6", "id": "2302-da8c43ec-b6ca-4bd2-871e-72e288c66ee6", "name": "my-bare-metal-server-network-attachment", "primary_ip": {"address": "192.168.3.4", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e/reserved_ips/6d353a0f-aeb1-4ae1-832e-1110d10981bb", "id": "6d353a0f-aeb1-4ae1-832e-1110d10981bb", "name": "my-reserved-ip", "resource_type": "subnet_reserved_ip"}, "resource_type": "bare_metal_server_network_attachment", "subnet": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "id": "7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "name": "my-subnet", "resource_type": "subnet"}}, "primary_network_interface": {"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/1e09281b-f177-46fb-baf1-bc152b2e391a/network_interfaces/10c02d81-0ecb-4dc5-897d-28392913b81e", "id": "10c02d81-0ecb-4dc5-897d-28392913b81e", "name": "my-bare-metal-server-network-interface", "primary_ip": {"address": "192.168.3.4", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e/reserved_ips/6d353a0f-aeb1-4ae1-832e-1110d10981bb", "id": "6d353a0f-aeb1-4ae1-832e-1110d10981bb", "name": "my-reserved-ip", "resource_type": "subnet_reserved_ip"}, "resource_type": "network_interface", "subnet": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "id": "7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "name": "my-subnet", "resource_type": "subnet"}}, "profile": {"href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/profiles/bx2-metal-192x768", "name": "bx2-metal-192x768", "resource_type": "bare_metal_server_profile"}, "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "resource_type": "bare_metal_server", "status": "deleting", "status_reasons": [{"code": "cannot_start_capacity", "message": "The bare metal server cannot start as there is no more capacity in this\nzone for a bare metal server with the requested profile.", "more_info": "https://console.bluemix.net/docs/iaas/bare_metal_server.html"}], "trusted_platform_module": {"enabled": true, "mode": "disabled", "supported_modes": ["disabled"]}, "vpc": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::vpc:4727d842-f94f-4a2d-824a-9bc9b02c523b", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/vpcs/4727d842-f94f-4a2d-824a-9bc9b02c523b", "id": "4727d842-f94f-4a2d-824a-9bc9b02c523b", "name": "my-vpc", "resource_type": "vpc"}, "zone": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south/zones/us-south-1", "name": "us-south-1"}}`) })) }) - It(`Invoke ListBareMetalServerNetworkAttachments successfully with retries`, func() { + It(`Invoke UpdateBareMetalServer successfully with retries`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -48570,23 +48975,34 @@ var _ = Describe(`VpcV1`, func() { Expect(vpcService).ToNot(BeNil()) vpcService.EnableRetries(0, 0) - // Construct an instance of the ListBareMetalServerNetworkAttachmentsOptions model - listBareMetalServerNetworkAttachmentsOptionsModel := new(vpcv1.ListBareMetalServerNetworkAttachmentsOptions) - listBareMetalServerNetworkAttachmentsOptionsModel.BareMetalServerID = core.StringPtr("testString") - listBareMetalServerNetworkAttachmentsOptionsModel.Start = core.StringPtr("testString") - listBareMetalServerNetworkAttachmentsOptionsModel.Limit = core.Int64Ptr(int64(10)) - listBareMetalServerNetworkAttachmentsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the BareMetalServerTrustedPlatformModulePatch model + bareMetalServerTrustedPlatformModulePatchModel := new(vpcv1.BareMetalServerTrustedPlatformModulePatch) + bareMetalServerTrustedPlatformModulePatchModel.Mode = core.StringPtr("disabled") + + // Construct an instance of the BareMetalServerPatch model + bareMetalServerPatchModel := new(vpcv1.BareMetalServerPatch) + bareMetalServerPatchModel.EnableSecureBoot = core.BoolPtr(false) + bareMetalServerPatchModel.Name = core.StringPtr("my-bare-metal-server") + bareMetalServerPatchModel.TrustedPlatformModule = bareMetalServerTrustedPlatformModulePatchModel + bareMetalServerPatchModelAsPatch, asPatchErr := bareMetalServerPatchModel.AsPatch() + Expect(asPatchErr).To(BeNil()) + + // Construct an instance of the UpdateBareMetalServerOptions model + updateBareMetalServerOptionsModel := new(vpcv1.UpdateBareMetalServerOptions) + updateBareMetalServerOptionsModel.ID = core.StringPtr("testString") + updateBareMetalServerOptionsModel.BareMetalServerPatch = bareMetalServerPatchModelAsPatch + updateBareMetalServerOptionsModel.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.ListBareMetalServerNetworkAttachmentsWithContext(ctx, listBareMetalServerNetworkAttachmentsOptionsModel) + _, _, operationErr := vpcService.UpdateBareMetalServerWithContext(ctx, updateBareMetalServerOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) // Disable retries and test again vpcService.DisableRetries() - result, response, operationErr := vpcService.ListBareMetalServerNetworkAttachments(listBareMetalServerNetworkAttachmentsOptionsModel) + result, response, operationErr := vpcService.UpdateBareMetalServer(updateBareMetalServerOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) @@ -48594,7 +49010,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.ListBareMetalServerNetworkAttachmentsWithContext(ctx, listBareMetalServerNetworkAttachmentsOptionsModel) + _, _, operationErr = vpcService.UpdateBareMetalServerWithContext(ctx, updateBareMetalServerOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) }) @@ -48608,20 +49024,34 @@ var _ = Describe(`VpcV1`, func() { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(listBareMetalServerNetworkAttachmentsPath)) - Expect(req.Method).To(Equal("GET")) + Expect(req.URL.EscapedPath()).To(Equal(updateBareMetalServerPath)) + 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.URL.Query()["version"]).To(Equal([]string{"testString"})) Expect(req.URL.Query()["generation"]).To(Equal([]string{fmt.Sprint(int64(2))})) - Expect(req.URL.Query()["start"]).To(Equal([]string{"testString"})) - Expect(req.URL.Query()["limit"]).To(Equal([]string{fmt.Sprint(int64(10))})) // 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/bare_metal_servers/3b2669a2-4c2b-4003-bc91-1b81f1326267/network_attachments?limit=20"}, "limit": 20, "network_attachments": [{"created_at": "2019-01-01T12:00:00.000Z", "href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/2302-f7a2bf57-af7c-49d9-b599-b2c91293d30c/network_attachments/2302-da8c43ec-b6ca-4bd2-871e-72e288c66ee6", "id": "2302-da8c43ec-b6ca-4bd2-871e-72e288c66ee6", "lifecycle_state": "stable", "name": "my-bare-metal-server-network-attachment", "port_speed": 1000, "primary_ip": {"address": "192.168.3.4", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e/reserved_ips/6d353a0f-aeb1-4ae1-832e-1110d10981bb", "id": "6d353a0f-aeb1-4ae1-832e-1110d10981bb", "name": "my-reserved-ip", "resource_type": "subnet_reserved_ip"}, "resource_type": "bare_metal_server_network_attachment", "subnet": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "id": "7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "name": "my-subnet", "resource_type": "subnet"}, "type": "primary", "virtual_network_interface": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::virtual-network-interface:0767-fa41aecb-4f21-423d-8082-630bfba1e1d9", "href": "https://us-south.iaas.cloud.ibm.com/v1/virtual_network_interfaces/0767-fa41aecb-4f21-423d-8082-630bfba1e1d9", "id": "0767-fa41aecb-4f21-423d-8082-630bfba1e1d9", "name": "my-virtual-network-interface", "resource_type": "virtual_network_interface"}, "allowed_vlans": [4], "interface_type": "pci"}], "next": {"href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/3b2669a2-4c2b-4003-bc91-1b81f1326267/network_attachments?start=d3e721fd-c988-4670-9927-dbd5e7b07fc6&limit=20"}, "total_count": 132}`) + fmt.Fprintf(res, "%s", `{"bandwidth": 20000, "boot_target": {"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/1e09281b-f177-46fb-baf1-bc152b2e391a/disks/10c02d81-0ecb-4dc5-897d-28392913b81e", "id": "10c02d81-0ecb-4dc5-897d-28392913b81e", "name": "my-bare-metal-server-disk", "resource_type": "bare_metal_server_disk"}, "cpu": {"architecture": "amd64", "core_count": 80, "socket_count": 4, "threads_per_core": 2}, "created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::bare-metal-server:1e09281b-f177-46fb-baf1-bc152b2e391a", "disks": [{"created_at": "2019-01-01T12:00:00.000Z", "href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/1e09281b-f177-46fb-baf1-bc152b2e391a/disks/10c02d81-0ecb-4dc5-897d-28392913b81e", "id": "10c02d81-0ecb-4dc5-897d-28392913b81e", "interface_type": "fcp", "name": "my-bare-metal-server-disk", "resource_type": "bare_metal_server_disk", "size": 100}], "enable_secure_boot": false, "href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/1e09281b-f177-46fb-baf1-bc152b2e391a", "id": "1e09281b-f177-46fb-baf1-bc152b2e391a", "lifecycle_reasons": [{"code": "resource_suspended_by_provider", "message": "The resource has been suspended. Contact IBM support with the CRN for next steps.", "more_info": "https://cloud.ibm.com/apidocs/vpc#resource-suspension"}], "lifecycle_state": "stable", "memory": 1536, "name": "my-bare-metal-server", "network_attachments": [{"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/2302-f7a2bf57-af7c-49d9-b599-b2c91293d30c/network_attachments/2302-da8c43ec-b6ca-4bd2-871e-72e288c66ee6", "id": "2302-da8c43ec-b6ca-4bd2-871e-72e288c66ee6", "name": "my-bare-metal-server-network-attachment", "primary_ip": {"address": "192.168.3.4", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e/reserved_ips/6d353a0f-aeb1-4ae1-832e-1110d10981bb", "id": "6d353a0f-aeb1-4ae1-832e-1110d10981bb", "name": "my-reserved-ip", "resource_type": "subnet_reserved_ip"}, "resource_type": "bare_metal_server_network_attachment", "subnet": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "id": "7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "name": "my-subnet", "resource_type": "subnet"}}], "network_interfaces": [{"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/1e09281b-f177-46fb-baf1-bc152b2e391a/network_interfaces/10c02d81-0ecb-4dc5-897d-28392913b81e", "id": "10c02d81-0ecb-4dc5-897d-28392913b81e", "name": "my-bare-metal-server-network-interface", "primary_ip": {"address": "192.168.3.4", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e/reserved_ips/6d353a0f-aeb1-4ae1-832e-1110d10981bb", "id": "6d353a0f-aeb1-4ae1-832e-1110d10981bb", "name": "my-reserved-ip", "resource_type": "subnet_reserved_ip"}, "resource_type": "network_interface", "subnet": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "id": "7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "name": "my-subnet", "resource_type": "subnet"}}], "primary_network_attachment": {"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/2302-f7a2bf57-af7c-49d9-b599-b2c91293d30c/network_attachments/2302-da8c43ec-b6ca-4bd2-871e-72e288c66ee6", "id": "2302-da8c43ec-b6ca-4bd2-871e-72e288c66ee6", "name": "my-bare-metal-server-network-attachment", "primary_ip": {"address": "192.168.3.4", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e/reserved_ips/6d353a0f-aeb1-4ae1-832e-1110d10981bb", "id": "6d353a0f-aeb1-4ae1-832e-1110d10981bb", "name": "my-reserved-ip", "resource_type": "subnet_reserved_ip"}, "resource_type": "bare_metal_server_network_attachment", "subnet": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "id": "7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "name": "my-subnet", "resource_type": "subnet"}}, "primary_network_interface": {"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/1e09281b-f177-46fb-baf1-bc152b2e391a/network_interfaces/10c02d81-0ecb-4dc5-897d-28392913b81e", "id": "10c02d81-0ecb-4dc5-897d-28392913b81e", "name": "my-bare-metal-server-network-interface", "primary_ip": {"address": "192.168.3.4", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e/reserved_ips/6d353a0f-aeb1-4ae1-832e-1110d10981bb", "id": "6d353a0f-aeb1-4ae1-832e-1110d10981bb", "name": "my-reserved-ip", "resource_type": "subnet_reserved_ip"}, "resource_type": "network_interface", "subnet": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "id": "7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "name": "my-subnet", "resource_type": "subnet"}}, "profile": {"href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/profiles/bx2-metal-192x768", "name": "bx2-metal-192x768", "resource_type": "bare_metal_server_profile"}, "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "resource_type": "bare_metal_server", "status": "deleting", "status_reasons": [{"code": "cannot_start_capacity", "message": "The bare metal server cannot start as there is no more capacity in this\nzone for a bare metal server with the requested profile.", "more_info": "https://console.bluemix.net/docs/iaas/bare_metal_server.html"}], "trusted_platform_module": {"enabled": true, "mode": "disabled", "supported_modes": ["disabled"]}, "vpc": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::vpc:4727d842-f94f-4a2d-824a-9bc9b02c523b", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/vpcs/4727d842-f94f-4a2d-824a-9bc9b02c523b", "id": "4727d842-f94f-4a2d-824a-9bc9b02c523b", "name": "my-vpc", "resource_type": "vpc"}, "zone": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south/zones/us-south-1", "name": "us-south-1"}}`) })) }) - It(`Invoke ListBareMetalServerNetworkAttachments successfully`, func() { + It(`Invoke UpdateBareMetalServer successfully`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -48631,26 +49061,37 @@ var _ = Describe(`VpcV1`, func() { Expect(vpcService).ToNot(BeNil()) // Invoke operation with nil options model (negative test) - result, response, operationErr := vpcService.ListBareMetalServerNetworkAttachments(nil) + result, response, operationErr := vpcService.UpdateBareMetalServer(nil) Expect(operationErr).NotTo(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) - // Construct an instance of the ListBareMetalServerNetworkAttachmentsOptions model - listBareMetalServerNetworkAttachmentsOptionsModel := new(vpcv1.ListBareMetalServerNetworkAttachmentsOptions) - listBareMetalServerNetworkAttachmentsOptionsModel.BareMetalServerID = core.StringPtr("testString") - listBareMetalServerNetworkAttachmentsOptionsModel.Start = core.StringPtr("testString") - listBareMetalServerNetworkAttachmentsOptionsModel.Limit = core.Int64Ptr(int64(10)) - listBareMetalServerNetworkAttachmentsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the BareMetalServerTrustedPlatformModulePatch model + bareMetalServerTrustedPlatformModulePatchModel := new(vpcv1.BareMetalServerTrustedPlatformModulePatch) + bareMetalServerTrustedPlatformModulePatchModel.Mode = core.StringPtr("disabled") + + // Construct an instance of the BareMetalServerPatch model + bareMetalServerPatchModel := new(vpcv1.BareMetalServerPatch) + bareMetalServerPatchModel.EnableSecureBoot = core.BoolPtr(false) + bareMetalServerPatchModel.Name = core.StringPtr("my-bare-metal-server") + bareMetalServerPatchModel.TrustedPlatformModule = bareMetalServerTrustedPlatformModulePatchModel + bareMetalServerPatchModelAsPatch, asPatchErr := bareMetalServerPatchModel.AsPatch() + Expect(asPatchErr).To(BeNil()) + + // Construct an instance of the UpdateBareMetalServerOptions model + updateBareMetalServerOptionsModel := new(vpcv1.UpdateBareMetalServerOptions) + updateBareMetalServerOptionsModel.ID = core.StringPtr("testString") + updateBareMetalServerOptionsModel.BareMetalServerPatch = bareMetalServerPatchModelAsPatch + updateBareMetalServerOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with valid options model (positive test) - result, response, operationErr = vpcService.ListBareMetalServerNetworkAttachments(listBareMetalServerNetworkAttachmentsOptionsModel) + result, response, operationErr = vpcService.UpdateBareMetalServer(updateBareMetalServerOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) }) - It(`Invoke ListBareMetalServerNetworkAttachments with error: Operation validation and request error`, func() { + It(`Invoke UpdateBareMetalServer with error: Operation validation and request error`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -48659,24 +49100,35 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the ListBareMetalServerNetworkAttachmentsOptions model - listBareMetalServerNetworkAttachmentsOptionsModel := new(vpcv1.ListBareMetalServerNetworkAttachmentsOptions) - listBareMetalServerNetworkAttachmentsOptionsModel.BareMetalServerID = core.StringPtr("testString") - listBareMetalServerNetworkAttachmentsOptionsModel.Start = core.StringPtr("testString") - listBareMetalServerNetworkAttachmentsOptionsModel.Limit = core.Int64Ptr(int64(10)) - listBareMetalServerNetworkAttachmentsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the BareMetalServerTrustedPlatformModulePatch model + bareMetalServerTrustedPlatformModulePatchModel := new(vpcv1.BareMetalServerTrustedPlatformModulePatch) + bareMetalServerTrustedPlatformModulePatchModel.Mode = core.StringPtr("disabled") + + // Construct an instance of the BareMetalServerPatch model + bareMetalServerPatchModel := new(vpcv1.BareMetalServerPatch) + bareMetalServerPatchModel.EnableSecureBoot = core.BoolPtr(false) + bareMetalServerPatchModel.Name = core.StringPtr("my-bare-metal-server") + bareMetalServerPatchModel.TrustedPlatformModule = bareMetalServerTrustedPlatformModulePatchModel + bareMetalServerPatchModelAsPatch, asPatchErr := bareMetalServerPatchModel.AsPatch() + Expect(asPatchErr).To(BeNil()) + + // Construct an instance of the UpdateBareMetalServerOptions model + updateBareMetalServerOptionsModel := new(vpcv1.UpdateBareMetalServerOptions) + updateBareMetalServerOptionsModel.ID = core.StringPtr("testString") + updateBareMetalServerOptionsModel.BareMetalServerPatch = bareMetalServerPatchModelAsPatch + updateBareMetalServerOptionsModel.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.ListBareMetalServerNetworkAttachments(listBareMetalServerNetworkAttachmentsOptionsModel) + result, response, operationErr := vpcService.UpdateBareMetalServer(updateBareMetalServerOptionsModel) 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 ListBareMetalServerNetworkAttachmentsOptions model with no property values - listBareMetalServerNetworkAttachmentsOptionsModelNew := new(vpcv1.ListBareMetalServerNetworkAttachmentsOptions) + // Construct a second instance of the UpdateBareMetalServerOptions model with no property values + updateBareMetalServerOptionsModelNew := new(vpcv1.UpdateBareMetalServerOptions) // Invoke operation with invalid model (negative test) - result, response, operationErr = vpcService.ListBareMetalServerNetworkAttachments(listBareMetalServerNetworkAttachmentsOptionsModelNew) + result, response, operationErr = vpcService.UpdateBareMetalServer(updateBareMetalServerOptionsModelNew) Expect(operationErr).ToNot(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) @@ -48694,7 +49146,7 @@ var _ = Describe(`VpcV1`, func() { res.WriteHeader(200) })) }) - It(`Invoke ListBareMetalServerNetworkAttachments successfully`, func() { + It(`Invoke UpdateBareMetalServer successfully`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -48703,15 +49155,26 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the ListBareMetalServerNetworkAttachmentsOptions model - listBareMetalServerNetworkAttachmentsOptionsModel := new(vpcv1.ListBareMetalServerNetworkAttachmentsOptions) - listBareMetalServerNetworkAttachmentsOptionsModel.BareMetalServerID = core.StringPtr("testString") - listBareMetalServerNetworkAttachmentsOptionsModel.Start = core.StringPtr("testString") - listBareMetalServerNetworkAttachmentsOptionsModel.Limit = core.Int64Ptr(int64(10)) - listBareMetalServerNetworkAttachmentsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the BareMetalServerTrustedPlatformModulePatch model + bareMetalServerTrustedPlatformModulePatchModel := new(vpcv1.BareMetalServerTrustedPlatformModulePatch) + bareMetalServerTrustedPlatformModulePatchModel.Mode = core.StringPtr("disabled") + + // Construct an instance of the BareMetalServerPatch model + bareMetalServerPatchModel := new(vpcv1.BareMetalServerPatch) + bareMetalServerPatchModel.EnableSecureBoot = core.BoolPtr(false) + bareMetalServerPatchModel.Name = core.StringPtr("my-bare-metal-server") + bareMetalServerPatchModel.TrustedPlatformModule = bareMetalServerTrustedPlatformModulePatchModel + bareMetalServerPatchModelAsPatch, asPatchErr := bareMetalServerPatchModel.AsPatch() + Expect(asPatchErr).To(BeNil()) + + // Construct an instance of the UpdateBareMetalServerOptions model + updateBareMetalServerOptionsModel := new(vpcv1.UpdateBareMetalServerOptions) + updateBareMetalServerOptionsModel.ID = core.StringPtr("testString") + updateBareMetalServerOptionsModel.BareMetalServerPatch = bareMetalServerPatchModelAsPatch + updateBareMetalServerOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation - result, response, operationErr := vpcService.ListBareMetalServerNetworkAttachments(listBareMetalServerNetworkAttachmentsOptionsModel) + result, response, operationErr := vpcService.UpdateBareMetalServer(updateBareMetalServerOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) @@ -48722,129 +49185,26 @@ var _ = Describe(`VpcV1`, func() { testServer.Close() }) }) - Context(`Test pagination helper method on response`, func() { - It(`Invoke GetNextStart successfully`, func() { - responseObject := new(vpcv1.BareMetalServerNetworkAttachmentCollection) - nextObject := new(vpcv1.BareMetalServerNetworkAttachmentCollectionNext) - 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.BareMetalServerNetworkAttachmentCollection) - - 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.BareMetalServerNetworkAttachmentCollection) - nextObject := new(vpcv1.BareMetalServerNetworkAttachmentCollectionNext) - nextObject.Href = core.StringPtr("ibm.com") - responseObject.Next = nextObject - - value, err := responseObject.GetNextStart() - Expect(err).To(BeNil()) - Expect(value).To(BeNil()) - }) - }) - Context(`Using mock server endpoint - paginated response`, func() { - BeforeEach(func() { - var requestNumber int = 0 - testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { - defer GinkgoRecover() - - // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(listBareMetalServerNetworkAttachmentsPath)) - Expect(req.Method).To(Equal("GET")) - - // Set mock response - res.Header().Set("Content-type", "application/json") - res.WriteHeader(200) - requestNumber++ - if requestNumber == 1 { - fmt.Fprintf(res, "%s", `{"next":{"href":"https://myhost.com/somePath?start=1"},"total_count":2,"limit":1,"network_attachments":[{"created_at":"2019-01-01T12:00:00.000Z","href":"https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/2302-f7a2bf57-af7c-49d9-b599-b2c91293d30c/network_attachments/2302-da8c43ec-b6ca-4bd2-871e-72e288c66ee6","id":"2302-da8c43ec-b6ca-4bd2-871e-72e288c66ee6","lifecycle_state":"stable","name":"my-bare-metal-server-network-attachment","port_speed":1000,"primary_ip":{"address":"192.168.3.4","deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e/reserved_ips/6d353a0f-aeb1-4ae1-832e-1110d10981bb","id":"6d353a0f-aeb1-4ae1-832e-1110d10981bb","name":"my-reserved-ip","resource_type":"subnet_reserved_ip"},"resource_type":"bare_metal_server_network_attachment","subnet":{"crn":"crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e","deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e","id":"7ec86020-1c6e-4889-b3f0-a15f2e50f87e","name":"my-subnet","resource_type":"subnet"},"type":"primary","virtual_network_interface":{"crn":"crn:v1:bluemix:public:is:us-south-1:a/123456::virtual-network-interface:0767-fa41aecb-4f21-423d-8082-630bfba1e1d9","href":"https://us-south.iaas.cloud.ibm.com/v1/virtual_network_interfaces/0767-fa41aecb-4f21-423d-8082-630bfba1e1d9","id":"0767-fa41aecb-4f21-423d-8082-630bfba1e1d9","name":"my-virtual-network-interface","resource_type":"virtual_network_interface"},"allowed_vlans":[4],"interface_type":"pci"}]}`) - } else if requestNumber == 2 { - fmt.Fprintf(res, "%s", `{"total_count":2,"limit":1,"network_attachments":[{"created_at":"2019-01-01T12:00:00.000Z","href":"https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/2302-f7a2bf57-af7c-49d9-b599-b2c91293d30c/network_attachments/2302-da8c43ec-b6ca-4bd2-871e-72e288c66ee6","id":"2302-da8c43ec-b6ca-4bd2-871e-72e288c66ee6","lifecycle_state":"stable","name":"my-bare-metal-server-network-attachment","port_speed":1000,"primary_ip":{"address":"192.168.3.4","deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e/reserved_ips/6d353a0f-aeb1-4ae1-832e-1110d10981bb","id":"6d353a0f-aeb1-4ae1-832e-1110d10981bb","name":"my-reserved-ip","resource_type":"subnet_reserved_ip"},"resource_type":"bare_metal_server_network_attachment","subnet":{"crn":"crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e","deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e","id":"7ec86020-1c6e-4889-b3f0-a15f2e50f87e","name":"my-subnet","resource_type":"subnet"},"type":"primary","virtual_network_interface":{"crn":"crn:v1:bluemix:public:is:us-south-1:a/123456::virtual-network-interface:0767-fa41aecb-4f21-423d-8082-630bfba1e1d9","href":"https://us-south.iaas.cloud.ibm.com/v1/virtual_network_interfaces/0767-fa41aecb-4f21-423d-8082-630bfba1e1d9","id":"0767-fa41aecb-4f21-423d-8082-630bfba1e1d9","name":"my-virtual-network-interface","resource_type":"virtual_network_interface"},"allowed_vlans":[4],"interface_type":"pci"}]}`) - } else { - res.WriteHeader(400) - } - })) - }) - It(`Use BareMetalServerNetworkAttachmentsPager.GetNext successfully`, func() { - vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ - URL: testServer.URL, - Authenticator: &core.NoAuthAuthenticator{}, - Version: core.StringPtr(version), - }) - Expect(serviceErr).To(BeNil()) - Expect(vpcService).ToNot(BeNil()) - - listBareMetalServerNetworkAttachmentsOptionsModel := &vpcv1.ListBareMetalServerNetworkAttachmentsOptions{ - BareMetalServerID: core.StringPtr("testString"), - Limit: core.Int64Ptr(int64(10)), - } - - pager, err := vpcService.NewBareMetalServerNetworkAttachmentsPager(listBareMetalServerNetworkAttachmentsOptionsModel) - Expect(err).To(BeNil()) - Expect(pager).ToNot(BeNil()) - - var allResults []vpcv1.BareMetalServerNetworkAttachmentIntf - for pager.HasNext() { - nextPage, err := pager.GetNext() - Expect(err).To(BeNil()) - Expect(nextPage).ToNot(BeNil()) - allResults = append(allResults, nextPage...) - } - Expect(len(allResults)).To(Equal(2)) - }) - It(`Use BareMetalServerNetworkAttachmentsPager.GetAll successfully`, func() { - vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ - URL: testServer.URL, - Authenticator: &core.NoAuthAuthenticator{}, - Version: core.StringPtr(version), - }) - Expect(serviceErr).To(BeNil()) - Expect(vpcService).ToNot(BeNil()) - - listBareMetalServerNetworkAttachmentsOptionsModel := &vpcv1.ListBareMetalServerNetworkAttachmentsOptions{ - BareMetalServerID: core.StringPtr("testString"), - Limit: core.Int64Ptr(int64(10)), - } - - pager, err := vpcService.NewBareMetalServerNetworkAttachmentsPager(listBareMetalServerNetworkAttachmentsOptionsModel) - Expect(err).To(BeNil()) - Expect(pager).ToNot(BeNil()) - - allResults, err := pager.GetAll() - Expect(err).To(BeNil()) - Expect(allResults).ToNot(BeNil()) - Expect(len(allResults)).To(Equal(2)) - }) - }) }) - Describe(`CreateBareMetalServerNetworkAttachment(createBareMetalServerNetworkAttachmentOptions *CreateBareMetalServerNetworkAttachmentOptions) - Operation response error`, func() { + Describe(`GetBareMetalServerInitialization(getBareMetalServerInitializationOptions *GetBareMetalServerInitializationOptions) - Operation response error`, func() { version := "testString" - createBareMetalServerNetworkAttachmentPath := "/bare_metal_servers/testString/network_attachments" + getBareMetalServerInitializationPath := "/bare_metal_servers/testString/initialization" 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(createBareMetalServerNetworkAttachmentPath)) - Expect(req.Method).To(Equal("POST")) + Expect(req.URL.EscapedPath()).To(Equal(getBareMetalServerInitializationPath)) + 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(201) + res.WriteHeader(200) fmt.Fprint(res, `} this is not valid json {`) })) }) - It(`Invoke CreateBareMetalServerNetworkAttachment with error: Operation response processing error`, func() { + It(`Invoke GetBareMetalServerInitialization with error: Operation response processing error`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -48853,63 +49213,19 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the VirtualNetworkInterfaceIPPrototypeReservedIPPrototypeVirtualNetworkInterfaceIPsContext model - virtualNetworkInterfaceIPPrototypeModel := new(vpcv1.VirtualNetworkInterfaceIPPrototypeReservedIPPrototypeVirtualNetworkInterfaceIPsContext) - virtualNetworkInterfaceIPPrototypeModel.Address = core.StringPtr("10.0.0.5") - virtualNetworkInterfaceIPPrototypeModel.AutoDelete = core.BoolPtr(false) - virtualNetworkInterfaceIPPrototypeModel.Name = core.StringPtr("my-reserved-ip") - - // Construct an instance of the VirtualNetworkInterfacePrimaryIPPrototypeReservedIPPrototypeVirtualNetworkInterfacePrimaryIPContext model - virtualNetworkInterfacePrimaryIPPrototypeModel := new(vpcv1.VirtualNetworkInterfacePrimaryIPPrototypeReservedIPPrototypeVirtualNetworkInterfacePrimaryIPContext) - virtualNetworkInterfacePrimaryIPPrototypeModel.Address = core.StringPtr("10.0.0.5") - virtualNetworkInterfacePrimaryIPPrototypeModel.AutoDelete = core.BoolPtr(false) - virtualNetworkInterfacePrimaryIPPrototypeModel.Name = core.StringPtr("my-reserved-ip") - - // Construct an instance of the ResourceGroupIdentityByID model - resourceGroupIdentityModel := new(vpcv1.ResourceGroupIdentityByID) - resourceGroupIdentityModel.ID = core.StringPtr("fee82deba12e4c0fb69c3b09d1f12345") - - // Construct an instance of the SecurityGroupIdentityByID model - securityGroupIdentityModel := new(vpcv1.SecurityGroupIdentityByID) - securityGroupIdentityModel.ID = core.StringPtr("be5df5ca-12a0-494b-907e-aa6ec2bfa271") - - // Construct an instance of the SubnetIdentityByID model - subnetIdentityModel := new(vpcv1.SubnetIdentityByID) - subnetIdentityModel.ID = core.StringPtr("7ec86020-1c6e-4889-b3f0-a15f2e50f87e") - - // Construct an instance of the BareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceVirtualNetworkInterfacePrototypeBareMetalServerNetworkAttachmentContext model - bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel := new(vpcv1.BareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceVirtualNetworkInterfacePrototypeBareMetalServerNetworkAttachmentContext) - bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel.AllowIPSpoofing = core.BoolPtr(true) - bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel.AutoDelete = core.BoolPtr(false) - bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel.EnableInfrastructureNat = core.BoolPtr(true) - bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel.Ips = []vpcv1.VirtualNetworkInterfaceIPPrototypeIntf{virtualNetworkInterfaceIPPrototypeModel} - bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel.Name = core.StringPtr("my-virtual-network-interface") - bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel.PrimaryIP = virtualNetworkInterfacePrimaryIPPrototypeModel - bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel.ResourceGroup = resourceGroupIdentityModel - bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel.SecurityGroups = []vpcv1.SecurityGroupIdentityIntf{securityGroupIdentityModel} - bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel.Subnet = subnetIdentityModel - - // Construct an instance of the BareMetalServerNetworkAttachmentPrototypeBareMetalServerNetworkAttachmentByPciPrototype model - bareMetalServerNetworkAttachmentPrototypeModel := new(vpcv1.BareMetalServerNetworkAttachmentPrototypeBareMetalServerNetworkAttachmentByPciPrototype) - bareMetalServerNetworkAttachmentPrototypeModel.Name = core.StringPtr("my-bare-metal-server-network-attachment") - bareMetalServerNetworkAttachmentPrototypeModel.VirtualNetworkInterface = bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel - bareMetalServerNetworkAttachmentPrototypeModel.AllowedVlans = []int64{} - bareMetalServerNetworkAttachmentPrototypeModel.InterfaceType = core.StringPtr("pci") - - // Construct an instance of the CreateBareMetalServerNetworkAttachmentOptions model - createBareMetalServerNetworkAttachmentOptionsModel := new(vpcv1.CreateBareMetalServerNetworkAttachmentOptions) - createBareMetalServerNetworkAttachmentOptionsModel.BareMetalServerID = core.StringPtr("testString") - createBareMetalServerNetworkAttachmentOptionsModel.BareMetalServerNetworkAttachmentPrototype = bareMetalServerNetworkAttachmentPrototypeModel - createBareMetalServerNetworkAttachmentOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the GetBareMetalServerInitializationOptions model + getBareMetalServerInitializationOptionsModel := new(vpcv1.GetBareMetalServerInitializationOptions) + getBareMetalServerInitializationOptionsModel.ID = core.StringPtr("testString") + getBareMetalServerInitializationOptionsModel.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.CreateBareMetalServerNetworkAttachment(createBareMetalServerNetworkAttachmentOptionsModel) + result, response, operationErr := vpcService.GetBareMetalServerInitialization(getBareMetalServerInitializationOptionsModel) 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.CreateBareMetalServerNetworkAttachment(createBareMetalServerNetworkAttachmentOptionsModel) + result, response, operationErr = vpcService.GetBareMetalServerInitialization(getBareMetalServerInitializationOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).To(BeNil()) @@ -48919,114 +49235,54 @@ var _ = Describe(`VpcV1`, func() { }) }) }) - Describe(`CreateBareMetalServerNetworkAttachment(createBareMetalServerNetworkAttachmentOptions *CreateBareMetalServerNetworkAttachmentOptions)`, func() { + Describe(`GetBareMetalServerInitialization(getBareMetalServerInitializationOptions *GetBareMetalServerInitializationOptions)`, func() { version := "testString" - createBareMetalServerNetworkAttachmentPath := "/bare_metal_servers/testString/network_attachments" + getBareMetalServerInitializationPath := "/bare_metal_servers/testString/initialization" 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(createBareMetalServerNetworkAttachmentPath)) - 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", "href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/2302-f7a2bf57-af7c-49d9-b599-b2c91293d30c/network_attachments/2302-da8c43ec-b6ca-4bd2-871e-72e288c66ee6", "id": "2302-da8c43ec-b6ca-4bd2-871e-72e288c66ee6", "lifecycle_state": "stable", "name": "my-bare-metal-server-network-attachment", "port_speed": 1000, "primary_ip": {"address": "192.168.3.4", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e/reserved_ips/6d353a0f-aeb1-4ae1-832e-1110d10981bb", "id": "6d353a0f-aeb1-4ae1-832e-1110d10981bb", "name": "my-reserved-ip", "resource_type": "subnet_reserved_ip"}, "resource_type": "bare_metal_server_network_attachment", "subnet": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "id": "7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "name": "my-subnet", "resource_type": "subnet"}, "type": "primary", "virtual_network_interface": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::virtual-network-interface:0767-fa41aecb-4f21-423d-8082-630bfba1e1d9", "href": "https://us-south.iaas.cloud.ibm.com/v1/virtual_network_interfaces/0767-fa41aecb-4f21-423d-8082-630bfba1e1d9", "id": "0767-fa41aecb-4f21-423d-8082-630bfba1e1d9", "name": "my-virtual-network-interface", "resource_type": "virtual_network_interface"}, "allowed_vlans": [4], "interface_type": "pci"}`) - })) - }) - It(`Invoke CreateBareMetalServerNetworkAttachment 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 VirtualNetworkInterfaceIPPrototypeReservedIPPrototypeVirtualNetworkInterfaceIPsContext model - virtualNetworkInterfaceIPPrototypeModel := new(vpcv1.VirtualNetworkInterfaceIPPrototypeReservedIPPrototypeVirtualNetworkInterfaceIPsContext) - virtualNetworkInterfaceIPPrototypeModel.Address = core.StringPtr("10.0.0.5") - virtualNetworkInterfaceIPPrototypeModel.AutoDelete = core.BoolPtr(false) - virtualNetworkInterfaceIPPrototypeModel.Name = core.StringPtr("my-reserved-ip") - - // Construct an instance of the VirtualNetworkInterfacePrimaryIPPrototypeReservedIPPrototypeVirtualNetworkInterfacePrimaryIPContext model - virtualNetworkInterfacePrimaryIPPrototypeModel := new(vpcv1.VirtualNetworkInterfacePrimaryIPPrototypeReservedIPPrototypeVirtualNetworkInterfacePrimaryIPContext) - virtualNetworkInterfacePrimaryIPPrototypeModel.Address = core.StringPtr("10.0.0.5") - virtualNetworkInterfacePrimaryIPPrototypeModel.AutoDelete = core.BoolPtr(false) - virtualNetworkInterfacePrimaryIPPrototypeModel.Name = core.StringPtr("my-reserved-ip") - - // Construct an instance of the ResourceGroupIdentityByID model - resourceGroupIdentityModel := new(vpcv1.ResourceGroupIdentityByID) - resourceGroupIdentityModel.ID = core.StringPtr("fee82deba12e4c0fb69c3b09d1f12345") - - // Construct an instance of the SecurityGroupIdentityByID model - securityGroupIdentityModel := new(vpcv1.SecurityGroupIdentityByID) - securityGroupIdentityModel.ID = core.StringPtr("be5df5ca-12a0-494b-907e-aa6ec2bfa271") - - // Construct an instance of the SubnetIdentityByID model - subnetIdentityModel := new(vpcv1.SubnetIdentityByID) - subnetIdentityModel.ID = core.StringPtr("7ec86020-1c6e-4889-b3f0-a15f2e50f87e") - - // Construct an instance of the BareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceVirtualNetworkInterfacePrototypeBareMetalServerNetworkAttachmentContext model - bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel := new(vpcv1.BareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceVirtualNetworkInterfacePrototypeBareMetalServerNetworkAttachmentContext) - bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel.AllowIPSpoofing = core.BoolPtr(true) - bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel.AutoDelete = core.BoolPtr(false) - bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel.EnableInfrastructureNat = core.BoolPtr(true) - bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel.Ips = []vpcv1.VirtualNetworkInterfaceIPPrototypeIntf{virtualNetworkInterfaceIPPrototypeModel} - bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel.Name = core.StringPtr("my-virtual-network-interface") - bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel.PrimaryIP = virtualNetworkInterfacePrimaryIPPrototypeModel - bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel.ResourceGroup = resourceGroupIdentityModel - bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel.SecurityGroups = []vpcv1.SecurityGroupIdentityIntf{securityGroupIdentityModel} - bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel.Subnet = subnetIdentityModel + // Verify the contents of the request + Expect(req.URL.EscapedPath()).To(Equal(getBareMetalServerInitializationPath)) + Expect(req.Method).To(Equal("GET")) - // Construct an instance of the BareMetalServerNetworkAttachmentPrototypeBareMetalServerNetworkAttachmentByPciPrototype model - bareMetalServerNetworkAttachmentPrototypeModel := new(vpcv1.BareMetalServerNetworkAttachmentPrototypeBareMetalServerNetworkAttachmentByPciPrototype) - bareMetalServerNetworkAttachmentPrototypeModel.Name = core.StringPtr("my-bare-metal-server-network-attachment") - bareMetalServerNetworkAttachmentPrototypeModel.VirtualNetworkInterface = bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel - bareMetalServerNetworkAttachmentPrototypeModel.AllowedVlans = []int64{} - bareMetalServerNetworkAttachmentPrototypeModel.InterfaceType = core.StringPtr("pci") + 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) - // Construct an instance of the CreateBareMetalServerNetworkAttachmentOptions model - createBareMetalServerNetworkAttachmentOptionsModel := new(vpcv1.CreateBareMetalServerNetworkAttachmentOptions) - createBareMetalServerNetworkAttachmentOptionsModel.BareMetalServerID = core.StringPtr("testString") - createBareMetalServerNetworkAttachmentOptionsModel.BareMetalServerNetworkAttachmentPrototype = bareMetalServerNetworkAttachmentPrototypeModel - createBareMetalServerNetworkAttachmentOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Set mock response + res.Header().Set("Content-type", "application/json") + res.WriteHeader(200) + fmt.Fprintf(res, "%s", `{"image": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::image:72b27b5c-f4b0-48bb-b954-5becc7c1dcb8", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/images/72b27b5c-f4b0-48bb-b954-5becc7c1dcb8", "id": "72b27b5c-f4b0-48bb-b954-5becc7c1dcb8", "name": "my-image", "remote": {"account": {"id": "aa2432b1fa4d4ace891e9b80fc104e34", "resource_type": "account"}, "region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "image"}, "keys": [{"crn": "crn:v1:bluemix:public:is:us-south:a/123456::key:a6b1a881-2ce8-41a3-80fc-36316a73f803", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "fingerprint": "SHA256:yxavE4CIOL2NlsqcurRO3xGjkP6m/0mp8ugojH5yxlY", "href": "https://us-south.iaas.cloud.ibm.com/v1/keys/a6b1a881-2ce8-41a3-80fc-36316a73f803", "id": "a6b1a881-2ce8-41a3-80fc-36316a73f803", "name": "my-key"}], "user_accounts": [{"encrypted_password": "qQ+/YEApnl1ZtEgIrfprzb065307thTkzlnLqL5ICpesdbBN03dyCQ==", "encryption_key": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::key:a6b1a881-2ce8-41a3-80fc-36316a73f803", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "fingerprint": "SHA256:yxavE4CIOL2NlsqcurRO3xGjkP6m/0mp8ugojH5yxlY", "href": "https://us-south.iaas.cloud.ibm.com/v1/keys/a6b1a881-2ce8-41a3-80fc-36316a73f803", "id": "a6b1a881-2ce8-41a3-80fc-36316a73f803", "name": "my-key"}, "resource_type": "host_user_account", "username": "Administrator"}]}`) + })) + }) + It(`Invoke GetBareMetalServerInitialization 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 GetBareMetalServerInitializationOptions model + getBareMetalServerInitializationOptionsModel := new(vpcv1.GetBareMetalServerInitializationOptions) + getBareMetalServerInitializationOptionsModel.ID = core.StringPtr("testString") + getBareMetalServerInitializationOptionsModel.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.CreateBareMetalServerNetworkAttachmentWithContext(ctx, createBareMetalServerNetworkAttachmentOptionsModel) + _, _, operationErr := vpcService.GetBareMetalServerInitializationWithContext(ctx, getBareMetalServerInitializationOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) // Disable retries and test again vpcService.DisableRetries() - result, response, operationErr := vpcService.CreateBareMetalServerNetworkAttachment(createBareMetalServerNetworkAttachmentOptionsModel) + result, response, operationErr := vpcService.GetBareMetalServerInitialization(getBareMetalServerInitializationOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) @@ -49034,7 +49290,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.CreateBareMetalServerNetworkAttachmentWithContext(ctx, createBareMetalServerNetworkAttachmentOptionsModel) + _, _, operationErr = vpcService.GetBareMetalServerInitializationWithContext(ctx, getBareMetalServerInitializationOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) }) @@ -49048,34 +49304,18 @@ var _ = Describe(`VpcV1`, func() { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(createBareMetalServerNetworkAttachmentPath)) - 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.EscapedPath()).To(Equal(getBareMetalServerInitializationPath)) + 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(201) - fmt.Fprintf(res, "%s", `{"created_at": "2019-01-01T12:00:00.000Z", "href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/2302-f7a2bf57-af7c-49d9-b599-b2c91293d30c/network_attachments/2302-da8c43ec-b6ca-4bd2-871e-72e288c66ee6", "id": "2302-da8c43ec-b6ca-4bd2-871e-72e288c66ee6", "lifecycle_state": "stable", "name": "my-bare-metal-server-network-attachment", "port_speed": 1000, "primary_ip": {"address": "192.168.3.4", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e/reserved_ips/6d353a0f-aeb1-4ae1-832e-1110d10981bb", "id": "6d353a0f-aeb1-4ae1-832e-1110d10981bb", "name": "my-reserved-ip", "resource_type": "subnet_reserved_ip"}, "resource_type": "bare_metal_server_network_attachment", "subnet": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "id": "7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "name": "my-subnet", "resource_type": "subnet"}, "type": "primary", "virtual_network_interface": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::virtual-network-interface:0767-fa41aecb-4f21-423d-8082-630bfba1e1d9", "href": "https://us-south.iaas.cloud.ibm.com/v1/virtual_network_interfaces/0767-fa41aecb-4f21-423d-8082-630bfba1e1d9", "id": "0767-fa41aecb-4f21-423d-8082-630bfba1e1d9", "name": "my-virtual-network-interface", "resource_type": "virtual_network_interface"}, "allowed_vlans": [4], "interface_type": "pci"}`) + res.WriteHeader(200) + fmt.Fprintf(res, "%s", `{"image": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::image:72b27b5c-f4b0-48bb-b954-5becc7c1dcb8", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/images/72b27b5c-f4b0-48bb-b954-5becc7c1dcb8", "id": "72b27b5c-f4b0-48bb-b954-5becc7c1dcb8", "name": "my-image", "remote": {"account": {"id": "aa2432b1fa4d4ace891e9b80fc104e34", "resource_type": "account"}, "region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "image"}, "keys": [{"crn": "crn:v1:bluemix:public:is:us-south:a/123456::key:a6b1a881-2ce8-41a3-80fc-36316a73f803", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "fingerprint": "SHA256:yxavE4CIOL2NlsqcurRO3xGjkP6m/0mp8ugojH5yxlY", "href": "https://us-south.iaas.cloud.ibm.com/v1/keys/a6b1a881-2ce8-41a3-80fc-36316a73f803", "id": "a6b1a881-2ce8-41a3-80fc-36316a73f803", "name": "my-key"}], "user_accounts": [{"encrypted_password": "qQ+/YEApnl1ZtEgIrfprzb065307thTkzlnLqL5ICpesdbBN03dyCQ==", "encryption_key": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::key:a6b1a881-2ce8-41a3-80fc-36316a73f803", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "fingerprint": "SHA256:yxavE4CIOL2NlsqcurRO3xGjkP6m/0mp8ugojH5yxlY", "href": "https://us-south.iaas.cloud.ibm.com/v1/keys/a6b1a881-2ce8-41a3-80fc-36316a73f803", "id": "a6b1a881-2ce8-41a3-80fc-36316a73f803", "name": "my-key"}, "resource_type": "host_user_account", "username": "Administrator"}]}`) })) }) - It(`Invoke CreateBareMetalServerNetworkAttachment successfully`, func() { + It(`Invoke GetBareMetalServerInitialization successfully`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -49085,68 +49325,24 @@ var _ = Describe(`VpcV1`, func() { Expect(vpcService).ToNot(BeNil()) // Invoke operation with nil options model (negative test) - result, response, operationErr := vpcService.CreateBareMetalServerNetworkAttachment(nil) + result, response, operationErr := vpcService.GetBareMetalServerInitialization(nil) Expect(operationErr).NotTo(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) - // Construct an instance of the VirtualNetworkInterfaceIPPrototypeReservedIPPrototypeVirtualNetworkInterfaceIPsContext model - virtualNetworkInterfaceIPPrototypeModel := new(vpcv1.VirtualNetworkInterfaceIPPrototypeReservedIPPrototypeVirtualNetworkInterfaceIPsContext) - virtualNetworkInterfaceIPPrototypeModel.Address = core.StringPtr("10.0.0.5") - virtualNetworkInterfaceIPPrototypeModel.AutoDelete = core.BoolPtr(false) - virtualNetworkInterfaceIPPrototypeModel.Name = core.StringPtr("my-reserved-ip") - - // Construct an instance of the VirtualNetworkInterfacePrimaryIPPrototypeReservedIPPrototypeVirtualNetworkInterfacePrimaryIPContext model - virtualNetworkInterfacePrimaryIPPrototypeModel := new(vpcv1.VirtualNetworkInterfacePrimaryIPPrototypeReservedIPPrototypeVirtualNetworkInterfacePrimaryIPContext) - virtualNetworkInterfacePrimaryIPPrototypeModel.Address = core.StringPtr("10.0.0.5") - virtualNetworkInterfacePrimaryIPPrototypeModel.AutoDelete = core.BoolPtr(false) - virtualNetworkInterfacePrimaryIPPrototypeModel.Name = core.StringPtr("my-reserved-ip") - - // Construct an instance of the ResourceGroupIdentityByID model - resourceGroupIdentityModel := new(vpcv1.ResourceGroupIdentityByID) - resourceGroupIdentityModel.ID = core.StringPtr("fee82deba12e4c0fb69c3b09d1f12345") - - // Construct an instance of the SecurityGroupIdentityByID model - securityGroupIdentityModel := new(vpcv1.SecurityGroupIdentityByID) - securityGroupIdentityModel.ID = core.StringPtr("be5df5ca-12a0-494b-907e-aa6ec2bfa271") - - // Construct an instance of the SubnetIdentityByID model - subnetIdentityModel := new(vpcv1.SubnetIdentityByID) - subnetIdentityModel.ID = core.StringPtr("7ec86020-1c6e-4889-b3f0-a15f2e50f87e") - - // Construct an instance of the BareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceVirtualNetworkInterfacePrototypeBareMetalServerNetworkAttachmentContext model - bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel := new(vpcv1.BareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceVirtualNetworkInterfacePrototypeBareMetalServerNetworkAttachmentContext) - bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel.AllowIPSpoofing = core.BoolPtr(true) - bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel.AutoDelete = core.BoolPtr(false) - bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel.EnableInfrastructureNat = core.BoolPtr(true) - bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel.Ips = []vpcv1.VirtualNetworkInterfaceIPPrototypeIntf{virtualNetworkInterfaceIPPrototypeModel} - bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel.Name = core.StringPtr("my-virtual-network-interface") - bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel.PrimaryIP = virtualNetworkInterfacePrimaryIPPrototypeModel - bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel.ResourceGroup = resourceGroupIdentityModel - bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel.SecurityGroups = []vpcv1.SecurityGroupIdentityIntf{securityGroupIdentityModel} - bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel.Subnet = subnetIdentityModel - - // Construct an instance of the BareMetalServerNetworkAttachmentPrototypeBareMetalServerNetworkAttachmentByPciPrototype model - bareMetalServerNetworkAttachmentPrototypeModel := new(vpcv1.BareMetalServerNetworkAttachmentPrototypeBareMetalServerNetworkAttachmentByPciPrototype) - bareMetalServerNetworkAttachmentPrototypeModel.Name = core.StringPtr("my-bare-metal-server-network-attachment") - bareMetalServerNetworkAttachmentPrototypeModel.VirtualNetworkInterface = bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel - bareMetalServerNetworkAttachmentPrototypeModel.AllowedVlans = []int64{} - bareMetalServerNetworkAttachmentPrototypeModel.InterfaceType = core.StringPtr("pci") - - // Construct an instance of the CreateBareMetalServerNetworkAttachmentOptions model - createBareMetalServerNetworkAttachmentOptionsModel := new(vpcv1.CreateBareMetalServerNetworkAttachmentOptions) - createBareMetalServerNetworkAttachmentOptionsModel.BareMetalServerID = core.StringPtr("testString") - createBareMetalServerNetworkAttachmentOptionsModel.BareMetalServerNetworkAttachmentPrototype = bareMetalServerNetworkAttachmentPrototypeModel - createBareMetalServerNetworkAttachmentOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the GetBareMetalServerInitializationOptions model + getBareMetalServerInitializationOptionsModel := new(vpcv1.GetBareMetalServerInitializationOptions) + getBareMetalServerInitializationOptionsModel.ID = core.StringPtr("testString") + getBareMetalServerInitializationOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with valid options model (positive test) - result, response, operationErr = vpcService.CreateBareMetalServerNetworkAttachment(createBareMetalServerNetworkAttachmentOptionsModel) + result, response, operationErr = vpcService.GetBareMetalServerInitialization(getBareMetalServerInitializationOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) }) - It(`Invoke CreateBareMetalServerNetworkAttachment with error: Operation validation and request error`, func() { + It(`Invoke GetBareMetalServerInitialization with error: Operation validation and request error`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -49155,66 +49351,22 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the VirtualNetworkInterfaceIPPrototypeReservedIPPrototypeVirtualNetworkInterfaceIPsContext model - virtualNetworkInterfaceIPPrototypeModel := new(vpcv1.VirtualNetworkInterfaceIPPrototypeReservedIPPrototypeVirtualNetworkInterfaceIPsContext) - virtualNetworkInterfaceIPPrototypeModel.Address = core.StringPtr("10.0.0.5") - virtualNetworkInterfaceIPPrototypeModel.AutoDelete = core.BoolPtr(false) - virtualNetworkInterfaceIPPrototypeModel.Name = core.StringPtr("my-reserved-ip") - - // Construct an instance of the VirtualNetworkInterfacePrimaryIPPrototypeReservedIPPrototypeVirtualNetworkInterfacePrimaryIPContext model - virtualNetworkInterfacePrimaryIPPrototypeModel := new(vpcv1.VirtualNetworkInterfacePrimaryIPPrototypeReservedIPPrototypeVirtualNetworkInterfacePrimaryIPContext) - virtualNetworkInterfacePrimaryIPPrototypeModel.Address = core.StringPtr("10.0.0.5") - virtualNetworkInterfacePrimaryIPPrototypeModel.AutoDelete = core.BoolPtr(false) - virtualNetworkInterfacePrimaryIPPrototypeModel.Name = core.StringPtr("my-reserved-ip") - - // Construct an instance of the ResourceGroupIdentityByID model - resourceGroupIdentityModel := new(vpcv1.ResourceGroupIdentityByID) - resourceGroupIdentityModel.ID = core.StringPtr("fee82deba12e4c0fb69c3b09d1f12345") - - // Construct an instance of the SecurityGroupIdentityByID model - securityGroupIdentityModel := new(vpcv1.SecurityGroupIdentityByID) - securityGroupIdentityModel.ID = core.StringPtr("be5df5ca-12a0-494b-907e-aa6ec2bfa271") - - // Construct an instance of the SubnetIdentityByID model - subnetIdentityModel := new(vpcv1.SubnetIdentityByID) - subnetIdentityModel.ID = core.StringPtr("7ec86020-1c6e-4889-b3f0-a15f2e50f87e") - - // Construct an instance of the BareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceVirtualNetworkInterfacePrototypeBareMetalServerNetworkAttachmentContext model - bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel := new(vpcv1.BareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceVirtualNetworkInterfacePrototypeBareMetalServerNetworkAttachmentContext) - bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel.AllowIPSpoofing = core.BoolPtr(true) - bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel.AutoDelete = core.BoolPtr(false) - bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel.EnableInfrastructureNat = core.BoolPtr(true) - bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel.Ips = []vpcv1.VirtualNetworkInterfaceIPPrototypeIntf{virtualNetworkInterfaceIPPrototypeModel} - bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel.Name = core.StringPtr("my-virtual-network-interface") - bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel.PrimaryIP = virtualNetworkInterfacePrimaryIPPrototypeModel - bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel.ResourceGroup = resourceGroupIdentityModel - bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel.SecurityGroups = []vpcv1.SecurityGroupIdentityIntf{securityGroupIdentityModel} - bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel.Subnet = subnetIdentityModel - - // Construct an instance of the BareMetalServerNetworkAttachmentPrototypeBareMetalServerNetworkAttachmentByPciPrototype model - bareMetalServerNetworkAttachmentPrototypeModel := new(vpcv1.BareMetalServerNetworkAttachmentPrototypeBareMetalServerNetworkAttachmentByPciPrototype) - bareMetalServerNetworkAttachmentPrototypeModel.Name = core.StringPtr("my-bare-metal-server-network-attachment") - bareMetalServerNetworkAttachmentPrototypeModel.VirtualNetworkInterface = bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel - bareMetalServerNetworkAttachmentPrototypeModel.AllowedVlans = []int64{} - bareMetalServerNetworkAttachmentPrototypeModel.InterfaceType = core.StringPtr("pci") - - // Construct an instance of the CreateBareMetalServerNetworkAttachmentOptions model - createBareMetalServerNetworkAttachmentOptionsModel := new(vpcv1.CreateBareMetalServerNetworkAttachmentOptions) - createBareMetalServerNetworkAttachmentOptionsModel.BareMetalServerID = core.StringPtr("testString") - createBareMetalServerNetworkAttachmentOptionsModel.BareMetalServerNetworkAttachmentPrototype = bareMetalServerNetworkAttachmentPrototypeModel - createBareMetalServerNetworkAttachmentOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the GetBareMetalServerInitializationOptions model + getBareMetalServerInitializationOptionsModel := new(vpcv1.GetBareMetalServerInitializationOptions) + getBareMetalServerInitializationOptionsModel.ID = core.StringPtr("testString") + getBareMetalServerInitializationOptionsModel.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.CreateBareMetalServerNetworkAttachment(createBareMetalServerNetworkAttachmentOptionsModel) + result, response, operationErr := vpcService.GetBareMetalServerInitialization(getBareMetalServerInitializationOptionsModel) 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 CreateBareMetalServerNetworkAttachmentOptions model with no property values - createBareMetalServerNetworkAttachmentOptionsModelNew := new(vpcv1.CreateBareMetalServerNetworkAttachmentOptions) + // Construct a second instance of the GetBareMetalServerInitializationOptions model with no property values + getBareMetalServerInitializationOptionsModelNew := new(vpcv1.GetBareMetalServerInitializationOptions) // Invoke operation with invalid model (negative test) - result, response, operationErr = vpcService.CreateBareMetalServerNetworkAttachment(createBareMetalServerNetworkAttachmentOptionsModelNew) + result, response, operationErr = vpcService.GetBareMetalServerInitialization(getBareMetalServerInitializationOptionsModelNew) Expect(operationErr).ToNot(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) @@ -49229,10 +49381,10 @@ var _ = Describe(`VpcV1`, func() { defer GinkgoRecover() // Set success status code with no respoonse body - res.WriteHeader(201) + res.WriteHeader(200) })) }) - It(`Invoke CreateBareMetalServerNetworkAttachment successfully`, func() { + It(`Invoke GetBareMetalServerInitialization successfully`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -49241,57 +49393,13 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the VirtualNetworkInterfaceIPPrototypeReservedIPPrototypeVirtualNetworkInterfaceIPsContext model - virtualNetworkInterfaceIPPrototypeModel := new(vpcv1.VirtualNetworkInterfaceIPPrototypeReservedIPPrototypeVirtualNetworkInterfaceIPsContext) - virtualNetworkInterfaceIPPrototypeModel.Address = core.StringPtr("10.0.0.5") - virtualNetworkInterfaceIPPrototypeModel.AutoDelete = core.BoolPtr(false) - virtualNetworkInterfaceIPPrototypeModel.Name = core.StringPtr("my-reserved-ip") - - // Construct an instance of the VirtualNetworkInterfacePrimaryIPPrototypeReservedIPPrototypeVirtualNetworkInterfacePrimaryIPContext model - virtualNetworkInterfacePrimaryIPPrototypeModel := new(vpcv1.VirtualNetworkInterfacePrimaryIPPrototypeReservedIPPrototypeVirtualNetworkInterfacePrimaryIPContext) - virtualNetworkInterfacePrimaryIPPrototypeModel.Address = core.StringPtr("10.0.0.5") - virtualNetworkInterfacePrimaryIPPrototypeModel.AutoDelete = core.BoolPtr(false) - virtualNetworkInterfacePrimaryIPPrototypeModel.Name = core.StringPtr("my-reserved-ip") - - // Construct an instance of the ResourceGroupIdentityByID model - resourceGroupIdentityModel := new(vpcv1.ResourceGroupIdentityByID) - resourceGroupIdentityModel.ID = core.StringPtr("fee82deba12e4c0fb69c3b09d1f12345") - - // Construct an instance of the SecurityGroupIdentityByID model - securityGroupIdentityModel := new(vpcv1.SecurityGroupIdentityByID) - securityGroupIdentityModel.ID = core.StringPtr("be5df5ca-12a0-494b-907e-aa6ec2bfa271") - - // Construct an instance of the SubnetIdentityByID model - subnetIdentityModel := new(vpcv1.SubnetIdentityByID) - subnetIdentityModel.ID = core.StringPtr("7ec86020-1c6e-4889-b3f0-a15f2e50f87e") - - // Construct an instance of the BareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceVirtualNetworkInterfacePrototypeBareMetalServerNetworkAttachmentContext model - bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel := new(vpcv1.BareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceVirtualNetworkInterfacePrototypeBareMetalServerNetworkAttachmentContext) - bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel.AllowIPSpoofing = core.BoolPtr(true) - bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel.AutoDelete = core.BoolPtr(false) - bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel.EnableInfrastructureNat = core.BoolPtr(true) - bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel.Ips = []vpcv1.VirtualNetworkInterfaceIPPrototypeIntf{virtualNetworkInterfaceIPPrototypeModel} - bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel.Name = core.StringPtr("my-virtual-network-interface") - bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel.PrimaryIP = virtualNetworkInterfacePrimaryIPPrototypeModel - bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel.ResourceGroup = resourceGroupIdentityModel - bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel.SecurityGroups = []vpcv1.SecurityGroupIdentityIntf{securityGroupIdentityModel} - bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel.Subnet = subnetIdentityModel - - // Construct an instance of the BareMetalServerNetworkAttachmentPrototypeBareMetalServerNetworkAttachmentByPciPrototype model - bareMetalServerNetworkAttachmentPrototypeModel := new(vpcv1.BareMetalServerNetworkAttachmentPrototypeBareMetalServerNetworkAttachmentByPciPrototype) - bareMetalServerNetworkAttachmentPrototypeModel.Name = core.StringPtr("my-bare-metal-server-network-attachment") - bareMetalServerNetworkAttachmentPrototypeModel.VirtualNetworkInterface = bareMetalServerNetworkAttachmentPrototypeVirtualNetworkInterfaceModel - bareMetalServerNetworkAttachmentPrototypeModel.AllowedVlans = []int64{} - bareMetalServerNetworkAttachmentPrototypeModel.InterfaceType = core.StringPtr("pci") - - // Construct an instance of the CreateBareMetalServerNetworkAttachmentOptions model - createBareMetalServerNetworkAttachmentOptionsModel := new(vpcv1.CreateBareMetalServerNetworkAttachmentOptions) - createBareMetalServerNetworkAttachmentOptionsModel.BareMetalServerID = core.StringPtr("testString") - createBareMetalServerNetworkAttachmentOptionsModel.BareMetalServerNetworkAttachmentPrototype = bareMetalServerNetworkAttachmentPrototypeModel - createBareMetalServerNetworkAttachmentOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the GetBareMetalServerInitializationOptions model + getBareMetalServerInitializationOptionsModel := new(vpcv1.GetBareMetalServerInitializationOptions) + getBareMetalServerInitializationOptionsModel.ID = core.StringPtr("testString") + getBareMetalServerInitializationOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation - result, response, operationErr := vpcService.CreateBareMetalServerNetworkAttachment(createBareMetalServerNetworkAttachmentOptionsModel) + result, response, operationErr := vpcService.GetBareMetalServerInitialization(getBareMetalServerInitializationOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) @@ -49303,24 +49411,24 @@ var _ = Describe(`VpcV1`, func() { }) }) }) - Describe(`DeleteBareMetalServerNetworkAttachment(deleteBareMetalServerNetworkAttachmentOptions *DeleteBareMetalServerNetworkAttachmentOptions)`, func() { + Describe(`RestartBareMetalServer(restartBareMetalServerOptions *RestartBareMetalServerOptions)`, func() { version := "testString" - deleteBareMetalServerNetworkAttachmentPath := "/bare_metal_servers/testString/network_attachments/testString" + restartBareMetalServerPath := "/bare_metal_servers/testString/restart" 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(deleteBareMetalServerNetworkAttachmentPath)) - Expect(req.Method).To(Equal("DELETE")) + Expect(req.URL.EscapedPath()).To(Equal(restartBareMetalServerPath)) + 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.WriteHeader(202) + res.WriteHeader(204) })) }) - It(`Invoke DeleteBareMetalServerNetworkAttachment successfully`, func() { + It(`Invoke RestartBareMetalServer successfully`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -49330,22 +49438,21 @@ var _ = Describe(`VpcV1`, func() { Expect(vpcService).ToNot(BeNil()) // Invoke operation with nil options model (negative test) - response, operationErr := vpcService.DeleteBareMetalServerNetworkAttachment(nil) + response, operationErr := vpcService.RestartBareMetalServer(nil) Expect(operationErr).NotTo(BeNil()) Expect(response).To(BeNil()) - // Construct an instance of the DeleteBareMetalServerNetworkAttachmentOptions model - deleteBareMetalServerNetworkAttachmentOptionsModel := new(vpcv1.DeleteBareMetalServerNetworkAttachmentOptions) - deleteBareMetalServerNetworkAttachmentOptionsModel.BareMetalServerID = core.StringPtr("testString") - deleteBareMetalServerNetworkAttachmentOptionsModel.ID = core.StringPtr("testString") - deleteBareMetalServerNetworkAttachmentOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the RestartBareMetalServerOptions model + restartBareMetalServerOptionsModel := new(vpcv1.RestartBareMetalServerOptions) + restartBareMetalServerOptionsModel.ID = core.StringPtr("testString") + restartBareMetalServerOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with valid options model (positive test) - response, operationErr = vpcService.DeleteBareMetalServerNetworkAttachment(deleteBareMetalServerNetworkAttachmentOptionsModel) + response, operationErr = vpcService.RestartBareMetalServer(restartBareMetalServerOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) }) - It(`Invoke DeleteBareMetalServerNetworkAttachment with error: Operation validation and request error`, func() { + It(`Invoke RestartBareMetalServer with error: Operation validation and request error`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -49354,22 +49461,21 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the DeleteBareMetalServerNetworkAttachmentOptions model - deleteBareMetalServerNetworkAttachmentOptionsModel := new(vpcv1.DeleteBareMetalServerNetworkAttachmentOptions) - deleteBareMetalServerNetworkAttachmentOptionsModel.BareMetalServerID = core.StringPtr("testString") - deleteBareMetalServerNetworkAttachmentOptionsModel.ID = core.StringPtr("testString") - deleteBareMetalServerNetworkAttachmentOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the RestartBareMetalServerOptions model + restartBareMetalServerOptionsModel := new(vpcv1.RestartBareMetalServerOptions) + restartBareMetalServerOptionsModel.ID = core.StringPtr("testString") + restartBareMetalServerOptionsModel.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.DeleteBareMetalServerNetworkAttachment(deleteBareMetalServerNetworkAttachmentOptionsModel) + response, operationErr := vpcService.RestartBareMetalServer(restartBareMetalServerOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING)) Expect(response).To(BeNil()) - // Construct a second instance of the DeleteBareMetalServerNetworkAttachmentOptions model with no property values - deleteBareMetalServerNetworkAttachmentOptionsModelNew := new(vpcv1.DeleteBareMetalServerNetworkAttachmentOptions) + // Construct a second instance of the RestartBareMetalServerOptions model with no property values + restartBareMetalServerOptionsModelNew := new(vpcv1.RestartBareMetalServerOptions) // Invoke operation with invalid model (negative test) - response, operationErr = vpcService.DeleteBareMetalServerNetworkAttachment(deleteBareMetalServerNetworkAttachmentOptionsModelNew) + response, operationErr = vpcService.RestartBareMetalServer(restartBareMetalServerOptionsModelNew) Expect(operationErr).ToNot(BeNil()) Expect(response).To(BeNil()) }) @@ -49378,25 +49484,24 @@ var _ = Describe(`VpcV1`, func() { }) }) }) - Describe(`GetBareMetalServerNetworkAttachment(getBareMetalServerNetworkAttachmentOptions *GetBareMetalServerNetworkAttachmentOptions) - Operation response error`, func() { + Describe(`StartBareMetalServer(startBareMetalServerOptions *StartBareMetalServerOptions)`, func() { version := "testString" - getBareMetalServerNetworkAttachmentPath := "/bare_metal_servers/testString/network_attachments/testString" - Context(`Using mock server endpoint with invalid JSON response`, func() { + startBareMetalServerPath := "/bare_metal_servers/testString/start" + 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(getBareMetalServerNetworkAttachmentPath)) - Expect(req.Method).To(Equal("GET")) + Expect(req.URL.EscapedPath()).To(Equal(startBareMetalServerPath)) + 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) - fmt.Fprint(res, `} this is not valid json {`) + res.WriteHeader(204) })) }) - It(`Invoke GetBareMetalServerNetworkAttachment with error: Operation response processing error`, func() { + It(`Invoke StartBareMetalServer successfully`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -49405,53 +49510,22 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the GetBareMetalServerNetworkAttachmentOptions model - getBareMetalServerNetworkAttachmentOptionsModel := new(vpcv1.GetBareMetalServerNetworkAttachmentOptions) - getBareMetalServerNetworkAttachmentOptionsModel.BareMetalServerID = core.StringPtr("testString") - getBareMetalServerNetworkAttachmentOptionsModel.ID = core.StringPtr("testString") - getBareMetalServerNetworkAttachmentOptionsModel.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.GetBareMetalServerNetworkAttachment(getBareMetalServerNetworkAttachmentOptionsModel) - 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.GetBareMetalServerNetworkAttachment(getBareMetalServerNetworkAttachmentOptionsModel) - Expect(operationErr).ToNot(BeNil()) - Expect(response).ToNot(BeNil()) - Expect(result).To(BeNil()) - }) - AfterEach(func() { - testServer.Close() - }) - }) - }) - Describe(`GetBareMetalServerNetworkAttachment(getBareMetalServerNetworkAttachmentOptions *GetBareMetalServerNetworkAttachmentOptions)`, func() { - version := "testString" - getBareMetalServerNetworkAttachmentPath := "/bare_metal_servers/testString/network_attachments/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(getBareMetalServerNetworkAttachmentPath)) - Expect(req.Method).To(Equal("GET")) + // Invoke operation with nil options model (negative test) + response, operationErr := vpcService.StartBareMetalServer(nil) + Expect(operationErr).NotTo(BeNil()) + Expect(response).To(BeNil()) - 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) + // Construct an instance of the StartBareMetalServerOptions model + startBareMetalServerOptionsModel := new(vpcv1.StartBareMetalServerOptions) + startBareMetalServerOptionsModel.ID = core.StringPtr("testString") + startBareMetalServerOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} - // 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", "href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/2302-f7a2bf57-af7c-49d9-b599-b2c91293d30c/network_attachments/2302-da8c43ec-b6ca-4bd2-871e-72e288c66ee6", "id": "2302-da8c43ec-b6ca-4bd2-871e-72e288c66ee6", "lifecycle_state": "stable", "name": "my-bare-metal-server-network-attachment", "port_speed": 1000, "primary_ip": {"address": "192.168.3.4", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e/reserved_ips/6d353a0f-aeb1-4ae1-832e-1110d10981bb", "id": "6d353a0f-aeb1-4ae1-832e-1110d10981bb", "name": "my-reserved-ip", "resource_type": "subnet_reserved_ip"}, "resource_type": "bare_metal_server_network_attachment", "subnet": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "id": "7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "name": "my-subnet", "resource_type": "subnet"}, "type": "primary", "virtual_network_interface": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::virtual-network-interface:0767-fa41aecb-4f21-423d-8082-630bfba1e1d9", "href": "https://us-south.iaas.cloud.ibm.com/v1/virtual_network_interfaces/0767-fa41aecb-4f21-423d-8082-630bfba1e1d9", "id": "0767-fa41aecb-4f21-423d-8082-630bfba1e1d9", "name": "my-virtual-network-interface", "resource_type": "virtual_network_interface"}, "allowed_vlans": [4], "interface_type": "pci"}`) - })) + // Invoke operation with valid options model (positive test) + response, operationErr = vpcService.StartBareMetalServer(startBareMetalServerOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) }) - It(`Invoke GetBareMetalServerNetworkAttachment successfully with retries`, func() { + It(`Invoke StartBareMetalServer with error: Operation validation and request error`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -49459,57 +49533,64 @@ var _ = Describe(`VpcV1`, func() { }) Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - vpcService.EnableRetries(0, 0) - - // Construct an instance of the GetBareMetalServerNetworkAttachmentOptions model - getBareMetalServerNetworkAttachmentOptionsModel := new(vpcv1.GetBareMetalServerNetworkAttachmentOptions) - getBareMetalServerNetworkAttachmentOptionsModel.BareMetalServerID = core.StringPtr("testString") - getBareMetalServerNetworkAttachmentOptionsModel.ID = core.StringPtr("testString") - getBareMetalServerNetworkAttachmentOptionsModel.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.GetBareMetalServerNetworkAttachmentWithContext(ctx, getBareMetalServerNetworkAttachmentOptionsModel) + // Construct an instance of the StartBareMetalServerOptions model + startBareMetalServerOptionsModel := new(vpcv1.StartBareMetalServerOptions) + startBareMetalServerOptionsModel.ID = core.StringPtr("testString") + startBareMetalServerOptionsModel.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.StartBareMetalServer(startBareMetalServerOptionsModel) Expect(operationErr).ToNot(BeNil()) - Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) - - // Disable retries and test again - vpcService.DisableRetries() - result, response, operationErr := vpcService.GetBareMetalServerNetworkAttachment(getBareMetalServerNetworkAttachmentOptionsModel) - 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.GetBareMetalServerNetworkAttachmentWithContext(ctx, getBareMetalServerNetworkAttachmentOptionsModel) + Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING)) + Expect(response).To(BeNil()) + // Construct a second instance of the StartBareMetalServerOptions model with no property values + startBareMetalServerOptionsModelNew := new(vpcv1.StartBareMetalServerOptions) + // Invoke operation with invalid model (negative test) + response, operationErr = vpcService.StartBareMetalServer(startBareMetalServerOptionsModelNew) Expect(operationErr).ToNot(BeNil()) - Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) + Expect(response).To(BeNil()) }) AfterEach(func() { testServer.Close() }) }) + }) + Describe(`StopBareMetalServer(stopBareMetalServerOptions *StopBareMetalServerOptions)`, func() { + version := "testString" + stopBareMetalServerPath := "/bare_metal_servers/testString/stop" 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(getBareMetalServerNetworkAttachmentPath)) - Expect(req.Method).To(Equal("GET")) + Expect(req.URL.EscapedPath()).To(Equal(stopBareMetalServerPath)) + 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(200) - fmt.Fprintf(res, "%s", `{"created_at": "2019-01-01T12:00:00.000Z", "href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/2302-f7a2bf57-af7c-49d9-b599-b2c91293d30c/network_attachments/2302-da8c43ec-b6ca-4bd2-871e-72e288c66ee6", "id": "2302-da8c43ec-b6ca-4bd2-871e-72e288c66ee6", "lifecycle_state": "stable", "name": "my-bare-metal-server-network-attachment", "port_speed": 1000, "primary_ip": {"address": "192.168.3.4", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e/reserved_ips/6d353a0f-aeb1-4ae1-832e-1110d10981bb", "id": "6d353a0f-aeb1-4ae1-832e-1110d10981bb", "name": "my-reserved-ip", "resource_type": "subnet_reserved_ip"}, "resource_type": "bare_metal_server_network_attachment", "subnet": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "id": "7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "name": "my-subnet", "resource_type": "subnet"}, "type": "primary", "virtual_network_interface": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::virtual-network-interface:0767-fa41aecb-4f21-423d-8082-630bfba1e1d9", "href": "https://us-south.iaas.cloud.ibm.com/v1/virtual_network_interfaces/0767-fa41aecb-4f21-423d-8082-630bfba1e1d9", "id": "0767-fa41aecb-4f21-423d-8082-630bfba1e1d9", "name": "my-virtual-network-interface", "resource_type": "virtual_network_interface"}, "allowed_vlans": [4], "interface_type": "pci"}`) + res.WriteHeader(204) })) }) - It(`Invoke GetBareMetalServerNetworkAttachment successfully`, func() { + It(`Invoke StopBareMetalServer successfully`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -49519,25 +49600,22 @@ var _ = Describe(`VpcV1`, func() { Expect(vpcService).ToNot(BeNil()) // Invoke operation with nil options model (negative test) - result, response, operationErr := vpcService.GetBareMetalServerNetworkAttachment(nil) + response, operationErr := vpcService.StopBareMetalServer(nil) Expect(operationErr).NotTo(BeNil()) Expect(response).To(BeNil()) - Expect(result).To(BeNil()) - // Construct an instance of the GetBareMetalServerNetworkAttachmentOptions model - getBareMetalServerNetworkAttachmentOptionsModel := new(vpcv1.GetBareMetalServerNetworkAttachmentOptions) - getBareMetalServerNetworkAttachmentOptionsModel.BareMetalServerID = core.StringPtr("testString") - getBareMetalServerNetworkAttachmentOptionsModel.ID = core.StringPtr("testString") - getBareMetalServerNetworkAttachmentOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the StopBareMetalServerOptions model + stopBareMetalServerOptionsModel := new(vpcv1.StopBareMetalServerOptions) + stopBareMetalServerOptionsModel.ID = core.StringPtr("testString") + stopBareMetalServerOptionsModel.Type = core.StringPtr("hard") + stopBareMetalServerOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with valid options model (positive test) - result, response, operationErr = vpcService.GetBareMetalServerNetworkAttachment(getBareMetalServerNetworkAttachmentOptionsModel) + response, operationErr = vpcService.StopBareMetalServer(stopBareMetalServerOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) - Expect(result).ToNot(BeNil()) - }) - It(`Invoke GetBareMetalServerNetworkAttachment with error: Operation validation and request error`, func() { + It(`Invoke StopBareMetalServer with error: Operation validation and request error`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -49546,87 +49624,51 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the GetBareMetalServerNetworkAttachmentOptions model - getBareMetalServerNetworkAttachmentOptionsModel := new(vpcv1.GetBareMetalServerNetworkAttachmentOptions) - getBareMetalServerNetworkAttachmentOptionsModel.BareMetalServerID = core.StringPtr("testString") - getBareMetalServerNetworkAttachmentOptionsModel.ID = core.StringPtr("testString") - getBareMetalServerNetworkAttachmentOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the StopBareMetalServerOptions model + stopBareMetalServerOptionsModel := new(vpcv1.StopBareMetalServerOptions) + stopBareMetalServerOptionsModel.ID = core.StringPtr("testString") + stopBareMetalServerOptionsModel.Type = core.StringPtr("hard") + stopBareMetalServerOptionsModel.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.GetBareMetalServerNetworkAttachment(getBareMetalServerNetworkAttachmentOptionsModel) - 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 GetBareMetalServerNetworkAttachmentOptions model with no property values - getBareMetalServerNetworkAttachmentOptionsModelNew := new(vpcv1.GetBareMetalServerNetworkAttachmentOptions) - // Invoke operation with invalid model (negative test) - result, response, operationErr = vpcService.GetBareMetalServerNetworkAttachment(getBareMetalServerNetworkAttachmentOptionsModelNew) - 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 GetBareMetalServerNetworkAttachment 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 GetBareMetalServerNetworkAttachmentOptions model - getBareMetalServerNetworkAttachmentOptionsModel := new(vpcv1.GetBareMetalServerNetworkAttachmentOptions) - getBareMetalServerNetworkAttachmentOptionsModel.BareMetalServerID = core.StringPtr("testString") - getBareMetalServerNetworkAttachmentOptionsModel.ID = core.StringPtr("testString") - getBareMetalServerNetworkAttachmentOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} - - // Invoke operation - result, response, operationErr := vpcService.GetBareMetalServerNetworkAttachment(getBareMetalServerNetworkAttachmentOptionsModel) - Expect(operationErr).To(BeNil()) - Expect(response).ToNot(BeNil()) - - // Verify a nil result - Expect(result).To(BeNil()) + response, operationErr := vpcService.StopBareMetalServer(stopBareMetalServerOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING)) + Expect(response).To(BeNil()) + // Construct a second instance of the StopBareMetalServerOptions model with no property values + stopBareMetalServerOptionsModelNew := new(vpcv1.StopBareMetalServerOptions) + // Invoke operation with invalid model (negative test) + response, operationErr = vpcService.StopBareMetalServer(stopBareMetalServerOptionsModelNew) + Expect(operationErr).ToNot(BeNil()) + Expect(response).To(BeNil()) }) AfterEach(func() { testServer.Close() }) }) }) - Describe(`UpdateBareMetalServerNetworkAttachment(updateBareMetalServerNetworkAttachmentOptions *UpdateBareMetalServerNetworkAttachmentOptions) - Operation response error`, func() { + Describe(`ListVolumeProfiles(listVolumeProfilesOptions *ListVolumeProfilesOptions) - Operation response error`, func() { version := "testString" - updateBareMetalServerNetworkAttachmentPath := "/bare_metal_servers/testString/network_attachments/testString" + listVolumeProfilesPath := "/volume/profiles" 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(updateBareMetalServerNetworkAttachmentPath)) - Expect(req.Method).To(Equal("PATCH")) + Expect(req.URL.EscapedPath()).To(Equal(listVolumeProfilesPath)) + Expect(req.Method).To(Equal("GET")) Expect(req.URL.Query()["version"]).To(Equal([]string{"testString"})) Expect(req.URL.Query()["generation"]).To(Equal([]string{fmt.Sprint(int64(2))})) + Expect(req.URL.Query()["start"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["limit"]).To(Equal([]string{fmt.Sprint(int64(10))})) res.Header().Set("Content-type", "application/json") res.WriteHeader(200) fmt.Fprint(res, `} this is not valid json {`) })) }) - It(`Invoke UpdateBareMetalServerNetworkAttachment with error: Operation response processing error`, func() { + It(`Invoke ListVolumeProfiles with error: Operation response processing error`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -49635,28 +49677,20 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the BareMetalServerNetworkAttachmentPatch model - bareMetalServerNetworkAttachmentPatchModel := new(vpcv1.BareMetalServerNetworkAttachmentPatch) - bareMetalServerNetworkAttachmentPatchModel.AllowedVlans = []int64{int64(4)} - bareMetalServerNetworkAttachmentPatchModel.Name = core.StringPtr("my-bare-metal-server-network-attachment-updated") - bareMetalServerNetworkAttachmentPatchModelAsPatch, asPatchErr := bareMetalServerNetworkAttachmentPatchModel.AsPatch() - Expect(asPatchErr).To(BeNil()) - - // Construct an instance of the UpdateBareMetalServerNetworkAttachmentOptions model - updateBareMetalServerNetworkAttachmentOptionsModel := new(vpcv1.UpdateBareMetalServerNetworkAttachmentOptions) - updateBareMetalServerNetworkAttachmentOptionsModel.BareMetalServerID = core.StringPtr("testString") - updateBareMetalServerNetworkAttachmentOptionsModel.ID = core.StringPtr("testString") - updateBareMetalServerNetworkAttachmentOptionsModel.BareMetalServerNetworkAttachmentPatch = bareMetalServerNetworkAttachmentPatchModelAsPatch - updateBareMetalServerNetworkAttachmentOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the ListVolumeProfilesOptions model + listVolumeProfilesOptionsModel := new(vpcv1.ListVolumeProfilesOptions) + listVolumeProfilesOptionsModel.Start = core.StringPtr("testString") + listVolumeProfilesOptionsModel.Limit = core.Int64Ptr(int64(10)) + listVolumeProfilesOptionsModel.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.UpdateBareMetalServerNetworkAttachment(updateBareMetalServerNetworkAttachmentOptionsModel) + result, response, operationErr := vpcService.ListVolumeProfiles(listVolumeProfilesOptionsModel) 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.UpdateBareMetalServerNetworkAttachment(updateBareMetalServerNetworkAttachmentOptionsModel) + result, response, operationErr = vpcService.ListVolumeProfiles(listVolumeProfilesOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).To(BeNil()) @@ -49666,46 +49700,32 @@ var _ = Describe(`VpcV1`, func() { }) }) }) - Describe(`UpdateBareMetalServerNetworkAttachment(updateBareMetalServerNetworkAttachmentOptions *UpdateBareMetalServerNetworkAttachmentOptions)`, func() { + Describe(`ListVolumeProfiles(listVolumeProfilesOptions *ListVolumeProfilesOptions)`, func() { version := "testString" - updateBareMetalServerNetworkAttachmentPath := "/bare_metal_servers/testString/network_attachments/testString" + listVolumeProfilesPath := "/volume/profiles" 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(updateBareMetalServerNetworkAttachmentPath)) - 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.URL.EscapedPath()).To(Equal(listVolumeProfilesPath)) + Expect(req.Method).To(Equal("GET")) Expect(req.URL.Query()["version"]).To(Equal([]string{"testString"})) Expect(req.URL.Query()["generation"]).To(Equal([]string{fmt.Sprint(int64(2))})) + Expect(req.URL.Query()["start"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["limit"]).To(Equal([]string{fmt.Sprint(int64(10))})) // 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", "href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/2302-f7a2bf57-af7c-49d9-b599-b2c91293d30c/network_attachments/2302-da8c43ec-b6ca-4bd2-871e-72e288c66ee6", "id": "2302-da8c43ec-b6ca-4bd2-871e-72e288c66ee6", "lifecycle_state": "stable", "name": "my-bare-metal-server-network-attachment", "port_speed": 1000, "primary_ip": {"address": "192.168.3.4", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e/reserved_ips/6d353a0f-aeb1-4ae1-832e-1110d10981bb", "id": "6d353a0f-aeb1-4ae1-832e-1110d10981bb", "name": "my-reserved-ip", "resource_type": "subnet_reserved_ip"}, "resource_type": "bare_metal_server_network_attachment", "subnet": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "id": "7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "name": "my-subnet", "resource_type": "subnet"}, "type": "primary", "virtual_network_interface": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::virtual-network-interface:0767-fa41aecb-4f21-423d-8082-630bfba1e1d9", "href": "https://us-south.iaas.cloud.ibm.com/v1/virtual_network_interfaces/0767-fa41aecb-4f21-423d-8082-630bfba1e1d9", "id": "0767-fa41aecb-4f21-423d-8082-630bfba1e1d9", "name": "my-virtual-network-interface", "resource_type": "virtual_network_interface"}, "allowed_vlans": [4], "interface_type": "pci"}`) + fmt.Fprintf(res, "%s", `{"first": {"href": "https://us-south.iaas.cloud.ibm.com/v1/volume/profiles?limit=20"}, "limit": 20, "next": {"href": "https://us-south.iaas.cloud.ibm.com/v1/volume/profiles?start=9d5a91a3e2cbd233b5a5b33436855ed1&limit=20"}, "profiles": [{"family": "tiered", "href": "https://us-south.iaas.cloud.ibm.com/v1/volume/profiles/general-purpose", "name": "general-purpose"}], "total_count": 132}`) })) }) - It(`Invoke UpdateBareMetalServerNetworkAttachment successfully with retries`, func() { + It(`Invoke ListVolumeProfiles successfully with retries`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -49715,30 +49735,22 @@ var _ = Describe(`VpcV1`, func() { Expect(vpcService).ToNot(BeNil()) vpcService.EnableRetries(0, 0) - // Construct an instance of the BareMetalServerNetworkAttachmentPatch model - bareMetalServerNetworkAttachmentPatchModel := new(vpcv1.BareMetalServerNetworkAttachmentPatch) - bareMetalServerNetworkAttachmentPatchModel.AllowedVlans = []int64{int64(4)} - bareMetalServerNetworkAttachmentPatchModel.Name = core.StringPtr("my-bare-metal-server-network-attachment-updated") - bareMetalServerNetworkAttachmentPatchModelAsPatch, asPatchErr := bareMetalServerNetworkAttachmentPatchModel.AsPatch() - Expect(asPatchErr).To(BeNil()) - - // Construct an instance of the UpdateBareMetalServerNetworkAttachmentOptions model - updateBareMetalServerNetworkAttachmentOptionsModel := new(vpcv1.UpdateBareMetalServerNetworkAttachmentOptions) - updateBareMetalServerNetworkAttachmentOptionsModel.BareMetalServerID = core.StringPtr("testString") - updateBareMetalServerNetworkAttachmentOptionsModel.ID = core.StringPtr("testString") - updateBareMetalServerNetworkAttachmentOptionsModel.BareMetalServerNetworkAttachmentPatch = bareMetalServerNetworkAttachmentPatchModelAsPatch - updateBareMetalServerNetworkAttachmentOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the ListVolumeProfilesOptions model + listVolumeProfilesOptionsModel := new(vpcv1.ListVolumeProfilesOptions) + listVolumeProfilesOptionsModel.Start = core.StringPtr("testString") + listVolumeProfilesOptionsModel.Limit = core.Int64Ptr(int64(10)) + listVolumeProfilesOptionsModel.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.UpdateBareMetalServerNetworkAttachmentWithContext(ctx, updateBareMetalServerNetworkAttachmentOptionsModel) + _, _, operationErr := vpcService.ListVolumeProfilesWithContext(ctx, listVolumeProfilesOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) // Disable retries and test again vpcService.DisableRetries() - result, response, operationErr := vpcService.UpdateBareMetalServerNetworkAttachment(updateBareMetalServerNetworkAttachmentOptionsModel) + result, response, operationErr := vpcService.ListVolumeProfiles(listVolumeProfilesOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) @@ -49746,7 +49758,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.UpdateBareMetalServerNetworkAttachmentWithContext(ctx, updateBareMetalServerNetworkAttachmentOptionsModel) + _, _, operationErr = vpcService.ListVolumeProfilesWithContext(ctx, listVolumeProfilesOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) }) @@ -49760,34 +49772,20 @@ var _ = Describe(`VpcV1`, func() { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(updateBareMetalServerNetworkAttachmentPath)) - 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.URL.EscapedPath()).To(Equal(listVolumeProfilesPath)) + Expect(req.Method).To(Equal("GET")) Expect(req.URL.Query()["version"]).To(Equal([]string{"testString"})) Expect(req.URL.Query()["generation"]).To(Equal([]string{fmt.Sprint(int64(2))})) + Expect(req.URL.Query()["start"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["limit"]).To(Equal([]string{fmt.Sprint(int64(10))})) // 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", "href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/2302-f7a2bf57-af7c-49d9-b599-b2c91293d30c/network_attachments/2302-da8c43ec-b6ca-4bd2-871e-72e288c66ee6", "id": "2302-da8c43ec-b6ca-4bd2-871e-72e288c66ee6", "lifecycle_state": "stable", "name": "my-bare-metal-server-network-attachment", "port_speed": 1000, "primary_ip": {"address": "192.168.3.4", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e/reserved_ips/6d353a0f-aeb1-4ae1-832e-1110d10981bb", "id": "6d353a0f-aeb1-4ae1-832e-1110d10981bb", "name": "my-reserved-ip", "resource_type": "subnet_reserved_ip"}, "resource_type": "bare_metal_server_network_attachment", "subnet": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "id": "7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "name": "my-subnet", "resource_type": "subnet"}, "type": "primary", "virtual_network_interface": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::virtual-network-interface:0767-fa41aecb-4f21-423d-8082-630bfba1e1d9", "href": "https://us-south.iaas.cloud.ibm.com/v1/virtual_network_interfaces/0767-fa41aecb-4f21-423d-8082-630bfba1e1d9", "id": "0767-fa41aecb-4f21-423d-8082-630bfba1e1d9", "name": "my-virtual-network-interface", "resource_type": "virtual_network_interface"}, "allowed_vlans": [4], "interface_type": "pci"}`) + fmt.Fprintf(res, "%s", `{"first": {"href": "https://us-south.iaas.cloud.ibm.com/v1/volume/profiles?limit=20"}, "limit": 20, "next": {"href": "https://us-south.iaas.cloud.ibm.com/v1/volume/profiles?start=9d5a91a3e2cbd233b5a5b33436855ed1&limit=20"}, "profiles": [{"family": "tiered", "href": "https://us-south.iaas.cloud.ibm.com/v1/volume/profiles/general-purpose", "name": "general-purpose"}], "total_count": 132}`) })) }) - It(`Invoke UpdateBareMetalServerNetworkAttachment successfully`, func() { + It(`Invoke ListVolumeProfiles successfully`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -49797,33 +49795,25 @@ var _ = Describe(`VpcV1`, func() { Expect(vpcService).ToNot(BeNil()) // Invoke operation with nil options model (negative test) - result, response, operationErr := vpcService.UpdateBareMetalServerNetworkAttachment(nil) + result, response, operationErr := vpcService.ListVolumeProfiles(nil) Expect(operationErr).NotTo(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) - // Construct an instance of the BareMetalServerNetworkAttachmentPatch model - bareMetalServerNetworkAttachmentPatchModel := new(vpcv1.BareMetalServerNetworkAttachmentPatch) - bareMetalServerNetworkAttachmentPatchModel.AllowedVlans = []int64{int64(4)} - bareMetalServerNetworkAttachmentPatchModel.Name = core.StringPtr("my-bare-metal-server-network-attachment-updated") - bareMetalServerNetworkAttachmentPatchModelAsPatch, asPatchErr := bareMetalServerNetworkAttachmentPatchModel.AsPatch() - Expect(asPatchErr).To(BeNil()) - - // Construct an instance of the UpdateBareMetalServerNetworkAttachmentOptions model - updateBareMetalServerNetworkAttachmentOptionsModel := new(vpcv1.UpdateBareMetalServerNetworkAttachmentOptions) - updateBareMetalServerNetworkAttachmentOptionsModel.BareMetalServerID = core.StringPtr("testString") - updateBareMetalServerNetworkAttachmentOptionsModel.ID = core.StringPtr("testString") - updateBareMetalServerNetworkAttachmentOptionsModel.BareMetalServerNetworkAttachmentPatch = bareMetalServerNetworkAttachmentPatchModelAsPatch - updateBareMetalServerNetworkAttachmentOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the ListVolumeProfilesOptions model + listVolumeProfilesOptionsModel := new(vpcv1.ListVolumeProfilesOptions) + listVolumeProfilesOptionsModel.Start = core.StringPtr("testString") + listVolumeProfilesOptionsModel.Limit = core.Int64Ptr(int64(10)) + listVolumeProfilesOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with valid options model (positive test) - result, response, operationErr = vpcService.UpdateBareMetalServerNetworkAttachment(updateBareMetalServerNetworkAttachmentOptionsModel) + result, response, operationErr = vpcService.ListVolumeProfiles(listVolumeProfilesOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) }) - It(`Invoke UpdateBareMetalServerNetworkAttachment with error: Operation validation and request error`, func() { + It(`Invoke ListVolumeProfiles with error: Operation request error`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -49832,34 +49822,19 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the BareMetalServerNetworkAttachmentPatch model - bareMetalServerNetworkAttachmentPatchModel := new(vpcv1.BareMetalServerNetworkAttachmentPatch) - bareMetalServerNetworkAttachmentPatchModel.AllowedVlans = []int64{int64(4)} - bareMetalServerNetworkAttachmentPatchModel.Name = core.StringPtr("my-bare-metal-server-network-attachment-updated") - bareMetalServerNetworkAttachmentPatchModelAsPatch, asPatchErr := bareMetalServerNetworkAttachmentPatchModel.AsPatch() - Expect(asPatchErr).To(BeNil()) - - // Construct an instance of the UpdateBareMetalServerNetworkAttachmentOptions model - updateBareMetalServerNetworkAttachmentOptionsModel := new(vpcv1.UpdateBareMetalServerNetworkAttachmentOptions) - updateBareMetalServerNetworkAttachmentOptionsModel.BareMetalServerID = core.StringPtr("testString") - updateBareMetalServerNetworkAttachmentOptionsModel.ID = core.StringPtr("testString") - updateBareMetalServerNetworkAttachmentOptionsModel.BareMetalServerNetworkAttachmentPatch = bareMetalServerNetworkAttachmentPatchModelAsPatch - updateBareMetalServerNetworkAttachmentOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the ListVolumeProfilesOptions model + listVolumeProfilesOptionsModel := new(vpcv1.ListVolumeProfilesOptions) + listVolumeProfilesOptionsModel.Start = core.StringPtr("testString") + listVolumeProfilesOptionsModel.Limit = core.Int64Ptr(int64(10)) + listVolumeProfilesOptionsModel.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.UpdateBareMetalServerNetworkAttachment(updateBareMetalServerNetworkAttachmentOptionsModel) + result, response, operationErr := vpcService.ListVolumeProfiles(listVolumeProfilesOptionsModel) 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 UpdateBareMetalServerNetworkAttachmentOptions model with no property values - updateBareMetalServerNetworkAttachmentOptionsModelNew := new(vpcv1.UpdateBareMetalServerNetworkAttachmentOptions) - // Invoke operation with invalid model (negative test) - result, response, operationErr = vpcService.UpdateBareMetalServerNetworkAttachment(updateBareMetalServerNetworkAttachmentOptionsModelNew) - Expect(operationErr).ToNot(BeNil()) - Expect(response).To(BeNil()) - Expect(result).To(BeNil()) }) AfterEach(func() { testServer.Close() @@ -49874,7 +49849,7 @@ var _ = Describe(`VpcV1`, func() { res.WriteHeader(200) })) }) - It(`Invoke UpdateBareMetalServerNetworkAttachment successfully`, func() { + It(`Invoke ListVolumeProfiles successfully`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -49883,22 +49858,14 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the BareMetalServerNetworkAttachmentPatch model - bareMetalServerNetworkAttachmentPatchModel := new(vpcv1.BareMetalServerNetworkAttachmentPatch) - bareMetalServerNetworkAttachmentPatchModel.AllowedVlans = []int64{int64(4)} - bareMetalServerNetworkAttachmentPatchModel.Name = core.StringPtr("my-bare-metal-server-network-attachment-updated") - bareMetalServerNetworkAttachmentPatchModelAsPatch, asPatchErr := bareMetalServerNetworkAttachmentPatchModel.AsPatch() - Expect(asPatchErr).To(BeNil()) - - // Construct an instance of the UpdateBareMetalServerNetworkAttachmentOptions model - updateBareMetalServerNetworkAttachmentOptionsModel := new(vpcv1.UpdateBareMetalServerNetworkAttachmentOptions) - updateBareMetalServerNetworkAttachmentOptionsModel.BareMetalServerID = core.StringPtr("testString") - updateBareMetalServerNetworkAttachmentOptionsModel.ID = core.StringPtr("testString") - updateBareMetalServerNetworkAttachmentOptionsModel.BareMetalServerNetworkAttachmentPatch = bareMetalServerNetworkAttachmentPatchModelAsPatch - updateBareMetalServerNetworkAttachmentOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the ListVolumeProfilesOptions model + listVolumeProfilesOptionsModel := new(vpcv1.ListVolumeProfilesOptions) + listVolumeProfilesOptionsModel.Start = core.StringPtr("testString") + listVolumeProfilesOptionsModel.Limit = core.Int64Ptr(int64(10)) + listVolumeProfilesOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation - result, response, operationErr := vpcService.UpdateBareMetalServerNetworkAttachment(updateBareMetalServerNetworkAttachmentOptionsModel) + result, response, operationErr := vpcService.ListVolumeProfiles(listVolumeProfilesOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) @@ -49909,28 +49876,127 @@ var _ = Describe(`VpcV1`, func() { testServer.Close() }) }) + Context(`Test pagination helper method on response`, func() { + It(`Invoke GetNextStart successfully`, func() { + responseObject := new(vpcv1.VolumeProfileCollection) + nextObject := new(vpcv1.VolumeProfileCollectionNext) + 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.VolumeProfileCollection) + + 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.VolumeProfileCollection) + nextObject := new(vpcv1.VolumeProfileCollectionNext) + nextObject.Href = core.StringPtr("ibm.com") + responseObject.Next = nextObject + + value, err := responseObject.GetNextStart() + Expect(err).To(BeNil()) + Expect(value).To(BeNil()) + }) + }) + Context(`Using mock server endpoint - paginated response`, func() { + BeforeEach(func() { + var requestNumber int = 0 + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Verify the contents of the request + Expect(req.URL.EscapedPath()).To(Equal(listVolumeProfilesPath)) + Expect(req.Method).To(Equal("GET")) + + // Set mock response + res.Header().Set("Content-type", "application/json") + res.WriteHeader(200) + requestNumber++ + if requestNumber == 1 { + fmt.Fprintf(res, "%s", `{"next":{"href":"https://myhost.com/somePath?start=1"},"total_count":2,"limit":1,"profiles":[{"family":"tiered","href":"https://us-south.iaas.cloud.ibm.com/v1/volume/profiles/general-purpose","name":"general-purpose"}]}`) + } else if requestNumber == 2 { + fmt.Fprintf(res, "%s", `{"total_count":2,"limit":1,"profiles":[{"family":"tiered","href":"https://us-south.iaas.cloud.ibm.com/v1/volume/profiles/general-purpose","name":"general-purpose"}]}`) + } else { + res.WriteHeader(400) + } + })) + }) + It(`Use VolumeProfilesPager.GetNext successfully`, func() { + vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + Version: core.StringPtr(version), + }) + Expect(serviceErr).To(BeNil()) + Expect(vpcService).ToNot(BeNil()) + + listVolumeProfilesOptionsModel := &vpcv1.ListVolumeProfilesOptions{ + Limit: core.Int64Ptr(int64(10)), + } + + pager, err := vpcService.NewVolumeProfilesPager(listVolumeProfilesOptionsModel) + Expect(err).To(BeNil()) + Expect(pager).ToNot(BeNil()) + + var allResults []vpcv1.VolumeProfile + for pager.HasNext() { + nextPage, err := pager.GetNext() + Expect(err).To(BeNil()) + Expect(nextPage).ToNot(BeNil()) + allResults = append(allResults, nextPage...) + } + Expect(len(allResults)).To(Equal(2)) + }) + It(`Use VolumeProfilesPager.GetAll successfully`, func() { + vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + Version: core.StringPtr(version), + }) + Expect(serviceErr).To(BeNil()) + Expect(vpcService).ToNot(BeNil()) + + listVolumeProfilesOptionsModel := &vpcv1.ListVolumeProfilesOptions{ + Limit: core.Int64Ptr(int64(10)), + } + + pager, err := vpcService.NewVolumeProfilesPager(listVolumeProfilesOptionsModel) + Expect(err).To(BeNil()) + Expect(pager).ToNot(BeNil()) + + allResults, err := pager.GetAll() + Expect(err).To(BeNil()) + Expect(allResults).ToNot(BeNil()) + Expect(len(allResults)).To(Equal(2)) + }) + }) }) - Describe(`ListBareMetalServerNetworkInterfaces(listBareMetalServerNetworkInterfacesOptions *ListBareMetalServerNetworkInterfacesOptions) - Operation response error`, func() { + Describe(`GetVolumeProfile(getVolumeProfileOptions *GetVolumeProfileOptions) - Operation response error`, func() { version := "testString" - listBareMetalServerNetworkInterfacesPath := "/bare_metal_servers/testString/network_interfaces" + getVolumeProfilePath := "/volume/profiles/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(listBareMetalServerNetworkInterfacesPath)) + Expect(req.URL.EscapedPath()).To(Equal(getVolumeProfilePath)) Expect(req.Method).To(Equal("GET")) Expect(req.URL.Query()["version"]).To(Equal([]string{"testString"})) Expect(req.URL.Query()["generation"]).To(Equal([]string{fmt.Sprint(int64(2))})) - Expect(req.URL.Query()["start"]).To(Equal([]string{"testString"})) - Expect(req.URL.Query()["limit"]).To(Equal([]string{fmt.Sprint(int64(10))})) res.Header().Set("Content-type", "application/json") res.WriteHeader(200) fmt.Fprint(res, `} this is not valid json {`) })) }) - It(`Invoke ListBareMetalServerNetworkInterfaces with error: Operation response processing error`, func() { + It(`Invoke GetVolumeProfile with error: Operation response processing error`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -49939,21 +50005,19 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the ListBareMetalServerNetworkInterfacesOptions model - listBareMetalServerNetworkInterfacesOptionsModel := new(vpcv1.ListBareMetalServerNetworkInterfacesOptions) - listBareMetalServerNetworkInterfacesOptionsModel.BareMetalServerID = core.StringPtr("testString") - listBareMetalServerNetworkInterfacesOptionsModel.Start = core.StringPtr("testString") - listBareMetalServerNetworkInterfacesOptionsModel.Limit = core.Int64Ptr(int64(10)) - listBareMetalServerNetworkInterfacesOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the GetVolumeProfileOptions model + getVolumeProfileOptionsModel := new(vpcv1.GetVolumeProfileOptions) + getVolumeProfileOptionsModel.Name = core.StringPtr("testString") + getVolumeProfileOptionsModel.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.ListBareMetalServerNetworkInterfaces(listBareMetalServerNetworkInterfacesOptionsModel) + result, response, operationErr := vpcService.GetVolumeProfile(getVolumeProfileOptionsModel) 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.ListBareMetalServerNetworkInterfaces(listBareMetalServerNetworkInterfacesOptionsModel) + result, response, operationErr = vpcService.GetVolumeProfile(getVolumeProfileOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).To(BeNil()) @@ -49963,32 +50027,30 @@ var _ = Describe(`VpcV1`, func() { }) }) }) - Describe(`ListBareMetalServerNetworkInterfaces(listBareMetalServerNetworkInterfacesOptions *ListBareMetalServerNetworkInterfacesOptions)`, func() { + Describe(`GetVolumeProfile(getVolumeProfileOptions *GetVolumeProfileOptions)`, func() { version := "testString" - listBareMetalServerNetworkInterfacesPath := "/bare_metal_servers/testString/network_interfaces" + getVolumeProfilePath := "/volume/profiles/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(listBareMetalServerNetworkInterfacesPath)) + Expect(req.URL.EscapedPath()).To(Equal(getVolumeProfilePath)) Expect(req.Method).To(Equal("GET")) Expect(req.URL.Query()["version"]).To(Equal([]string{"testString"})) Expect(req.URL.Query()["generation"]).To(Equal([]string{fmt.Sprint(int64(2))})) - Expect(req.URL.Query()["start"]).To(Equal([]string{"testString"})) - Expect(req.URL.Query()["limit"]).To(Equal([]string{fmt.Sprint(int64(10))})) // 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/bare_metal_servers/3b2669a2-4c2b-4003-bc91-1b81f1326267/network_interfaces?limit=20"}, "limit": 20, "network_interfaces": [{"allow_ip_spoofing": true, "created_at": "2019-01-01T12:00:00.000Z", "enable_infrastructure_nat": true, "floating_ips": [{"address": "203.0.113.1", "crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::floating-ip:39300233-9995-4806-89a5-3c1b6eb88689", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/floating_ips/39300233-9995-4806-89a5-3c1b6eb88689", "id": "39300233-9995-4806-89a5-3c1b6eb88689", "name": "my-floating-ip"}], "href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/1e09281b-f177-46fb-baf1-bc152b2e391a/network_interfaces/10c02d81-0ecb-4dc5-897d-28392913b81e", "id": "10c02d81-0ecb-4dc5-897d-28392913b81e", "mac_address": "02:00:04:00:C4:6A", "name": "my-bare-metal-server-network-interface", "port_speed": 1000, "primary_ip": {"address": "192.168.3.4", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e/reserved_ips/6d353a0f-aeb1-4ae1-832e-1110d10981bb", "id": "6d353a0f-aeb1-4ae1-832e-1110d10981bb", "name": "my-reserved-ip", "resource_type": "subnet_reserved_ip"}, "resource_type": "network_interface", "security_groups": [{"crn": "crn:v1:bluemix:public:is:us-south:a/123456::security-group:be5df5ca-12a0-494b-907e-aa6ec2bfa271", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/security_groups/be5df5ca-12a0-494b-907e-aa6ec2bfa271", "id": "be5df5ca-12a0-494b-907e-aa6ec2bfa271", "name": "my-security-group"}], "status": "available", "subnet": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "id": "7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "name": "my-subnet", "resource_type": "subnet"}, "type": "primary", "interface_type": "hipersocket"}], "next": {"href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/3b2669a2-4c2b-4003-bc91-1b81f1326267/network_interfaces?start=d3e721fd-c988-4670-9927-dbd5e7b07fc6&limit=20"}, "total_count": 132}`) + fmt.Fprintf(res, "%s", `{"family": "tiered", "href": "https://us-south.iaas.cloud.ibm.com/v1/volume/profiles/general-purpose", "name": "general-purpose"}`) })) }) - It(`Invoke ListBareMetalServerNetworkInterfaces successfully with retries`, func() { + It(`Invoke GetVolumeProfile successfully with retries`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -49998,23 +50060,21 @@ var _ = Describe(`VpcV1`, func() { Expect(vpcService).ToNot(BeNil()) vpcService.EnableRetries(0, 0) - // Construct an instance of the ListBareMetalServerNetworkInterfacesOptions model - listBareMetalServerNetworkInterfacesOptionsModel := new(vpcv1.ListBareMetalServerNetworkInterfacesOptions) - listBareMetalServerNetworkInterfacesOptionsModel.BareMetalServerID = core.StringPtr("testString") - listBareMetalServerNetworkInterfacesOptionsModel.Start = core.StringPtr("testString") - listBareMetalServerNetworkInterfacesOptionsModel.Limit = core.Int64Ptr(int64(10)) - listBareMetalServerNetworkInterfacesOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the GetVolumeProfileOptions model + getVolumeProfileOptionsModel := new(vpcv1.GetVolumeProfileOptions) + getVolumeProfileOptionsModel.Name = core.StringPtr("testString") + getVolumeProfileOptionsModel.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.ListBareMetalServerNetworkInterfacesWithContext(ctx, listBareMetalServerNetworkInterfacesOptionsModel) + _, _, operationErr := vpcService.GetVolumeProfileWithContext(ctx, getVolumeProfileOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) // Disable retries and test again vpcService.DisableRetries() - result, response, operationErr := vpcService.ListBareMetalServerNetworkInterfaces(listBareMetalServerNetworkInterfacesOptionsModel) + result, response, operationErr := vpcService.GetVolumeProfile(getVolumeProfileOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) @@ -50022,7 +50082,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.ListBareMetalServerNetworkInterfacesWithContext(ctx, listBareMetalServerNetworkInterfacesOptionsModel) + _, _, operationErr = vpcService.GetVolumeProfileWithContext(ctx, getVolumeProfileOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) }) @@ -50036,20 +50096,18 @@ var _ = Describe(`VpcV1`, func() { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(listBareMetalServerNetworkInterfacesPath)) + Expect(req.URL.EscapedPath()).To(Equal(getVolumeProfilePath)) Expect(req.Method).To(Equal("GET")) Expect(req.URL.Query()["version"]).To(Equal([]string{"testString"})) Expect(req.URL.Query()["generation"]).To(Equal([]string{fmt.Sprint(int64(2))})) - Expect(req.URL.Query()["start"]).To(Equal([]string{"testString"})) - Expect(req.URL.Query()["limit"]).To(Equal([]string{fmt.Sprint(int64(10))})) // 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/bare_metal_servers/3b2669a2-4c2b-4003-bc91-1b81f1326267/network_interfaces?limit=20"}, "limit": 20, "network_interfaces": [{"allow_ip_spoofing": true, "created_at": "2019-01-01T12:00:00.000Z", "enable_infrastructure_nat": true, "floating_ips": [{"address": "203.0.113.1", "crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::floating-ip:39300233-9995-4806-89a5-3c1b6eb88689", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/floating_ips/39300233-9995-4806-89a5-3c1b6eb88689", "id": "39300233-9995-4806-89a5-3c1b6eb88689", "name": "my-floating-ip"}], "href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/1e09281b-f177-46fb-baf1-bc152b2e391a/network_interfaces/10c02d81-0ecb-4dc5-897d-28392913b81e", "id": "10c02d81-0ecb-4dc5-897d-28392913b81e", "mac_address": "02:00:04:00:C4:6A", "name": "my-bare-metal-server-network-interface", "port_speed": 1000, "primary_ip": {"address": "192.168.3.4", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e/reserved_ips/6d353a0f-aeb1-4ae1-832e-1110d10981bb", "id": "6d353a0f-aeb1-4ae1-832e-1110d10981bb", "name": "my-reserved-ip", "resource_type": "subnet_reserved_ip"}, "resource_type": "network_interface", "security_groups": [{"crn": "crn:v1:bluemix:public:is:us-south:a/123456::security-group:be5df5ca-12a0-494b-907e-aa6ec2bfa271", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/security_groups/be5df5ca-12a0-494b-907e-aa6ec2bfa271", "id": "be5df5ca-12a0-494b-907e-aa6ec2bfa271", "name": "my-security-group"}], "status": "available", "subnet": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "id": "7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "name": "my-subnet", "resource_type": "subnet"}, "type": "primary", "interface_type": "hipersocket"}], "next": {"href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/3b2669a2-4c2b-4003-bc91-1b81f1326267/network_interfaces?start=d3e721fd-c988-4670-9927-dbd5e7b07fc6&limit=20"}, "total_count": 132}`) + fmt.Fprintf(res, "%s", `{"family": "tiered", "href": "https://us-south.iaas.cloud.ibm.com/v1/volume/profiles/general-purpose", "name": "general-purpose"}`) })) }) - It(`Invoke ListBareMetalServerNetworkInterfaces successfully`, func() { + It(`Invoke GetVolumeProfile successfully`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -50059,26 +50117,24 @@ var _ = Describe(`VpcV1`, func() { Expect(vpcService).ToNot(BeNil()) // Invoke operation with nil options model (negative test) - result, response, operationErr := vpcService.ListBareMetalServerNetworkInterfaces(nil) + result, response, operationErr := vpcService.GetVolumeProfile(nil) Expect(operationErr).NotTo(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) - // Construct an instance of the ListBareMetalServerNetworkInterfacesOptions model - listBareMetalServerNetworkInterfacesOptionsModel := new(vpcv1.ListBareMetalServerNetworkInterfacesOptions) - listBareMetalServerNetworkInterfacesOptionsModel.BareMetalServerID = core.StringPtr("testString") - listBareMetalServerNetworkInterfacesOptionsModel.Start = core.StringPtr("testString") - listBareMetalServerNetworkInterfacesOptionsModel.Limit = core.Int64Ptr(int64(10)) - listBareMetalServerNetworkInterfacesOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the GetVolumeProfileOptions model + getVolumeProfileOptionsModel := new(vpcv1.GetVolumeProfileOptions) + getVolumeProfileOptionsModel.Name = core.StringPtr("testString") + getVolumeProfileOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with valid options model (positive test) - result, response, operationErr = vpcService.ListBareMetalServerNetworkInterfaces(listBareMetalServerNetworkInterfacesOptionsModel) + result, response, operationErr = vpcService.GetVolumeProfile(getVolumeProfileOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) }) - It(`Invoke ListBareMetalServerNetworkInterfaces with error: Operation validation and request error`, func() { + It(`Invoke GetVolumeProfile with error: Operation validation and request error`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -50087,24 +50143,22 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the ListBareMetalServerNetworkInterfacesOptions model - listBareMetalServerNetworkInterfacesOptionsModel := new(vpcv1.ListBareMetalServerNetworkInterfacesOptions) - listBareMetalServerNetworkInterfacesOptionsModel.BareMetalServerID = core.StringPtr("testString") - listBareMetalServerNetworkInterfacesOptionsModel.Start = core.StringPtr("testString") - listBareMetalServerNetworkInterfacesOptionsModel.Limit = core.Int64Ptr(int64(10)) - listBareMetalServerNetworkInterfacesOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the GetVolumeProfileOptions model + getVolumeProfileOptionsModel := new(vpcv1.GetVolumeProfileOptions) + getVolumeProfileOptionsModel.Name = core.StringPtr("testString") + getVolumeProfileOptionsModel.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.ListBareMetalServerNetworkInterfaces(listBareMetalServerNetworkInterfacesOptionsModel) + result, response, operationErr := vpcService.GetVolumeProfile(getVolumeProfileOptionsModel) 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 ListBareMetalServerNetworkInterfacesOptions model with no property values - listBareMetalServerNetworkInterfacesOptionsModelNew := new(vpcv1.ListBareMetalServerNetworkInterfacesOptions) + // Construct a second instance of the GetVolumeProfileOptions model with no property values + getVolumeProfileOptionsModelNew := new(vpcv1.GetVolumeProfileOptions) // Invoke operation with invalid model (negative test) - result, response, operationErr = vpcService.ListBareMetalServerNetworkInterfaces(listBareMetalServerNetworkInterfacesOptionsModelNew) + result, response, operationErr = vpcService.GetVolumeProfile(getVolumeProfileOptionsModelNew) Expect(operationErr).ToNot(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) @@ -50122,7 +50176,7 @@ var _ = Describe(`VpcV1`, func() { res.WriteHeader(200) })) }) - It(`Invoke ListBareMetalServerNetworkInterfaces successfully`, func() { + It(`Invoke GetVolumeProfile successfully`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -50131,148 +50185,52 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the ListBareMetalServerNetworkInterfacesOptions model - listBareMetalServerNetworkInterfacesOptionsModel := new(vpcv1.ListBareMetalServerNetworkInterfacesOptions) - listBareMetalServerNetworkInterfacesOptionsModel.BareMetalServerID = core.StringPtr("testString") - listBareMetalServerNetworkInterfacesOptionsModel.Start = core.StringPtr("testString") - listBareMetalServerNetworkInterfacesOptionsModel.Limit = core.Int64Ptr(int64(10)) - listBareMetalServerNetworkInterfacesOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the GetVolumeProfileOptions model + getVolumeProfileOptionsModel := new(vpcv1.GetVolumeProfileOptions) + getVolumeProfileOptionsModel.Name = core.StringPtr("testString") + getVolumeProfileOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation - result, response, operationErr := vpcService.ListBareMetalServerNetworkInterfaces(listBareMetalServerNetworkInterfacesOptionsModel) + result, response, operationErr := vpcService.GetVolumeProfile(getVolumeProfileOptionsModel) 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.BareMetalServerNetworkInterfaceCollection) - nextObject := new(vpcv1.BareMetalServerNetworkInterfaceCollectionNext) - 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.BareMetalServerNetworkInterfaceCollection) - - 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.BareMetalServerNetworkInterfaceCollection) - nextObject := new(vpcv1.BareMetalServerNetworkInterfaceCollectionNext) - nextObject.Href = core.StringPtr("ibm.com") - responseObject.Next = nextObject - - value, err := responseObject.GetNextStart() - Expect(err).To(BeNil()) - Expect(value).To(BeNil()) - }) - }) - Context(`Using mock server endpoint - paginated response`, func() { - BeforeEach(func() { - var requestNumber int = 0 - testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { - defer GinkgoRecover() - - // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(listBareMetalServerNetworkInterfacesPath)) - Expect(req.Method).To(Equal("GET")) - - // Set mock response - res.Header().Set("Content-type", "application/json") - res.WriteHeader(200) - requestNumber++ - if requestNumber == 1 { - fmt.Fprintf(res, "%s", `{"next":{"href":"https://myhost.com/somePath?start=1"},"total_count":2,"limit":1,"network_interfaces":[{"allow_ip_spoofing":true,"created_at":"2019-01-01T12:00:00.000Z","enable_infrastructure_nat":true,"floating_ips":[{"address":"203.0.113.1","crn":"crn:v1:bluemix:public:is:us-south-1:a/123456::floating-ip:39300233-9995-4806-89a5-3c1b6eb88689","deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/floating_ips/39300233-9995-4806-89a5-3c1b6eb88689","id":"39300233-9995-4806-89a5-3c1b6eb88689","name":"my-floating-ip"}],"href":"https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/1e09281b-f177-46fb-baf1-bc152b2e391a/network_interfaces/10c02d81-0ecb-4dc5-897d-28392913b81e","id":"10c02d81-0ecb-4dc5-897d-28392913b81e","mac_address":"02:00:04:00:C4:6A","name":"my-bare-metal-server-network-interface","port_speed":1000,"primary_ip":{"address":"192.168.3.4","deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e/reserved_ips/6d353a0f-aeb1-4ae1-832e-1110d10981bb","id":"6d353a0f-aeb1-4ae1-832e-1110d10981bb","name":"my-reserved-ip","resource_type":"subnet_reserved_ip"},"resource_type":"network_interface","security_groups":[{"crn":"crn:v1:bluemix:public:is:us-south:a/123456::security-group:be5df5ca-12a0-494b-907e-aa6ec2bfa271","deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/security_groups/be5df5ca-12a0-494b-907e-aa6ec2bfa271","id":"be5df5ca-12a0-494b-907e-aa6ec2bfa271","name":"my-security-group"}],"status":"available","subnet":{"crn":"crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e","deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e","id":"7ec86020-1c6e-4889-b3f0-a15f2e50f87e","name":"my-subnet","resource_type":"subnet"},"type":"primary","interface_type":"hipersocket"}]}`) - } else if requestNumber == 2 { - fmt.Fprintf(res, "%s", `{"total_count":2,"limit":1,"network_interfaces":[{"allow_ip_spoofing":true,"created_at":"2019-01-01T12:00:00.000Z","enable_infrastructure_nat":true,"floating_ips":[{"address":"203.0.113.1","crn":"crn:v1:bluemix:public:is:us-south-1:a/123456::floating-ip:39300233-9995-4806-89a5-3c1b6eb88689","deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/floating_ips/39300233-9995-4806-89a5-3c1b6eb88689","id":"39300233-9995-4806-89a5-3c1b6eb88689","name":"my-floating-ip"}],"href":"https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/1e09281b-f177-46fb-baf1-bc152b2e391a/network_interfaces/10c02d81-0ecb-4dc5-897d-28392913b81e","id":"10c02d81-0ecb-4dc5-897d-28392913b81e","mac_address":"02:00:04:00:C4:6A","name":"my-bare-metal-server-network-interface","port_speed":1000,"primary_ip":{"address":"192.168.3.4","deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e/reserved_ips/6d353a0f-aeb1-4ae1-832e-1110d10981bb","id":"6d353a0f-aeb1-4ae1-832e-1110d10981bb","name":"my-reserved-ip","resource_type":"subnet_reserved_ip"},"resource_type":"network_interface","security_groups":[{"crn":"crn:v1:bluemix:public:is:us-south:a/123456::security-group:be5df5ca-12a0-494b-907e-aa6ec2bfa271","deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/security_groups/be5df5ca-12a0-494b-907e-aa6ec2bfa271","id":"be5df5ca-12a0-494b-907e-aa6ec2bfa271","name":"my-security-group"}],"status":"available","subnet":{"crn":"crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e","deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e","id":"7ec86020-1c6e-4889-b3f0-a15f2e50f87e","name":"my-subnet","resource_type":"subnet"},"type":"primary","interface_type":"hipersocket"}]}`) - } else { - res.WriteHeader(400) - } - })) - }) - It(`Use BareMetalServerNetworkInterfacesPager.GetNext successfully`, func() { - vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ - URL: testServer.URL, - Authenticator: &core.NoAuthAuthenticator{}, - Version: core.StringPtr(version), - }) - Expect(serviceErr).To(BeNil()) - Expect(vpcService).ToNot(BeNil()) - - listBareMetalServerNetworkInterfacesOptionsModel := &vpcv1.ListBareMetalServerNetworkInterfacesOptions{ - BareMetalServerID: core.StringPtr("testString"), - Limit: core.Int64Ptr(int64(10)), - } - - pager, err := vpcService.NewBareMetalServerNetworkInterfacesPager(listBareMetalServerNetworkInterfacesOptionsModel) - Expect(err).To(BeNil()) - Expect(pager).ToNot(BeNil()) - - var allResults []vpcv1.BareMetalServerNetworkInterfaceIntf - for pager.HasNext() { - nextPage, err := pager.GetNext() - Expect(err).To(BeNil()) - Expect(nextPage).ToNot(BeNil()) - allResults = append(allResults, nextPage...) - } - Expect(len(allResults)).To(Equal(2)) - }) - It(`Use BareMetalServerNetworkInterfacesPager.GetAll successfully`, func() { - vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ - URL: testServer.URL, - Authenticator: &core.NoAuthAuthenticator{}, - Version: core.StringPtr(version), - }) - Expect(serviceErr).To(BeNil()) - Expect(vpcService).ToNot(BeNil()) - - listBareMetalServerNetworkInterfacesOptionsModel := &vpcv1.ListBareMetalServerNetworkInterfacesOptions{ - BareMetalServerID: core.StringPtr("testString"), - Limit: core.Int64Ptr(int64(10)), - } - - pager, err := vpcService.NewBareMetalServerNetworkInterfacesPager(listBareMetalServerNetworkInterfacesOptionsModel) - Expect(err).To(BeNil()) - Expect(pager).ToNot(BeNil()) - - allResults, err := pager.GetAll() - Expect(err).To(BeNil()) - Expect(allResults).ToNot(BeNil()) - Expect(len(allResults)).To(Equal(2)) - }) + AfterEach(func() { + testServer.Close() + }) }) }) - Describe(`CreateBareMetalServerNetworkInterface(createBareMetalServerNetworkInterfaceOptions *CreateBareMetalServerNetworkInterfaceOptions) - Operation response error`, func() { + Describe(`ListVolumes(listVolumesOptions *ListVolumesOptions) - Operation response error`, func() { version := "testString" - createBareMetalServerNetworkInterfacePath := "/bare_metal_servers/testString/network_interfaces" + listVolumesPath := "/volumes" 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(createBareMetalServerNetworkInterfacePath)) - Expect(req.Method).To(Equal("POST")) + Expect(req.URL.EscapedPath()).To(Equal(listVolumesPath)) + Expect(req.Method).To(Equal("GET")) Expect(req.URL.Query()["version"]).To(Equal([]string{"testString"})) Expect(req.URL.Query()["generation"]).To(Equal([]string{fmt.Sprint(int64(2))})) + Expect(req.URL.Query()["start"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["limit"]).To(Equal([]string{fmt.Sprint(int64(10))})) + Expect(req.URL.Query()["name"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["attachment_state"]).To(Equal([]string{"attached"})) + Expect(req.URL.Query()["encryption"]).To(Equal([]string{"provider_managed"})) + Expect(req.URL.Query()["operating_system.family"]).To(Equal([]string{"Ubuntu Server"})) + Expect(req.URL.Query()["operating_system.architecture"]).To(Equal([]string{"amd64"})) + Expect(req.URL.Query()["zone.name"]).To(Equal([]string{"us-south-1"})) + Expect(req.URL.Query()["tag"]).To(Equal([]string{"testString"})) res.Header().Set("Content-type", "application/json") - res.WriteHeader(201) + res.WriteHeader(200) fmt.Fprint(res, `} this is not valid json {`) })) }) - It(`Invoke CreateBareMetalServerNetworkInterface with error: Operation response processing error`, func() { + It(`Invoke ListVolumes with error: Operation response processing error`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -50281,44 +50239,27 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the NetworkInterfaceIPPrototypeReservedIPPrototypeNetworkInterfaceContext model - networkInterfaceIPPrototypeModel := new(vpcv1.NetworkInterfaceIPPrototypeReservedIPPrototypeNetworkInterfaceContext) - networkInterfaceIPPrototypeModel.Address = core.StringPtr("10.0.0.5") - networkInterfaceIPPrototypeModel.AutoDelete = core.BoolPtr(false) - networkInterfaceIPPrototypeModel.Name = core.StringPtr("my-reserved-ip") - - // Construct an instance of the SecurityGroupIdentityByID model - securityGroupIdentityModel := new(vpcv1.SecurityGroupIdentityByID) - securityGroupIdentityModel.ID = core.StringPtr("be5df5ca-12a0-494b-907e-aa6ec2bfa271") - - // Construct an instance of the SubnetIdentityByID model - subnetIdentityModel := new(vpcv1.SubnetIdentityByID) - subnetIdentityModel.ID = core.StringPtr("7ec86020-1c6e-4889-b3f0-a15f2e50f87e") - - // Construct an instance of the BareMetalServerNetworkInterfacePrototypeBareMetalServerNetworkInterfaceByHiperSocketPrototype model - bareMetalServerNetworkInterfacePrototypeModel := new(vpcv1.BareMetalServerNetworkInterfacePrototypeBareMetalServerNetworkInterfaceByHiperSocketPrototype) - bareMetalServerNetworkInterfacePrototypeModel.AllowIPSpoofing = core.BoolPtr(true) - bareMetalServerNetworkInterfacePrototypeModel.EnableInfrastructureNat = core.BoolPtr(true) - bareMetalServerNetworkInterfacePrototypeModel.Name = core.StringPtr("my-bare-metal-server-network-interface") - bareMetalServerNetworkInterfacePrototypeModel.PrimaryIP = networkInterfaceIPPrototypeModel - bareMetalServerNetworkInterfacePrototypeModel.SecurityGroups = []vpcv1.SecurityGroupIdentityIntf{securityGroupIdentityModel} - bareMetalServerNetworkInterfacePrototypeModel.Subnet = subnetIdentityModel - bareMetalServerNetworkInterfacePrototypeModel.InterfaceType = core.StringPtr("hipersocket") - - // Construct an instance of the CreateBareMetalServerNetworkInterfaceOptions model - createBareMetalServerNetworkInterfaceOptionsModel := new(vpcv1.CreateBareMetalServerNetworkInterfaceOptions) - createBareMetalServerNetworkInterfaceOptionsModel.BareMetalServerID = core.StringPtr("testString") - createBareMetalServerNetworkInterfaceOptionsModel.BareMetalServerNetworkInterfacePrototype = bareMetalServerNetworkInterfacePrototypeModel - createBareMetalServerNetworkInterfaceOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the ListVolumesOptions model + listVolumesOptionsModel := new(vpcv1.ListVolumesOptions) + listVolumesOptionsModel.Start = core.StringPtr("testString") + listVolumesOptionsModel.Limit = core.Int64Ptr(int64(10)) + listVolumesOptionsModel.Name = core.StringPtr("testString") + listVolumesOptionsModel.AttachmentState = core.StringPtr("attached") + listVolumesOptionsModel.Encryption = core.StringPtr("provider_managed") + listVolumesOptionsModel.OperatingSystemFamily = core.StringPtr("Ubuntu Server") + listVolumesOptionsModel.OperatingSystemArchitecture = core.StringPtr("amd64") + listVolumesOptionsModel.ZoneName = core.StringPtr("us-south-1") + listVolumesOptionsModel.Tag = core.StringPtr("testString") + listVolumesOptionsModel.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.CreateBareMetalServerNetworkInterface(createBareMetalServerNetworkInterfaceOptionsModel) + result, response, operationErr := vpcService.ListVolumes(listVolumesOptionsModel) 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.CreateBareMetalServerNetworkInterface(createBareMetalServerNetworkInterfaceOptionsModel) + result, response, operationErr = vpcService.ListVolumes(listVolumesOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).To(BeNil()) @@ -50328,46 +50269,39 @@ var _ = Describe(`VpcV1`, func() { }) }) }) - Describe(`CreateBareMetalServerNetworkInterface(createBareMetalServerNetworkInterfaceOptions *CreateBareMetalServerNetworkInterfaceOptions)`, func() { + Describe(`ListVolumes(listVolumesOptions *ListVolumesOptions)`, func() { version := "testString" - createBareMetalServerNetworkInterfacePath := "/bare_metal_servers/testString/network_interfaces" + listVolumesPath := "/volumes" 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(createBareMetalServerNetworkInterfacePath)) - 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.EscapedPath()).To(Equal(listVolumesPath)) + Expect(req.Method).To(Equal("GET")) Expect(req.URL.Query()["version"]).To(Equal([]string{"testString"})) Expect(req.URL.Query()["generation"]).To(Equal([]string{fmt.Sprint(int64(2))})) + Expect(req.URL.Query()["start"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["limit"]).To(Equal([]string{fmt.Sprint(int64(10))})) + Expect(req.URL.Query()["name"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["attachment_state"]).To(Equal([]string{"attached"})) + Expect(req.URL.Query()["encryption"]).To(Equal([]string{"provider_managed"})) + Expect(req.URL.Query()["operating_system.family"]).To(Equal([]string{"Ubuntu Server"})) + Expect(req.URL.Query()["operating_system.architecture"]).To(Equal([]string{"amd64"})) + Expect(req.URL.Query()["zone.name"]).To(Equal([]string{"us-south-1"})) + 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(201) - fmt.Fprintf(res, "%s", `{"allow_ip_spoofing": true, "created_at": "2019-01-01T12:00:00.000Z", "enable_infrastructure_nat": true, "floating_ips": [{"address": "203.0.113.1", "crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::floating-ip:39300233-9995-4806-89a5-3c1b6eb88689", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/floating_ips/39300233-9995-4806-89a5-3c1b6eb88689", "id": "39300233-9995-4806-89a5-3c1b6eb88689", "name": "my-floating-ip"}], "href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/1e09281b-f177-46fb-baf1-bc152b2e391a/network_interfaces/10c02d81-0ecb-4dc5-897d-28392913b81e", "id": "10c02d81-0ecb-4dc5-897d-28392913b81e", "mac_address": "02:00:04:00:C4:6A", "name": "my-bare-metal-server-network-interface", "port_speed": 1000, "primary_ip": {"address": "192.168.3.4", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e/reserved_ips/6d353a0f-aeb1-4ae1-832e-1110d10981bb", "id": "6d353a0f-aeb1-4ae1-832e-1110d10981bb", "name": "my-reserved-ip", "resource_type": "subnet_reserved_ip"}, "resource_type": "network_interface", "security_groups": [{"crn": "crn:v1:bluemix:public:is:us-south:a/123456::security-group:be5df5ca-12a0-494b-907e-aa6ec2bfa271", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/security_groups/be5df5ca-12a0-494b-907e-aa6ec2bfa271", "id": "be5df5ca-12a0-494b-907e-aa6ec2bfa271", "name": "my-security-group"}], "status": "available", "subnet": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "id": "7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "name": "my-subnet", "resource_type": "subnet"}, "type": "primary", "interface_type": "hipersocket"}`) + res.WriteHeader(200) + fmt.Fprintf(res, "%s", `{"first": {"href": "https://us-south.iaas.cloud.ibm.com/v1/volumes?limit=20"}, "limit": 20, "next": {"href": "https://us-south.iaas.cloud.ibm.com/v1/volumes?start=9d5a91a3e2cbd233b5a5b33436855ed1&limit=20"}, "total_count": 132, "volumes": [{"active": true, "attachment_state": "attached", "bandwidth": 1000, "busy": true, "capacity": 1000, "created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::volume:1a6b7274-678d-4dfb-8981-c71dd9d4daa5", "encryption": "provider_managed", "encryption_key": {"crn": "crn:v1:bluemix:public:kms:us-south:a/123456:e4a29d1a-2ef0-42a6-8fd2-350deb1c647e:key:5437653b-c4b1-447f-9646-b2a2a4cd6179"}, "health_reasons": [{"code": "initializing_from_snapshot", "message": "Performance will be degraded while this volume is being initialized from its snapshot", "more_info": "https://cloud.ibm.com/docs/vpc?topic=vpc-snapshots-vpc-troubleshooting&interface=ui#snapshot_ts_degraded_perf"}], "health_state": "ok", "href": "https://us-south.iaas.cloud.ibm.com/v1/volumes/1a6b7274-678d-4dfb-8981-c71dd9d4daa5", "id": "1a6b7274-678d-4dfb-8981-c71dd9d4daa5", "iops": 10000, "name": "my-volume", "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"}, "profile": {"href": "https://us-south.iaas.cloud.ibm.com/v1/volume/profiles/general-purpose", "name": "general-purpose"}, "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "resource_type": "volume", "source_image": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::image:72b27b5c-f4b0-48bb-b954-5becc7c1dcb8", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/images/72b27b5c-f4b0-48bb-b954-5becc7c1dcb8", "id": "72b27b5c-f4b0-48bb-b954-5becc7c1dcb8", "name": "my-image", "remote": {"account": {"id": "aa2432b1fa4d4ace891e9b80fc104e34", "resource_type": "account"}, "region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "image"}, "source_snapshot": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "id": "r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "name": "my-snapshot", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "snapshot"}, "status": "available", "status_reasons": [{"code": "encryption_key_deleted", "message": "Message", "more_info": "https://cloud.ibm.com/docs/key-protect?topic=key-protect-restore-keys"}], "user_tags": ["UserTags"], "volume_attachments": [{"delete_volume_on_instance_delete": true, "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "device": {"id": "80b3e36e-41f4-40e9-bd56-beae81792a68"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/instances/1e09281b-f177-46fb-baf1-bc152b2e391a/volume_attachments/82cbf856-9cbb-45fb-b62f-d7bcef32399a", "id": "82cbf856-9cbb-45fb-b62f-d7bcef32399a", "instance": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::instance:1e09281b-f177-46fb-baf1-bc152b2e391a", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/instances/1e09281b-f177-46fb-baf1-bc152b2e391a", "id": "1e09281b-f177-46fb-baf1-bc152b2e391a", "name": "my-instance"}, "name": "my-volume-attachment", "type": "boot"}], "zone": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south/zones/us-south-1", "name": "us-south-1"}}]}`) })) }) - It(`Invoke CreateBareMetalServerNetworkInterface successfully with retries`, func() { + It(`Invoke ListVolumes successfully with retries`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -50377,46 +50311,29 @@ var _ = Describe(`VpcV1`, func() { Expect(vpcService).ToNot(BeNil()) vpcService.EnableRetries(0, 0) - // Construct an instance of the NetworkInterfaceIPPrototypeReservedIPPrototypeNetworkInterfaceContext model - networkInterfaceIPPrototypeModel := new(vpcv1.NetworkInterfaceIPPrototypeReservedIPPrototypeNetworkInterfaceContext) - networkInterfaceIPPrototypeModel.Address = core.StringPtr("10.0.0.5") - networkInterfaceIPPrototypeModel.AutoDelete = core.BoolPtr(false) - networkInterfaceIPPrototypeModel.Name = core.StringPtr("my-reserved-ip") - - // Construct an instance of the SecurityGroupIdentityByID model - securityGroupIdentityModel := new(vpcv1.SecurityGroupIdentityByID) - securityGroupIdentityModel.ID = core.StringPtr("be5df5ca-12a0-494b-907e-aa6ec2bfa271") - - // Construct an instance of the SubnetIdentityByID model - subnetIdentityModel := new(vpcv1.SubnetIdentityByID) - subnetIdentityModel.ID = core.StringPtr("7ec86020-1c6e-4889-b3f0-a15f2e50f87e") - - // Construct an instance of the BareMetalServerNetworkInterfacePrototypeBareMetalServerNetworkInterfaceByHiperSocketPrototype model - bareMetalServerNetworkInterfacePrototypeModel := new(vpcv1.BareMetalServerNetworkInterfacePrototypeBareMetalServerNetworkInterfaceByHiperSocketPrototype) - bareMetalServerNetworkInterfacePrototypeModel.AllowIPSpoofing = core.BoolPtr(true) - bareMetalServerNetworkInterfacePrototypeModel.EnableInfrastructureNat = core.BoolPtr(true) - bareMetalServerNetworkInterfacePrototypeModel.Name = core.StringPtr("my-bare-metal-server-network-interface") - bareMetalServerNetworkInterfacePrototypeModel.PrimaryIP = networkInterfaceIPPrototypeModel - bareMetalServerNetworkInterfacePrototypeModel.SecurityGroups = []vpcv1.SecurityGroupIdentityIntf{securityGroupIdentityModel} - bareMetalServerNetworkInterfacePrototypeModel.Subnet = subnetIdentityModel - bareMetalServerNetworkInterfacePrototypeModel.InterfaceType = core.StringPtr("hipersocket") - - // Construct an instance of the CreateBareMetalServerNetworkInterfaceOptions model - createBareMetalServerNetworkInterfaceOptionsModel := new(vpcv1.CreateBareMetalServerNetworkInterfaceOptions) - createBareMetalServerNetworkInterfaceOptionsModel.BareMetalServerID = core.StringPtr("testString") - createBareMetalServerNetworkInterfaceOptionsModel.BareMetalServerNetworkInterfacePrototype = bareMetalServerNetworkInterfacePrototypeModel - createBareMetalServerNetworkInterfaceOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the ListVolumesOptions model + listVolumesOptionsModel := new(vpcv1.ListVolumesOptions) + listVolumesOptionsModel.Start = core.StringPtr("testString") + listVolumesOptionsModel.Limit = core.Int64Ptr(int64(10)) + listVolumesOptionsModel.Name = core.StringPtr("testString") + listVolumesOptionsModel.AttachmentState = core.StringPtr("attached") + listVolumesOptionsModel.Encryption = core.StringPtr("provider_managed") + listVolumesOptionsModel.OperatingSystemFamily = core.StringPtr("Ubuntu Server") + listVolumesOptionsModel.OperatingSystemArchitecture = core.StringPtr("amd64") + listVolumesOptionsModel.ZoneName = core.StringPtr("us-south-1") + listVolumesOptionsModel.Tag = core.StringPtr("testString") + listVolumesOptionsModel.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.CreateBareMetalServerNetworkInterfaceWithContext(ctx, createBareMetalServerNetworkInterfaceOptionsModel) + _, _, operationErr := vpcService.ListVolumesWithContext(ctx, listVolumesOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) // Disable retries and test again vpcService.DisableRetries() - result, response, operationErr := vpcService.CreateBareMetalServerNetworkInterface(createBareMetalServerNetworkInterfaceOptionsModel) + result, response, operationErr := vpcService.ListVolumes(listVolumesOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) @@ -50424,7 +50341,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.CreateBareMetalServerNetworkInterfaceWithContext(ctx, createBareMetalServerNetworkInterfaceOptionsModel) + _, _, operationErr = vpcService.ListVolumesWithContext(ctx, listVolumesOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) }) @@ -50438,34 +50355,27 @@ var _ = Describe(`VpcV1`, func() { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(createBareMetalServerNetworkInterfacePath)) - 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.EscapedPath()).To(Equal(listVolumesPath)) + Expect(req.Method).To(Equal("GET")) Expect(req.URL.Query()["version"]).To(Equal([]string{"testString"})) Expect(req.URL.Query()["generation"]).To(Equal([]string{fmt.Sprint(int64(2))})) + Expect(req.URL.Query()["start"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["limit"]).To(Equal([]string{fmt.Sprint(int64(10))})) + Expect(req.URL.Query()["name"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["attachment_state"]).To(Equal([]string{"attached"})) + Expect(req.URL.Query()["encryption"]).To(Equal([]string{"provider_managed"})) + Expect(req.URL.Query()["operating_system.family"]).To(Equal([]string{"Ubuntu Server"})) + Expect(req.URL.Query()["operating_system.architecture"]).To(Equal([]string{"amd64"})) + Expect(req.URL.Query()["zone.name"]).To(Equal([]string{"us-south-1"})) + Expect(req.URL.Query()["tag"]).To(Equal([]string{"testString"})) // Set mock response res.Header().Set("Content-type", "application/json") - res.WriteHeader(201) - fmt.Fprintf(res, "%s", `{"allow_ip_spoofing": true, "created_at": "2019-01-01T12:00:00.000Z", "enable_infrastructure_nat": true, "floating_ips": [{"address": "203.0.113.1", "crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::floating-ip:39300233-9995-4806-89a5-3c1b6eb88689", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/floating_ips/39300233-9995-4806-89a5-3c1b6eb88689", "id": "39300233-9995-4806-89a5-3c1b6eb88689", "name": "my-floating-ip"}], "href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/1e09281b-f177-46fb-baf1-bc152b2e391a/network_interfaces/10c02d81-0ecb-4dc5-897d-28392913b81e", "id": "10c02d81-0ecb-4dc5-897d-28392913b81e", "mac_address": "02:00:04:00:C4:6A", "name": "my-bare-metal-server-network-interface", "port_speed": 1000, "primary_ip": {"address": "192.168.3.4", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e/reserved_ips/6d353a0f-aeb1-4ae1-832e-1110d10981bb", "id": "6d353a0f-aeb1-4ae1-832e-1110d10981bb", "name": "my-reserved-ip", "resource_type": "subnet_reserved_ip"}, "resource_type": "network_interface", "security_groups": [{"crn": "crn:v1:bluemix:public:is:us-south:a/123456::security-group:be5df5ca-12a0-494b-907e-aa6ec2bfa271", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/security_groups/be5df5ca-12a0-494b-907e-aa6ec2bfa271", "id": "be5df5ca-12a0-494b-907e-aa6ec2bfa271", "name": "my-security-group"}], "status": "available", "subnet": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "id": "7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "name": "my-subnet", "resource_type": "subnet"}, "type": "primary", "interface_type": "hipersocket"}`) + res.WriteHeader(200) + fmt.Fprintf(res, "%s", `{"first": {"href": "https://us-south.iaas.cloud.ibm.com/v1/volumes?limit=20"}, "limit": 20, "next": {"href": "https://us-south.iaas.cloud.ibm.com/v1/volumes?start=9d5a91a3e2cbd233b5a5b33436855ed1&limit=20"}, "total_count": 132, "volumes": [{"active": true, "attachment_state": "attached", "bandwidth": 1000, "busy": true, "capacity": 1000, "created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::volume:1a6b7274-678d-4dfb-8981-c71dd9d4daa5", "encryption": "provider_managed", "encryption_key": {"crn": "crn:v1:bluemix:public:kms:us-south:a/123456:e4a29d1a-2ef0-42a6-8fd2-350deb1c647e:key:5437653b-c4b1-447f-9646-b2a2a4cd6179"}, "health_reasons": [{"code": "initializing_from_snapshot", "message": "Performance will be degraded while this volume is being initialized from its snapshot", "more_info": "https://cloud.ibm.com/docs/vpc?topic=vpc-snapshots-vpc-troubleshooting&interface=ui#snapshot_ts_degraded_perf"}], "health_state": "ok", "href": "https://us-south.iaas.cloud.ibm.com/v1/volumes/1a6b7274-678d-4dfb-8981-c71dd9d4daa5", "id": "1a6b7274-678d-4dfb-8981-c71dd9d4daa5", "iops": 10000, "name": "my-volume", "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"}, "profile": {"href": "https://us-south.iaas.cloud.ibm.com/v1/volume/profiles/general-purpose", "name": "general-purpose"}, "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "resource_type": "volume", "source_image": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::image:72b27b5c-f4b0-48bb-b954-5becc7c1dcb8", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/images/72b27b5c-f4b0-48bb-b954-5becc7c1dcb8", "id": "72b27b5c-f4b0-48bb-b954-5becc7c1dcb8", "name": "my-image", "remote": {"account": {"id": "aa2432b1fa4d4ace891e9b80fc104e34", "resource_type": "account"}, "region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "image"}, "source_snapshot": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "id": "r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "name": "my-snapshot", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "snapshot"}, "status": "available", "status_reasons": [{"code": "encryption_key_deleted", "message": "Message", "more_info": "https://cloud.ibm.com/docs/key-protect?topic=key-protect-restore-keys"}], "user_tags": ["UserTags"], "volume_attachments": [{"delete_volume_on_instance_delete": true, "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "device": {"id": "80b3e36e-41f4-40e9-bd56-beae81792a68"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/instances/1e09281b-f177-46fb-baf1-bc152b2e391a/volume_attachments/82cbf856-9cbb-45fb-b62f-d7bcef32399a", "id": "82cbf856-9cbb-45fb-b62f-d7bcef32399a", "instance": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::instance:1e09281b-f177-46fb-baf1-bc152b2e391a", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/instances/1e09281b-f177-46fb-baf1-bc152b2e391a", "id": "1e09281b-f177-46fb-baf1-bc152b2e391a", "name": "my-instance"}, "name": "my-volume-attachment", "type": "boot"}], "zone": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south/zones/us-south-1", "name": "us-south-1"}}]}`) })) }) - It(`Invoke CreateBareMetalServerNetworkInterface successfully`, func() { + It(`Invoke ListVolumes successfully`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -50475,49 +50385,32 @@ var _ = Describe(`VpcV1`, func() { Expect(vpcService).ToNot(BeNil()) // Invoke operation with nil options model (negative test) - result, response, operationErr := vpcService.CreateBareMetalServerNetworkInterface(nil) + result, response, operationErr := vpcService.ListVolumes(nil) Expect(operationErr).NotTo(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) - // Construct an instance of the NetworkInterfaceIPPrototypeReservedIPPrototypeNetworkInterfaceContext model - networkInterfaceIPPrototypeModel := new(vpcv1.NetworkInterfaceIPPrototypeReservedIPPrototypeNetworkInterfaceContext) - networkInterfaceIPPrototypeModel.Address = core.StringPtr("10.0.0.5") - networkInterfaceIPPrototypeModel.AutoDelete = core.BoolPtr(false) - networkInterfaceIPPrototypeModel.Name = core.StringPtr("my-reserved-ip") - - // Construct an instance of the SecurityGroupIdentityByID model - securityGroupIdentityModel := new(vpcv1.SecurityGroupIdentityByID) - securityGroupIdentityModel.ID = core.StringPtr("be5df5ca-12a0-494b-907e-aa6ec2bfa271") - - // Construct an instance of the SubnetIdentityByID model - subnetIdentityModel := new(vpcv1.SubnetIdentityByID) - subnetIdentityModel.ID = core.StringPtr("7ec86020-1c6e-4889-b3f0-a15f2e50f87e") - - // Construct an instance of the BareMetalServerNetworkInterfacePrototypeBareMetalServerNetworkInterfaceByHiperSocketPrototype model - bareMetalServerNetworkInterfacePrototypeModel := new(vpcv1.BareMetalServerNetworkInterfacePrototypeBareMetalServerNetworkInterfaceByHiperSocketPrototype) - bareMetalServerNetworkInterfacePrototypeModel.AllowIPSpoofing = core.BoolPtr(true) - bareMetalServerNetworkInterfacePrototypeModel.EnableInfrastructureNat = core.BoolPtr(true) - bareMetalServerNetworkInterfacePrototypeModel.Name = core.StringPtr("my-bare-metal-server-network-interface") - bareMetalServerNetworkInterfacePrototypeModel.PrimaryIP = networkInterfaceIPPrototypeModel - bareMetalServerNetworkInterfacePrototypeModel.SecurityGroups = []vpcv1.SecurityGroupIdentityIntf{securityGroupIdentityModel} - bareMetalServerNetworkInterfacePrototypeModel.Subnet = subnetIdentityModel - bareMetalServerNetworkInterfacePrototypeModel.InterfaceType = core.StringPtr("hipersocket") - - // Construct an instance of the CreateBareMetalServerNetworkInterfaceOptions model - createBareMetalServerNetworkInterfaceOptionsModel := new(vpcv1.CreateBareMetalServerNetworkInterfaceOptions) - createBareMetalServerNetworkInterfaceOptionsModel.BareMetalServerID = core.StringPtr("testString") - createBareMetalServerNetworkInterfaceOptionsModel.BareMetalServerNetworkInterfacePrototype = bareMetalServerNetworkInterfacePrototypeModel - createBareMetalServerNetworkInterfaceOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the ListVolumesOptions model + listVolumesOptionsModel := new(vpcv1.ListVolumesOptions) + listVolumesOptionsModel.Start = core.StringPtr("testString") + listVolumesOptionsModel.Limit = core.Int64Ptr(int64(10)) + listVolumesOptionsModel.Name = core.StringPtr("testString") + listVolumesOptionsModel.AttachmentState = core.StringPtr("attached") + listVolumesOptionsModel.Encryption = core.StringPtr("provider_managed") + listVolumesOptionsModel.OperatingSystemFamily = core.StringPtr("Ubuntu Server") + listVolumesOptionsModel.OperatingSystemArchitecture = core.StringPtr("amd64") + listVolumesOptionsModel.ZoneName = core.StringPtr("us-south-1") + listVolumesOptionsModel.Tag = core.StringPtr("testString") + listVolumesOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with valid options model (positive test) - result, response, operationErr = vpcService.CreateBareMetalServerNetworkInterface(createBareMetalServerNetworkInterfaceOptionsModel) + result, response, operationErr = vpcService.ListVolumes(listVolumesOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) }) - It(`Invoke CreateBareMetalServerNetworkInterface with error: Operation validation and request error`, func() { + It(`Invoke ListVolumes with error: Operation request error`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -50526,50 +50419,26 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the NetworkInterfaceIPPrototypeReservedIPPrototypeNetworkInterfaceContext model - networkInterfaceIPPrototypeModel := new(vpcv1.NetworkInterfaceIPPrototypeReservedIPPrototypeNetworkInterfaceContext) - networkInterfaceIPPrototypeModel.Address = core.StringPtr("10.0.0.5") - networkInterfaceIPPrototypeModel.AutoDelete = core.BoolPtr(false) - networkInterfaceIPPrototypeModel.Name = core.StringPtr("my-reserved-ip") - - // Construct an instance of the SecurityGroupIdentityByID model - securityGroupIdentityModel := new(vpcv1.SecurityGroupIdentityByID) - securityGroupIdentityModel.ID = core.StringPtr("be5df5ca-12a0-494b-907e-aa6ec2bfa271") - - // Construct an instance of the SubnetIdentityByID model - subnetIdentityModel := new(vpcv1.SubnetIdentityByID) - subnetIdentityModel.ID = core.StringPtr("7ec86020-1c6e-4889-b3f0-a15f2e50f87e") - - // Construct an instance of the BareMetalServerNetworkInterfacePrototypeBareMetalServerNetworkInterfaceByHiperSocketPrototype model - bareMetalServerNetworkInterfacePrototypeModel := new(vpcv1.BareMetalServerNetworkInterfacePrototypeBareMetalServerNetworkInterfaceByHiperSocketPrototype) - bareMetalServerNetworkInterfacePrototypeModel.AllowIPSpoofing = core.BoolPtr(true) - bareMetalServerNetworkInterfacePrototypeModel.EnableInfrastructureNat = core.BoolPtr(true) - bareMetalServerNetworkInterfacePrototypeModel.Name = core.StringPtr("my-bare-metal-server-network-interface") - bareMetalServerNetworkInterfacePrototypeModel.PrimaryIP = networkInterfaceIPPrototypeModel - bareMetalServerNetworkInterfacePrototypeModel.SecurityGroups = []vpcv1.SecurityGroupIdentityIntf{securityGroupIdentityModel} - bareMetalServerNetworkInterfacePrototypeModel.Subnet = subnetIdentityModel - bareMetalServerNetworkInterfacePrototypeModel.InterfaceType = core.StringPtr("hipersocket") - - // Construct an instance of the CreateBareMetalServerNetworkInterfaceOptions model - createBareMetalServerNetworkInterfaceOptionsModel := new(vpcv1.CreateBareMetalServerNetworkInterfaceOptions) - createBareMetalServerNetworkInterfaceOptionsModel.BareMetalServerID = core.StringPtr("testString") - createBareMetalServerNetworkInterfaceOptionsModel.BareMetalServerNetworkInterfacePrototype = bareMetalServerNetworkInterfacePrototypeModel - createBareMetalServerNetworkInterfaceOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the ListVolumesOptions model + listVolumesOptionsModel := new(vpcv1.ListVolumesOptions) + listVolumesOptionsModel.Start = core.StringPtr("testString") + listVolumesOptionsModel.Limit = core.Int64Ptr(int64(10)) + listVolumesOptionsModel.Name = core.StringPtr("testString") + listVolumesOptionsModel.AttachmentState = core.StringPtr("attached") + listVolumesOptionsModel.Encryption = core.StringPtr("provider_managed") + listVolumesOptionsModel.OperatingSystemFamily = core.StringPtr("Ubuntu Server") + listVolumesOptionsModel.OperatingSystemArchitecture = core.StringPtr("amd64") + listVolumesOptionsModel.ZoneName = core.StringPtr("us-south-1") + listVolumesOptionsModel.Tag = core.StringPtr("testString") + listVolumesOptionsModel.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.CreateBareMetalServerNetworkInterface(createBareMetalServerNetworkInterfaceOptionsModel) + result, response, operationErr := vpcService.ListVolumes(listVolumesOptionsModel) 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 CreateBareMetalServerNetworkInterfaceOptions model with no property values - createBareMetalServerNetworkInterfaceOptionsModelNew := new(vpcv1.CreateBareMetalServerNetworkInterfaceOptions) - // Invoke operation with invalid model (negative test) - result, response, operationErr = vpcService.CreateBareMetalServerNetworkInterface(createBareMetalServerNetworkInterfaceOptionsModelNew) - Expect(operationErr).ToNot(BeNil()) - Expect(response).To(BeNil()) - Expect(result).To(BeNil()) }) AfterEach(func() { testServer.Close() @@ -50581,10 +50450,10 @@ var _ = Describe(`VpcV1`, func() { defer GinkgoRecover() // Set success status code with no respoonse body - res.WriteHeader(201) + res.WriteHeader(200) })) }) - It(`Invoke CreateBareMetalServerNetworkInterface successfully`, func() { + It(`Invoke ListVolumes successfully`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -50593,38 +50462,21 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the NetworkInterfaceIPPrototypeReservedIPPrototypeNetworkInterfaceContext model - networkInterfaceIPPrototypeModel := new(vpcv1.NetworkInterfaceIPPrototypeReservedIPPrototypeNetworkInterfaceContext) - networkInterfaceIPPrototypeModel.Address = core.StringPtr("10.0.0.5") - networkInterfaceIPPrototypeModel.AutoDelete = core.BoolPtr(false) - networkInterfaceIPPrototypeModel.Name = core.StringPtr("my-reserved-ip") - - // Construct an instance of the SecurityGroupIdentityByID model - securityGroupIdentityModel := new(vpcv1.SecurityGroupIdentityByID) - securityGroupIdentityModel.ID = core.StringPtr("be5df5ca-12a0-494b-907e-aa6ec2bfa271") - - // Construct an instance of the SubnetIdentityByID model - subnetIdentityModel := new(vpcv1.SubnetIdentityByID) - subnetIdentityModel.ID = core.StringPtr("7ec86020-1c6e-4889-b3f0-a15f2e50f87e") - - // Construct an instance of the BareMetalServerNetworkInterfacePrototypeBareMetalServerNetworkInterfaceByHiperSocketPrototype model - bareMetalServerNetworkInterfacePrototypeModel := new(vpcv1.BareMetalServerNetworkInterfacePrototypeBareMetalServerNetworkInterfaceByHiperSocketPrototype) - bareMetalServerNetworkInterfacePrototypeModel.AllowIPSpoofing = core.BoolPtr(true) - bareMetalServerNetworkInterfacePrototypeModel.EnableInfrastructureNat = core.BoolPtr(true) - bareMetalServerNetworkInterfacePrototypeModel.Name = core.StringPtr("my-bare-metal-server-network-interface") - bareMetalServerNetworkInterfacePrototypeModel.PrimaryIP = networkInterfaceIPPrototypeModel - bareMetalServerNetworkInterfacePrototypeModel.SecurityGroups = []vpcv1.SecurityGroupIdentityIntf{securityGroupIdentityModel} - bareMetalServerNetworkInterfacePrototypeModel.Subnet = subnetIdentityModel - bareMetalServerNetworkInterfacePrototypeModel.InterfaceType = core.StringPtr("hipersocket") - - // Construct an instance of the CreateBareMetalServerNetworkInterfaceOptions model - createBareMetalServerNetworkInterfaceOptionsModel := new(vpcv1.CreateBareMetalServerNetworkInterfaceOptions) - createBareMetalServerNetworkInterfaceOptionsModel.BareMetalServerID = core.StringPtr("testString") - createBareMetalServerNetworkInterfaceOptionsModel.BareMetalServerNetworkInterfacePrototype = bareMetalServerNetworkInterfacePrototypeModel - createBareMetalServerNetworkInterfaceOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the ListVolumesOptions model + listVolumesOptionsModel := new(vpcv1.ListVolumesOptions) + listVolumesOptionsModel.Start = core.StringPtr("testString") + listVolumesOptionsModel.Limit = core.Int64Ptr(int64(10)) + listVolumesOptionsModel.Name = core.StringPtr("testString") + listVolumesOptionsModel.AttachmentState = core.StringPtr("attached") + listVolumesOptionsModel.Encryption = core.StringPtr("provider_managed") + listVolumesOptionsModel.OperatingSystemFamily = core.StringPtr("Ubuntu Server") + listVolumesOptionsModel.OperatingSystemArchitecture = core.StringPtr("amd64") + listVolumesOptionsModel.ZoneName = core.StringPtr("us-south-1") + listVolumesOptionsModel.Tag = core.StringPtr("testString") + listVolumesOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation - result, response, operationErr := vpcService.CreateBareMetalServerNetworkInterface(createBareMetalServerNetworkInterfaceOptionsModel) + result, response, operationErr := vpcService.ListVolumes(listVolumesOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) @@ -50635,25 +50487,59 @@ var _ = Describe(`VpcV1`, func() { testServer.Close() }) }) - }) - Describe(`DeleteBareMetalServerNetworkInterface(deleteBareMetalServerNetworkInterfaceOptions *DeleteBareMetalServerNetworkInterfaceOptions)`, func() { - version := "testString" - deleteBareMetalServerNetworkInterfacePath := "/bare_metal_servers/testString/network_interfaces/testString" - Context(`Using mock server endpoint`, func() { + Context(`Test pagination helper method on response`, func() { + It(`Invoke GetNextStart successfully`, func() { + responseObject := new(vpcv1.VolumeCollection) + nextObject := new(vpcv1.VolumeCollectionNext) + 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.VolumeCollection) + + 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.VolumeCollection) + nextObject := new(vpcv1.VolumeCollectionNext) + nextObject.Href = core.StringPtr("ibm.com") + responseObject.Next = nextObject + + value, err := responseObject.GetNextStart() + Expect(err).To(BeNil()) + Expect(value).To(BeNil()) + }) + }) + Context(`Using mock server endpoint - paginated response`, func() { BeforeEach(func() { + var requestNumber int = 0 testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(deleteBareMetalServerNetworkInterfacePath)) - Expect(req.Method).To(Equal("DELETE")) + Expect(req.URL.EscapedPath()).To(Equal(listVolumesPath)) + 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.WriteHeader(204) + // Set mock response + res.Header().Set("Content-type", "application/json") + res.WriteHeader(200) + requestNumber++ + if requestNumber == 1 { + fmt.Fprintf(res, "%s", `{"next":{"href":"https://myhost.com/somePath?start=1"},"total_count":2,"limit":1,"volumes":[{"active":true,"attachment_state":"attached","bandwidth":1000,"busy":true,"capacity":1000,"created_at":"2019-01-01T12:00:00.000Z","crn":"crn:v1:bluemix:public:is:us-south-1:a/123456::volume:1a6b7274-678d-4dfb-8981-c71dd9d4daa5","encryption":"provider_managed","encryption_key":{"crn":"crn:v1:bluemix:public:kms:us-south:a/123456:e4a29d1a-2ef0-42a6-8fd2-350deb1c647e:key:5437653b-c4b1-447f-9646-b2a2a4cd6179"},"health_reasons":[{"code":"initializing_from_snapshot","message":"Performance will be degraded while this volume is being initialized from its snapshot","more_info":"https://cloud.ibm.com/docs/vpc?topic=vpc-snapshots-vpc-troubleshooting&interface=ui#snapshot_ts_degraded_perf"}],"health_state":"ok","href":"https://us-south.iaas.cloud.ibm.com/v1/volumes/1a6b7274-678d-4dfb-8981-c71dd9d4daa5","id":"1a6b7274-678d-4dfb-8981-c71dd9d4daa5","iops":10000,"name":"my-volume","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"},"profile":{"href":"https://us-south.iaas.cloud.ibm.com/v1/volume/profiles/general-purpose","name":"general-purpose"},"resource_group":{"href":"https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345","id":"fee82deba12e4c0fb69c3b09d1f12345","name":"my-resource-group"},"resource_type":"volume","source_image":{"crn":"crn:v1:bluemix:public:is:us-south:a/123456::image:72b27b5c-f4b0-48bb-b954-5becc7c1dcb8","deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/images/72b27b5c-f4b0-48bb-b954-5becc7c1dcb8","id":"72b27b5c-f4b0-48bb-b954-5becc7c1dcb8","name":"my-image","remote":{"account":{"id":"aa2432b1fa4d4ace891e9b80fc104e34","resource_type":"account"},"region":{"href":"https://us-south.iaas.cloud.ibm.com/v1/regions/us-south","name":"us-south"}},"resource_type":"image"},"source_snapshot":{"crn":"crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263","deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263","id":"r134-f6bfa329-0e36-433f-a3bb-0df632e79263","name":"my-snapshot","remote":{"region":{"href":"https://us-south.iaas.cloud.ibm.com/v1/regions/us-south","name":"us-south"}},"resource_type":"snapshot"},"status":"available","status_reasons":[{"code":"encryption_key_deleted","message":"Message","more_info":"https://cloud.ibm.com/docs/key-protect?topic=key-protect-restore-keys"}],"user_tags":["UserTags"],"volume_attachments":[{"delete_volume_on_instance_delete":true,"deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"device":{"id":"80b3e36e-41f4-40e9-bd56-beae81792a68"},"href":"https://us-south.iaas.cloud.ibm.com/v1/instances/1e09281b-f177-46fb-baf1-bc152b2e391a/volume_attachments/82cbf856-9cbb-45fb-b62f-d7bcef32399a","id":"82cbf856-9cbb-45fb-b62f-d7bcef32399a","instance":{"crn":"crn:v1:bluemix:public:is:us-south-1:a/123456::instance:1e09281b-f177-46fb-baf1-bc152b2e391a","deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/instances/1e09281b-f177-46fb-baf1-bc152b2e391a","id":"1e09281b-f177-46fb-baf1-bc152b2e391a","name":"my-instance"},"name":"my-volume-attachment","type":"boot"}],"zone":{"href":"https://us-south.iaas.cloud.ibm.com/v1/regions/us-south/zones/us-south-1","name":"us-south-1"}}]}`) + } else if requestNumber == 2 { + fmt.Fprintf(res, "%s", `{"total_count":2,"limit":1,"volumes":[{"active":true,"attachment_state":"attached","bandwidth":1000,"busy":true,"capacity":1000,"created_at":"2019-01-01T12:00:00.000Z","crn":"crn:v1:bluemix:public:is:us-south-1:a/123456::volume:1a6b7274-678d-4dfb-8981-c71dd9d4daa5","encryption":"provider_managed","encryption_key":{"crn":"crn:v1:bluemix:public:kms:us-south:a/123456:e4a29d1a-2ef0-42a6-8fd2-350deb1c647e:key:5437653b-c4b1-447f-9646-b2a2a4cd6179"},"health_reasons":[{"code":"initializing_from_snapshot","message":"Performance will be degraded while this volume is being initialized from its snapshot","more_info":"https://cloud.ibm.com/docs/vpc?topic=vpc-snapshots-vpc-troubleshooting&interface=ui#snapshot_ts_degraded_perf"}],"health_state":"ok","href":"https://us-south.iaas.cloud.ibm.com/v1/volumes/1a6b7274-678d-4dfb-8981-c71dd9d4daa5","id":"1a6b7274-678d-4dfb-8981-c71dd9d4daa5","iops":10000,"name":"my-volume","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"},"profile":{"href":"https://us-south.iaas.cloud.ibm.com/v1/volume/profiles/general-purpose","name":"general-purpose"},"resource_group":{"href":"https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345","id":"fee82deba12e4c0fb69c3b09d1f12345","name":"my-resource-group"},"resource_type":"volume","source_image":{"crn":"crn:v1:bluemix:public:is:us-south:a/123456::image:72b27b5c-f4b0-48bb-b954-5becc7c1dcb8","deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/images/72b27b5c-f4b0-48bb-b954-5becc7c1dcb8","id":"72b27b5c-f4b0-48bb-b954-5becc7c1dcb8","name":"my-image","remote":{"account":{"id":"aa2432b1fa4d4ace891e9b80fc104e34","resource_type":"account"},"region":{"href":"https://us-south.iaas.cloud.ibm.com/v1/regions/us-south","name":"us-south"}},"resource_type":"image"},"source_snapshot":{"crn":"crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263","deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263","id":"r134-f6bfa329-0e36-433f-a3bb-0df632e79263","name":"my-snapshot","remote":{"region":{"href":"https://us-south.iaas.cloud.ibm.com/v1/regions/us-south","name":"us-south"}},"resource_type":"snapshot"},"status":"available","status_reasons":[{"code":"encryption_key_deleted","message":"Message","more_info":"https://cloud.ibm.com/docs/key-protect?topic=key-protect-restore-keys"}],"user_tags":["UserTags"],"volume_attachments":[{"delete_volume_on_instance_delete":true,"deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"device":{"id":"80b3e36e-41f4-40e9-bd56-beae81792a68"},"href":"https://us-south.iaas.cloud.ibm.com/v1/instances/1e09281b-f177-46fb-baf1-bc152b2e391a/volume_attachments/82cbf856-9cbb-45fb-b62f-d7bcef32399a","id":"82cbf856-9cbb-45fb-b62f-d7bcef32399a","instance":{"crn":"crn:v1:bluemix:public:is:us-south-1:a/123456::instance:1e09281b-f177-46fb-baf1-bc152b2e391a","deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/instances/1e09281b-f177-46fb-baf1-bc152b2e391a","id":"1e09281b-f177-46fb-baf1-bc152b2e391a","name":"my-instance"},"name":"my-volume-attachment","type":"boot"}],"zone":{"href":"https://us-south.iaas.cloud.ibm.com/v1/regions/us-south/zones/us-south-1","name":"us-south-1"}}]}`) + } else { + res.WriteHeader(400) + } })) }) - It(`Invoke DeleteBareMetalServerNetworkInterface successfully`, func() { + It(`Use VolumesPager.GetNext successfully`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -50662,23 +50548,31 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Invoke operation with nil options model (negative test) - response, operationErr := vpcService.DeleteBareMetalServerNetworkInterface(nil) - Expect(operationErr).NotTo(BeNil()) - Expect(response).To(BeNil()) + listVolumesOptionsModel := &vpcv1.ListVolumesOptions{ + Limit: core.Int64Ptr(int64(10)), + Name: core.StringPtr("testString"), + AttachmentState: core.StringPtr("attached"), + Encryption: core.StringPtr("provider_managed"), + OperatingSystemFamily: core.StringPtr("Ubuntu Server"), + OperatingSystemArchitecture: core.StringPtr("amd64"), + ZoneName: core.StringPtr("us-south-1"), + Tag: core.StringPtr("testString"), + } - // Construct an instance of the DeleteBareMetalServerNetworkInterfaceOptions model - deleteBareMetalServerNetworkInterfaceOptionsModel := new(vpcv1.DeleteBareMetalServerNetworkInterfaceOptions) - deleteBareMetalServerNetworkInterfaceOptionsModel.BareMetalServerID = core.StringPtr("testString") - deleteBareMetalServerNetworkInterfaceOptionsModel.ID = core.StringPtr("testString") - deleteBareMetalServerNetworkInterfaceOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + pager, err := vpcService.NewVolumesPager(listVolumesOptionsModel) + Expect(err).To(BeNil()) + Expect(pager).ToNot(BeNil()) - // Invoke operation with valid options model (positive test) - response, operationErr = vpcService.DeleteBareMetalServerNetworkInterface(deleteBareMetalServerNetworkInterfaceOptionsModel) - Expect(operationErr).To(BeNil()) - Expect(response).ToNot(BeNil()) + var allResults []vpcv1.Volume + for pager.HasNext() { + nextPage, err := pager.GetNext() + Expect(err).To(BeNil()) + Expect(nextPage).ToNot(BeNil()) + allResults = append(allResults, nextPage...) + } + Expect(len(allResults)).To(Equal(2)) }) - It(`Invoke DeleteBareMetalServerNetworkInterface with error: Operation validation and request error`, func() { + It(`Use VolumesPager.GetAll successfully`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -50687,49 +50581,47 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the DeleteBareMetalServerNetworkInterfaceOptions model - deleteBareMetalServerNetworkInterfaceOptionsModel := new(vpcv1.DeleteBareMetalServerNetworkInterfaceOptions) - deleteBareMetalServerNetworkInterfaceOptionsModel.BareMetalServerID = core.StringPtr("testString") - deleteBareMetalServerNetworkInterfaceOptionsModel.ID = core.StringPtr("testString") - deleteBareMetalServerNetworkInterfaceOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} - // Invoke operation with empty URL (negative test) - err := vpcService.SetServiceURL("") + listVolumesOptionsModel := &vpcv1.ListVolumesOptions{ + Limit: core.Int64Ptr(int64(10)), + Name: core.StringPtr("testString"), + AttachmentState: core.StringPtr("attached"), + Encryption: core.StringPtr("provider_managed"), + OperatingSystemFamily: core.StringPtr("Ubuntu Server"), + OperatingSystemArchitecture: core.StringPtr("amd64"), + ZoneName: core.StringPtr("us-south-1"), + Tag: core.StringPtr("testString"), + } + + pager, err := vpcService.NewVolumesPager(listVolumesOptionsModel) Expect(err).To(BeNil()) - response, operationErr := vpcService.DeleteBareMetalServerNetworkInterface(deleteBareMetalServerNetworkInterfaceOptionsModel) - Expect(operationErr).ToNot(BeNil()) - Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING)) - Expect(response).To(BeNil()) - // Construct a second instance of the DeleteBareMetalServerNetworkInterfaceOptions model with no property values - deleteBareMetalServerNetworkInterfaceOptionsModelNew := new(vpcv1.DeleteBareMetalServerNetworkInterfaceOptions) - // Invoke operation with invalid model (negative test) - response, operationErr = vpcService.DeleteBareMetalServerNetworkInterface(deleteBareMetalServerNetworkInterfaceOptionsModelNew) - Expect(operationErr).ToNot(BeNil()) - Expect(response).To(BeNil()) - }) - AfterEach(func() { - testServer.Close() + Expect(pager).ToNot(BeNil()) + + allResults, err := pager.GetAll() + Expect(err).To(BeNil()) + Expect(allResults).ToNot(BeNil()) + Expect(len(allResults)).To(Equal(2)) }) }) }) - Describe(`GetBareMetalServerNetworkInterface(getBareMetalServerNetworkInterfaceOptions *GetBareMetalServerNetworkInterfaceOptions) - Operation response error`, func() { + Describe(`CreateVolume(createVolumeOptions *CreateVolumeOptions) - Operation response error`, func() { version := "testString" - getBareMetalServerNetworkInterfacePath := "/bare_metal_servers/testString/network_interfaces/testString" + createVolumePath := "/volumes" 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(getBareMetalServerNetworkInterfacePath)) - Expect(req.Method).To(Equal("GET")) + Expect(req.URL.EscapedPath()).To(Equal(createVolumePath)) + 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 GetBareMetalServerNetworkInterface with error: Operation response processing error`, func() { + It(`Invoke CreateVolume with error: Operation response processing error`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -50738,20 +50630,46 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the GetBareMetalServerNetworkInterfaceOptions model - getBareMetalServerNetworkInterfaceOptionsModel := new(vpcv1.GetBareMetalServerNetworkInterfaceOptions) - getBareMetalServerNetworkInterfaceOptionsModel.BareMetalServerID = core.StringPtr("testString") - getBareMetalServerNetworkInterfaceOptionsModel.ID = core.StringPtr("testString") - getBareMetalServerNetworkInterfaceOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the VolumeProfileIdentityByName model + volumeProfileIdentityModel := new(vpcv1.VolumeProfileIdentityByName) + volumeProfileIdentityModel.Name = core.StringPtr("5iops-tier") + + // Construct an instance of the ResourceGroupIdentityByID model + resourceGroupIdentityModel := new(vpcv1.ResourceGroupIdentityByID) + resourceGroupIdentityModel.ID = core.StringPtr("fee82deba12e4c0fb69c3b09d1f12345") + + // Construct an instance of the ZoneIdentityByName model + zoneIdentityModel := new(vpcv1.ZoneIdentityByName) + zoneIdentityModel.Name = core.StringPtr("us-south-1") + + // Construct an instance of the EncryptionKeyIdentityByCRN model + encryptionKeyIdentityModel := new(vpcv1.EncryptionKeyIdentityByCRN) + encryptionKeyIdentityModel.CRN = core.StringPtr("crn:v1:bluemix:public:kms:us-south:a/123456:e4a29d1a-2ef0-42a6-8fd2-350deb1c647e:key:5437653b-c4b1-447f-9646-b2a2a4cd6179") + + // Construct an instance of the VolumePrototypeVolumeByCapacity model + volumePrototypeModel := new(vpcv1.VolumePrototypeVolumeByCapacity) + volumePrototypeModel.Iops = core.Int64Ptr(int64(10000)) + volumePrototypeModel.Name = core.StringPtr("my-volume") + volumePrototypeModel.Profile = volumeProfileIdentityModel + volumePrototypeModel.ResourceGroup = resourceGroupIdentityModel + volumePrototypeModel.UserTags = []string{} + volumePrototypeModel.Zone = zoneIdentityModel + volumePrototypeModel.Capacity = core.Int64Ptr(int64(100)) + volumePrototypeModel.EncryptionKey = encryptionKeyIdentityModel + + // Construct an instance of the CreateVolumeOptions model + createVolumeOptionsModel := new(vpcv1.CreateVolumeOptions) + createVolumeOptionsModel.VolumePrototype = volumePrototypeModel + createVolumeOptionsModel.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.GetBareMetalServerNetworkInterface(getBareMetalServerNetworkInterfaceOptionsModel) + result, response, operationErr := vpcService.CreateVolume(createVolumeOptionsModel) 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.GetBareMetalServerNetworkInterface(getBareMetalServerNetworkInterfaceOptionsModel) + result, response, operationErr = vpcService.CreateVolume(createVolumeOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).To(BeNil()) @@ -50761,17 +50679,33 @@ var _ = Describe(`VpcV1`, func() { }) }) }) - Describe(`GetBareMetalServerNetworkInterface(getBareMetalServerNetworkInterfaceOptions *GetBareMetalServerNetworkInterfaceOptions)`, func() { + Describe(`CreateVolume(createVolumeOptions *CreateVolumeOptions)`, func() { version := "testString" - getBareMetalServerNetworkInterfacePath := "/bare_metal_servers/testString/network_interfaces/testString" + createVolumePath := "/volumes" 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(getBareMetalServerNetworkInterfacePath)) - Expect(req.Method).To(Equal("GET")) + Expect(req.URL.EscapedPath()).To(Equal(createVolumePath)) + 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))})) @@ -50780,11 +50714,11 @@ var _ = Describe(`VpcV1`, func() { // Set mock response res.Header().Set("Content-type", "application/json") - res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"allow_ip_spoofing": true, "created_at": "2019-01-01T12:00:00.000Z", "enable_infrastructure_nat": true, "floating_ips": [{"address": "203.0.113.1", "crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::floating-ip:39300233-9995-4806-89a5-3c1b6eb88689", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/floating_ips/39300233-9995-4806-89a5-3c1b6eb88689", "id": "39300233-9995-4806-89a5-3c1b6eb88689", "name": "my-floating-ip"}], "href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/1e09281b-f177-46fb-baf1-bc152b2e391a/network_interfaces/10c02d81-0ecb-4dc5-897d-28392913b81e", "id": "10c02d81-0ecb-4dc5-897d-28392913b81e", "mac_address": "02:00:04:00:C4:6A", "name": "my-bare-metal-server-network-interface", "port_speed": 1000, "primary_ip": {"address": "192.168.3.4", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e/reserved_ips/6d353a0f-aeb1-4ae1-832e-1110d10981bb", "id": "6d353a0f-aeb1-4ae1-832e-1110d10981bb", "name": "my-reserved-ip", "resource_type": "subnet_reserved_ip"}, "resource_type": "network_interface", "security_groups": [{"crn": "crn:v1:bluemix:public:is:us-south:a/123456::security-group:be5df5ca-12a0-494b-907e-aa6ec2bfa271", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/security_groups/be5df5ca-12a0-494b-907e-aa6ec2bfa271", "id": "be5df5ca-12a0-494b-907e-aa6ec2bfa271", "name": "my-security-group"}], "status": "available", "subnet": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "id": "7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "name": "my-subnet", "resource_type": "subnet"}, "type": "primary", "interface_type": "hipersocket"}`) + res.WriteHeader(201) + fmt.Fprintf(res, "%s", `{"active": true, "attachment_state": "attached", "bandwidth": 1000, "busy": true, "capacity": 1000, "created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::volume:1a6b7274-678d-4dfb-8981-c71dd9d4daa5", "encryption": "provider_managed", "encryption_key": {"crn": "crn:v1:bluemix:public:kms:us-south:a/123456:e4a29d1a-2ef0-42a6-8fd2-350deb1c647e:key:5437653b-c4b1-447f-9646-b2a2a4cd6179"}, "health_reasons": [{"code": "initializing_from_snapshot", "message": "Performance will be degraded while this volume is being initialized from its snapshot", "more_info": "https://cloud.ibm.com/docs/vpc?topic=vpc-snapshots-vpc-troubleshooting&interface=ui#snapshot_ts_degraded_perf"}], "health_state": "ok", "href": "https://us-south.iaas.cloud.ibm.com/v1/volumes/1a6b7274-678d-4dfb-8981-c71dd9d4daa5", "id": "1a6b7274-678d-4dfb-8981-c71dd9d4daa5", "iops": 10000, "name": "my-volume", "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"}, "profile": {"href": "https://us-south.iaas.cloud.ibm.com/v1/volume/profiles/general-purpose", "name": "general-purpose"}, "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "resource_type": "volume", "source_image": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::image:72b27b5c-f4b0-48bb-b954-5becc7c1dcb8", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/images/72b27b5c-f4b0-48bb-b954-5becc7c1dcb8", "id": "72b27b5c-f4b0-48bb-b954-5becc7c1dcb8", "name": "my-image", "remote": {"account": {"id": "aa2432b1fa4d4ace891e9b80fc104e34", "resource_type": "account"}, "region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "image"}, "source_snapshot": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "id": "r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "name": "my-snapshot", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "snapshot"}, "status": "available", "status_reasons": [{"code": "encryption_key_deleted", "message": "Message", "more_info": "https://cloud.ibm.com/docs/key-protect?topic=key-protect-restore-keys"}], "user_tags": ["UserTags"], "volume_attachments": [{"delete_volume_on_instance_delete": true, "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "device": {"id": "80b3e36e-41f4-40e9-bd56-beae81792a68"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/instances/1e09281b-f177-46fb-baf1-bc152b2e391a/volume_attachments/82cbf856-9cbb-45fb-b62f-d7bcef32399a", "id": "82cbf856-9cbb-45fb-b62f-d7bcef32399a", "instance": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::instance:1e09281b-f177-46fb-baf1-bc152b2e391a", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/instances/1e09281b-f177-46fb-baf1-bc152b2e391a", "id": "1e09281b-f177-46fb-baf1-bc152b2e391a", "name": "my-instance"}, "name": "my-volume-attachment", "type": "boot"}], "zone": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south/zones/us-south-1", "name": "us-south-1"}}`) })) }) - It(`Invoke GetBareMetalServerNetworkInterface successfully with retries`, func() { + It(`Invoke CreateVolume successfully with retries`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -50794,22 +50728,48 @@ var _ = Describe(`VpcV1`, func() { Expect(vpcService).ToNot(BeNil()) vpcService.EnableRetries(0, 0) - // Construct an instance of the GetBareMetalServerNetworkInterfaceOptions model - getBareMetalServerNetworkInterfaceOptionsModel := new(vpcv1.GetBareMetalServerNetworkInterfaceOptions) - getBareMetalServerNetworkInterfaceOptionsModel.BareMetalServerID = core.StringPtr("testString") - getBareMetalServerNetworkInterfaceOptionsModel.ID = core.StringPtr("testString") - getBareMetalServerNetworkInterfaceOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the VolumeProfileIdentityByName model + volumeProfileIdentityModel := new(vpcv1.VolumeProfileIdentityByName) + volumeProfileIdentityModel.Name = core.StringPtr("5iops-tier") + + // Construct an instance of the ResourceGroupIdentityByID model + resourceGroupIdentityModel := new(vpcv1.ResourceGroupIdentityByID) + resourceGroupIdentityModel.ID = core.StringPtr("fee82deba12e4c0fb69c3b09d1f12345") + + // Construct an instance of the ZoneIdentityByName model + zoneIdentityModel := new(vpcv1.ZoneIdentityByName) + zoneIdentityModel.Name = core.StringPtr("us-south-1") + + // Construct an instance of the EncryptionKeyIdentityByCRN model + encryptionKeyIdentityModel := new(vpcv1.EncryptionKeyIdentityByCRN) + encryptionKeyIdentityModel.CRN = core.StringPtr("crn:v1:bluemix:public:kms:us-south:a/123456:e4a29d1a-2ef0-42a6-8fd2-350deb1c647e:key:5437653b-c4b1-447f-9646-b2a2a4cd6179") + + // Construct an instance of the VolumePrototypeVolumeByCapacity model + volumePrototypeModel := new(vpcv1.VolumePrototypeVolumeByCapacity) + volumePrototypeModel.Iops = core.Int64Ptr(int64(10000)) + volumePrototypeModel.Name = core.StringPtr("my-volume") + volumePrototypeModel.Profile = volumeProfileIdentityModel + volumePrototypeModel.ResourceGroup = resourceGroupIdentityModel + volumePrototypeModel.UserTags = []string{} + volumePrototypeModel.Zone = zoneIdentityModel + volumePrototypeModel.Capacity = core.Int64Ptr(int64(100)) + volumePrototypeModel.EncryptionKey = encryptionKeyIdentityModel + + // Construct an instance of the CreateVolumeOptions model + createVolumeOptionsModel := new(vpcv1.CreateVolumeOptions) + createVolumeOptionsModel.VolumePrototype = volumePrototypeModel + createVolumeOptionsModel.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.GetBareMetalServerNetworkInterfaceWithContext(ctx, getBareMetalServerNetworkInterfaceOptionsModel) + _, _, operationErr := vpcService.CreateVolumeWithContext(ctx, createVolumeOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) // Disable retries and test again vpcService.DisableRetries() - result, response, operationErr := vpcService.GetBareMetalServerNetworkInterface(getBareMetalServerNetworkInterfaceOptionsModel) + result, response, operationErr := vpcService.CreateVolume(createVolumeOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) @@ -50817,7 +50777,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.GetBareMetalServerNetworkInterfaceWithContext(ctx, getBareMetalServerNetworkInterfaceOptionsModel) + _, _, operationErr = vpcService.CreateVolumeWithContext(ctx, createVolumeOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) }) @@ -50831,18 +50791,34 @@ var _ = Describe(`VpcV1`, func() { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(getBareMetalServerNetworkInterfacePath)) - Expect(req.Method).To(Equal("GET")) + Expect(req.URL.EscapedPath()).To(Equal(createVolumePath)) + 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(200) - fmt.Fprintf(res, "%s", `{"allow_ip_spoofing": true, "created_at": "2019-01-01T12:00:00.000Z", "enable_infrastructure_nat": true, "floating_ips": [{"address": "203.0.113.1", "crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::floating-ip:39300233-9995-4806-89a5-3c1b6eb88689", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/floating_ips/39300233-9995-4806-89a5-3c1b6eb88689", "id": "39300233-9995-4806-89a5-3c1b6eb88689", "name": "my-floating-ip"}], "href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/1e09281b-f177-46fb-baf1-bc152b2e391a/network_interfaces/10c02d81-0ecb-4dc5-897d-28392913b81e", "id": "10c02d81-0ecb-4dc5-897d-28392913b81e", "mac_address": "02:00:04:00:C4:6A", "name": "my-bare-metal-server-network-interface", "port_speed": 1000, "primary_ip": {"address": "192.168.3.4", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e/reserved_ips/6d353a0f-aeb1-4ae1-832e-1110d10981bb", "id": "6d353a0f-aeb1-4ae1-832e-1110d10981bb", "name": "my-reserved-ip", "resource_type": "subnet_reserved_ip"}, "resource_type": "network_interface", "security_groups": [{"crn": "crn:v1:bluemix:public:is:us-south:a/123456::security-group:be5df5ca-12a0-494b-907e-aa6ec2bfa271", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/security_groups/be5df5ca-12a0-494b-907e-aa6ec2bfa271", "id": "be5df5ca-12a0-494b-907e-aa6ec2bfa271", "name": "my-security-group"}], "status": "available", "subnet": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "id": "7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "name": "my-subnet", "resource_type": "subnet"}, "type": "primary", "interface_type": "hipersocket"}`) + res.WriteHeader(201) + fmt.Fprintf(res, "%s", `{"active": true, "attachment_state": "attached", "bandwidth": 1000, "busy": true, "capacity": 1000, "created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::volume:1a6b7274-678d-4dfb-8981-c71dd9d4daa5", "encryption": "provider_managed", "encryption_key": {"crn": "crn:v1:bluemix:public:kms:us-south:a/123456:e4a29d1a-2ef0-42a6-8fd2-350deb1c647e:key:5437653b-c4b1-447f-9646-b2a2a4cd6179"}, "health_reasons": [{"code": "initializing_from_snapshot", "message": "Performance will be degraded while this volume is being initialized from its snapshot", "more_info": "https://cloud.ibm.com/docs/vpc?topic=vpc-snapshots-vpc-troubleshooting&interface=ui#snapshot_ts_degraded_perf"}], "health_state": "ok", "href": "https://us-south.iaas.cloud.ibm.com/v1/volumes/1a6b7274-678d-4dfb-8981-c71dd9d4daa5", "id": "1a6b7274-678d-4dfb-8981-c71dd9d4daa5", "iops": 10000, "name": "my-volume", "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"}, "profile": {"href": "https://us-south.iaas.cloud.ibm.com/v1/volume/profiles/general-purpose", "name": "general-purpose"}, "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "resource_type": "volume", "source_image": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::image:72b27b5c-f4b0-48bb-b954-5becc7c1dcb8", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/images/72b27b5c-f4b0-48bb-b954-5becc7c1dcb8", "id": "72b27b5c-f4b0-48bb-b954-5becc7c1dcb8", "name": "my-image", "remote": {"account": {"id": "aa2432b1fa4d4ace891e9b80fc104e34", "resource_type": "account"}, "region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "image"}, "source_snapshot": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "id": "r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "name": "my-snapshot", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "snapshot"}, "status": "available", "status_reasons": [{"code": "encryption_key_deleted", "message": "Message", "more_info": "https://cloud.ibm.com/docs/key-protect?topic=key-protect-restore-keys"}], "user_tags": ["UserTags"], "volume_attachments": [{"delete_volume_on_instance_delete": true, "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "device": {"id": "80b3e36e-41f4-40e9-bd56-beae81792a68"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/instances/1e09281b-f177-46fb-baf1-bc152b2e391a/volume_attachments/82cbf856-9cbb-45fb-b62f-d7bcef32399a", "id": "82cbf856-9cbb-45fb-b62f-d7bcef32399a", "instance": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::instance:1e09281b-f177-46fb-baf1-bc152b2e391a", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/instances/1e09281b-f177-46fb-baf1-bc152b2e391a", "id": "1e09281b-f177-46fb-baf1-bc152b2e391a", "name": "my-instance"}, "name": "my-volume-attachment", "type": "boot"}], "zone": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south/zones/us-south-1", "name": "us-south-1"}}`) })) }) - It(`Invoke GetBareMetalServerNetworkInterface successfully`, func() { + It(`Invoke CreateVolume successfully`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -50852,25 +50828,51 @@ var _ = Describe(`VpcV1`, func() { Expect(vpcService).ToNot(BeNil()) // Invoke operation with nil options model (negative test) - result, response, operationErr := vpcService.GetBareMetalServerNetworkInterface(nil) + result, response, operationErr := vpcService.CreateVolume(nil) Expect(operationErr).NotTo(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) - // Construct an instance of the GetBareMetalServerNetworkInterfaceOptions model - getBareMetalServerNetworkInterfaceOptionsModel := new(vpcv1.GetBareMetalServerNetworkInterfaceOptions) - getBareMetalServerNetworkInterfaceOptionsModel.BareMetalServerID = core.StringPtr("testString") - getBareMetalServerNetworkInterfaceOptionsModel.ID = core.StringPtr("testString") - getBareMetalServerNetworkInterfaceOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the VolumeProfileIdentityByName model + volumeProfileIdentityModel := new(vpcv1.VolumeProfileIdentityByName) + volumeProfileIdentityModel.Name = core.StringPtr("5iops-tier") + + // Construct an instance of the ResourceGroupIdentityByID model + resourceGroupIdentityModel := new(vpcv1.ResourceGroupIdentityByID) + resourceGroupIdentityModel.ID = core.StringPtr("fee82deba12e4c0fb69c3b09d1f12345") + + // Construct an instance of the ZoneIdentityByName model + zoneIdentityModel := new(vpcv1.ZoneIdentityByName) + zoneIdentityModel.Name = core.StringPtr("us-south-1") + + // Construct an instance of the EncryptionKeyIdentityByCRN model + encryptionKeyIdentityModel := new(vpcv1.EncryptionKeyIdentityByCRN) + encryptionKeyIdentityModel.CRN = core.StringPtr("crn:v1:bluemix:public:kms:us-south:a/123456:e4a29d1a-2ef0-42a6-8fd2-350deb1c647e:key:5437653b-c4b1-447f-9646-b2a2a4cd6179") + + // Construct an instance of the VolumePrototypeVolumeByCapacity model + volumePrototypeModel := new(vpcv1.VolumePrototypeVolumeByCapacity) + volumePrototypeModel.Iops = core.Int64Ptr(int64(10000)) + volumePrototypeModel.Name = core.StringPtr("my-volume") + volumePrototypeModel.Profile = volumeProfileIdentityModel + volumePrototypeModel.ResourceGroup = resourceGroupIdentityModel + volumePrototypeModel.UserTags = []string{} + volumePrototypeModel.Zone = zoneIdentityModel + volumePrototypeModel.Capacity = core.Int64Ptr(int64(100)) + volumePrototypeModel.EncryptionKey = encryptionKeyIdentityModel + + // Construct an instance of the CreateVolumeOptions model + createVolumeOptionsModel := new(vpcv1.CreateVolumeOptions) + createVolumeOptionsModel.VolumePrototype = volumePrototypeModel + createVolumeOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with valid options model (positive test) - result, response, operationErr = vpcService.GetBareMetalServerNetworkInterface(getBareMetalServerNetworkInterfaceOptionsModel) + result, response, operationErr = vpcService.CreateVolume(createVolumeOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) }) - It(`Invoke GetBareMetalServerNetworkInterface with error: Operation validation and request error`, func() { + It(`Invoke CreateVolume with error: Operation validation and request error`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -50879,23 +50881,49 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the GetBareMetalServerNetworkInterfaceOptions model - getBareMetalServerNetworkInterfaceOptionsModel := new(vpcv1.GetBareMetalServerNetworkInterfaceOptions) - getBareMetalServerNetworkInterfaceOptionsModel.BareMetalServerID = core.StringPtr("testString") - getBareMetalServerNetworkInterfaceOptionsModel.ID = core.StringPtr("testString") - getBareMetalServerNetworkInterfaceOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the VolumeProfileIdentityByName model + volumeProfileIdentityModel := new(vpcv1.VolumeProfileIdentityByName) + volumeProfileIdentityModel.Name = core.StringPtr("5iops-tier") + + // Construct an instance of the ResourceGroupIdentityByID model + resourceGroupIdentityModel := new(vpcv1.ResourceGroupIdentityByID) + resourceGroupIdentityModel.ID = core.StringPtr("fee82deba12e4c0fb69c3b09d1f12345") + + // Construct an instance of the ZoneIdentityByName model + zoneIdentityModel := new(vpcv1.ZoneIdentityByName) + zoneIdentityModel.Name = core.StringPtr("us-south-1") + + // Construct an instance of the EncryptionKeyIdentityByCRN model + encryptionKeyIdentityModel := new(vpcv1.EncryptionKeyIdentityByCRN) + encryptionKeyIdentityModel.CRN = core.StringPtr("crn:v1:bluemix:public:kms:us-south:a/123456:e4a29d1a-2ef0-42a6-8fd2-350deb1c647e:key:5437653b-c4b1-447f-9646-b2a2a4cd6179") + + // Construct an instance of the VolumePrototypeVolumeByCapacity model + volumePrototypeModel := new(vpcv1.VolumePrototypeVolumeByCapacity) + volumePrototypeModel.Iops = core.Int64Ptr(int64(10000)) + volumePrototypeModel.Name = core.StringPtr("my-volume") + volumePrototypeModel.Profile = volumeProfileIdentityModel + volumePrototypeModel.ResourceGroup = resourceGroupIdentityModel + volumePrototypeModel.UserTags = []string{} + volumePrototypeModel.Zone = zoneIdentityModel + volumePrototypeModel.Capacity = core.Int64Ptr(int64(100)) + volumePrototypeModel.EncryptionKey = encryptionKeyIdentityModel + + // Construct an instance of the CreateVolumeOptions model + createVolumeOptionsModel := new(vpcv1.CreateVolumeOptions) + createVolumeOptionsModel.VolumePrototype = volumePrototypeModel + createVolumeOptionsModel.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.GetBareMetalServerNetworkInterface(getBareMetalServerNetworkInterfaceOptionsModel) + result, response, operationErr := vpcService.CreateVolume(createVolumeOptionsModel) 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 GetBareMetalServerNetworkInterfaceOptions model with no property values - getBareMetalServerNetworkInterfaceOptionsModelNew := new(vpcv1.GetBareMetalServerNetworkInterfaceOptions) + // Construct a second instance of the CreateVolumeOptions model with no property values + createVolumeOptionsModelNew := new(vpcv1.CreateVolumeOptions) // Invoke operation with invalid model (negative test) - result, response, operationErr = vpcService.GetBareMetalServerNetworkInterface(getBareMetalServerNetworkInterfaceOptionsModelNew) + result, response, operationErr = vpcService.CreateVolume(createVolumeOptionsModelNew) Expect(operationErr).ToNot(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) @@ -50910,10 +50938,10 @@ var _ = Describe(`VpcV1`, func() { defer GinkgoRecover() // Set success status code with no respoonse body - res.WriteHeader(200) + res.WriteHeader(201) })) }) - It(`Invoke GetBareMetalServerNetworkInterface successfully`, func() { + It(`Invoke CreateVolume successfully`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -50922,14 +50950,40 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the GetBareMetalServerNetworkInterfaceOptions model - getBareMetalServerNetworkInterfaceOptionsModel := new(vpcv1.GetBareMetalServerNetworkInterfaceOptions) - getBareMetalServerNetworkInterfaceOptionsModel.BareMetalServerID = core.StringPtr("testString") - getBareMetalServerNetworkInterfaceOptionsModel.ID = core.StringPtr("testString") - getBareMetalServerNetworkInterfaceOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the VolumeProfileIdentityByName model + volumeProfileIdentityModel := new(vpcv1.VolumeProfileIdentityByName) + volumeProfileIdentityModel.Name = core.StringPtr("5iops-tier") + + // Construct an instance of the ResourceGroupIdentityByID model + resourceGroupIdentityModel := new(vpcv1.ResourceGroupIdentityByID) + resourceGroupIdentityModel.ID = core.StringPtr("fee82deba12e4c0fb69c3b09d1f12345") + + // Construct an instance of the ZoneIdentityByName model + zoneIdentityModel := new(vpcv1.ZoneIdentityByName) + zoneIdentityModel.Name = core.StringPtr("us-south-1") + + // Construct an instance of the EncryptionKeyIdentityByCRN model + encryptionKeyIdentityModel := new(vpcv1.EncryptionKeyIdentityByCRN) + encryptionKeyIdentityModel.CRN = core.StringPtr("crn:v1:bluemix:public:kms:us-south:a/123456:e4a29d1a-2ef0-42a6-8fd2-350deb1c647e:key:5437653b-c4b1-447f-9646-b2a2a4cd6179") + + // Construct an instance of the VolumePrototypeVolumeByCapacity model + volumePrototypeModel := new(vpcv1.VolumePrototypeVolumeByCapacity) + volumePrototypeModel.Iops = core.Int64Ptr(int64(10000)) + volumePrototypeModel.Name = core.StringPtr("my-volume") + volumePrototypeModel.Profile = volumeProfileIdentityModel + volumePrototypeModel.ResourceGroup = resourceGroupIdentityModel + volumePrototypeModel.UserTags = []string{} + volumePrototypeModel.Zone = zoneIdentityModel + volumePrototypeModel.Capacity = core.Int64Ptr(int64(100)) + volumePrototypeModel.EncryptionKey = encryptionKeyIdentityModel + + // Construct an instance of the CreateVolumeOptions model + createVolumeOptionsModel := new(vpcv1.CreateVolumeOptions) + createVolumeOptionsModel.VolumePrototype = volumePrototypeModel + createVolumeOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation - result, response, operationErr := vpcService.GetBareMetalServerNetworkInterface(getBareMetalServerNetworkInterfaceOptionsModel) + result, response, operationErr := vpcService.CreateVolume(createVolumeOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) @@ -50941,17 +50995,94 @@ var _ = Describe(`VpcV1`, func() { }) }) }) - Describe(`UpdateBareMetalServerNetworkInterface(updateBareMetalServerNetworkInterfaceOptions *UpdateBareMetalServerNetworkInterfaceOptions) - Operation response error`, func() { + Describe(`DeleteVolume(deleteVolumeOptions *DeleteVolumeOptions)`, func() { version := "testString" - updateBareMetalServerNetworkInterfacePath := "/bare_metal_servers/testString/network_interfaces/testString" + deleteVolumePath := "/volumes/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(deleteVolumePath)) + Expect(req.Method).To(Equal("DELETE")) + + Expect(req.Header["If-Match"]).ToNot(BeNil()) + Expect(req.Header["If-Match"][0]).To(Equal(fmt.Sprintf("%v", "W/\"96d225c4-56bd-43d9-98fc-d7148e5c5028\""))) + Expect(req.URL.Query()["version"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["generation"]).To(Equal([]string{fmt.Sprint(int64(2))})) + res.WriteHeader(204) + })) + }) + It(`Invoke DeleteVolume 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.DeleteVolume(nil) + Expect(operationErr).NotTo(BeNil()) + Expect(response).To(BeNil()) + + // Construct an instance of the DeleteVolumeOptions model + deleteVolumeOptionsModel := new(vpcv1.DeleteVolumeOptions) + deleteVolumeOptionsModel.ID = core.StringPtr("testString") + deleteVolumeOptionsModel.IfMatch = core.StringPtr("W/\"96d225c4-56bd-43d9-98fc-d7148e5c5028\"") + deleteVolumeOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation with valid options model (positive test) + response, operationErr = vpcService.DeleteVolume(deleteVolumeOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + }) + It(`Invoke DeleteVolume 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 DeleteVolumeOptions model + deleteVolumeOptionsModel := new(vpcv1.DeleteVolumeOptions) + deleteVolumeOptionsModel.ID = core.StringPtr("testString") + deleteVolumeOptionsModel.IfMatch = core.StringPtr("W/\"96d225c4-56bd-43d9-98fc-d7148e5c5028\"") + deleteVolumeOptionsModel.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.DeleteVolume(deleteVolumeOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING)) + Expect(response).To(BeNil()) + // Construct a second instance of the DeleteVolumeOptions model with no property values + deleteVolumeOptionsModelNew := new(vpcv1.DeleteVolumeOptions) + // Invoke operation with invalid model (negative test) + response, operationErr = vpcService.DeleteVolume(deleteVolumeOptionsModelNew) + Expect(operationErr).ToNot(BeNil()) + Expect(response).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + }) + Describe(`GetVolume(getVolumeOptions *GetVolumeOptions) - Operation response error`, func() { + version := "testString" + getVolumePath := "/volumes/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(updateBareMetalServerNetworkInterfacePath)) - Expect(req.Method).To(Equal("PATCH")) + Expect(req.URL.EscapedPath()).To(Equal(getVolumePath)) + 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") @@ -50959,7 +51090,7 @@ var _ = Describe(`VpcV1`, func() { fmt.Fprint(res, `} this is not valid json {`) })) }) - It(`Invoke UpdateBareMetalServerNetworkInterface with error: Operation response processing error`, func() { + It(`Invoke GetVolume with error: Operation response processing error`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -50968,30 +51099,19 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the BareMetalServerNetworkInterfacePatch model - bareMetalServerNetworkInterfacePatchModel := new(vpcv1.BareMetalServerNetworkInterfacePatch) - bareMetalServerNetworkInterfacePatchModel.AllowIPSpoofing = core.BoolPtr(true) - bareMetalServerNetworkInterfacePatchModel.AllowedVlans = []int64{int64(4)} - bareMetalServerNetworkInterfacePatchModel.EnableInfrastructureNat = core.BoolPtr(true) - bareMetalServerNetworkInterfacePatchModel.Name = core.StringPtr("my-bare-metal-server-network-interface") - bareMetalServerNetworkInterfacePatchModelAsPatch, asPatchErr := bareMetalServerNetworkInterfacePatchModel.AsPatch() - Expect(asPatchErr).To(BeNil()) - - // Construct an instance of the UpdateBareMetalServerNetworkInterfaceOptions model - updateBareMetalServerNetworkInterfaceOptionsModel := new(vpcv1.UpdateBareMetalServerNetworkInterfaceOptions) - updateBareMetalServerNetworkInterfaceOptionsModel.BareMetalServerID = core.StringPtr("testString") - updateBareMetalServerNetworkInterfaceOptionsModel.ID = core.StringPtr("testString") - updateBareMetalServerNetworkInterfaceOptionsModel.BareMetalServerNetworkInterfacePatch = bareMetalServerNetworkInterfacePatchModelAsPatch - updateBareMetalServerNetworkInterfaceOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the GetVolumeOptions model + getVolumeOptionsModel := new(vpcv1.GetVolumeOptions) + getVolumeOptionsModel.ID = core.StringPtr("testString") + getVolumeOptionsModel.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.UpdateBareMetalServerNetworkInterface(updateBareMetalServerNetworkInterfaceOptionsModel) + result, response, operationErr := vpcService.GetVolume(getVolumeOptionsModel) 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.UpdateBareMetalServerNetworkInterface(updateBareMetalServerNetworkInterfaceOptionsModel) + result, response, operationErr = vpcService.GetVolume(getVolumeOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).To(BeNil()) @@ -51001,33 +51121,17 @@ var _ = Describe(`VpcV1`, func() { }) }) }) - Describe(`UpdateBareMetalServerNetworkInterface(updateBareMetalServerNetworkInterfaceOptions *UpdateBareMetalServerNetworkInterfaceOptions)`, func() { + Describe(`GetVolume(getVolumeOptions *GetVolumeOptions)`, func() { version := "testString" - updateBareMetalServerNetworkInterfacePath := "/bare_metal_servers/testString/network_interfaces/testString" + getVolumePath := "/volumes/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(updateBareMetalServerNetworkInterfacePath)) - 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.URL.EscapedPath()).To(Equal(getVolumePath)) + 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))})) @@ -51037,10 +51141,10 @@ var _ = Describe(`VpcV1`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"allow_ip_spoofing": true, "created_at": "2019-01-01T12:00:00.000Z", "enable_infrastructure_nat": true, "floating_ips": [{"address": "203.0.113.1", "crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::floating-ip:39300233-9995-4806-89a5-3c1b6eb88689", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/floating_ips/39300233-9995-4806-89a5-3c1b6eb88689", "id": "39300233-9995-4806-89a5-3c1b6eb88689", "name": "my-floating-ip"}], "href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/1e09281b-f177-46fb-baf1-bc152b2e391a/network_interfaces/10c02d81-0ecb-4dc5-897d-28392913b81e", "id": "10c02d81-0ecb-4dc5-897d-28392913b81e", "mac_address": "02:00:04:00:C4:6A", "name": "my-bare-metal-server-network-interface", "port_speed": 1000, "primary_ip": {"address": "192.168.3.4", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e/reserved_ips/6d353a0f-aeb1-4ae1-832e-1110d10981bb", "id": "6d353a0f-aeb1-4ae1-832e-1110d10981bb", "name": "my-reserved-ip", "resource_type": "subnet_reserved_ip"}, "resource_type": "network_interface", "security_groups": [{"crn": "crn:v1:bluemix:public:is:us-south:a/123456::security-group:be5df5ca-12a0-494b-907e-aa6ec2bfa271", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/security_groups/be5df5ca-12a0-494b-907e-aa6ec2bfa271", "id": "be5df5ca-12a0-494b-907e-aa6ec2bfa271", "name": "my-security-group"}], "status": "available", "subnet": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "id": "7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "name": "my-subnet", "resource_type": "subnet"}, "type": "primary", "interface_type": "hipersocket"}`) + fmt.Fprintf(res, "%s", `{"active": true, "attachment_state": "attached", "bandwidth": 1000, "busy": true, "capacity": 1000, "created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::volume:1a6b7274-678d-4dfb-8981-c71dd9d4daa5", "encryption": "provider_managed", "encryption_key": {"crn": "crn:v1:bluemix:public:kms:us-south:a/123456:e4a29d1a-2ef0-42a6-8fd2-350deb1c647e:key:5437653b-c4b1-447f-9646-b2a2a4cd6179"}, "health_reasons": [{"code": "initializing_from_snapshot", "message": "Performance will be degraded while this volume is being initialized from its snapshot", "more_info": "https://cloud.ibm.com/docs/vpc?topic=vpc-snapshots-vpc-troubleshooting&interface=ui#snapshot_ts_degraded_perf"}], "health_state": "ok", "href": "https://us-south.iaas.cloud.ibm.com/v1/volumes/1a6b7274-678d-4dfb-8981-c71dd9d4daa5", "id": "1a6b7274-678d-4dfb-8981-c71dd9d4daa5", "iops": 10000, "name": "my-volume", "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"}, "profile": {"href": "https://us-south.iaas.cloud.ibm.com/v1/volume/profiles/general-purpose", "name": "general-purpose"}, "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "resource_type": "volume", "source_image": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::image:72b27b5c-f4b0-48bb-b954-5becc7c1dcb8", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/images/72b27b5c-f4b0-48bb-b954-5becc7c1dcb8", "id": "72b27b5c-f4b0-48bb-b954-5becc7c1dcb8", "name": "my-image", "remote": {"account": {"id": "aa2432b1fa4d4ace891e9b80fc104e34", "resource_type": "account"}, "region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "image"}, "source_snapshot": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "id": "r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "name": "my-snapshot", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "snapshot"}, "status": "available", "status_reasons": [{"code": "encryption_key_deleted", "message": "Message", "more_info": "https://cloud.ibm.com/docs/key-protect?topic=key-protect-restore-keys"}], "user_tags": ["UserTags"], "volume_attachments": [{"delete_volume_on_instance_delete": true, "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "device": {"id": "80b3e36e-41f4-40e9-bd56-beae81792a68"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/instances/1e09281b-f177-46fb-baf1-bc152b2e391a/volume_attachments/82cbf856-9cbb-45fb-b62f-d7bcef32399a", "id": "82cbf856-9cbb-45fb-b62f-d7bcef32399a", "instance": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::instance:1e09281b-f177-46fb-baf1-bc152b2e391a", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/instances/1e09281b-f177-46fb-baf1-bc152b2e391a", "id": "1e09281b-f177-46fb-baf1-bc152b2e391a", "name": "my-instance"}, "name": "my-volume-attachment", "type": "boot"}], "zone": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south/zones/us-south-1", "name": "us-south-1"}}`) })) }) - It(`Invoke UpdateBareMetalServerNetworkInterface successfully with retries`, func() { + It(`Invoke GetVolume successfully with retries`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -51050,32 +51154,21 @@ var _ = Describe(`VpcV1`, func() { Expect(vpcService).ToNot(BeNil()) vpcService.EnableRetries(0, 0) - // Construct an instance of the BareMetalServerNetworkInterfacePatch model - bareMetalServerNetworkInterfacePatchModel := new(vpcv1.BareMetalServerNetworkInterfacePatch) - bareMetalServerNetworkInterfacePatchModel.AllowIPSpoofing = core.BoolPtr(true) - bareMetalServerNetworkInterfacePatchModel.AllowedVlans = []int64{int64(4)} - bareMetalServerNetworkInterfacePatchModel.EnableInfrastructureNat = core.BoolPtr(true) - bareMetalServerNetworkInterfacePatchModel.Name = core.StringPtr("my-bare-metal-server-network-interface") - bareMetalServerNetworkInterfacePatchModelAsPatch, asPatchErr := bareMetalServerNetworkInterfacePatchModel.AsPatch() - Expect(asPatchErr).To(BeNil()) - - // Construct an instance of the UpdateBareMetalServerNetworkInterfaceOptions model - updateBareMetalServerNetworkInterfaceOptionsModel := new(vpcv1.UpdateBareMetalServerNetworkInterfaceOptions) - updateBareMetalServerNetworkInterfaceOptionsModel.BareMetalServerID = core.StringPtr("testString") - updateBareMetalServerNetworkInterfaceOptionsModel.ID = core.StringPtr("testString") - updateBareMetalServerNetworkInterfaceOptionsModel.BareMetalServerNetworkInterfacePatch = bareMetalServerNetworkInterfacePatchModelAsPatch - updateBareMetalServerNetworkInterfaceOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the GetVolumeOptions model + getVolumeOptionsModel := new(vpcv1.GetVolumeOptions) + getVolumeOptionsModel.ID = core.StringPtr("testString") + getVolumeOptionsModel.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.UpdateBareMetalServerNetworkInterfaceWithContext(ctx, updateBareMetalServerNetworkInterfaceOptionsModel) + _, _, operationErr := vpcService.GetVolumeWithContext(ctx, getVolumeOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) // Disable retries and test again vpcService.DisableRetries() - result, response, operationErr := vpcService.UpdateBareMetalServerNetworkInterface(updateBareMetalServerNetworkInterfaceOptionsModel) + result, response, operationErr := vpcService.GetVolume(getVolumeOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) @@ -51083,7 +51176,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.UpdateBareMetalServerNetworkInterfaceWithContext(ctx, updateBareMetalServerNetworkInterfaceOptionsModel) + _, _, operationErr = vpcService.GetVolumeWithContext(ctx, getVolumeOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) }) @@ -51097,34 +51190,18 @@ var _ = Describe(`VpcV1`, func() { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(updateBareMetalServerNetworkInterfacePath)) - 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.URL.EscapedPath()).To(Equal(getVolumePath)) + 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", `{"allow_ip_spoofing": true, "created_at": "2019-01-01T12:00:00.000Z", "enable_infrastructure_nat": true, "floating_ips": [{"address": "203.0.113.1", "crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::floating-ip:39300233-9995-4806-89a5-3c1b6eb88689", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/floating_ips/39300233-9995-4806-89a5-3c1b6eb88689", "id": "39300233-9995-4806-89a5-3c1b6eb88689", "name": "my-floating-ip"}], "href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/1e09281b-f177-46fb-baf1-bc152b2e391a/network_interfaces/10c02d81-0ecb-4dc5-897d-28392913b81e", "id": "10c02d81-0ecb-4dc5-897d-28392913b81e", "mac_address": "02:00:04:00:C4:6A", "name": "my-bare-metal-server-network-interface", "port_speed": 1000, "primary_ip": {"address": "192.168.3.4", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e/reserved_ips/6d353a0f-aeb1-4ae1-832e-1110d10981bb", "id": "6d353a0f-aeb1-4ae1-832e-1110d10981bb", "name": "my-reserved-ip", "resource_type": "subnet_reserved_ip"}, "resource_type": "network_interface", "security_groups": [{"crn": "crn:v1:bluemix:public:is:us-south:a/123456::security-group:be5df5ca-12a0-494b-907e-aa6ec2bfa271", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/security_groups/be5df5ca-12a0-494b-907e-aa6ec2bfa271", "id": "be5df5ca-12a0-494b-907e-aa6ec2bfa271", "name": "my-security-group"}], "status": "available", "subnet": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "id": "7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "name": "my-subnet", "resource_type": "subnet"}, "type": "primary", "interface_type": "hipersocket"}`) + fmt.Fprintf(res, "%s", `{"active": true, "attachment_state": "attached", "bandwidth": 1000, "busy": true, "capacity": 1000, "created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::volume:1a6b7274-678d-4dfb-8981-c71dd9d4daa5", "encryption": "provider_managed", "encryption_key": {"crn": "crn:v1:bluemix:public:kms:us-south:a/123456:e4a29d1a-2ef0-42a6-8fd2-350deb1c647e:key:5437653b-c4b1-447f-9646-b2a2a4cd6179"}, "health_reasons": [{"code": "initializing_from_snapshot", "message": "Performance will be degraded while this volume is being initialized from its snapshot", "more_info": "https://cloud.ibm.com/docs/vpc?topic=vpc-snapshots-vpc-troubleshooting&interface=ui#snapshot_ts_degraded_perf"}], "health_state": "ok", "href": "https://us-south.iaas.cloud.ibm.com/v1/volumes/1a6b7274-678d-4dfb-8981-c71dd9d4daa5", "id": "1a6b7274-678d-4dfb-8981-c71dd9d4daa5", "iops": 10000, "name": "my-volume", "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"}, "profile": {"href": "https://us-south.iaas.cloud.ibm.com/v1/volume/profiles/general-purpose", "name": "general-purpose"}, "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "resource_type": "volume", "source_image": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::image:72b27b5c-f4b0-48bb-b954-5becc7c1dcb8", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/images/72b27b5c-f4b0-48bb-b954-5becc7c1dcb8", "id": "72b27b5c-f4b0-48bb-b954-5becc7c1dcb8", "name": "my-image", "remote": {"account": {"id": "aa2432b1fa4d4ace891e9b80fc104e34", "resource_type": "account"}, "region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "image"}, "source_snapshot": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "id": "r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "name": "my-snapshot", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "snapshot"}, "status": "available", "status_reasons": [{"code": "encryption_key_deleted", "message": "Message", "more_info": "https://cloud.ibm.com/docs/key-protect?topic=key-protect-restore-keys"}], "user_tags": ["UserTags"], "volume_attachments": [{"delete_volume_on_instance_delete": true, "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "device": {"id": "80b3e36e-41f4-40e9-bd56-beae81792a68"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/instances/1e09281b-f177-46fb-baf1-bc152b2e391a/volume_attachments/82cbf856-9cbb-45fb-b62f-d7bcef32399a", "id": "82cbf856-9cbb-45fb-b62f-d7bcef32399a", "instance": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::instance:1e09281b-f177-46fb-baf1-bc152b2e391a", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/instances/1e09281b-f177-46fb-baf1-bc152b2e391a", "id": "1e09281b-f177-46fb-baf1-bc152b2e391a", "name": "my-instance"}, "name": "my-volume-attachment", "type": "boot"}], "zone": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south/zones/us-south-1", "name": "us-south-1"}}`) })) }) - It(`Invoke UpdateBareMetalServerNetworkInterface successfully`, func() { + It(`Invoke GetVolume successfully`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -51134,35 +51211,24 @@ var _ = Describe(`VpcV1`, func() { Expect(vpcService).ToNot(BeNil()) // Invoke operation with nil options model (negative test) - result, response, operationErr := vpcService.UpdateBareMetalServerNetworkInterface(nil) + result, response, operationErr := vpcService.GetVolume(nil) Expect(operationErr).NotTo(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) - // Construct an instance of the BareMetalServerNetworkInterfacePatch model - bareMetalServerNetworkInterfacePatchModel := new(vpcv1.BareMetalServerNetworkInterfacePatch) - bareMetalServerNetworkInterfacePatchModel.AllowIPSpoofing = core.BoolPtr(true) - bareMetalServerNetworkInterfacePatchModel.AllowedVlans = []int64{int64(4)} - bareMetalServerNetworkInterfacePatchModel.EnableInfrastructureNat = core.BoolPtr(true) - bareMetalServerNetworkInterfacePatchModel.Name = core.StringPtr("my-bare-metal-server-network-interface") - bareMetalServerNetworkInterfacePatchModelAsPatch, asPatchErr := bareMetalServerNetworkInterfacePatchModel.AsPatch() - Expect(asPatchErr).To(BeNil()) - - // Construct an instance of the UpdateBareMetalServerNetworkInterfaceOptions model - updateBareMetalServerNetworkInterfaceOptionsModel := new(vpcv1.UpdateBareMetalServerNetworkInterfaceOptions) - updateBareMetalServerNetworkInterfaceOptionsModel.BareMetalServerID = core.StringPtr("testString") - updateBareMetalServerNetworkInterfaceOptionsModel.ID = core.StringPtr("testString") - updateBareMetalServerNetworkInterfaceOptionsModel.BareMetalServerNetworkInterfacePatch = bareMetalServerNetworkInterfacePatchModelAsPatch - updateBareMetalServerNetworkInterfaceOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the GetVolumeOptions model + getVolumeOptionsModel := new(vpcv1.GetVolumeOptions) + getVolumeOptionsModel.ID = core.StringPtr("testString") + getVolumeOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with valid options model (positive test) - result, response, operationErr = vpcService.UpdateBareMetalServerNetworkInterface(updateBareMetalServerNetworkInterfaceOptionsModel) + result, response, operationErr = vpcService.GetVolume(getVolumeOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) }) - It(`Invoke UpdateBareMetalServerNetworkInterface with error: Operation validation and request error`, func() { + It(`Invoke GetVolume with error: Operation validation and request error`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -51171,33 +51237,22 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the BareMetalServerNetworkInterfacePatch model - bareMetalServerNetworkInterfacePatchModel := new(vpcv1.BareMetalServerNetworkInterfacePatch) - bareMetalServerNetworkInterfacePatchModel.AllowIPSpoofing = core.BoolPtr(true) - bareMetalServerNetworkInterfacePatchModel.AllowedVlans = []int64{int64(4)} - bareMetalServerNetworkInterfacePatchModel.EnableInfrastructureNat = core.BoolPtr(true) - bareMetalServerNetworkInterfacePatchModel.Name = core.StringPtr("my-bare-metal-server-network-interface") - bareMetalServerNetworkInterfacePatchModelAsPatch, asPatchErr := bareMetalServerNetworkInterfacePatchModel.AsPatch() - Expect(asPatchErr).To(BeNil()) - - // Construct an instance of the UpdateBareMetalServerNetworkInterfaceOptions model - updateBareMetalServerNetworkInterfaceOptionsModel := new(vpcv1.UpdateBareMetalServerNetworkInterfaceOptions) - updateBareMetalServerNetworkInterfaceOptionsModel.BareMetalServerID = core.StringPtr("testString") - updateBareMetalServerNetworkInterfaceOptionsModel.ID = core.StringPtr("testString") - updateBareMetalServerNetworkInterfaceOptionsModel.BareMetalServerNetworkInterfacePatch = bareMetalServerNetworkInterfacePatchModelAsPatch - updateBareMetalServerNetworkInterfaceOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the GetVolumeOptions model + getVolumeOptionsModel := new(vpcv1.GetVolumeOptions) + getVolumeOptionsModel.ID = core.StringPtr("testString") + getVolumeOptionsModel.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.UpdateBareMetalServerNetworkInterface(updateBareMetalServerNetworkInterfaceOptionsModel) + result, response, operationErr := vpcService.GetVolume(getVolumeOptionsModel) 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 UpdateBareMetalServerNetworkInterfaceOptions model with no property values - updateBareMetalServerNetworkInterfaceOptionsModelNew := new(vpcv1.UpdateBareMetalServerNetworkInterfaceOptions) + // Construct a second instance of the GetVolumeOptions model with no property values + getVolumeOptionsModelNew := new(vpcv1.GetVolumeOptions) // Invoke operation with invalid model (negative test) - result, response, operationErr = vpcService.UpdateBareMetalServerNetworkInterface(updateBareMetalServerNetworkInterfaceOptionsModelNew) + result, response, operationErr = vpcService.GetVolume(getVolumeOptionsModelNew) Expect(operationErr).ToNot(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) @@ -51215,7 +51270,7 @@ var _ = Describe(`VpcV1`, func() { res.WriteHeader(200) })) }) - It(`Invoke UpdateBareMetalServerNetworkInterface successfully`, func() { + It(`Invoke GetVolume successfully`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -51224,24 +51279,13 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the BareMetalServerNetworkInterfacePatch model - bareMetalServerNetworkInterfacePatchModel := new(vpcv1.BareMetalServerNetworkInterfacePatch) - bareMetalServerNetworkInterfacePatchModel.AllowIPSpoofing = core.BoolPtr(true) - bareMetalServerNetworkInterfacePatchModel.AllowedVlans = []int64{int64(4)} - bareMetalServerNetworkInterfacePatchModel.EnableInfrastructureNat = core.BoolPtr(true) - bareMetalServerNetworkInterfacePatchModel.Name = core.StringPtr("my-bare-metal-server-network-interface") - bareMetalServerNetworkInterfacePatchModelAsPatch, asPatchErr := bareMetalServerNetworkInterfacePatchModel.AsPatch() - Expect(asPatchErr).To(BeNil()) - - // Construct an instance of the UpdateBareMetalServerNetworkInterfaceOptions model - updateBareMetalServerNetworkInterfaceOptionsModel := new(vpcv1.UpdateBareMetalServerNetworkInterfaceOptions) - updateBareMetalServerNetworkInterfaceOptionsModel.BareMetalServerID = core.StringPtr("testString") - updateBareMetalServerNetworkInterfaceOptionsModel.ID = core.StringPtr("testString") - updateBareMetalServerNetworkInterfaceOptionsModel.BareMetalServerNetworkInterfacePatch = bareMetalServerNetworkInterfacePatchModelAsPatch - updateBareMetalServerNetworkInterfaceOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the GetVolumeOptions model + getVolumeOptionsModel := new(vpcv1.GetVolumeOptions) + getVolumeOptionsModel.ID = core.StringPtr("testString") + getVolumeOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation - result, response, operationErr := vpcService.UpdateBareMetalServerNetworkInterface(updateBareMetalServerNetworkInterfaceOptionsModel) + result, response, operationErr := vpcService.GetVolume(getVolumeOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) @@ -51253,17 +51297,19 @@ var _ = Describe(`VpcV1`, func() { }) }) }) - Describe(`ListBareMetalServerNetworkInterfaceFloatingIps(listBareMetalServerNetworkInterfaceFloatingIpsOptions *ListBareMetalServerNetworkInterfaceFloatingIpsOptions) - Operation response error`, func() { + Describe(`UpdateVolume(updateVolumeOptions *UpdateVolumeOptions) - Operation response error`, func() { version := "testString" - listBareMetalServerNetworkInterfaceFloatingIpsPath := "/bare_metal_servers/testString/network_interfaces/testString/floating_ips" + updateVolumePath := "/volumes/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(listBareMetalServerNetworkInterfaceFloatingIpsPath)) - Expect(req.Method).To(Equal("GET")) + Expect(req.URL.EscapedPath()).To(Equal(updateVolumePath)) + 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") @@ -51271,7 +51317,7 @@ var _ = Describe(`VpcV1`, func() { fmt.Fprint(res, `} this is not valid json {`) })) }) - It(`Invoke ListBareMetalServerNetworkInterfaceFloatingIps with error: Operation response processing error`, func() { + It(`Invoke UpdateVolume with error: Operation response processing error`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -51280,20 +51326,35 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the ListBareMetalServerNetworkInterfaceFloatingIpsOptions model - listBareMetalServerNetworkInterfaceFloatingIpsOptionsModel := new(vpcv1.ListBareMetalServerNetworkInterfaceFloatingIpsOptions) - listBareMetalServerNetworkInterfaceFloatingIpsOptionsModel.BareMetalServerID = core.StringPtr("testString") - listBareMetalServerNetworkInterfaceFloatingIpsOptionsModel.NetworkInterfaceID = core.StringPtr("testString") - listBareMetalServerNetworkInterfaceFloatingIpsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the VolumeProfileIdentityByName model + volumeProfileIdentityModel := new(vpcv1.VolumeProfileIdentityByName) + volumeProfileIdentityModel.Name = core.StringPtr("general-purpose") + + // Construct an instance of the VolumePatch model + volumePatchModel := new(vpcv1.VolumePatch) + volumePatchModel.Capacity = core.Int64Ptr(int64(100)) + volumePatchModel.Iops = core.Int64Ptr(int64(10000)) + volumePatchModel.Name = core.StringPtr("my-volume") + volumePatchModel.Profile = volumeProfileIdentityModel + volumePatchModel.UserTags = []string{"testString"} + volumePatchModelAsPatch, asPatchErr := volumePatchModel.AsPatch() + Expect(asPatchErr).To(BeNil()) + + // Construct an instance of the UpdateVolumeOptions model + updateVolumeOptionsModel := new(vpcv1.UpdateVolumeOptions) + updateVolumeOptionsModel.ID = core.StringPtr("testString") + updateVolumeOptionsModel.VolumePatch = volumePatchModelAsPatch + updateVolumeOptionsModel.IfMatch = core.StringPtr("W/\"96d225c4-56bd-43d9-98fc-d7148e5c5028\"") + updateVolumeOptionsModel.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.ListBareMetalServerNetworkInterfaceFloatingIps(listBareMetalServerNetworkInterfaceFloatingIpsOptionsModel) + result, response, operationErr := vpcService.UpdateVolume(updateVolumeOptionsModel) 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.ListBareMetalServerNetworkInterfaceFloatingIps(listBareMetalServerNetworkInterfaceFloatingIpsOptionsModel) + result, response, operationErr = vpcService.UpdateVolume(updateVolumeOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).To(BeNil()) @@ -51303,18 +51364,36 @@ var _ = Describe(`VpcV1`, func() { }) }) }) - Describe(`ListBareMetalServerNetworkInterfaceFloatingIps(listBareMetalServerNetworkInterfaceFloatingIpsOptions *ListBareMetalServerNetworkInterfaceFloatingIpsOptions)`, func() { + Describe(`UpdateVolume(updateVolumeOptions *UpdateVolumeOptions)`, func() { version := "testString" - listBareMetalServerNetworkInterfaceFloatingIpsPath := "/bare_metal_servers/testString/network_interfaces/testString/floating_ips" + updateVolumePath := "/volumes/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(listBareMetalServerNetworkInterfaceFloatingIpsPath)) - Expect(req.Method).To(Equal("GET")) + Expect(req.URL.EscapedPath()).To(Equal(updateVolumePath)) + 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 @@ -51323,10 +51402,10 @@ var _ = Describe(`VpcV1`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"floating_ips": [{"address": "203.0.113.1", "created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::floating-ip:39300233-9995-4806-89a5-3c1b6eb88689", "href": "https://us-south.iaas.cloud.ibm.com/v1/floating_ips/39300233-9995-4806-89a5-3c1b6eb88689", "id": "39300233-9995-4806-89a5-3c1b6eb88689", "name": "my-floating-ip", "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "status": "available", "target": {"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/instances/1e09281b-f177-46fb-baf1-bc152b2e391a/network_interfaces/10c02d81-0ecb-4dc5-897d-28392913b81e", "id": "10c02d81-0ecb-4dc5-897d-28392913b81e", "name": "my-instance-network-interface", "primary_ip": {"address": "192.168.3.4", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e/reserved_ips/6d353a0f-aeb1-4ae1-832e-1110d10981bb", "id": "6d353a0f-aeb1-4ae1-832e-1110d10981bb", "name": "my-reserved-ip", "resource_type": "subnet_reserved_ip"}, "resource_type": "network_interface"}, "zone": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south/zones/us-south-1", "name": "us-south-1"}}]}`) + fmt.Fprintf(res, "%s", `{"active": true, "attachment_state": "attached", "bandwidth": 1000, "busy": true, "capacity": 1000, "created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::volume:1a6b7274-678d-4dfb-8981-c71dd9d4daa5", "encryption": "provider_managed", "encryption_key": {"crn": "crn:v1:bluemix:public:kms:us-south:a/123456:e4a29d1a-2ef0-42a6-8fd2-350deb1c647e:key:5437653b-c4b1-447f-9646-b2a2a4cd6179"}, "health_reasons": [{"code": "initializing_from_snapshot", "message": "Performance will be degraded while this volume is being initialized from its snapshot", "more_info": "https://cloud.ibm.com/docs/vpc?topic=vpc-snapshots-vpc-troubleshooting&interface=ui#snapshot_ts_degraded_perf"}], "health_state": "ok", "href": "https://us-south.iaas.cloud.ibm.com/v1/volumes/1a6b7274-678d-4dfb-8981-c71dd9d4daa5", "id": "1a6b7274-678d-4dfb-8981-c71dd9d4daa5", "iops": 10000, "name": "my-volume", "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"}, "profile": {"href": "https://us-south.iaas.cloud.ibm.com/v1/volume/profiles/general-purpose", "name": "general-purpose"}, "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "resource_type": "volume", "source_image": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::image:72b27b5c-f4b0-48bb-b954-5becc7c1dcb8", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/images/72b27b5c-f4b0-48bb-b954-5becc7c1dcb8", "id": "72b27b5c-f4b0-48bb-b954-5becc7c1dcb8", "name": "my-image", "remote": {"account": {"id": "aa2432b1fa4d4ace891e9b80fc104e34", "resource_type": "account"}, "region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "image"}, "source_snapshot": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "id": "r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "name": "my-snapshot", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "snapshot"}, "status": "available", "status_reasons": [{"code": "encryption_key_deleted", "message": "Message", "more_info": "https://cloud.ibm.com/docs/key-protect?topic=key-protect-restore-keys"}], "user_tags": ["UserTags"], "volume_attachments": [{"delete_volume_on_instance_delete": true, "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "device": {"id": "80b3e36e-41f4-40e9-bd56-beae81792a68"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/instances/1e09281b-f177-46fb-baf1-bc152b2e391a/volume_attachments/82cbf856-9cbb-45fb-b62f-d7bcef32399a", "id": "82cbf856-9cbb-45fb-b62f-d7bcef32399a", "instance": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::instance:1e09281b-f177-46fb-baf1-bc152b2e391a", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/instances/1e09281b-f177-46fb-baf1-bc152b2e391a", "id": "1e09281b-f177-46fb-baf1-bc152b2e391a", "name": "my-instance"}, "name": "my-volume-attachment", "type": "boot"}], "zone": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south/zones/us-south-1", "name": "us-south-1"}}`) })) }) - It(`Invoke ListBareMetalServerNetworkInterfaceFloatingIps successfully with retries`, func() { + It(`Invoke UpdateVolume successfully with retries`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -51336,22 +51415,37 @@ var _ = Describe(`VpcV1`, func() { Expect(vpcService).ToNot(BeNil()) vpcService.EnableRetries(0, 0) - // Construct an instance of the ListBareMetalServerNetworkInterfaceFloatingIpsOptions model - listBareMetalServerNetworkInterfaceFloatingIpsOptionsModel := new(vpcv1.ListBareMetalServerNetworkInterfaceFloatingIpsOptions) - listBareMetalServerNetworkInterfaceFloatingIpsOptionsModel.BareMetalServerID = core.StringPtr("testString") - listBareMetalServerNetworkInterfaceFloatingIpsOptionsModel.NetworkInterfaceID = core.StringPtr("testString") - listBareMetalServerNetworkInterfaceFloatingIpsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the VolumeProfileIdentityByName model + volumeProfileIdentityModel := new(vpcv1.VolumeProfileIdentityByName) + volumeProfileIdentityModel.Name = core.StringPtr("general-purpose") + + // Construct an instance of the VolumePatch model + volumePatchModel := new(vpcv1.VolumePatch) + volumePatchModel.Capacity = core.Int64Ptr(int64(100)) + volumePatchModel.Iops = core.Int64Ptr(int64(10000)) + volumePatchModel.Name = core.StringPtr("my-volume") + volumePatchModel.Profile = volumeProfileIdentityModel + volumePatchModel.UserTags = []string{"testString"} + volumePatchModelAsPatch, asPatchErr := volumePatchModel.AsPatch() + Expect(asPatchErr).To(BeNil()) + + // Construct an instance of the UpdateVolumeOptions model + updateVolumeOptionsModel := new(vpcv1.UpdateVolumeOptions) + updateVolumeOptionsModel.ID = core.StringPtr("testString") + updateVolumeOptionsModel.VolumePatch = volumePatchModelAsPatch + updateVolumeOptionsModel.IfMatch = core.StringPtr("W/\"96d225c4-56bd-43d9-98fc-d7148e5c5028\"") + updateVolumeOptionsModel.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.ListBareMetalServerNetworkInterfaceFloatingIpsWithContext(ctx, listBareMetalServerNetworkInterfaceFloatingIpsOptionsModel) + _, _, operationErr := vpcService.UpdateVolumeWithContext(ctx, updateVolumeOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) // Disable retries and test again vpcService.DisableRetries() - result, response, operationErr := vpcService.ListBareMetalServerNetworkInterfaceFloatingIps(listBareMetalServerNetworkInterfaceFloatingIpsOptionsModel) + result, response, operationErr := vpcService.UpdateVolume(updateVolumeOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) @@ -51359,7 +51453,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.ListBareMetalServerNetworkInterfaceFloatingIpsWithContext(ctx, listBareMetalServerNetworkInterfaceFloatingIpsOptionsModel) + _, _, operationErr = vpcService.UpdateVolumeWithContext(ctx, updateVolumeOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) }) @@ -51373,18 +51467,36 @@ var _ = Describe(`VpcV1`, func() { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(listBareMetalServerNetworkInterfaceFloatingIpsPath)) - Expect(req.Method).To(Equal("GET")) + Expect(req.URL.EscapedPath()).To(Equal(updateVolumePath)) + 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", `{"floating_ips": [{"address": "203.0.113.1", "created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::floating-ip:39300233-9995-4806-89a5-3c1b6eb88689", "href": "https://us-south.iaas.cloud.ibm.com/v1/floating_ips/39300233-9995-4806-89a5-3c1b6eb88689", "id": "39300233-9995-4806-89a5-3c1b6eb88689", "name": "my-floating-ip", "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "status": "available", "target": {"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/instances/1e09281b-f177-46fb-baf1-bc152b2e391a/network_interfaces/10c02d81-0ecb-4dc5-897d-28392913b81e", "id": "10c02d81-0ecb-4dc5-897d-28392913b81e", "name": "my-instance-network-interface", "primary_ip": {"address": "192.168.3.4", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e/reserved_ips/6d353a0f-aeb1-4ae1-832e-1110d10981bb", "id": "6d353a0f-aeb1-4ae1-832e-1110d10981bb", "name": "my-reserved-ip", "resource_type": "subnet_reserved_ip"}, "resource_type": "network_interface"}, "zone": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south/zones/us-south-1", "name": "us-south-1"}}]}`) + fmt.Fprintf(res, "%s", `{"active": true, "attachment_state": "attached", "bandwidth": 1000, "busy": true, "capacity": 1000, "created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::volume:1a6b7274-678d-4dfb-8981-c71dd9d4daa5", "encryption": "provider_managed", "encryption_key": {"crn": "crn:v1:bluemix:public:kms:us-south:a/123456:e4a29d1a-2ef0-42a6-8fd2-350deb1c647e:key:5437653b-c4b1-447f-9646-b2a2a4cd6179"}, "health_reasons": [{"code": "initializing_from_snapshot", "message": "Performance will be degraded while this volume is being initialized from its snapshot", "more_info": "https://cloud.ibm.com/docs/vpc?topic=vpc-snapshots-vpc-troubleshooting&interface=ui#snapshot_ts_degraded_perf"}], "health_state": "ok", "href": "https://us-south.iaas.cloud.ibm.com/v1/volumes/1a6b7274-678d-4dfb-8981-c71dd9d4daa5", "id": "1a6b7274-678d-4dfb-8981-c71dd9d4daa5", "iops": 10000, "name": "my-volume", "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"}, "profile": {"href": "https://us-south.iaas.cloud.ibm.com/v1/volume/profiles/general-purpose", "name": "general-purpose"}, "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "resource_type": "volume", "source_image": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::image:72b27b5c-f4b0-48bb-b954-5becc7c1dcb8", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/images/72b27b5c-f4b0-48bb-b954-5becc7c1dcb8", "id": "72b27b5c-f4b0-48bb-b954-5becc7c1dcb8", "name": "my-image", "remote": {"account": {"id": "aa2432b1fa4d4ace891e9b80fc104e34", "resource_type": "account"}, "region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "image"}, "source_snapshot": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "id": "r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "name": "my-snapshot", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "snapshot"}, "status": "available", "status_reasons": [{"code": "encryption_key_deleted", "message": "Message", "more_info": "https://cloud.ibm.com/docs/key-protect?topic=key-protect-restore-keys"}], "user_tags": ["UserTags"], "volume_attachments": [{"delete_volume_on_instance_delete": true, "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "device": {"id": "80b3e36e-41f4-40e9-bd56-beae81792a68"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/instances/1e09281b-f177-46fb-baf1-bc152b2e391a/volume_attachments/82cbf856-9cbb-45fb-b62f-d7bcef32399a", "id": "82cbf856-9cbb-45fb-b62f-d7bcef32399a", "instance": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::instance:1e09281b-f177-46fb-baf1-bc152b2e391a", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/instances/1e09281b-f177-46fb-baf1-bc152b2e391a", "id": "1e09281b-f177-46fb-baf1-bc152b2e391a", "name": "my-instance"}, "name": "my-volume-attachment", "type": "boot"}], "zone": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south/zones/us-south-1", "name": "us-south-1"}}`) })) }) - It(`Invoke ListBareMetalServerNetworkInterfaceFloatingIps successfully`, func() { + It(`Invoke UpdateVolume successfully`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -51394,25 +51506,40 @@ var _ = Describe(`VpcV1`, func() { Expect(vpcService).ToNot(BeNil()) // Invoke operation with nil options model (negative test) - result, response, operationErr := vpcService.ListBareMetalServerNetworkInterfaceFloatingIps(nil) + result, response, operationErr := vpcService.UpdateVolume(nil) Expect(operationErr).NotTo(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) - // Construct an instance of the ListBareMetalServerNetworkInterfaceFloatingIpsOptions model - listBareMetalServerNetworkInterfaceFloatingIpsOptionsModel := new(vpcv1.ListBareMetalServerNetworkInterfaceFloatingIpsOptions) - listBareMetalServerNetworkInterfaceFloatingIpsOptionsModel.BareMetalServerID = core.StringPtr("testString") - listBareMetalServerNetworkInterfaceFloatingIpsOptionsModel.NetworkInterfaceID = core.StringPtr("testString") - listBareMetalServerNetworkInterfaceFloatingIpsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the VolumeProfileIdentityByName model + volumeProfileIdentityModel := new(vpcv1.VolumeProfileIdentityByName) + volumeProfileIdentityModel.Name = core.StringPtr("general-purpose") + + // Construct an instance of the VolumePatch model + volumePatchModel := new(vpcv1.VolumePatch) + volumePatchModel.Capacity = core.Int64Ptr(int64(100)) + volumePatchModel.Iops = core.Int64Ptr(int64(10000)) + volumePatchModel.Name = core.StringPtr("my-volume") + volumePatchModel.Profile = volumeProfileIdentityModel + volumePatchModel.UserTags = []string{"testString"} + volumePatchModelAsPatch, asPatchErr := volumePatchModel.AsPatch() + Expect(asPatchErr).To(BeNil()) + + // Construct an instance of the UpdateVolumeOptions model + updateVolumeOptionsModel := new(vpcv1.UpdateVolumeOptions) + updateVolumeOptionsModel.ID = core.StringPtr("testString") + updateVolumeOptionsModel.VolumePatch = volumePatchModelAsPatch + updateVolumeOptionsModel.IfMatch = core.StringPtr("W/\"96d225c4-56bd-43d9-98fc-d7148e5c5028\"") + updateVolumeOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with valid options model (positive test) - result, response, operationErr = vpcService.ListBareMetalServerNetworkInterfaceFloatingIps(listBareMetalServerNetworkInterfaceFloatingIpsOptionsModel) + result, response, operationErr = vpcService.UpdateVolume(updateVolumeOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) }) - It(`Invoke ListBareMetalServerNetworkInterfaceFloatingIps with error: Operation validation and request error`, func() { + It(`Invoke UpdateVolume with error: Operation validation and request error`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -51421,23 +51548,38 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the ListBareMetalServerNetworkInterfaceFloatingIpsOptions model - listBareMetalServerNetworkInterfaceFloatingIpsOptionsModel := new(vpcv1.ListBareMetalServerNetworkInterfaceFloatingIpsOptions) - listBareMetalServerNetworkInterfaceFloatingIpsOptionsModel.BareMetalServerID = core.StringPtr("testString") - listBareMetalServerNetworkInterfaceFloatingIpsOptionsModel.NetworkInterfaceID = core.StringPtr("testString") - listBareMetalServerNetworkInterfaceFloatingIpsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the VolumeProfileIdentityByName model + volumeProfileIdentityModel := new(vpcv1.VolumeProfileIdentityByName) + volumeProfileIdentityModel.Name = core.StringPtr("general-purpose") + + // Construct an instance of the VolumePatch model + volumePatchModel := new(vpcv1.VolumePatch) + volumePatchModel.Capacity = core.Int64Ptr(int64(100)) + volumePatchModel.Iops = core.Int64Ptr(int64(10000)) + volumePatchModel.Name = core.StringPtr("my-volume") + volumePatchModel.Profile = volumeProfileIdentityModel + volumePatchModel.UserTags = []string{"testString"} + volumePatchModelAsPatch, asPatchErr := volumePatchModel.AsPatch() + Expect(asPatchErr).To(BeNil()) + + // Construct an instance of the UpdateVolumeOptions model + updateVolumeOptionsModel := new(vpcv1.UpdateVolumeOptions) + updateVolumeOptionsModel.ID = core.StringPtr("testString") + updateVolumeOptionsModel.VolumePatch = volumePatchModelAsPatch + updateVolumeOptionsModel.IfMatch = core.StringPtr("W/\"96d225c4-56bd-43d9-98fc-d7148e5c5028\"") + updateVolumeOptionsModel.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.ListBareMetalServerNetworkInterfaceFloatingIps(listBareMetalServerNetworkInterfaceFloatingIpsOptionsModel) + result, response, operationErr := vpcService.UpdateVolume(updateVolumeOptionsModel) 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 ListBareMetalServerNetworkInterfaceFloatingIpsOptions model with no property values - listBareMetalServerNetworkInterfaceFloatingIpsOptionsModelNew := new(vpcv1.ListBareMetalServerNetworkInterfaceFloatingIpsOptions) + // Construct a second instance of the UpdateVolumeOptions model with no property values + updateVolumeOptionsModelNew := new(vpcv1.UpdateVolumeOptions) // Invoke operation with invalid model (negative test) - result, response, operationErr = vpcService.ListBareMetalServerNetworkInterfaceFloatingIps(listBareMetalServerNetworkInterfaceFloatingIpsOptionsModelNew) + result, response, operationErr = vpcService.UpdateVolume(updateVolumeOptionsModelNew) Expect(operationErr).ToNot(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) @@ -51455,7 +51597,7 @@ var _ = Describe(`VpcV1`, func() { res.WriteHeader(200) })) }) - It(`Invoke ListBareMetalServerNetworkInterfaceFloatingIps successfully`, func() { + It(`Invoke UpdateVolume successfully`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -51464,14 +51606,29 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the ListBareMetalServerNetworkInterfaceFloatingIpsOptions model - listBareMetalServerNetworkInterfaceFloatingIpsOptionsModel := new(vpcv1.ListBareMetalServerNetworkInterfaceFloatingIpsOptions) - listBareMetalServerNetworkInterfaceFloatingIpsOptionsModel.BareMetalServerID = core.StringPtr("testString") - listBareMetalServerNetworkInterfaceFloatingIpsOptionsModel.NetworkInterfaceID = core.StringPtr("testString") - listBareMetalServerNetworkInterfaceFloatingIpsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the VolumeProfileIdentityByName model + volumeProfileIdentityModel := new(vpcv1.VolumeProfileIdentityByName) + volumeProfileIdentityModel.Name = core.StringPtr("general-purpose") + + // Construct an instance of the VolumePatch model + volumePatchModel := new(vpcv1.VolumePatch) + volumePatchModel.Capacity = core.Int64Ptr(int64(100)) + volumePatchModel.Iops = core.Int64Ptr(int64(10000)) + volumePatchModel.Name = core.StringPtr("my-volume") + volumePatchModel.Profile = volumeProfileIdentityModel + volumePatchModel.UserTags = []string{"testString"} + volumePatchModelAsPatch, asPatchErr := volumePatchModel.AsPatch() + Expect(asPatchErr).To(BeNil()) + + // Construct an instance of the UpdateVolumeOptions model + updateVolumeOptionsModel := new(vpcv1.UpdateVolumeOptions) + updateVolumeOptionsModel.ID = core.StringPtr("testString") + updateVolumeOptionsModel.VolumePatch = volumePatchModelAsPatch + updateVolumeOptionsModel.IfMatch = core.StringPtr("W/\"96d225c4-56bd-43d9-98fc-d7148e5c5028\"") + updateVolumeOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation - result, response, operationErr := vpcService.ListBareMetalServerNetworkInterfaceFloatingIps(listBareMetalServerNetworkInterfaceFloatingIpsOptionsModel) + result, response, operationErr := vpcService.UpdateVolume(updateVolumeOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) @@ -51483,102 +51640,31 @@ var _ = Describe(`VpcV1`, func() { }) }) }) - Describe(`RemoveBareMetalServerNetworkInterfaceFloatingIP(removeBareMetalServerNetworkInterfaceFloatingIPOptions *RemoveBareMetalServerNetworkInterfaceFloatingIPOptions)`, func() { - version := "testString" - removeBareMetalServerNetworkInterfaceFloatingIPPath := "/bare_metal_servers/testString/network_interfaces/testString/floating_ips/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(removeBareMetalServerNetworkInterfaceFloatingIPPath)) - 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(204) - })) - }) - It(`Invoke RemoveBareMetalServerNetworkInterfaceFloatingIP 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.RemoveBareMetalServerNetworkInterfaceFloatingIP(nil) - Expect(operationErr).NotTo(BeNil()) - Expect(response).To(BeNil()) - - // Construct an instance of the RemoveBareMetalServerNetworkInterfaceFloatingIPOptions model - removeBareMetalServerNetworkInterfaceFloatingIPOptionsModel := new(vpcv1.RemoveBareMetalServerNetworkInterfaceFloatingIPOptions) - removeBareMetalServerNetworkInterfaceFloatingIPOptionsModel.BareMetalServerID = core.StringPtr("testString") - removeBareMetalServerNetworkInterfaceFloatingIPOptionsModel.NetworkInterfaceID = core.StringPtr("testString") - removeBareMetalServerNetworkInterfaceFloatingIPOptionsModel.ID = core.StringPtr("testString") - removeBareMetalServerNetworkInterfaceFloatingIPOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} - - // Invoke operation with valid options model (positive test) - response, operationErr = vpcService.RemoveBareMetalServerNetworkInterfaceFloatingIP(removeBareMetalServerNetworkInterfaceFloatingIPOptionsModel) - Expect(operationErr).To(BeNil()) - Expect(response).ToNot(BeNil()) - }) - It(`Invoke RemoveBareMetalServerNetworkInterfaceFloatingIP 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 RemoveBareMetalServerNetworkInterfaceFloatingIPOptions model - removeBareMetalServerNetworkInterfaceFloatingIPOptionsModel := new(vpcv1.RemoveBareMetalServerNetworkInterfaceFloatingIPOptions) - removeBareMetalServerNetworkInterfaceFloatingIPOptionsModel.BareMetalServerID = core.StringPtr("testString") - removeBareMetalServerNetworkInterfaceFloatingIPOptionsModel.NetworkInterfaceID = core.StringPtr("testString") - removeBareMetalServerNetworkInterfaceFloatingIPOptionsModel.ID = core.StringPtr("testString") - removeBareMetalServerNetworkInterfaceFloatingIPOptionsModel.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.RemoveBareMetalServerNetworkInterfaceFloatingIP(removeBareMetalServerNetworkInterfaceFloatingIPOptionsModel) - Expect(operationErr).ToNot(BeNil()) - Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING)) - Expect(response).To(BeNil()) - // Construct a second instance of the RemoveBareMetalServerNetworkInterfaceFloatingIPOptions model with no property values - removeBareMetalServerNetworkInterfaceFloatingIPOptionsModelNew := new(vpcv1.RemoveBareMetalServerNetworkInterfaceFloatingIPOptions) - // Invoke operation with invalid model (negative test) - response, operationErr = vpcService.RemoveBareMetalServerNetworkInterfaceFloatingIP(removeBareMetalServerNetworkInterfaceFloatingIPOptionsModelNew) - Expect(operationErr).ToNot(BeNil()) - Expect(response).To(BeNil()) - }) - AfterEach(func() { - testServer.Close() - }) - }) - }) - Describe(`GetBareMetalServerNetworkInterfaceFloatingIP(getBareMetalServerNetworkInterfaceFloatingIPOptions *GetBareMetalServerNetworkInterfaceFloatingIPOptions) - Operation response error`, func() { + Describe(`ListSnapshotConsistencyGroups(listSnapshotConsistencyGroupsOptions *ListSnapshotConsistencyGroupsOptions) - Operation response error`, func() { version := "testString" - getBareMetalServerNetworkInterfaceFloatingIPPath := "/bare_metal_servers/testString/network_interfaces/testString/floating_ips/testString" + listSnapshotConsistencyGroupsPath := "/snapshot_consistency_groups" Context(`Using mock server endpoint with invalid JSON response`, func() { BeforeEach(func() { testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(getBareMetalServerNetworkInterfaceFloatingIPPath)) + Expect(req.URL.EscapedPath()).To(Equal(listSnapshotConsistencyGroupsPath)) Expect(req.Method).To(Equal("GET")) Expect(req.URL.Query()["version"]).To(Equal([]string{"testString"})) Expect(req.URL.Query()["generation"]).To(Equal([]string{fmt.Sprint(int64(2))})) + Expect(req.URL.Query()["start"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["limit"]).To(Equal([]string{fmt.Sprint(int64(10))})) + Expect(req.URL.Query()["resource_group.id"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["name"]).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 {`) })) }) - It(`Invoke GetBareMetalServerNetworkInterfaceFloatingIP with error: Operation response processing error`, func() { + It(`Invoke ListSnapshotConsistencyGroups with error: Operation response processing error`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -51587,21 +51673,24 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the GetBareMetalServerNetworkInterfaceFloatingIPOptions model - getBareMetalServerNetworkInterfaceFloatingIPOptionsModel := new(vpcv1.GetBareMetalServerNetworkInterfaceFloatingIPOptions) - getBareMetalServerNetworkInterfaceFloatingIPOptionsModel.BareMetalServerID = core.StringPtr("testString") - getBareMetalServerNetworkInterfaceFloatingIPOptionsModel.NetworkInterfaceID = core.StringPtr("testString") - getBareMetalServerNetworkInterfaceFloatingIPOptionsModel.ID = core.StringPtr("testString") - getBareMetalServerNetworkInterfaceFloatingIPOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the ListSnapshotConsistencyGroupsOptions model + listSnapshotConsistencyGroupsOptionsModel := new(vpcv1.ListSnapshotConsistencyGroupsOptions) + listSnapshotConsistencyGroupsOptionsModel.Start = core.StringPtr("testString") + listSnapshotConsistencyGroupsOptionsModel.Limit = core.Int64Ptr(int64(10)) + listSnapshotConsistencyGroupsOptionsModel.ResourceGroupID = core.StringPtr("testString") + listSnapshotConsistencyGroupsOptionsModel.Name = core.StringPtr("testString") + listSnapshotConsistencyGroupsOptionsModel.Sort = core.StringPtr("name") + listSnapshotConsistencyGroupsOptionsModel.BackupPolicyPlanID = core.StringPtr("testString") + listSnapshotConsistencyGroupsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Expect response parsing to fail since we are receiving a text/plain response - result, response, operationErr := vpcService.GetBareMetalServerNetworkInterfaceFloatingIP(getBareMetalServerNetworkInterfaceFloatingIPOptionsModel) + result, response, operationErr := vpcService.ListSnapshotConsistencyGroups(listSnapshotConsistencyGroupsOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).To(BeNil()) // Enable retries and test again vpcService.EnableRetries(0, 0) - result, response, operationErr = vpcService.GetBareMetalServerNetworkInterfaceFloatingIP(getBareMetalServerNetworkInterfaceFloatingIPOptionsModel) + result, response, operationErr = vpcService.ListSnapshotConsistencyGroups(listSnapshotConsistencyGroupsOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).To(BeNil()) @@ -51611,30 +51700,36 @@ var _ = Describe(`VpcV1`, func() { }) }) }) - Describe(`GetBareMetalServerNetworkInterfaceFloatingIP(getBareMetalServerNetworkInterfaceFloatingIPOptions *GetBareMetalServerNetworkInterfaceFloatingIPOptions)`, func() { + Describe(`ListSnapshotConsistencyGroups(listSnapshotConsistencyGroupsOptions *ListSnapshotConsistencyGroupsOptions)`, func() { version := "testString" - getBareMetalServerNetworkInterfaceFloatingIPPath := "/bare_metal_servers/testString/network_interfaces/testString/floating_ips/testString" + listSnapshotConsistencyGroupsPath := "/snapshot_consistency_groups" Context(`Using mock server endpoint with timeout`, func() { BeforeEach(func() { testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(getBareMetalServerNetworkInterfaceFloatingIPPath)) + Expect(req.URL.EscapedPath()).To(Equal(listSnapshotConsistencyGroupsPath)) Expect(req.Method).To(Equal("GET")) Expect(req.URL.Query()["version"]).To(Equal([]string{"testString"})) Expect(req.URL.Query()["generation"]).To(Equal([]string{fmt.Sprint(int64(2))})) + Expect(req.URL.Query()["start"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["limit"]).To(Equal([]string{fmt.Sprint(int64(10))})) + Expect(req.URL.Query()["resource_group.id"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["name"]).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", `{"address": "203.0.113.1", "created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::floating-ip:39300233-9995-4806-89a5-3c1b6eb88689", "href": "https://us-south.iaas.cloud.ibm.com/v1/floating_ips/39300233-9995-4806-89a5-3c1b6eb88689", "id": "39300233-9995-4806-89a5-3c1b6eb88689", "name": "my-floating-ip", "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "status": "available", "target": {"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/instances/1e09281b-f177-46fb-baf1-bc152b2e391a/network_interfaces/10c02d81-0ecb-4dc5-897d-28392913b81e", "id": "10c02d81-0ecb-4dc5-897d-28392913b81e", "name": "my-instance-network-interface", "primary_ip": {"address": "192.168.3.4", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e/reserved_ips/6d353a0f-aeb1-4ae1-832e-1110d10981bb", "id": "6d353a0f-aeb1-4ae1-832e-1110d10981bb", "name": "my-reserved-ip", "resource_type": "subnet_reserved_ip"}, "resource_type": "network_interface"}, "zone": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south/zones/us-south-1", "name": "us-south-1"}}`) + fmt.Fprintf(res, "%s", `{"first": {"href": "https://us-south.iaas.cloud.ibm.com/v1/snapshot_consistency_groups?limit=20"}, "limit": 20, "next": {"href": "https://us-south.iaas.cloud.ibm.com/v1/snapshot_consistency_groups?start=9d5a91a3e2cbd233b5a5b33436855ed1&limit=20"}, "snapshot_consistency_groups": [{"backup_policy_plan": {"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6/plans/r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "id": "r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "name": "my-policy-plan", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "backup_policy_plan"}, "created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot-consistency-group:r134-fa329f6b-0e36-433f-a3bb-0df632e79263", "delete_snapshots_on_delete": false, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshot_consistency_groups/r134-fa329f6b-0e36-433f-a3bb-0df632e79263", "id": "r134-fa329f6b-0e36-433f-a3bb-0df632e79263", "lifecycle_state": "stable", "name": "my-snapshot-consistency-group", "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "resource_type": "snapshot_consistency_group", "service_tags": ["ServiceTags"], "snapshots": [{"crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "id": "r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "name": "my-snapshot", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "snapshot"}]}], "total_count": 132}`) })) }) - It(`Invoke GetBareMetalServerNetworkInterfaceFloatingIP successfully with retries`, func() { + It(`Invoke ListSnapshotConsistencyGroups successfully with retries`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -51644,23 +51739,26 @@ var _ = Describe(`VpcV1`, func() { Expect(vpcService).ToNot(BeNil()) vpcService.EnableRetries(0, 0) - // Construct an instance of the GetBareMetalServerNetworkInterfaceFloatingIPOptions model - getBareMetalServerNetworkInterfaceFloatingIPOptionsModel := new(vpcv1.GetBareMetalServerNetworkInterfaceFloatingIPOptions) - getBareMetalServerNetworkInterfaceFloatingIPOptionsModel.BareMetalServerID = core.StringPtr("testString") - getBareMetalServerNetworkInterfaceFloatingIPOptionsModel.NetworkInterfaceID = core.StringPtr("testString") - getBareMetalServerNetworkInterfaceFloatingIPOptionsModel.ID = core.StringPtr("testString") - getBareMetalServerNetworkInterfaceFloatingIPOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the ListSnapshotConsistencyGroupsOptions model + listSnapshotConsistencyGroupsOptionsModel := new(vpcv1.ListSnapshotConsistencyGroupsOptions) + listSnapshotConsistencyGroupsOptionsModel.Start = core.StringPtr("testString") + listSnapshotConsistencyGroupsOptionsModel.Limit = core.Int64Ptr(int64(10)) + listSnapshotConsistencyGroupsOptionsModel.ResourceGroupID = core.StringPtr("testString") + listSnapshotConsistencyGroupsOptionsModel.Name = core.StringPtr("testString") + listSnapshotConsistencyGroupsOptionsModel.Sort = core.StringPtr("name") + listSnapshotConsistencyGroupsOptionsModel.BackupPolicyPlanID = core.StringPtr("testString") + listSnapshotConsistencyGroupsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with a Context to test a timeout error ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond) defer cancelFunc() - _, _, operationErr := vpcService.GetBareMetalServerNetworkInterfaceFloatingIPWithContext(ctx, getBareMetalServerNetworkInterfaceFloatingIPOptionsModel) + _, _, operationErr := vpcService.ListSnapshotConsistencyGroupsWithContext(ctx, listSnapshotConsistencyGroupsOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) // Disable retries and test again vpcService.DisableRetries() - result, response, operationErr := vpcService.GetBareMetalServerNetworkInterfaceFloatingIP(getBareMetalServerNetworkInterfaceFloatingIPOptionsModel) + result, response, operationErr := vpcService.ListSnapshotConsistencyGroups(listSnapshotConsistencyGroupsOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) @@ -51668,7 +51766,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.GetBareMetalServerNetworkInterfaceFloatingIPWithContext(ctx, getBareMetalServerNetworkInterfaceFloatingIPOptionsModel) + _, _, operationErr = vpcService.ListSnapshotConsistencyGroupsWithContext(ctx, listSnapshotConsistencyGroupsOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) }) @@ -51682,18 +51780,24 @@ var _ = Describe(`VpcV1`, func() { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(getBareMetalServerNetworkInterfaceFloatingIPPath)) + Expect(req.URL.EscapedPath()).To(Equal(listSnapshotConsistencyGroupsPath)) Expect(req.Method).To(Equal("GET")) Expect(req.URL.Query()["version"]).To(Equal([]string{"testString"})) Expect(req.URL.Query()["generation"]).To(Equal([]string{fmt.Sprint(int64(2))})) + Expect(req.URL.Query()["start"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["limit"]).To(Equal([]string{fmt.Sprint(int64(10))})) + Expect(req.URL.Query()["resource_group.id"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["name"]).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", `{"address": "203.0.113.1", "created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::floating-ip:39300233-9995-4806-89a5-3c1b6eb88689", "href": "https://us-south.iaas.cloud.ibm.com/v1/floating_ips/39300233-9995-4806-89a5-3c1b6eb88689", "id": "39300233-9995-4806-89a5-3c1b6eb88689", "name": "my-floating-ip", "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "status": "available", "target": {"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/instances/1e09281b-f177-46fb-baf1-bc152b2e391a/network_interfaces/10c02d81-0ecb-4dc5-897d-28392913b81e", "id": "10c02d81-0ecb-4dc5-897d-28392913b81e", "name": "my-instance-network-interface", "primary_ip": {"address": "192.168.3.4", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e/reserved_ips/6d353a0f-aeb1-4ae1-832e-1110d10981bb", "id": "6d353a0f-aeb1-4ae1-832e-1110d10981bb", "name": "my-reserved-ip", "resource_type": "subnet_reserved_ip"}, "resource_type": "network_interface"}, "zone": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south/zones/us-south-1", "name": "us-south-1"}}`) + fmt.Fprintf(res, "%s", `{"first": {"href": "https://us-south.iaas.cloud.ibm.com/v1/snapshot_consistency_groups?limit=20"}, "limit": 20, "next": {"href": "https://us-south.iaas.cloud.ibm.com/v1/snapshot_consistency_groups?start=9d5a91a3e2cbd233b5a5b33436855ed1&limit=20"}, "snapshot_consistency_groups": [{"backup_policy_plan": {"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6/plans/r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "id": "r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "name": "my-policy-plan", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "backup_policy_plan"}, "created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot-consistency-group:r134-fa329f6b-0e36-433f-a3bb-0df632e79263", "delete_snapshots_on_delete": false, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshot_consistency_groups/r134-fa329f6b-0e36-433f-a3bb-0df632e79263", "id": "r134-fa329f6b-0e36-433f-a3bb-0df632e79263", "lifecycle_state": "stable", "name": "my-snapshot-consistency-group", "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "resource_type": "snapshot_consistency_group", "service_tags": ["ServiceTags"], "snapshots": [{"crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "id": "r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "name": "my-snapshot", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "snapshot"}]}], "total_count": 132}`) })) }) - It(`Invoke GetBareMetalServerNetworkInterfaceFloatingIP successfully`, func() { + It(`Invoke ListSnapshotConsistencyGroups successfully`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -51703,26 +51807,29 @@ var _ = Describe(`VpcV1`, func() { Expect(vpcService).ToNot(BeNil()) // Invoke operation with nil options model (negative test) - result, response, operationErr := vpcService.GetBareMetalServerNetworkInterfaceFloatingIP(nil) + result, response, operationErr := vpcService.ListSnapshotConsistencyGroups(nil) Expect(operationErr).NotTo(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) - // Construct an instance of the GetBareMetalServerNetworkInterfaceFloatingIPOptions model - getBareMetalServerNetworkInterfaceFloatingIPOptionsModel := new(vpcv1.GetBareMetalServerNetworkInterfaceFloatingIPOptions) - getBareMetalServerNetworkInterfaceFloatingIPOptionsModel.BareMetalServerID = core.StringPtr("testString") - getBareMetalServerNetworkInterfaceFloatingIPOptionsModel.NetworkInterfaceID = core.StringPtr("testString") - getBareMetalServerNetworkInterfaceFloatingIPOptionsModel.ID = core.StringPtr("testString") - getBareMetalServerNetworkInterfaceFloatingIPOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the ListSnapshotConsistencyGroupsOptions model + listSnapshotConsistencyGroupsOptionsModel := new(vpcv1.ListSnapshotConsistencyGroupsOptions) + listSnapshotConsistencyGroupsOptionsModel.Start = core.StringPtr("testString") + listSnapshotConsistencyGroupsOptionsModel.Limit = core.Int64Ptr(int64(10)) + listSnapshotConsistencyGroupsOptionsModel.ResourceGroupID = core.StringPtr("testString") + listSnapshotConsistencyGroupsOptionsModel.Name = core.StringPtr("testString") + listSnapshotConsistencyGroupsOptionsModel.Sort = core.StringPtr("name") + listSnapshotConsistencyGroupsOptionsModel.BackupPolicyPlanID = core.StringPtr("testString") + listSnapshotConsistencyGroupsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with valid options model (positive test) - result, response, operationErr = vpcService.GetBareMetalServerNetworkInterfaceFloatingIP(getBareMetalServerNetworkInterfaceFloatingIPOptionsModel) + result, response, operationErr = vpcService.ListSnapshotConsistencyGroups(listSnapshotConsistencyGroupsOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) }) - It(`Invoke GetBareMetalServerNetworkInterfaceFloatingIP with error: Operation validation and request error`, func() { + It(`Invoke ListSnapshotConsistencyGroups with error: Operation request error`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -51731,27 +51838,23 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the GetBareMetalServerNetworkInterfaceFloatingIPOptions model - getBareMetalServerNetworkInterfaceFloatingIPOptionsModel := new(vpcv1.GetBareMetalServerNetworkInterfaceFloatingIPOptions) - getBareMetalServerNetworkInterfaceFloatingIPOptionsModel.BareMetalServerID = core.StringPtr("testString") - getBareMetalServerNetworkInterfaceFloatingIPOptionsModel.NetworkInterfaceID = core.StringPtr("testString") - getBareMetalServerNetworkInterfaceFloatingIPOptionsModel.ID = core.StringPtr("testString") - getBareMetalServerNetworkInterfaceFloatingIPOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the ListSnapshotConsistencyGroupsOptions model + listSnapshotConsistencyGroupsOptionsModel := new(vpcv1.ListSnapshotConsistencyGroupsOptions) + listSnapshotConsistencyGroupsOptionsModel.Start = core.StringPtr("testString") + listSnapshotConsistencyGroupsOptionsModel.Limit = core.Int64Ptr(int64(10)) + listSnapshotConsistencyGroupsOptionsModel.ResourceGroupID = core.StringPtr("testString") + listSnapshotConsistencyGroupsOptionsModel.Name = core.StringPtr("testString") + listSnapshotConsistencyGroupsOptionsModel.Sort = core.StringPtr("name") + listSnapshotConsistencyGroupsOptionsModel.BackupPolicyPlanID = core.StringPtr("testString") + listSnapshotConsistencyGroupsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with empty URL (negative test) err := vpcService.SetServiceURL("") Expect(err).To(BeNil()) - result, response, operationErr := vpcService.GetBareMetalServerNetworkInterfaceFloatingIP(getBareMetalServerNetworkInterfaceFloatingIPOptionsModel) + result, response, operationErr := vpcService.ListSnapshotConsistencyGroups(listSnapshotConsistencyGroupsOptionsModel) 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 GetBareMetalServerNetworkInterfaceFloatingIPOptions model with no property values - getBareMetalServerNetworkInterfaceFloatingIPOptionsModelNew := new(vpcv1.GetBareMetalServerNetworkInterfaceFloatingIPOptions) - // Invoke operation with invalid model (negative test) - result, response, operationErr = vpcService.GetBareMetalServerNetworkInterfaceFloatingIP(getBareMetalServerNetworkInterfaceFloatingIPOptionsModelNew) - Expect(operationErr).ToNot(BeNil()) - Expect(response).To(BeNil()) - Expect(result).To(BeNil()) }) AfterEach(func() { testServer.Close() @@ -51766,7 +51869,7 @@ var _ = Describe(`VpcV1`, func() { res.WriteHeader(200) })) }) - It(`Invoke GetBareMetalServerNetworkInterfaceFloatingIP successfully`, func() { + It(`Invoke ListSnapshotConsistencyGroups successfully`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -51775,15 +51878,18 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the GetBareMetalServerNetworkInterfaceFloatingIPOptions model - getBareMetalServerNetworkInterfaceFloatingIPOptionsModel := new(vpcv1.GetBareMetalServerNetworkInterfaceFloatingIPOptions) - getBareMetalServerNetworkInterfaceFloatingIPOptionsModel.BareMetalServerID = core.StringPtr("testString") - getBareMetalServerNetworkInterfaceFloatingIPOptionsModel.NetworkInterfaceID = core.StringPtr("testString") - getBareMetalServerNetworkInterfaceFloatingIPOptionsModel.ID = core.StringPtr("testString") - getBareMetalServerNetworkInterfaceFloatingIPOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the ListSnapshotConsistencyGroupsOptions model + listSnapshotConsistencyGroupsOptionsModel := new(vpcv1.ListSnapshotConsistencyGroupsOptions) + listSnapshotConsistencyGroupsOptionsModel.Start = core.StringPtr("testString") + listSnapshotConsistencyGroupsOptionsModel.Limit = core.Int64Ptr(int64(10)) + listSnapshotConsistencyGroupsOptionsModel.ResourceGroupID = core.StringPtr("testString") + listSnapshotConsistencyGroupsOptionsModel.Name = core.StringPtr("testString") + listSnapshotConsistencyGroupsOptionsModel.Sort = core.StringPtr("name") + listSnapshotConsistencyGroupsOptionsModel.BackupPolicyPlanID = core.StringPtr("testString") + listSnapshotConsistencyGroupsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation - result, response, operationErr := vpcService.GetBareMetalServerNetworkInterfaceFloatingIP(getBareMetalServerNetworkInterfaceFloatingIPOptionsModel) + result, response, operationErr := vpcService.ListSnapshotConsistencyGroups(listSnapshotConsistencyGroupsOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) @@ -51794,18 +51900,127 @@ var _ = Describe(`VpcV1`, func() { testServer.Close() }) }) + Context(`Test pagination helper method on response`, func() { + It(`Invoke GetNextStart successfully`, func() { + responseObject := new(vpcv1.SnapshotConsistencyGroupCollection) + nextObject := new(vpcv1.SnapshotConsistencyGroupCollectionNext) + 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.SnapshotConsistencyGroupCollection) + + value, err := responseObject.GetNextStart() + Expect(err).To(BeNil()) + Expect(value).To(BeNil()) + }) + It(`Invoke GetNextStart without any query params in the "Next" URL`, func() { + responseObject := new(vpcv1.SnapshotConsistencyGroupCollection) + nextObject := new(vpcv1.SnapshotConsistencyGroupCollectionNext) + nextObject.Href = core.StringPtr("ibm.com") + responseObject.Next = nextObject + + value, err := responseObject.GetNextStart() + Expect(err).To(BeNil()) + Expect(value).To(BeNil()) + }) + }) + Context(`Using mock server endpoint - paginated response`, func() { + BeforeEach(func() { + var requestNumber int = 0 + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Verify the contents of the request + Expect(req.URL.EscapedPath()).To(Equal(listSnapshotConsistencyGroupsPath)) + Expect(req.Method).To(Equal("GET")) + + // Set mock response + res.Header().Set("Content-type", "application/json") + res.WriteHeader(200) + requestNumber++ + if requestNumber == 1 { + fmt.Fprintf(res, "%s", `{"next":{"href":"https://myhost.com/somePath?start=1"},"snapshot_consistency_groups":[{"backup_policy_plan":{"deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6/plans/r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178","id":"r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178","name":"my-policy-plan","remote":{"region":{"href":"https://us-south.iaas.cloud.ibm.com/v1/regions/us-south","name":"us-south"}},"resource_type":"backup_policy_plan"},"created_at":"2019-01-01T12:00:00.000Z","crn":"crn:v1:bluemix:public:is:us-south:a/123456::snapshot-consistency-group:r134-fa329f6b-0e36-433f-a3bb-0df632e79263","delete_snapshots_on_delete":false,"href":"https://us-south.iaas.cloud.ibm.com/v1/snapshot_consistency_groups/r134-fa329f6b-0e36-433f-a3bb-0df632e79263","id":"r134-fa329f6b-0e36-433f-a3bb-0df632e79263","lifecycle_state":"stable","name":"my-snapshot-consistency-group","resource_group":{"href":"https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345","id":"fee82deba12e4c0fb69c3b09d1f12345","name":"my-resource-group"},"resource_type":"snapshot_consistency_group","service_tags":["ServiceTags"],"snapshots":[{"crn":"crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263","deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263","id":"r134-f6bfa329-0e36-433f-a3bb-0df632e79263","name":"my-snapshot","remote":{"region":{"href":"https://us-south.iaas.cloud.ibm.com/v1/regions/us-south","name":"us-south"}},"resource_type":"snapshot"}]}],"total_count":2,"limit":1}`) + } else if requestNumber == 2 { + fmt.Fprintf(res, "%s", `{"snapshot_consistency_groups":[{"backup_policy_plan":{"deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6/plans/r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178","id":"r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178","name":"my-policy-plan","remote":{"region":{"href":"https://us-south.iaas.cloud.ibm.com/v1/regions/us-south","name":"us-south"}},"resource_type":"backup_policy_plan"},"created_at":"2019-01-01T12:00:00.000Z","crn":"crn:v1:bluemix:public:is:us-south:a/123456::snapshot-consistency-group:r134-fa329f6b-0e36-433f-a3bb-0df632e79263","delete_snapshots_on_delete":false,"href":"https://us-south.iaas.cloud.ibm.com/v1/snapshot_consistency_groups/r134-fa329f6b-0e36-433f-a3bb-0df632e79263","id":"r134-fa329f6b-0e36-433f-a3bb-0df632e79263","lifecycle_state":"stable","name":"my-snapshot-consistency-group","resource_group":{"href":"https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345","id":"fee82deba12e4c0fb69c3b09d1f12345","name":"my-resource-group"},"resource_type":"snapshot_consistency_group","service_tags":["ServiceTags"],"snapshots":[{"crn":"crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263","deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263","id":"r134-f6bfa329-0e36-433f-a3bb-0df632e79263","name":"my-snapshot","remote":{"region":{"href":"https://us-south.iaas.cloud.ibm.com/v1/regions/us-south","name":"us-south"}},"resource_type":"snapshot"}]}],"total_count":2,"limit":1}`) + } else { + res.WriteHeader(400) + } + })) + }) + It(`Use SnapshotConsistencyGroupsPager.GetNext successfully`, func() { + vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + Version: core.StringPtr(version), + }) + Expect(serviceErr).To(BeNil()) + Expect(vpcService).ToNot(BeNil()) + + listSnapshotConsistencyGroupsOptionsModel := &vpcv1.ListSnapshotConsistencyGroupsOptions{ + Limit: core.Int64Ptr(int64(10)), + ResourceGroupID: core.StringPtr("testString"), + Name: core.StringPtr("testString"), + Sort: core.StringPtr("name"), + BackupPolicyPlanID: core.StringPtr("testString"), + } + + pager, err := vpcService.NewSnapshotConsistencyGroupsPager(listSnapshotConsistencyGroupsOptionsModel) + Expect(err).To(BeNil()) + Expect(pager).ToNot(BeNil()) + + var allResults []vpcv1.SnapshotConsistencyGroup + for pager.HasNext() { + nextPage, err := pager.GetNext() + Expect(err).To(BeNil()) + Expect(nextPage).ToNot(BeNil()) + allResults = append(allResults, nextPage...) + } + Expect(len(allResults)).To(Equal(2)) + }) + It(`Use SnapshotConsistencyGroupsPager.GetAll successfully`, func() { + vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + Version: core.StringPtr(version), + }) + Expect(serviceErr).To(BeNil()) + Expect(vpcService).ToNot(BeNil()) + + listSnapshotConsistencyGroupsOptionsModel := &vpcv1.ListSnapshotConsistencyGroupsOptions{ + Limit: core.Int64Ptr(int64(10)), + ResourceGroupID: core.StringPtr("testString"), + Name: core.StringPtr("testString"), + Sort: core.StringPtr("name"), + BackupPolicyPlanID: core.StringPtr("testString"), + } + + pager, err := vpcService.NewSnapshotConsistencyGroupsPager(listSnapshotConsistencyGroupsOptionsModel) + Expect(err).To(BeNil()) + Expect(pager).ToNot(BeNil()) + + allResults, err := pager.GetAll() + Expect(err).To(BeNil()) + Expect(allResults).ToNot(BeNil()) + Expect(len(allResults)).To(Equal(2)) + }) + }) }) - Describe(`AddBareMetalServerNetworkInterfaceFloatingIP(addBareMetalServerNetworkInterfaceFloatingIPOptions *AddBareMetalServerNetworkInterfaceFloatingIPOptions) - Operation response error`, func() { + Describe(`CreateSnapshotConsistencyGroup(createSnapshotConsistencyGroupOptions *CreateSnapshotConsistencyGroupOptions) - Operation response error`, func() { version := "testString" - addBareMetalServerNetworkInterfaceFloatingIPPath := "/bare_metal_servers/testString/network_interfaces/testString/floating_ips/testString" + createSnapshotConsistencyGroupPath := "/snapshot_consistency_groups" Context(`Using mock server endpoint with invalid JSON response`, func() { BeforeEach(func() { testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(addBareMetalServerNetworkInterfaceFloatingIPPath)) - Expect(req.Method).To(Equal("PUT")) + Expect(req.URL.EscapedPath()).To(Equal(createSnapshotConsistencyGroupPath)) + Expect(req.Method).To(Equal("POST")) Expect(req.URL.Query()["version"]).To(Equal([]string{"testString"})) Expect(req.URL.Query()["generation"]).To(Equal([]string{fmt.Sprint(int64(2))})) res.Header().Set("Content-type", "application/json") @@ -51813,7 +52028,7 @@ var _ = Describe(`VpcV1`, func() { fmt.Fprint(res, `} this is not valid json {`) })) }) - It(`Invoke AddBareMetalServerNetworkInterfaceFloatingIP with error: Operation response processing error`, func() { + It(`Invoke CreateSnapshotConsistencyGroup with error: Operation response processing error`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -51822,21 +52037,40 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the AddBareMetalServerNetworkInterfaceFloatingIPOptions model - addBareMetalServerNetworkInterfaceFloatingIPOptionsModel := new(vpcv1.AddBareMetalServerNetworkInterfaceFloatingIPOptions) - addBareMetalServerNetworkInterfaceFloatingIPOptionsModel.BareMetalServerID = core.StringPtr("testString") - addBareMetalServerNetworkInterfaceFloatingIPOptionsModel.NetworkInterfaceID = core.StringPtr("testString") - addBareMetalServerNetworkInterfaceFloatingIPOptionsModel.ID = core.StringPtr("testString") - addBareMetalServerNetworkInterfaceFloatingIPOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the ResourceGroupIdentityByID model + resourceGroupIdentityModel := new(vpcv1.ResourceGroupIdentityByID) + resourceGroupIdentityModel.ID = core.StringPtr("fee82deba12e4c0fb69c3b09d1f12345") + + // Construct an instance of the VolumeIdentityByID model + volumeIdentityModel := new(vpcv1.VolumeIdentityByID) + volumeIdentityModel.ID = core.StringPtr("1a6b7274-678d-4dfb-8981-c71dd9d4daa5") + + // Construct an instance of the SnapshotPrototypeSnapshotConsistencyGroupContext model + snapshotPrototypeSnapshotConsistencyGroupContextModel := new(vpcv1.SnapshotPrototypeSnapshotConsistencyGroupContext) + snapshotPrototypeSnapshotConsistencyGroupContextModel.Name = core.StringPtr("my-snapshot") + snapshotPrototypeSnapshotConsistencyGroupContextModel.SourceVolume = volumeIdentityModel + snapshotPrototypeSnapshotConsistencyGroupContextModel.UserTags = []string{"testString"} + + // Construct an instance of the SnapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshots model + snapshotConsistencyGroupPrototypeModel := new(vpcv1.SnapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshots) + snapshotConsistencyGroupPrototypeModel.DeleteSnapshotsOnDelete = core.BoolPtr(true) + snapshotConsistencyGroupPrototypeModel.Name = core.StringPtr("my-snapshot-consistency-group") + snapshotConsistencyGroupPrototypeModel.ResourceGroup = resourceGroupIdentityModel + snapshotConsistencyGroupPrototypeModel.Snapshots = []vpcv1.SnapshotPrototypeSnapshotConsistencyGroupContext{*snapshotPrototypeSnapshotConsistencyGroupContextModel} + + // Construct an instance of the CreateSnapshotConsistencyGroupOptions model + createSnapshotConsistencyGroupOptionsModel := new(vpcv1.CreateSnapshotConsistencyGroupOptions) + createSnapshotConsistencyGroupOptionsModel.SnapshotConsistencyGroupPrototype = snapshotConsistencyGroupPrototypeModel + createSnapshotConsistencyGroupOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Expect response parsing to fail since we are receiving a text/plain response - result, response, operationErr := vpcService.AddBareMetalServerNetworkInterfaceFloatingIP(addBareMetalServerNetworkInterfaceFloatingIPOptionsModel) + result, response, operationErr := vpcService.CreateSnapshotConsistencyGroup(createSnapshotConsistencyGroupOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).To(BeNil()) // Enable retries and test again vpcService.EnableRetries(0, 0) - result, response, operationErr = vpcService.AddBareMetalServerNetworkInterfaceFloatingIP(addBareMetalServerNetworkInterfaceFloatingIPOptionsModel) + result, response, operationErr = vpcService.CreateSnapshotConsistencyGroup(createSnapshotConsistencyGroupOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).To(BeNil()) @@ -51846,17 +52080,33 @@ var _ = Describe(`VpcV1`, func() { }) }) }) - Describe(`AddBareMetalServerNetworkInterfaceFloatingIP(addBareMetalServerNetworkInterfaceFloatingIPOptions *AddBareMetalServerNetworkInterfaceFloatingIPOptions)`, func() { + Describe(`CreateSnapshotConsistencyGroup(createSnapshotConsistencyGroupOptions *CreateSnapshotConsistencyGroupOptions)`, func() { version := "testString" - addBareMetalServerNetworkInterfaceFloatingIPPath := "/bare_metal_servers/testString/network_interfaces/testString/floating_ips/testString" + createSnapshotConsistencyGroupPath := "/snapshot_consistency_groups" Context(`Using mock server endpoint with timeout`, func() { BeforeEach(func() { testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(addBareMetalServerNetworkInterfaceFloatingIPPath)) - Expect(req.Method).To(Equal("PUT")) + Expect(req.URL.EscapedPath()).To(Equal(createSnapshotConsistencyGroupPath)) + 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))})) @@ -51866,10 +52116,10 @@ var _ = Describe(`VpcV1`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(201) - fmt.Fprintf(res, "%s", `{"address": "203.0.113.1", "created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::floating-ip:39300233-9995-4806-89a5-3c1b6eb88689", "href": "https://us-south.iaas.cloud.ibm.com/v1/floating_ips/39300233-9995-4806-89a5-3c1b6eb88689", "id": "39300233-9995-4806-89a5-3c1b6eb88689", "name": "my-floating-ip", "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "status": "available", "target": {"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/instances/1e09281b-f177-46fb-baf1-bc152b2e391a/network_interfaces/10c02d81-0ecb-4dc5-897d-28392913b81e", "id": "10c02d81-0ecb-4dc5-897d-28392913b81e", "name": "my-instance-network-interface", "primary_ip": {"address": "192.168.3.4", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e/reserved_ips/6d353a0f-aeb1-4ae1-832e-1110d10981bb", "id": "6d353a0f-aeb1-4ae1-832e-1110d10981bb", "name": "my-reserved-ip", "resource_type": "subnet_reserved_ip"}, "resource_type": "network_interface"}, "zone": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south/zones/us-south-1", "name": "us-south-1"}}`) + fmt.Fprintf(res, "%s", `{"backup_policy_plan": {"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6/plans/r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "id": "r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "name": "my-policy-plan", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "backup_policy_plan"}, "created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot-consistency-group:r134-fa329f6b-0e36-433f-a3bb-0df632e79263", "delete_snapshots_on_delete": false, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshot_consistency_groups/r134-fa329f6b-0e36-433f-a3bb-0df632e79263", "id": "r134-fa329f6b-0e36-433f-a3bb-0df632e79263", "lifecycle_state": "stable", "name": "my-snapshot-consistency-group", "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "resource_type": "snapshot_consistency_group", "service_tags": ["ServiceTags"], "snapshots": [{"crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "id": "r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "name": "my-snapshot", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "snapshot"}]}`) })) }) - It(`Invoke AddBareMetalServerNetworkInterfaceFloatingIP successfully with retries`, func() { + It(`Invoke CreateSnapshotConsistencyGroup successfully with retries`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -51879,23 +52129,42 @@ var _ = Describe(`VpcV1`, func() { Expect(vpcService).ToNot(BeNil()) vpcService.EnableRetries(0, 0) - // Construct an instance of the AddBareMetalServerNetworkInterfaceFloatingIPOptions model - addBareMetalServerNetworkInterfaceFloatingIPOptionsModel := new(vpcv1.AddBareMetalServerNetworkInterfaceFloatingIPOptions) - addBareMetalServerNetworkInterfaceFloatingIPOptionsModel.BareMetalServerID = core.StringPtr("testString") - addBareMetalServerNetworkInterfaceFloatingIPOptionsModel.NetworkInterfaceID = core.StringPtr("testString") - addBareMetalServerNetworkInterfaceFloatingIPOptionsModel.ID = core.StringPtr("testString") - addBareMetalServerNetworkInterfaceFloatingIPOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the ResourceGroupIdentityByID model + resourceGroupIdentityModel := new(vpcv1.ResourceGroupIdentityByID) + resourceGroupIdentityModel.ID = core.StringPtr("fee82deba12e4c0fb69c3b09d1f12345") + + // Construct an instance of the VolumeIdentityByID model + volumeIdentityModel := new(vpcv1.VolumeIdentityByID) + volumeIdentityModel.ID = core.StringPtr("1a6b7274-678d-4dfb-8981-c71dd9d4daa5") + + // Construct an instance of the SnapshotPrototypeSnapshotConsistencyGroupContext model + snapshotPrototypeSnapshotConsistencyGroupContextModel := new(vpcv1.SnapshotPrototypeSnapshotConsistencyGroupContext) + snapshotPrototypeSnapshotConsistencyGroupContextModel.Name = core.StringPtr("my-snapshot") + snapshotPrototypeSnapshotConsistencyGroupContextModel.SourceVolume = volumeIdentityModel + snapshotPrototypeSnapshotConsistencyGroupContextModel.UserTags = []string{"testString"} + + // Construct an instance of the SnapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshots model + snapshotConsistencyGroupPrototypeModel := new(vpcv1.SnapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshots) + snapshotConsistencyGroupPrototypeModel.DeleteSnapshotsOnDelete = core.BoolPtr(true) + snapshotConsistencyGroupPrototypeModel.Name = core.StringPtr("my-snapshot-consistency-group") + snapshotConsistencyGroupPrototypeModel.ResourceGroup = resourceGroupIdentityModel + snapshotConsistencyGroupPrototypeModel.Snapshots = []vpcv1.SnapshotPrototypeSnapshotConsistencyGroupContext{*snapshotPrototypeSnapshotConsistencyGroupContextModel} + + // Construct an instance of the CreateSnapshotConsistencyGroupOptions model + createSnapshotConsistencyGroupOptionsModel := new(vpcv1.CreateSnapshotConsistencyGroupOptions) + createSnapshotConsistencyGroupOptionsModel.SnapshotConsistencyGroupPrototype = snapshotConsistencyGroupPrototypeModel + createSnapshotConsistencyGroupOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with a Context to test a timeout error ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond) defer cancelFunc() - _, _, operationErr := vpcService.AddBareMetalServerNetworkInterfaceFloatingIPWithContext(ctx, addBareMetalServerNetworkInterfaceFloatingIPOptionsModel) + _, _, operationErr := vpcService.CreateSnapshotConsistencyGroupWithContext(ctx, createSnapshotConsistencyGroupOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) // Disable retries and test again vpcService.DisableRetries() - result, response, operationErr := vpcService.AddBareMetalServerNetworkInterfaceFloatingIP(addBareMetalServerNetworkInterfaceFloatingIPOptionsModel) + result, response, operationErr := vpcService.CreateSnapshotConsistencyGroup(createSnapshotConsistencyGroupOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) @@ -51903,7 +52172,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.AddBareMetalServerNetworkInterfaceFloatingIPWithContext(ctx, addBareMetalServerNetworkInterfaceFloatingIPOptionsModel) + _, _, operationErr = vpcService.CreateSnapshotConsistencyGroupWithContext(ctx, createSnapshotConsistencyGroupOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) }) @@ -51917,18 +52186,34 @@ var _ = Describe(`VpcV1`, func() { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(addBareMetalServerNetworkInterfaceFloatingIPPath)) - Expect(req.Method).To(Equal("PUT")) + Expect(req.URL.EscapedPath()).To(Equal(createSnapshotConsistencyGroupPath)) + 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", `{"address": "203.0.113.1", "created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::floating-ip:39300233-9995-4806-89a5-3c1b6eb88689", "href": "https://us-south.iaas.cloud.ibm.com/v1/floating_ips/39300233-9995-4806-89a5-3c1b6eb88689", "id": "39300233-9995-4806-89a5-3c1b6eb88689", "name": "my-floating-ip", "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "status": "available", "target": {"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/instances/1e09281b-f177-46fb-baf1-bc152b2e391a/network_interfaces/10c02d81-0ecb-4dc5-897d-28392913b81e", "id": "10c02d81-0ecb-4dc5-897d-28392913b81e", "name": "my-instance-network-interface", "primary_ip": {"address": "192.168.3.4", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e/reserved_ips/6d353a0f-aeb1-4ae1-832e-1110d10981bb", "id": "6d353a0f-aeb1-4ae1-832e-1110d10981bb", "name": "my-reserved-ip", "resource_type": "subnet_reserved_ip"}, "resource_type": "network_interface"}, "zone": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south/zones/us-south-1", "name": "us-south-1"}}`) + fmt.Fprintf(res, "%s", `{"backup_policy_plan": {"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6/plans/r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "id": "r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "name": "my-policy-plan", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "backup_policy_plan"}, "created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot-consistency-group:r134-fa329f6b-0e36-433f-a3bb-0df632e79263", "delete_snapshots_on_delete": false, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshot_consistency_groups/r134-fa329f6b-0e36-433f-a3bb-0df632e79263", "id": "r134-fa329f6b-0e36-433f-a3bb-0df632e79263", "lifecycle_state": "stable", "name": "my-snapshot-consistency-group", "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "resource_type": "snapshot_consistency_group", "service_tags": ["ServiceTags"], "snapshots": [{"crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "id": "r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "name": "my-snapshot", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "snapshot"}]}`) })) }) - It(`Invoke AddBareMetalServerNetworkInterfaceFloatingIP successfully`, func() { + It(`Invoke CreateSnapshotConsistencyGroup successfully`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -51938,26 +52223,45 @@ var _ = Describe(`VpcV1`, func() { Expect(vpcService).ToNot(BeNil()) // Invoke operation with nil options model (negative test) - result, response, operationErr := vpcService.AddBareMetalServerNetworkInterfaceFloatingIP(nil) + result, response, operationErr := vpcService.CreateSnapshotConsistencyGroup(nil) Expect(operationErr).NotTo(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) - // Construct an instance of the AddBareMetalServerNetworkInterfaceFloatingIPOptions model - addBareMetalServerNetworkInterfaceFloatingIPOptionsModel := new(vpcv1.AddBareMetalServerNetworkInterfaceFloatingIPOptions) - addBareMetalServerNetworkInterfaceFloatingIPOptionsModel.BareMetalServerID = core.StringPtr("testString") - addBareMetalServerNetworkInterfaceFloatingIPOptionsModel.NetworkInterfaceID = core.StringPtr("testString") - addBareMetalServerNetworkInterfaceFloatingIPOptionsModel.ID = core.StringPtr("testString") - addBareMetalServerNetworkInterfaceFloatingIPOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the ResourceGroupIdentityByID model + resourceGroupIdentityModel := new(vpcv1.ResourceGroupIdentityByID) + resourceGroupIdentityModel.ID = core.StringPtr("fee82deba12e4c0fb69c3b09d1f12345") + + // Construct an instance of the VolumeIdentityByID model + volumeIdentityModel := new(vpcv1.VolumeIdentityByID) + volumeIdentityModel.ID = core.StringPtr("1a6b7274-678d-4dfb-8981-c71dd9d4daa5") + + // Construct an instance of the SnapshotPrototypeSnapshotConsistencyGroupContext model + snapshotPrototypeSnapshotConsistencyGroupContextModel := new(vpcv1.SnapshotPrototypeSnapshotConsistencyGroupContext) + snapshotPrototypeSnapshotConsistencyGroupContextModel.Name = core.StringPtr("my-snapshot") + snapshotPrototypeSnapshotConsistencyGroupContextModel.SourceVolume = volumeIdentityModel + snapshotPrototypeSnapshotConsistencyGroupContextModel.UserTags = []string{"testString"} + + // Construct an instance of the SnapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshots model + snapshotConsistencyGroupPrototypeModel := new(vpcv1.SnapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshots) + snapshotConsistencyGroupPrototypeModel.DeleteSnapshotsOnDelete = core.BoolPtr(true) + snapshotConsistencyGroupPrototypeModel.Name = core.StringPtr("my-snapshot-consistency-group") + snapshotConsistencyGroupPrototypeModel.ResourceGroup = resourceGroupIdentityModel + snapshotConsistencyGroupPrototypeModel.Snapshots = []vpcv1.SnapshotPrototypeSnapshotConsistencyGroupContext{*snapshotPrototypeSnapshotConsistencyGroupContextModel} + + // Construct an instance of the CreateSnapshotConsistencyGroupOptions model + createSnapshotConsistencyGroupOptionsModel := new(vpcv1.CreateSnapshotConsistencyGroupOptions) + createSnapshotConsistencyGroupOptionsModel.SnapshotConsistencyGroupPrototype = snapshotConsistencyGroupPrototypeModel + createSnapshotConsistencyGroupOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with valid options model (positive test) - result, response, operationErr = vpcService.AddBareMetalServerNetworkInterfaceFloatingIP(addBareMetalServerNetworkInterfaceFloatingIPOptionsModel) + result, response, operationErr = vpcService.CreateSnapshotConsistencyGroup(createSnapshotConsistencyGroupOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) }) - It(`Invoke AddBareMetalServerNetworkInterfaceFloatingIP with error: Operation validation and request error`, func() { + It(`Invoke CreateSnapshotConsistencyGroup with error: Operation validation and request error`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -51966,24 +52270,43 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the AddBareMetalServerNetworkInterfaceFloatingIPOptions model - addBareMetalServerNetworkInterfaceFloatingIPOptionsModel := new(vpcv1.AddBareMetalServerNetworkInterfaceFloatingIPOptions) - addBareMetalServerNetworkInterfaceFloatingIPOptionsModel.BareMetalServerID = core.StringPtr("testString") - addBareMetalServerNetworkInterfaceFloatingIPOptionsModel.NetworkInterfaceID = core.StringPtr("testString") - addBareMetalServerNetworkInterfaceFloatingIPOptionsModel.ID = core.StringPtr("testString") - addBareMetalServerNetworkInterfaceFloatingIPOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the ResourceGroupIdentityByID model + resourceGroupIdentityModel := new(vpcv1.ResourceGroupIdentityByID) + resourceGroupIdentityModel.ID = core.StringPtr("fee82deba12e4c0fb69c3b09d1f12345") + + // Construct an instance of the VolumeIdentityByID model + volumeIdentityModel := new(vpcv1.VolumeIdentityByID) + volumeIdentityModel.ID = core.StringPtr("1a6b7274-678d-4dfb-8981-c71dd9d4daa5") + + // Construct an instance of the SnapshotPrototypeSnapshotConsistencyGroupContext model + snapshotPrototypeSnapshotConsistencyGroupContextModel := new(vpcv1.SnapshotPrototypeSnapshotConsistencyGroupContext) + snapshotPrototypeSnapshotConsistencyGroupContextModel.Name = core.StringPtr("my-snapshot") + snapshotPrototypeSnapshotConsistencyGroupContextModel.SourceVolume = volumeIdentityModel + snapshotPrototypeSnapshotConsistencyGroupContextModel.UserTags = []string{"testString"} + + // Construct an instance of the SnapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshots model + snapshotConsistencyGroupPrototypeModel := new(vpcv1.SnapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshots) + snapshotConsistencyGroupPrototypeModel.DeleteSnapshotsOnDelete = core.BoolPtr(true) + snapshotConsistencyGroupPrototypeModel.Name = core.StringPtr("my-snapshot-consistency-group") + snapshotConsistencyGroupPrototypeModel.ResourceGroup = resourceGroupIdentityModel + snapshotConsistencyGroupPrototypeModel.Snapshots = []vpcv1.SnapshotPrototypeSnapshotConsistencyGroupContext{*snapshotPrototypeSnapshotConsistencyGroupContextModel} + + // Construct an instance of the CreateSnapshotConsistencyGroupOptions model + createSnapshotConsistencyGroupOptionsModel := new(vpcv1.CreateSnapshotConsistencyGroupOptions) + createSnapshotConsistencyGroupOptionsModel.SnapshotConsistencyGroupPrototype = snapshotConsistencyGroupPrototypeModel + createSnapshotConsistencyGroupOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with empty URL (negative test) err := vpcService.SetServiceURL("") Expect(err).To(BeNil()) - result, response, operationErr := vpcService.AddBareMetalServerNetworkInterfaceFloatingIP(addBareMetalServerNetworkInterfaceFloatingIPOptionsModel) + result, response, operationErr := vpcService.CreateSnapshotConsistencyGroup(createSnapshotConsistencyGroupOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING)) Expect(response).To(BeNil()) Expect(result).To(BeNil()) - // Construct a second instance of the AddBareMetalServerNetworkInterfaceFloatingIPOptions model with no property values - addBareMetalServerNetworkInterfaceFloatingIPOptionsModelNew := new(vpcv1.AddBareMetalServerNetworkInterfaceFloatingIPOptions) + // Construct a second instance of the CreateSnapshotConsistencyGroupOptions model with no property values + createSnapshotConsistencyGroupOptionsModelNew := new(vpcv1.CreateSnapshotConsistencyGroupOptions) // Invoke operation with invalid model (negative test) - result, response, operationErr = vpcService.AddBareMetalServerNetworkInterfaceFloatingIP(addBareMetalServerNetworkInterfaceFloatingIPOptionsModelNew) + result, response, operationErr = vpcService.CreateSnapshotConsistencyGroup(createSnapshotConsistencyGroupOptionsModelNew) Expect(operationErr).ToNot(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) @@ -52001,7 +52324,7 @@ var _ = Describe(`VpcV1`, func() { res.WriteHeader(201) })) }) - It(`Invoke AddBareMetalServerNetworkInterfaceFloatingIP successfully`, func() { + It(`Invoke CreateSnapshotConsistencyGroup successfully`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -52010,15 +52333,34 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the AddBareMetalServerNetworkInterfaceFloatingIPOptions model - addBareMetalServerNetworkInterfaceFloatingIPOptionsModel := new(vpcv1.AddBareMetalServerNetworkInterfaceFloatingIPOptions) - addBareMetalServerNetworkInterfaceFloatingIPOptionsModel.BareMetalServerID = core.StringPtr("testString") - addBareMetalServerNetworkInterfaceFloatingIPOptionsModel.NetworkInterfaceID = core.StringPtr("testString") - addBareMetalServerNetworkInterfaceFloatingIPOptionsModel.ID = core.StringPtr("testString") - addBareMetalServerNetworkInterfaceFloatingIPOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the ResourceGroupIdentityByID model + resourceGroupIdentityModel := new(vpcv1.ResourceGroupIdentityByID) + resourceGroupIdentityModel.ID = core.StringPtr("fee82deba12e4c0fb69c3b09d1f12345") + + // Construct an instance of the VolumeIdentityByID model + volumeIdentityModel := new(vpcv1.VolumeIdentityByID) + volumeIdentityModel.ID = core.StringPtr("1a6b7274-678d-4dfb-8981-c71dd9d4daa5") + + // Construct an instance of the SnapshotPrototypeSnapshotConsistencyGroupContext model + snapshotPrototypeSnapshotConsistencyGroupContextModel := new(vpcv1.SnapshotPrototypeSnapshotConsistencyGroupContext) + snapshotPrototypeSnapshotConsistencyGroupContextModel.Name = core.StringPtr("my-snapshot") + snapshotPrototypeSnapshotConsistencyGroupContextModel.SourceVolume = volumeIdentityModel + snapshotPrototypeSnapshotConsistencyGroupContextModel.UserTags = []string{"testString"} + + // Construct an instance of the SnapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshots model + snapshotConsistencyGroupPrototypeModel := new(vpcv1.SnapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshots) + snapshotConsistencyGroupPrototypeModel.DeleteSnapshotsOnDelete = core.BoolPtr(true) + snapshotConsistencyGroupPrototypeModel.Name = core.StringPtr("my-snapshot-consistency-group") + snapshotConsistencyGroupPrototypeModel.ResourceGroup = resourceGroupIdentityModel + snapshotConsistencyGroupPrototypeModel.Snapshots = []vpcv1.SnapshotPrototypeSnapshotConsistencyGroupContext{*snapshotPrototypeSnapshotConsistencyGroupContextModel} + + // Construct an instance of the CreateSnapshotConsistencyGroupOptions model + createSnapshotConsistencyGroupOptionsModel := new(vpcv1.CreateSnapshotConsistencyGroupOptions) + createSnapshotConsistencyGroupOptionsModel.SnapshotConsistencyGroupPrototype = snapshotConsistencyGroupPrototypeModel + createSnapshotConsistencyGroupOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation - result, response, operationErr := vpcService.AddBareMetalServerNetworkInterfaceFloatingIP(addBareMetalServerNetworkInterfaceFloatingIPOptionsModel) + result, response, operationErr := vpcService.CreateSnapshotConsistencyGroup(createSnapshotConsistencyGroupOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) @@ -52030,25 +52372,25 @@ var _ = Describe(`VpcV1`, func() { }) }) }) - Describe(`ListBareMetalServerNetworkInterfaceIps(listBareMetalServerNetworkInterfaceIpsOptions *ListBareMetalServerNetworkInterfaceIpsOptions) - Operation response error`, func() { + Describe(`DeleteSnapshotConsistencyGroup(deleteSnapshotConsistencyGroupOptions *DeleteSnapshotConsistencyGroupOptions) - Operation response error`, func() { version := "testString" - listBareMetalServerNetworkInterfaceIpsPath := "/bare_metal_servers/testString/network_interfaces/testString/ips" + deleteSnapshotConsistencyGroupPath := "/snapshot_consistency_groups/testString" Context(`Using mock server endpoint with invalid JSON response`, func() { BeforeEach(func() { testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(listBareMetalServerNetworkInterfaceIpsPath)) - Expect(req.Method).To(Equal("GET")) + Expect(req.URL.EscapedPath()).To(Equal(deleteSnapshotConsistencyGroupPath)) + Expect(req.Method).To(Equal("DELETE")) Expect(req.URL.Query()["version"]).To(Equal([]string{"testString"})) Expect(req.URL.Query()["generation"]).To(Equal([]string{fmt.Sprint(int64(2))})) res.Header().Set("Content-type", "application/json") - res.WriteHeader(200) + res.WriteHeader(202) fmt.Fprint(res, `} this is not valid json {`) })) }) - It(`Invoke ListBareMetalServerNetworkInterfaceIps with error: Operation response processing error`, func() { + It(`Invoke DeleteSnapshotConsistencyGroup with error: Operation response processing error`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -52057,20 +52399,19 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the ListBareMetalServerNetworkInterfaceIpsOptions model - listBareMetalServerNetworkInterfaceIpsOptionsModel := new(vpcv1.ListBareMetalServerNetworkInterfaceIpsOptions) - listBareMetalServerNetworkInterfaceIpsOptionsModel.BareMetalServerID = core.StringPtr("testString") - listBareMetalServerNetworkInterfaceIpsOptionsModel.NetworkInterfaceID = core.StringPtr("testString") - listBareMetalServerNetworkInterfaceIpsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the DeleteSnapshotConsistencyGroupOptions model + deleteSnapshotConsistencyGroupOptionsModel := new(vpcv1.DeleteSnapshotConsistencyGroupOptions) + deleteSnapshotConsistencyGroupOptionsModel.ID = core.StringPtr("testString") + deleteSnapshotConsistencyGroupOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Expect response parsing to fail since we are receiving a text/plain response - result, response, operationErr := vpcService.ListBareMetalServerNetworkInterfaceIps(listBareMetalServerNetworkInterfaceIpsOptionsModel) + result, response, operationErr := vpcService.DeleteSnapshotConsistencyGroup(deleteSnapshotConsistencyGroupOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).To(BeNil()) // Enable retries and test again vpcService.EnableRetries(0, 0) - result, response, operationErr = vpcService.ListBareMetalServerNetworkInterfaceIps(listBareMetalServerNetworkInterfaceIpsOptionsModel) + result, response, operationErr = vpcService.DeleteSnapshotConsistencyGroup(deleteSnapshotConsistencyGroupOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).To(BeNil()) @@ -52080,17 +52421,17 @@ var _ = Describe(`VpcV1`, func() { }) }) }) - Describe(`ListBareMetalServerNetworkInterfaceIps(listBareMetalServerNetworkInterfaceIpsOptions *ListBareMetalServerNetworkInterfaceIpsOptions)`, func() { + Describe(`DeleteSnapshotConsistencyGroup(deleteSnapshotConsistencyGroupOptions *DeleteSnapshotConsistencyGroupOptions)`, func() { version := "testString" - listBareMetalServerNetworkInterfaceIpsPath := "/bare_metal_servers/testString/network_interfaces/testString/ips" + deleteSnapshotConsistencyGroupPath := "/snapshot_consistency_groups/testString" Context(`Using mock server endpoint with timeout`, func() { BeforeEach(func() { testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(listBareMetalServerNetworkInterfaceIpsPath)) - Expect(req.Method).To(Equal("GET")) + Expect(req.URL.EscapedPath()).To(Equal(deleteSnapshotConsistencyGroupPath)) + Expect(req.Method).To(Equal("DELETE")) Expect(req.URL.Query()["version"]).To(Equal([]string{"testString"})) Expect(req.URL.Query()["generation"]).To(Equal([]string{fmt.Sprint(int64(2))})) @@ -52099,11 +52440,11 @@ var _ = Describe(`VpcV1`, func() { // 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/bare_metal_servers/1e09281b-f177-46fb-baf1-bc152b2e391a/network_interfaces/10c02d81-0ecb-4dc5-897d-28392913b81e/ips?limit=20"}, "ips": [{"address": "192.168.3.4", "auto_delete": false, "created_at": "2019-01-01T12:00:00.000Z", "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e/reserved_ips/6d353a0f-aeb1-4ae1-832e-1110d10981bb", "id": "6d353a0f-aeb1-4ae1-832e-1110d10981bb", "lifecycle_state": "stable", "name": "my-reserved-ip", "owner": "user", "resource_type": "subnet_reserved_ip", "target": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::endpoint-gateway:r134-d7cc5196-9864-48c4-82d8-3f30da41fcc5", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/endpoint_gateways/r134-d7cc5196-9864-48c4-82d8-3f30da41fcc5", "id": "r134-d7cc5196-9864-48c4-82d8-3f30da41fcc5", "name": "my-endpoint-gateway", "resource_type": "endpoint_gateway"}}], "limit": 20, "next": {"href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/1e09281b-f177-46fb-baf1-bc152b2e391a/network_interfaces/10c02d81-0ecb-4dc5-897d-28392913b81e/ips?start=a404e343444b4e1095c9edba76672d67&limit=20"}, "total_count": 132}`) + res.WriteHeader(202) + fmt.Fprintf(res, "%s", `{"backup_policy_plan": {"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6/plans/r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "id": "r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "name": "my-policy-plan", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "backup_policy_plan"}, "created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot-consistency-group:r134-fa329f6b-0e36-433f-a3bb-0df632e79263", "delete_snapshots_on_delete": false, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshot_consistency_groups/r134-fa329f6b-0e36-433f-a3bb-0df632e79263", "id": "r134-fa329f6b-0e36-433f-a3bb-0df632e79263", "lifecycle_state": "stable", "name": "my-snapshot-consistency-group", "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "resource_type": "snapshot_consistency_group", "service_tags": ["ServiceTags"], "snapshots": [{"crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "id": "r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "name": "my-snapshot", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "snapshot"}]}`) })) }) - It(`Invoke ListBareMetalServerNetworkInterfaceIps successfully with retries`, func() { + It(`Invoke DeleteSnapshotConsistencyGroup successfully with retries`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -52113,22 +52454,21 @@ var _ = Describe(`VpcV1`, func() { Expect(vpcService).ToNot(BeNil()) vpcService.EnableRetries(0, 0) - // Construct an instance of the ListBareMetalServerNetworkInterfaceIpsOptions model - listBareMetalServerNetworkInterfaceIpsOptionsModel := new(vpcv1.ListBareMetalServerNetworkInterfaceIpsOptions) - listBareMetalServerNetworkInterfaceIpsOptionsModel.BareMetalServerID = core.StringPtr("testString") - listBareMetalServerNetworkInterfaceIpsOptionsModel.NetworkInterfaceID = core.StringPtr("testString") - listBareMetalServerNetworkInterfaceIpsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the DeleteSnapshotConsistencyGroupOptions model + deleteSnapshotConsistencyGroupOptionsModel := new(vpcv1.DeleteSnapshotConsistencyGroupOptions) + deleteSnapshotConsistencyGroupOptionsModel.ID = core.StringPtr("testString") + deleteSnapshotConsistencyGroupOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with a Context to test a timeout error ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond) defer cancelFunc() - _, _, operationErr := vpcService.ListBareMetalServerNetworkInterfaceIpsWithContext(ctx, listBareMetalServerNetworkInterfaceIpsOptionsModel) + _, _, operationErr := vpcService.DeleteSnapshotConsistencyGroupWithContext(ctx, deleteSnapshotConsistencyGroupOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) // Disable retries and test again vpcService.DisableRetries() - result, response, operationErr := vpcService.ListBareMetalServerNetworkInterfaceIps(listBareMetalServerNetworkInterfaceIpsOptionsModel) + result, response, operationErr := vpcService.DeleteSnapshotConsistencyGroup(deleteSnapshotConsistencyGroupOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) @@ -52136,7 +52476,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.ListBareMetalServerNetworkInterfaceIpsWithContext(ctx, listBareMetalServerNetworkInterfaceIpsOptionsModel) + _, _, operationErr = vpcService.DeleteSnapshotConsistencyGroupWithContext(ctx, deleteSnapshotConsistencyGroupOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) }) @@ -52150,18 +52490,18 @@ var _ = Describe(`VpcV1`, func() { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(listBareMetalServerNetworkInterfaceIpsPath)) - Expect(req.Method).To(Equal("GET")) + Expect(req.URL.EscapedPath()).To(Equal(deleteSnapshotConsistencyGroupPath)) + Expect(req.Method).To(Equal("DELETE")) Expect(req.URL.Query()["version"]).To(Equal([]string{"testString"})) Expect(req.URL.Query()["generation"]).To(Equal([]string{fmt.Sprint(int64(2))})) // 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/bare_metal_servers/1e09281b-f177-46fb-baf1-bc152b2e391a/network_interfaces/10c02d81-0ecb-4dc5-897d-28392913b81e/ips?limit=20"}, "ips": [{"address": "192.168.3.4", "auto_delete": false, "created_at": "2019-01-01T12:00:00.000Z", "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e/reserved_ips/6d353a0f-aeb1-4ae1-832e-1110d10981bb", "id": "6d353a0f-aeb1-4ae1-832e-1110d10981bb", "lifecycle_state": "stable", "name": "my-reserved-ip", "owner": "user", "resource_type": "subnet_reserved_ip", "target": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::endpoint-gateway:r134-d7cc5196-9864-48c4-82d8-3f30da41fcc5", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/endpoint_gateways/r134-d7cc5196-9864-48c4-82d8-3f30da41fcc5", "id": "r134-d7cc5196-9864-48c4-82d8-3f30da41fcc5", "name": "my-endpoint-gateway", "resource_type": "endpoint_gateway"}}], "limit": 20, "next": {"href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/1e09281b-f177-46fb-baf1-bc152b2e391a/network_interfaces/10c02d81-0ecb-4dc5-897d-28392913b81e/ips?start=a404e343444b4e1095c9edba76672d67&limit=20"}, "total_count": 132}`) + res.WriteHeader(202) + fmt.Fprintf(res, "%s", `{"backup_policy_plan": {"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6/plans/r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "id": "r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "name": "my-policy-plan", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "backup_policy_plan"}, "created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot-consistency-group:r134-fa329f6b-0e36-433f-a3bb-0df632e79263", "delete_snapshots_on_delete": false, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshot_consistency_groups/r134-fa329f6b-0e36-433f-a3bb-0df632e79263", "id": "r134-fa329f6b-0e36-433f-a3bb-0df632e79263", "lifecycle_state": "stable", "name": "my-snapshot-consistency-group", "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "resource_type": "snapshot_consistency_group", "service_tags": ["ServiceTags"], "snapshots": [{"crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "id": "r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "name": "my-snapshot", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "snapshot"}]}`) })) }) - It(`Invoke ListBareMetalServerNetworkInterfaceIps successfully`, func() { + It(`Invoke DeleteSnapshotConsistencyGroup successfully`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -52171,25 +52511,24 @@ var _ = Describe(`VpcV1`, func() { Expect(vpcService).ToNot(BeNil()) // Invoke operation with nil options model (negative test) - result, response, operationErr := vpcService.ListBareMetalServerNetworkInterfaceIps(nil) + result, response, operationErr := vpcService.DeleteSnapshotConsistencyGroup(nil) Expect(operationErr).NotTo(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) - // Construct an instance of the ListBareMetalServerNetworkInterfaceIpsOptions model - listBareMetalServerNetworkInterfaceIpsOptionsModel := new(vpcv1.ListBareMetalServerNetworkInterfaceIpsOptions) - listBareMetalServerNetworkInterfaceIpsOptionsModel.BareMetalServerID = core.StringPtr("testString") - listBareMetalServerNetworkInterfaceIpsOptionsModel.NetworkInterfaceID = core.StringPtr("testString") - listBareMetalServerNetworkInterfaceIpsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the DeleteSnapshotConsistencyGroupOptions model + deleteSnapshotConsistencyGroupOptionsModel := new(vpcv1.DeleteSnapshotConsistencyGroupOptions) + deleteSnapshotConsistencyGroupOptionsModel.ID = core.StringPtr("testString") + deleteSnapshotConsistencyGroupOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with valid options model (positive test) - result, response, operationErr = vpcService.ListBareMetalServerNetworkInterfaceIps(listBareMetalServerNetworkInterfaceIpsOptionsModel) + result, response, operationErr = vpcService.DeleteSnapshotConsistencyGroup(deleteSnapshotConsistencyGroupOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) }) - It(`Invoke ListBareMetalServerNetworkInterfaceIps with error: Operation validation and request error`, func() { + It(`Invoke DeleteSnapshotConsistencyGroup with error: Operation validation and request error`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -52198,23 +52537,22 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the ListBareMetalServerNetworkInterfaceIpsOptions model - listBareMetalServerNetworkInterfaceIpsOptionsModel := new(vpcv1.ListBareMetalServerNetworkInterfaceIpsOptions) - listBareMetalServerNetworkInterfaceIpsOptionsModel.BareMetalServerID = core.StringPtr("testString") - listBareMetalServerNetworkInterfaceIpsOptionsModel.NetworkInterfaceID = core.StringPtr("testString") - listBareMetalServerNetworkInterfaceIpsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the DeleteSnapshotConsistencyGroupOptions model + deleteSnapshotConsistencyGroupOptionsModel := new(vpcv1.DeleteSnapshotConsistencyGroupOptions) + deleteSnapshotConsistencyGroupOptionsModel.ID = core.StringPtr("testString") + deleteSnapshotConsistencyGroupOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with empty URL (negative test) err := vpcService.SetServiceURL("") Expect(err).To(BeNil()) - result, response, operationErr := vpcService.ListBareMetalServerNetworkInterfaceIps(listBareMetalServerNetworkInterfaceIpsOptionsModel) + result, response, operationErr := vpcService.DeleteSnapshotConsistencyGroup(deleteSnapshotConsistencyGroupOptionsModel) 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 ListBareMetalServerNetworkInterfaceIpsOptions model with no property values - listBareMetalServerNetworkInterfaceIpsOptionsModelNew := new(vpcv1.ListBareMetalServerNetworkInterfaceIpsOptions) + // Construct a second instance of the DeleteSnapshotConsistencyGroupOptions model with no property values + deleteSnapshotConsistencyGroupOptionsModelNew := new(vpcv1.DeleteSnapshotConsistencyGroupOptions) // Invoke operation with invalid model (negative test) - result, response, operationErr = vpcService.ListBareMetalServerNetworkInterfaceIps(listBareMetalServerNetworkInterfaceIpsOptionsModelNew) + result, response, operationErr = vpcService.DeleteSnapshotConsistencyGroup(deleteSnapshotConsistencyGroupOptionsModelNew) Expect(operationErr).ToNot(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) @@ -52229,10 +52567,10 @@ var _ = Describe(`VpcV1`, func() { defer GinkgoRecover() // Set success status code with no respoonse body - res.WriteHeader(200) + res.WriteHeader(202) })) }) - It(`Invoke ListBareMetalServerNetworkInterfaceIps successfully`, func() { + It(`Invoke DeleteSnapshotConsistencyGroup successfully`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -52241,14 +52579,13 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the ListBareMetalServerNetworkInterfaceIpsOptions model - listBareMetalServerNetworkInterfaceIpsOptionsModel := new(vpcv1.ListBareMetalServerNetworkInterfaceIpsOptions) - listBareMetalServerNetworkInterfaceIpsOptionsModel.BareMetalServerID = core.StringPtr("testString") - listBareMetalServerNetworkInterfaceIpsOptionsModel.NetworkInterfaceID = core.StringPtr("testString") - listBareMetalServerNetworkInterfaceIpsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the DeleteSnapshotConsistencyGroupOptions model + deleteSnapshotConsistencyGroupOptionsModel := new(vpcv1.DeleteSnapshotConsistencyGroupOptions) + deleteSnapshotConsistencyGroupOptionsModel.ID = core.StringPtr("testString") + deleteSnapshotConsistencyGroupOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation - result, response, operationErr := vpcService.ListBareMetalServerNetworkInterfaceIps(listBareMetalServerNetworkInterfaceIpsOptionsModel) + result, response, operationErr := vpcService.DeleteSnapshotConsistencyGroup(deleteSnapshotConsistencyGroupOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) @@ -52260,16 +52597,16 @@ var _ = Describe(`VpcV1`, func() { }) }) }) - Describe(`GetBareMetalServerNetworkInterfaceIP(getBareMetalServerNetworkInterfaceIPOptions *GetBareMetalServerNetworkInterfaceIPOptions) - Operation response error`, func() { + Describe(`GetSnapshotConsistencyGroup(getSnapshotConsistencyGroupOptions *GetSnapshotConsistencyGroupOptions) - Operation response error`, func() { version := "testString" - getBareMetalServerNetworkInterfaceIPPath := "/bare_metal_servers/testString/network_interfaces/testString/ips/testString" + getSnapshotConsistencyGroupPath := "/snapshot_consistency_groups/testString" Context(`Using mock server endpoint with invalid JSON response`, func() { BeforeEach(func() { testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(getBareMetalServerNetworkInterfaceIPPath)) + Expect(req.URL.EscapedPath()).To(Equal(getSnapshotConsistencyGroupPath)) Expect(req.Method).To(Equal("GET")) Expect(req.URL.Query()["version"]).To(Equal([]string{"testString"})) Expect(req.URL.Query()["generation"]).To(Equal([]string{fmt.Sprint(int64(2))})) @@ -52278,7 +52615,7 @@ var _ = Describe(`VpcV1`, func() { fmt.Fprint(res, `} this is not valid json {`) })) }) - It(`Invoke GetBareMetalServerNetworkInterfaceIP with error: Operation response processing error`, func() { + It(`Invoke GetSnapshotConsistencyGroup with error: Operation response processing error`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -52287,21 +52624,19 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the GetBareMetalServerNetworkInterfaceIPOptions model - getBareMetalServerNetworkInterfaceIPOptionsModel := new(vpcv1.GetBareMetalServerNetworkInterfaceIPOptions) - getBareMetalServerNetworkInterfaceIPOptionsModel.BareMetalServerID = core.StringPtr("testString") - getBareMetalServerNetworkInterfaceIPOptionsModel.NetworkInterfaceID = core.StringPtr("testString") - getBareMetalServerNetworkInterfaceIPOptionsModel.ID = core.StringPtr("testString") - getBareMetalServerNetworkInterfaceIPOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the GetSnapshotConsistencyGroupOptions model + getSnapshotConsistencyGroupOptionsModel := new(vpcv1.GetSnapshotConsistencyGroupOptions) + getSnapshotConsistencyGroupOptionsModel.ID = core.StringPtr("testString") + getSnapshotConsistencyGroupOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Expect response parsing to fail since we are receiving a text/plain response - result, response, operationErr := vpcService.GetBareMetalServerNetworkInterfaceIP(getBareMetalServerNetworkInterfaceIPOptionsModel) + result, response, operationErr := vpcService.GetSnapshotConsistencyGroup(getSnapshotConsistencyGroupOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).To(BeNil()) // Enable retries and test again vpcService.EnableRetries(0, 0) - result, response, operationErr = vpcService.GetBareMetalServerNetworkInterfaceIP(getBareMetalServerNetworkInterfaceIPOptionsModel) + result, response, operationErr = vpcService.GetSnapshotConsistencyGroup(getSnapshotConsistencyGroupOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).To(BeNil()) @@ -52311,16 +52646,16 @@ var _ = Describe(`VpcV1`, func() { }) }) }) - Describe(`GetBareMetalServerNetworkInterfaceIP(getBareMetalServerNetworkInterfaceIPOptions *GetBareMetalServerNetworkInterfaceIPOptions)`, func() { + Describe(`GetSnapshotConsistencyGroup(getSnapshotConsistencyGroupOptions *GetSnapshotConsistencyGroupOptions)`, func() { version := "testString" - getBareMetalServerNetworkInterfaceIPPath := "/bare_metal_servers/testString/network_interfaces/testString/ips/testString" + getSnapshotConsistencyGroupPath := "/snapshot_consistency_groups/testString" Context(`Using mock server endpoint with timeout`, func() { BeforeEach(func() { testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(getBareMetalServerNetworkInterfaceIPPath)) + Expect(req.URL.EscapedPath()).To(Equal(getSnapshotConsistencyGroupPath)) Expect(req.Method).To(Equal("GET")) Expect(req.URL.Query()["version"]).To(Equal([]string{"testString"})) @@ -52331,10 +52666,10 @@ var _ = Describe(`VpcV1`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"address": "192.168.3.4", "auto_delete": false, "created_at": "2019-01-01T12:00:00.000Z", "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e/reserved_ips/6d353a0f-aeb1-4ae1-832e-1110d10981bb", "id": "6d353a0f-aeb1-4ae1-832e-1110d10981bb", "lifecycle_state": "stable", "name": "my-reserved-ip", "owner": "user", "resource_type": "subnet_reserved_ip", "target": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::endpoint-gateway:r134-d7cc5196-9864-48c4-82d8-3f30da41fcc5", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/endpoint_gateways/r134-d7cc5196-9864-48c4-82d8-3f30da41fcc5", "id": "r134-d7cc5196-9864-48c4-82d8-3f30da41fcc5", "name": "my-endpoint-gateway", "resource_type": "endpoint_gateway"}}`) + fmt.Fprintf(res, "%s", `{"backup_policy_plan": {"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6/plans/r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "id": "r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "name": "my-policy-plan", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "backup_policy_plan"}, "created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot-consistency-group:r134-fa329f6b-0e36-433f-a3bb-0df632e79263", "delete_snapshots_on_delete": false, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshot_consistency_groups/r134-fa329f6b-0e36-433f-a3bb-0df632e79263", "id": "r134-fa329f6b-0e36-433f-a3bb-0df632e79263", "lifecycle_state": "stable", "name": "my-snapshot-consistency-group", "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "resource_type": "snapshot_consistency_group", "service_tags": ["ServiceTags"], "snapshots": [{"crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "id": "r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "name": "my-snapshot", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "snapshot"}]}`) })) }) - It(`Invoke GetBareMetalServerNetworkInterfaceIP successfully with retries`, func() { + It(`Invoke GetSnapshotConsistencyGroup successfully with retries`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -52344,23 +52679,21 @@ var _ = Describe(`VpcV1`, func() { Expect(vpcService).ToNot(BeNil()) vpcService.EnableRetries(0, 0) - // Construct an instance of the GetBareMetalServerNetworkInterfaceIPOptions model - getBareMetalServerNetworkInterfaceIPOptionsModel := new(vpcv1.GetBareMetalServerNetworkInterfaceIPOptions) - getBareMetalServerNetworkInterfaceIPOptionsModel.BareMetalServerID = core.StringPtr("testString") - getBareMetalServerNetworkInterfaceIPOptionsModel.NetworkInterfaceID = core.StringPtr("testString") - getBareMetalServerNetworkInterfaceIPOptionsModel.ID = core.StringPtr("testString") - getBareMetalServerNetworkInterfaceIPOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the GetSnapshotConsistencyGroupOptions model + getSnapshotConsistencyGroupOptionsModel := new(vpcv1.GetSnapshotConsistencyGroupOptions) + getSnapshotConsistencyGroupOptionsModel.ID = core.StringPtr("testString") + getSnapshotConsistencyGroupOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with a Context to test a timeout error ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond) defer cancelFunc() - _, _, operationErr := vpcService.GetBareMetalServerNetworkInterfaceIPWithContext(ctx, getBareMetalServerNetworkInterfaceIPOptionsModel) + _, _, operationErr := vpcService.GetSnapshotConsistencyGroupWithContext(ctx, getSnapshotConsistencyGroupOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) // Disable retries and test again vpcService.DisableRetries() - result, response, operationErr := vpcService.GetBareMetalServerNetworkInterfaceIP(getBareMetalServerNetworkInterfaceIPOptionsModel) + result, response, operationErr := vpcService.GetSnapshotConsistencyGroup(getSnapshotConsistencyGroupOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) @@ -52368,7 +52701,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.GetBareMetalServerNetworkInterfaceIPWithContext(ctx, getBareMetalServerNetworkInterfaceIPOptionsModel) + _, _, operationErr = vpcService.GetSnapshotConsistencyGroupWithContext(ctx, getSnapshotConsistencyGroupOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) }) @@ -52382,7 +52715,7 @@ var _ = Describe(`VpcV1`, func() { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(getBareMetalServerNetworkInterfaceIPPath)) + Expect(req.URL.EscapedPath()).To(Equal(getSnapshotConsistencyGroupPath)) Expect(req.Method).To(Equal("GET")) Expect(req.URL.Query()["version"]).To(Equal([]string{"testString"})) @@ -52390,10 +52723,10 @@ var _ = Describe(`VpcV1`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"address": "192.168.3.4", "auto_delete": false, "created_at": "2019-01-01T12:00:00.000Z", "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e/reserved_ips/6d353a0f-aeb1-4ae1-832e-1110d10981bb", "id": "6d353a0f-aeb1-4ae1-832e-1110d10981bb", "lifecycle_state": "stable", "name": "my-reserved-ip", "owner": "user", "resource_type": "subnet_reserved_ip", "target": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::endpoint-gateway:r134-d7cc5196-9864-48c4-82d8-3f30da41fcc5", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/endpoint_gateways/r134-d7cc5196-9864-48c4-82d8-3f30da41fcc5", "id": "r134-d7cc5196-9864-48c4-82d8-3f30da41fcc5", "name": "my-endpoint-gateway", "resource_type": "endpoint_gateway"}}`) + fmt.Fprintf(res, "%s", `{"backup_policy_plan": {"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6/plans/r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "id": "r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "name": "my-policy-plan", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "backup_policy_plan"}, "created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot-consistency-group:r134-fa329f6b-0e36-433f-a3bb-0df632e79263", "delete_snapshots_on_delete": false, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshot_consistency_groups/r134-fa329f6b-0e36-433f-a3bb-0df632e79263", "id": "r134-fa329f6b-0e36-433f-a3bb-0df632e79263", "lifecycle_state": "stable", "name": "my-snapshot-consistency-group", "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "resource_type": "snapshot_consistency_group", "service_tags": ["ServiceTags"], "snapshots": [{"crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "id": "r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "name": "my-snapshot", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "snapshot"}]}`) })) }) - It(`Invoke GetBareMetalServerNetworkInterfaceIP successfully`, func() { + It(`Invoke GetSnapshotConsistencyGroup successfully`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -52403,26 +52736,24 @@ var _ = Describe(`VpcV1`, func() { Expect(vpcService).ToNot(BeNil()) // Invoke operation with nil options model (negative test) - result, response, operationErr := vpcService.GetBareMetalServerNetworkInterfaceIP(nil) + result, response, operationErr := vpcService.GetSnapshotConsistencyGroup(nil) Expect(operationErr).NotTo(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) - // Construct an instance of the GetBareMetalServerNetworkInterfaceIPOptions model - getBareMetalServerNetworkInterfaceIPOptionsModel := new(vpcv1.GetBareMetalServerNetworkInterfaceIPOptions) - getBareMetalServerNetworkInterfaceIPOptionsModel.BareMetalServerID = core.StringPtr("testString") - getBareMetalServerNetworkInterfaceIPOptionsModel.NetworkInterfaceID = core.StringPtr("testString") - getBareMetalServerNetworkInterfaceIPOptionsModel.ID = core.StringPtr("testString") - getBareMetalServerNetworkInterfaceIPOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the GetSnapshotConsistencyGroupOptions model + getSnapshotConsistencyGroupOptionsModel := new(vpcv1.GetSnapshotConsistencyGroupOptions) + getSnapshotConsistencyGroupOptionsModel.ID = core.StringPtr("testString") + getSnapshotConsistencyGroupOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with valid options model (positive test) - result, response, operationErr = vpcService.GetBareMetalServerNetworkInterfaceIP(getBareMetalServerNetworkInterfaceIPOptionsModel) + result, response, operationErr = vpcService.GetSnapshotConsistencyGroup(getSnapshotConsistencyGroupOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) }) - It(`Invoke GetBareMetalServerNetworkInterfaceIP with error: Operation validation and request error`, func() { + It(`Invoke GetSnapshotConsistencyGroup with error: Operation validation and request error`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -52431,24 +52762,22 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the GetBareMetalServerNetworkInterfaceIPOptions model - getBareMetalServerNetworkInterfaceIPOptionsModel := new(vpcv1.GetBareMetalServerNetworkInterfaceIPOptions) - getBareMetalServerNetworkInterfaceIPOptionsModel.BareMetalServerID = core.StringPtr("testString") - getBareMetalServerNetworkInterfaceIPOptionsModel.NetworkInterfaceID = core.StringPtr("testString") - getBareMetalServerNetworkInterfaceIPOptionsModel.ID = core.StringPtr("testString") - getBareMetalServerNetworkInterfaceIPOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the GetSnapshotConsistencyGroupOptions model + getSnapshotConsistencyGroupOptionsModel := new(vpcv1.GetSnapshotConsistencyGroupOptions) + getSnapshotConsistencyGroupOptionsModel.ID = core.StringPtr("testString") + getSnapshotConsistencyGroupOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with empty URL (negative test) err := vpcService.SetServiceURL("") Expect(err).To(BeNil()) - result, response, operationErr := vpcService.GetBareMetalServerNetworkInterfaceIP(getBareMetalServerNetworkInterfaceIPOptionsModel) + result, response, operationErr := vpcService.GetSnapshotConsistencyGroup(getSnapshotConsistencyGroupOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING)) Expect(response).To(BeNil()) Expect(result).To(BeNil()) - // Construct a second instance of the GetBareMetalServerNetworkInterfaceIPOptions model with no property values - getBareMetalServerNetworkInterfaceIPOptionsModelNew := new(vpcv1.GetBareMetalServerNetworkInterfaceIPOptions) + // Construct a second instance of the GetSnapshotConsistencyGroupOptions model with no property values + getSnapshotConsistencyGroupOptionsModelNew := new(vpcv1.GetSnapshotConsistencyGroupOptions) // Invoke operation with invalid model (negative test) - result, response, operationErr = vpcService.GetBareMetalServerNetworkInterfaceIP(getBareMetalServerNetworkInterfaceIPOptionsModelNew) + result, response, operationErr = vpcService.GetSnapshotConsistencyGroup(getSnapshotConsistencyGroupOptionsModelNew) Expect(operationErr).ToNot(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) @@ -52466,119 +52795,46 @@ var _ = Describe(`VpcV1`, func() { res.WriteHeader(200) })) }) - It(`Invoke GetBareMetalServerNetworkInterfaceIP 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 GetBareMetalServerNetworkInterfaceIPOptions model - getBareMetalServerNetworkInterfaceIPOptionsModel := new(vpcv1.GetBareMetalServerNetworkInterfaceIPOptions) - getBareMetalServerNetworkInterfaceIPOptionsModel.BareMetalServerID = core.StringPtr("testString") - getBareMetalServerNetworkInterfaceIPOptionsModel.NetworkInterfaceID = core.StringPtr("testString") - getBareMetalServerNetworkInterfaceIPOptionsModel.ID = core.StringPtr("testString") - getBareMetalServerNetworkInterfaceIPOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} - - // Invoke operation - result, response, operationErr := vpcService.GetBareMetalServerNetworkInterfaceIP(getBareMetalServerNetworkInterfaceIPOptionsModel) - Expect(operationErr).To(BeNil()) - Expect(response).ToNot(BeNil()) - - // Verify a nil result - Expect(result).To(BeNil()) - }) - AfterEach(func() { - testServer.Close() - }) - }) - }) - Describe(`DeleteBareMetalServer(deleteBareMetalServerOptions *DeleteBareMetalServerOptions)`, func() { - version := "testString" - deleteBareMetalServerPath := "/bare_metal_servers/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(deleteBareMetalServerPath)) - 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 DeleteBareMetalServer 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.DeleteBareMetalServer(nil) - Expect(operationErr).NotTo(BeNil()) - Expect(response).To(BeNil()) - - // Construct an instance of the DeleteBareMetalServerOptions model - deleteBareMetalServerOptionsModel := new(vpcv1.DeleteBareMetalServerOptions) - deleteBareMetalServerOptionsModel.ID = core.StringPtr("testString") - deleteBareMetalServerOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} - - // Invoke operation with valid options model (positive test) - response, operationErr = vpcService.DeleteBareMetalServer(deleteBareMetalServerOptionsModel) - Expect(operationErr).To(BeNil()) - Expect(response).ToNot(BeNil()) - }) - It(`Invoke DeleteBareMetalServer with error: Operation validation and request error`, func() { + It(`Invoke GetSnapshotConsistencyGroup 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 DeleteBareMetalServerOptions model - deleteBareMetalServerOptionsModel := new(vpcv1.DeleteBareMetalServerOptions) - deleteBareMetalServerOptionsModel.ID = core.StringPtr("testString") - deleteBareMetalServerOptionsModel.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.DeleteBareMetalServer(deleteBareMetalServerOptionsModel) - Expect(operationErr).ToNot(BeNil()) - Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING)) - Expect(response).To(BeNil()) - // Construct a second instance of the DeleteBareMetalServerOptions model with no property values - deleteBareMetalServerOptionsModelNew := new(vpcv1.DeleteBareMetalServerOptions) - // Invoke operation with invalid model (negative test) - response, operationErr = vpcService.DeleteBareMetalServer(deleteBareMetalServerOptionsModelNew) - Expect(operationErr).ToNot(BeNil()) - Expect(response).To(BeNil()) + Authenticator: &core.NoAuthAuthenticator{}, + Version: core.StringPtr(version), + }) + Expect(serviceErr).To(BeNil()) + Expect(vpcService).ToNot(BeNil()) + + // Construct an instance of the GetSnapshotConsistencyGroupOptions model + getSnapshotConsistencyGroupOptionsModel := new(vpcv1.GetSnapshotConsistencyGroupOptions) + getSnapshotConsistencyGroupOptionsModel.ID = core.StringPtr("testString") + getSnapshotConsistencyGroupOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation + result, response, operationErr := vpcService.GetSnapshotConsistencyGroup(getSnapshotConsistencyGroupOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + + // Verify a nil result + Expect(result).To(BeNil()) }) AfterEach(func() { testServer.Close() }) }) }) - Describe(`GetBareMetalServer(getBareMetalServerOptions *GetBareMetalServerOptions) - Operation response error`, func() { + Describe(`UpdateSnapshotConsistencyGroup(updateSnapshotConsistencyGroupOptions *UpdateSnapshotConsistencyGroupOptions) - Operation response error`, func() { version := "testString" - getBareMetalServerPath := "/bare_metal_servers/testString" + updateSnapshotConsistencyGroupPath := "/snapshot_consistency_groups/testString" Context(`Using mock server endpoint with invalid JSON response`, func() { BeforeEach(func() { testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(getBareMetalServerPath)) - Expect(req.Method).To(Equal("GET")) + Expect(req.URL.EscapedPath()).To(Equal(updateSnapshotConsistencyGroupPath)) + Expect(req.Method).To(Equal("PATCH")) + Expect(req.Header["If-Match"]).ToNot(BeNil()) + Expect(req.Header["If-Match"][0]).To(Equal(fmt.Sprintf("%v", "W/\"96d225c4-56bd-43d9-98fc-d7148e5c5028\""))) 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") @@ -52586,7 +52842,7 @@ var _ = Describe(`VpcV1`, func() { fmt.Fprint(res, `} this is not valid json {`) })) }) - It(`Invoke GetBareMetalServer with error: Operation response processing error`, func() { + It(`Invoke UpdateSnapshotConsistencyGroup with error: Operation response processing error`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -52595,19 +52851,28 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the GetBareMetalServerOptions model - getBareMetalServerOptionsModel := new(vpcv1.GetBareMetalServerOptions) - getBareMetalServerOptionsModel.ID = core.StringPtr("testString") - getBareMetalServerOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the SnapshotConsistencyGroupPatch model + snapshotConsistencyGroupPatchModel := new(vpcv1.SnapshotConsistencyGroupPatch) + snapshotConsistencyGroupPatchModel.DeleteSnapshotsOnDelete = core.BoolPtr(true) + snapshotConsistencyGroupPatchModel.Name = core.StringPtr("my-snapshot-consistency-group") + snapshotConsistencyGroupPatchModelAsPatch, asPatchErr := snapshotConsistencyGroupPatchModel.AsPatch() + Expect(asPatchErr).To(BeNil()) + + // Construct an instance of the UpdateSnapshotConsistencyGroupOptions model + updateSnapshotConsistencyGroupOptionsModel := new(vpcv1.UpdateSnapshotConsistencyGroupOptions) + updateSnapshotConsistencyGroupOptionsModel.ID = core.StringPtr("testString") + updateSnapshotConsistencyGroupOptionsModel.SnapshotConsistencyGroupPatch = snapshotConsistencyGroupPatchModelAsPatch + updateSnapshotConsistencyGroupOptionsModel.IfMatch = core.StringPtr("W/\"96d225c4-56bd-43d9-98fc-d7148e5c5028\"") + updateSnapshotConsistencyGroupOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Expect response parsing to fail since we are receiving a text/plain response - result, response, operationErr := vpcService.GetBareMetalServer(getBareMetalServerOptionsModel) + result, response, operationErr := vpcService.UpdateSnapshotConsistencyGroup(updateSnapshotConsistencyGroupOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).To(BeNil()) // Enable retries and test again vpcService.EnableRetries(0, 0) - result, response, operationErr = vpcService.GetBareMetalServer(getBareMetalServerOptionsModel) + result, response, operationErr = vpcService.UpdateSnapshotConsistencyGroup(updateSnapshotConsistencyGroupOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).To(BeNil()) @@ -52617,18 +52882,36 @@ var _ = Describe(`VpcV1`, func() { }) }) }) - Describe(`GetBareMetalServer(getBareMetalServerOptions *GetBareMetalServerOptions)`, func() { + Describe(`UpdateSnapshotConsistencyGroup(updateSnapshotConsistencyGroupOptions *UpdateSnapshotConsistencyGroupOptions)`, func() { version := "testString" - getBareMetalServerPath := "/bare_metal_servers/testString" + updateSnapshotConsistencyGroupPath := "/snapshot_consistency_groups/testString" Context(`Using mock server endpoint with timeout`, func() { BeforeEach(func() { testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(getBareMetalServerPath)) - Expect(req.Method).To(Equal("GET")) + Expect(req.URL.EscapedPath()).To(Equal(updateSnapshotConsistencyGroupPath)) + 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 @@ -52637,10 +52920,10 @@ var _ = Describe(`VpcV1`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"bandwidth": 20000, "boot_target": {"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/1e09281b-f177-46fb-baf1-bc152b2e391a/disks/10c02d81-0ecb-4dc5-897d-28392913b81e", "id": "10c02d81-0ecb-4dc5-897d-28392913b81e", "name": "my-bare-metal-server-disk", "resource_type": "bare_metal_server_disk"}, "cpu": {"architecture": "amd64", "core_count": 80, "socket_count": 4, "threads_per_core": 2}, "created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::bare-metal-server:1e09281b-f177-46fb-baf1-bc152b2e391a", "disks": [{"created_at": "2019-01-01T12:00:00.000Z", "href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/1e09281b-f177-46fb-baf1-bc152b2e391a/disks/10c02d81-0ecb-4dc5-897d-28392913b81e", "id": "10c02d81-0ecb-4dc5-897d-28392913b81e", "interface_type": "fcp", "name": "my-bare-metal-server-disk", "resource_type": "bare_metal_server_disk", "size": 100}], "enable_secure_boot": false, "href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/1e09281b-f177-46fb-baf1-bc152b2e391a", "id": "1e09281b-f177-46fb-baf1-bc152b2e391a", "lifecycle_reasons": [{"code": "resource_suspended_by_provider", "message": "The resource has been suspended. Contact IBM support with the CRN for next steps.", "more_info": "https://cloud.ibm.com/apidocs/vpc#resource-suspension"}], "lifecycle_state": "stable", "memory": 1536, "name": "my-bare-metal-server", "network_attachments": [{"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/2302-f7a2bf57-af7c-49d9-b599-b2c91293d30c/network_attachments/2302-da8c43ec-b6ca-4bd2-871e-72e288c66ee6", "id": "2302-da8c43ec-b6ca-4bd2-871e-72e288c66ee6", "name": "my-bare-metal-server-network-attachment", "primary_ip": {"address": "192.168.3.4", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e/reserved_ips/6d353a0f-aeb1-4ae1-832e-1110d10981bb", "id": "6d353a0f-aeb1-4ae1-832e-1110d10981bb", "name": "my-reserved-ip", "resource_type": "subnet_reserved_ip"}, "resource_type": "bare_metal_server_network_attachment", "subnet": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "id": "7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "name": "my-subnet", "resource_type": "subnet"}}], "network_interfaces": [{"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/1e09281b-f177-46fb-baf1-bc152b2e391a/network_interfaces/10c02d81-0ecb-4dc5-897d-28392913b81e", "id": "10c02d81-0ecb-4dc5-897d-28392913b81e", "name": "my-bare-metal-server-network-interface", "primary_ip": {"address": "192.168.3.4", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e/reserved_ips/6d353a0f-aeb1-4ae1-832e-1110d10981bb", "id": "6d353a0f-aeb1-4ae1-832e-1110d10981bb", "name": "my-reserved-ip", "resource_type": "subnet_reserved_ip"}, "resource_type": "network_interface", "subnet": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "id": "7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "name": "my-subnet", "resource_type": "subnet"}}], "primary_network_attachment": {"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/2302-f7a2bf57-af7c-49d9-b599-b2c91293d30c/network_attachments/2302-da8c43ec-b6ca-4bd2-871e-72e288c66ee6", "id": "2302-da8c43ec-b6ca-4bd2-871e-72e288c66ee6", "name": "my-bare-metal-server-network-attachment", "primary_ip": {"address": "192.168.3.4", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e/reserved_ips/6d353a0f-aeb1-4ae1-832e-1110d10981bb", "id": "6d353a0f-aeb1-4ae1-832e-1110d10981bb", "name": "my-reserved-ip", "resource_type": "subnet_reserved_ip"}, "resource_type": "bare_metal_server_network_attachment", "subnet": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "id": "7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "name": "my-subnet", "resource_type": "subnet"}}, "primary_network_interface": {"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/1e09281b-f177-46fb-baf1-bc152b2e391a/network_interfaces/10c02d81-0ecb-4dc5-897d-28392913b81e", "id": "10c02d81-0ecb-4dc5-897d-28392913b81e", "name": "my-bare-metal-server-network-interface", "primary_ip": {"address": "192.168.3.4", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e/reserved_ips/6d353a0f-aeb1-4ae1-832e-1110d10981bb", "id": "6d353a0f-aeb1-4ae1-832e-1110d10981bb", "name": "my-reserved-ip", "resource_type": "subnet_reserved_ip"}, "resource_type": "network_interface", "subnet": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "id": "7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "name": "my-subnet", "resource_type": "subnet"}}, "profile": {"href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/profiles/bx2-metal-192x768", "name": "bx2-metal-192x768", "resource_type": "bare_metal_server_profile"}, "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "resource_type": "bare_metal_server", "status": "deleting", "status_reasons": [{"code": "cannot_start_capacity", "message": "The bare metal server cannot start as there is no more capacity in this\nzone for a bare metal server with the requested profile.", "more_info": "https://console.bluemix.net/docs/iaas/bare_metal_server.html"}], "trusted_platform_module": {"enabled": true, "mode": "disabled", "supported_modes": ["disabled"]}, "vpc": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::vpc:4727d842-f94f-4a2d-824a-9bc9b02c523b", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/vpcs/4727d842-f94f-4a2d-824a-9bc9b02c523b", "id": "4727d842-f94f-4a2d-824a-9bc9b02c523b", "name": "my-vpc", "resource_type": "vpc"}, "zone": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south/zones/us-south-1", "name": "us-south-1"}}`) + fmt.Fprintf(res, "%s", `{"backup_policy_plan": {"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6/plans/r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "id": "r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "name": "my-policy-plan", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "backup_policy_plan"}, "created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot-consistency-group:r134-fa329f6b-0e36-433f-a3bb-0df632e79263", "delete_snapshots_on_delete": false, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshot_consistency_groups/r134-fa329f6b-0e36-433f-a3bb-0df632e79263", "id": "r134-fa329f6b-0e36-433f-a3bb-0df632e79263", "lifecycle_state": "stable", "name": "my-snapshot-consistency-group", "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "resource_type": "snapshot_consistency_group", "service_tags": ["ServiceTags"], "snapshots": [{"crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "id": "r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "name": "my-snapshot", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "snapshot"}]}`) })) }) - It(`Invoke GetBareMetalServer successfully with retries`, func() { + It(`Invoke UpdateSnapshotConsistencyGroup successfully with retries`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -52650,21 +52933,30 @@ var _ = Describe(`VpcV1`, func() { Expect(vpcService).ToNot(BeNil()) vpcService.EnableRetries(0, 0) - // Construct an instance of the GetBareMetalServerOptions model - getBareMetalServerOptionsModel := new(vpcv1.GetBareMetalServerOptions) - getBareMetalServerOptionsModel.ID = core.StringPtr("testString") - getBareMetalServerOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the SnapshotConsistencyGroupPatch model + snapshotConsistencyGroupPatchModel := new(vpcv1.SnapshotConsistencyGroupPatch) + snapshotConsistencyGroupPatchModel.DeleteSnapshotsOnDelete = core.BoolPtr(true) + snapshotConsistencyGroupPatchModel.Name = core.StringPtr("my-snapshot-consistency-group") + snapshotConsistencyGroupPatchModelAsPatch, asPatchErr := snapshotConsistencyGroupPatchModel.AsPatch() + Expect(asPatchErr).To(BeNil()) + + // Construct an instance of the UpdateSnapshotConsistencyGroupOptions model + updateSnapshotConsistencyGroupOptionsModel := new(vpcv1.UpdateSnapshotConsistencyGroupOptions) + updateSnapshotConsistencyGroupOptionsModel.ID = core.StringPtr("testString") + updateSnapshotConsistencyGroupOptionsModel.SnapshotConsistencyGroupPatch = snapshotConsistencyGroupPatchModelAsPatch + updateSnapshotConsistencyGroupOptionsModel.IfMatch = core.StringPtr("W/\"96d225c4-56bd-43d9-98fc-d7148e5c5028\"") + updateSnapshotConsistencyGroupOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with a Context to test a timeout error ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond) defer cancelFunc() - _, _, operationErr := vpcService.GetBareMetalServerWithContext(ctx, getBareMetalServerOptionsModel) + _, _, operationErr := vpcService.UpdateSnapshotConsistencyGroupWithContext(ctx, updateSnapshotConsistencyGroupOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) // Disable retries and test again vpcService.DisableRetries() - result, response, operationErr := vpcService.GetBareMetalServer(getBareMetalServerOptionsModel) + result, response, operationErr := vpcService.UpdateSnapshotConsistencyGroup(updateSnapshotConsistencyGroupOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) @@ -52672,7 +52964,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.GetBareMetalServerWithContext(ctx, getBareMetalServerOptionsModel) + _, _, operationErr = vpcService.UpdateSnapshotConsistencyGroupWithContext(ctx, updateSnapshotConsistencyGroupOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) }) @@ -52686,18 +52978,36 @@ var _ = Describe(`VpcV1`, func() { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(getBareMetalServerPath)) - Expect(req.Method).To(Equal("GET")) + Expect(req.URL.EscapedPath()).To(Equal(updateSnapshotConsistencyGroupPath)) + 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", `{"bandwidth": 20000, "boot_target": {"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/1e09281b-f177-46fb-baf1-bc152b2e391a/disks/10c02d81-0ecb-4dc5-897d-28392913b81e", "id": "10c02d81-0ecb-4dc5-897d-28392913b81e", "name": "my-bare-metal-server-disk", "resource_type": "bare_metal_server_disk"}, "cpu": {"architecture": "amd64", "core_count": 80, "socket_count": 4, "threads_per_core": 2}, "created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::bare-metal-server:1e09281b-f177-46fb-baf1-bc152b2e391a", "disks": [{"created_at": "2019-01-01T12:00:00.000Z", "href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/1e09281b-f177-46fb-baf1-bc152b2e391a/disks/10c02d81-0ecb-4dc5-897d-28392913b81e", "id": "10c02d81-0ecb-4dc5-897d-28392913b81e", "interface_type": "fcp", "name": "my-bare-metal-server-disk", "resource_type": "bare_metal_server_disk", "size": 100}], "enable_secure_boot": false, "href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/1e09281b-f177-46fb-baf1-bc152b2e391a", "id": "1e09281b-f177-46fb-baf1-bc152b2e391a", "lifecycle_reasons": [{"code": "resource_suspended_by_provider", "message": "The resource has been suspended. Contact IBM support with the CRN for next steps.", "more_info": "https://cloud.ibm.com/apidocs/vpc#resource-suspension"}], "lifecycle_state": "stable", "memory": 1536, "name": "my-bare-metal-server", "network_attachments": [{"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/2302-f7a2bf57-af7c-49d9-b599-b2c91293d30c/network_attachments/2302-da8c43ec-b6ca-4bd2-871e-72e288c66ee6", "id": "2302-da8c43ec-b6ca-4bd2-871e-72e288c66ee6", "name": "my-bare-metal-server-network-attachment", "primary_ip": {"address": "192.168.3.4", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e/reserved_ips/6d353a0f-aeb1-4ae1-832e-1110d10981bb", "id": "6d353a0f-aeb1-4ae1-832e-1110d10981bb", "name": "my-reserved-ip", "resource_type": "subnet_reserved_ip"}, "resource_type": "bare_metal_server_network_attachment", "subnet": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "id": "7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "name": "my-subnet", "resource_type": "subnet"}}], "network_interfaces": [{"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/1e09281b-f177-46fb-baf1-bc152b2e391a/network_interfaces/10c02d81-0ecb-4dc5-897d-28392913b81e", "id": "10c02d81-0ecb-4dc5-897d-28392913b81e", "name": "my-bare-metal-server-network-interface", "primary_ip": {"address": "192.168.3.4", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e/reserved_ips/6d353a0f-aeb1-4ae1-832e-1110d10981bb", "id": "6d353a0f-aeb1-4ae1-832e-1110d10981bb", "name": "my-reserved-ip", "resource_type": "subnet_reserved_ip"}, "resource_type": "network_interface", "subnet": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "id": "7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "name": "my-subnet", "resource_type": "subnet"}}], "primary_network_attachment": {"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/2302-f7a2bf57-af7c-49d9-b599-b2c91293d30c/network_attachments/2302-da8c43ec-b6ca-4bd2-871e-72e288c66ee6", "id": "2302-da8c43ec-b6ca-4bd2-871e-72e288c66ee6", "name": "my-bare-metal-server-network-attachment", "primary_ip": {"address": "192.168.3.4", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e/reserved_ips/6d353a0f-aeb1-4ae1-832e-1110d10981bb", "id": "6d353a0f-aeb1-4ae1-832e-1110d10981bb", "name": "my-reserved-ip", "resource_type": "subnet_reserved_ip"}, "resource_type": "bare_metal_server_network_attachment", "subnet": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "id": "7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "name": "my-subnet", "resource_type": "subnet"}}, "primary_network_interface": {"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/1e09281b-f177-46fb-baf1-bc152b2e391a/network_interfaces/10c02d81-0ecb-4dc5-897d-28392913b81e", "id": "10c02d81-0ecb-4dc5-897d-28392913b81e", "name": "my-bare-metal-server-network-interface", "primary_ip": {"address": "192.168.3.4", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e/reserved_ips/6d353a0f-aeb1-4ae1-832e-1110d10981bb", "id": "6d353a0f-aeb1-4ae1-832e-1110d10981bb", "name": "my-reserved-ip", "resource_type": "subnet_reserved_ip"}, "resource_type": "network_interface", "subnet": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "id": "7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "name": "my-subnet", "resource_type": "subnet"}}, "profile": {"href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/profiles/bx2-metal-192x768", "name": "bx2-metal-192x768", "resource_type": "bare_metal_server_profile"}, "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "resource_type": "bare_metal_server", "status": "deleting", "status_reasons": [{"code": "cannot_start_capacity", "message": "The bare metal server cannot start as there is no more capacity in this\nzone for a bare metal server with the requested profile.", "more_info": "https://console.bluemix.net/docs/iaas/bare_metal_server.html"}], "trusted_platform_module": {"enabled": true, "mode": "disabled", "supported_modes": ["disabled"]}, "vpc": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::vpc:4727d842-f94f-4a2d-824a-9bc9b02c523b", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/vpcs/4727d842-f94f-4a2d-824a-9bc9b02c523b", "id": "4727d842-f94f-4a2d-824a-9bc9b02c523b", "name": "my-vpc", "resource_type": "vpc"}, "zone": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south/zones/us-south-1", "name": "us-south-1"}}`) + fmt.Fprintf(res, "%s", `{"backup_policy_plan": {"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6/plans/r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "id": "r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "name": "my-policy-plan", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "backup_policy_plan"}, "created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot-consistency-group:r134-fa329f6b-0e36-433f-a3bb-0df632e79263", "delete_snapshots_on_delete": false, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshot_consistency_groups/r134-fa329f6b-0e36-433f-a3bb-0df632e79263", "id": "r134-fa329f6b-0e36-433f-a3bb-0df632e79263", "lifecycle_state": "stable", "name": "my-snapshot-consistency-group", "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "resource_type": "snapshot_consistency_group", "service_tags": ["ServiceTags"], "snapshots": [{"crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "id": "r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "name": "my-snapshot", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "snapshot"}]}`) })) }) - It(`Invoke GetBareMetalServer successfully`, func() { + It(`Invoke UpdateSnapshotConsistencyGroup successfully`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -52707,24 +53017,33 @@ var _ = Describe(`VpcV1`, func() { Expect(vpcService).ToNot(BeNil()) // Invoke operation with nil options model (negative test) - result, response, operationErr := vpcService.GetBareMetalServer(nil) + result, response, operationErr := vpcService.UpdateSnapshotConsistencyGroup(nil) Expect(operationErr).NotTo(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) - // Construct an instance of the GetBareMetalServerOptions model - getBareMetalServerOptionsModel := new(vpcv1.GetBareMetalServerOptions) - getBareMetalServerOptionsModel.ID = core.StringPtr("testString") - getBareMetalServerOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the SnapshotConsistencyGroupPatch model + snapshotConsistencyGroupPatchModel := new(vpcv1.SnapshotConsistencyGroupPatch) + snapshotConsistencyGroupPatchModel.DeleteSnapshotsOnDelete = core.BoolPtr(true) + snapshotConsistencyGroupPatchModel.Name = core.StringPtr("my-snapshot-consistency-group") + snapshotConsistencyGroupPatchModelAsPatch, asPatchErr := snapshotConsistencyGroupPatchModel.AsPatch() + Expect(asPatchErr).To(BeNil()) + + // Construct an instance of the UpdateSnapshotConsistencyGroupOptions model + updateSnapshotConsistencyGroupOptionsModel := new(vpcv1.UpdateSnapshotConsistencyGroupOptions) + updateSnapshotConsistencyGroupOptionsModel.ID = core.StringPtr("testString") + updateSnapshotConsistencyGroupOptionsModel.SnapshotConsistencyGroupPatch = snapshotConsistencyGroupPatchModelAsPatch + updateSnapshotConsistencyGroupOptionsModel.IfMatch = core.StringPtr("W/\"96d225c4-56bd-43d9-98fc-d7148e5c5028\"") + updateSnapshotConsistencyGroupOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with valid options model (positive test) - result, response, operationErr = vpcService.GetBareMetalServer(getBareMetalServerOptionsModel) + result, response, operationErr = vpcService.UpdateSnapshotConsistencyGroup(updateSnapshotConsistencyGroupOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) }) - It(`Invoke GetBareMetalServer with error: Operation validation and request error`, func() { + It(`Invoke UpdateSnapshotConsistencyGroup with error: Operation validation and request error`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -52733,22 +53052,31 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the GetBareMetalServerOptions model - getBareMetalServerOptionsModel := new(vpcv1.GetBareMetalServerOptions) - getBareMetalServerOptionsModel.ID = core.StringPtr("testString") - getBareMetalServerOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the SnapshotConsistencyGroupPatch model + snapshotConsistencyGroupPatchModel := new(vpcv1.SnapshotConsistencyGroupPatch) + snapshotConsistencyGroupPatchModel.DeleteSnapshotsOnDelete = core.BoolPtr(true) + snapshotConsistencyGroupPatchModel.Name = core.StringPtr("my-snapshot-consistency-group") + snapshotConsistencyGroupPatchModelAsPatch, asPatchErr := snapshotConsistencyGroupPatchModel.AsPatch() + Expect(asPatchErr).To(BeNil()) + + // Construct an instance of the UpdateSnapshotConsistencyGroupOptions model + updateSnapshotConsistencyGroupOptionsModel := new(vpcv1.UpdateSnapshotConsistencyGroupOptions) + updateSnapshotConsistencyGroupOptionsModel.ID = core.StringPtr("testString") + updateSnapshotConsistencyGroupOptionsModel.SnapshotConsistencyGroupPatch = snapshotConsistencyGroupPatchModelAsPatch + updateSnapshotConsistencyGroupOptionsModel.IfMatch = core.StringPtr("W/\"96d225c4-56bd-43d9-98fc-d7148e5c5028\"") + updateSnapshotConsistencyGroupOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with empty URL (negative test) err := vpcService.SetServiceURL("") Expect(err).To(BeNil()) - result, response, operationErr := vpcService.GetBareMetalServer(getBareMetalServerOptionsModel) + result, response, operationErr := vpcService.UpdateSnapshotConsistencyGroup(updateSnapshotConsistencyGroupOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING)) Expect(response).To(BeNil()) Expect(result).To(BeNil()) - // Construct a second instance of the GetBareMetalServerOptions model with no property values - getBareMetalServerOptionsModelNew := new(vpcv1.GetBareMetalServerOptions) + // Construct a second instance of the UpdateSnapshotConsistencyGroupOptions model with no property values + updateSnapshotConsistencyGroupOptionsModelNew := new(vpcv1.UpdateSnapshotConsistencyGroupOptions) // Invoke operation with invalid model (negative test) - result, response, operationErr = vpcService.GetBareMetalServer(getBareMetalServerOptionsModelNew) + result, response, operationErr = vpcService.UpdateSnapshotConsistencyGroup(updateSnapshotConsistencyGroupOptionsModelNew) Expect(operationErr).ToNot(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) @@ -52766,7 +53094,7 @@ var _ = Describe(`VpcV1`, func() { res.WriteHeader(200) })) }) - It(`Invoke GetBareMetalServer successfully`, func() { + It(`Invoke UpdateSnapshotConsistencyGroup successfully`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -52775,13 +53103,22 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the GetBareMetalServerOptions model - getBareMetalServerOptionsModel := new(vpcv1.GetBareMetalServerOptions) - getBareMetalServerOptionsModel.ID = core.StringPtr("testString") - getBareMetalServerOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the SnapshotConsistencyGroupPatch model + snapshotConsistencyGroupPatchModel := new(vpcv1.SnapshotConsistencyGroupPatch) + snapshotConsistencyGroupPatchModel.DeleteSnapshotsOnDelete = core.BoolPtr(true) + snapshotConsistencyGroupPatchModel.Name = core.StringPtr("my-snapshot-consistency-group") + snapshotConsistencyGroupPatchModelAsPatch, asPatchErr := snapshotConsistencyGroupPatchModel.AsPatch() + Expect(asPatchErr).To(BeNil()) + + // Construct an instance of the UpdateSnapshotConsistencyGroupOptions model + updateSnapshotConsistencyGroupOptionsModel := new(vpcv1.UpdateSnapshotConsistencyGroupOptions) + updateSnapshotConsistencyGroupOptionsModel.ID = core.StringPtr("testString") + updateSnapshotConsistencyGroupOptionsModel.SnapshotConsistencyGroupPatch = snapshotConsistencyGroupPatchModelAsPatch + updateSnapshotConsistencyGroupOptionsModel.IfMatch = core.StringPtr("W/\"96d225c4-56bd-43d9-98fc-d7148e5c5028\"") + updateSnapshotConsistencyGroupOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation - result, response, operationErr := vpcService.GetBareMetalServer(getBareMetalServerOptionsModel) + result, response, operationErr := vpcService.UpdateSnapshotConsistencyGroup(updateSnapshotConsistencyGroupOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) @@ -52793,25 +53130,121 @@ var _ = Describe(`VpcV1`, func() { }) }) }) - Describe(`UpdateBareMetalServer(updateBareMetalServerOptions *UpdateBareMetalServerOptions) - Operation response error`, func() { + Describe(`DeleteSnapshots(deleteSnapshotsOptions *DeleteSnapshotsOptions)`, func() { version := "testString" - updateBareMetalServerPath := "/bare_metal_servers/testString" + deleteSnapshotsPath := "/snapshots" + Context(`Using mock server endpoint`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Verify the contents of the request + Expect(req.URL.EscapedPath()).To(Equal(deleteSnapshotsPath)) + Expect(req.Method).To(Equal("DELETE")) + + Expect(req.URL.Query()["version"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["generation"]).To(Equal([]string{fmt.Sprint(int64(2))})) + Expect(req.URL.Query()["source_volume.id"]).To(Equal([]string{"testString"})) + res.WriteHeader(204) + })) + }) + It(`Invoke DeleteSnapshots successfully`, func() { + vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + Version: core.StringPtr(version), + }) + Expect(serviceErr).To(BeNil()) + Expect(vpcService).ToNot(BeNil()) + + // Invoke operation with nil options model (negative test) + response, operationErr := vpcService.DeleteSnapshots(nil) + Expect(operationErr).NotTo(BeNil()) + Expect(response).To(BeNil()) + + // Construct an instance of the DeleteSnapshotsOptions model + deleteSnapshotsOptionsModel := new(vpcv1.DeleteSnapshotsOptions) + deleteSnapshotsOptionsModel.SourceVolumeID = core.StringPtr("testString") + deleteSnapshotsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation with valid options model (positive test) + response, operationErr = vpcService.DeleteSnapshots(deleteSnapshotsOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + }) + It(`Invoke DeleteSnapshots with error: Operation validation and request error`, func() { + vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + Version: core.StringPtr(version), + }) + Expect(serviceErr).To(BeNil()) + Expect(vpcService).ToNot(BeNil()) + + // Construct an instance of the DeleteSnapshotsOptions model + deleteSnapshotsOptionsModel := new(vpcv1.DeleteSnapshotsOptions) + deleteSnapshotsOptionsModel.SourceVolumeID = core.StringPtr("testString") + deleteSnapshotsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Invoke operation with empty URL (negative test) + err := vpcService.SetServiceURL("") + Expect(err).To(BeNil()) + response, operationErr := vpcService.DeleteSnapshots(deleteSnapshotsOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING)) + Expect(response).To(BeNil()) + // Construct a second instance of the DeleteSnapshotsOptions model with no property values + deleteSnapshotsOptionsModelNew := new(vpcv1.DeleteSnapshotsOptions) + // Invoke operation with invalid model (negative test) + response, operationErr = vpcService.DeleteSnapshots(deleteSnapshotsOptionsModelNew) + Expect(operationErr).ToNot(BeNil()) + Expect(response).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + }) + Describe(`ListSnapshots(listSnapshotsOptions *ListSnapshotsOptions) - Operation response error`, func() { + version := "testString" + listSnapshotsPath := "/snapshots" Context(`Using mock server endpoint with invalid JSON response`, func() { BeforeEach(func() { testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(updateBareMetalServerPath)) - Expect(req.Method).To(Equal("PATCH")) + Expect(req.URL.EscapedPath()).To(Equal(listSnapshotsPath)) + Expect(req.Method).To(Equal("GET")) Expect(req.URL.Query()["version"]).To(Equal([]string{"testString"})) Expect(req.URL.Query()["generation"]).To(Equal([]string{fmt.Sprint(int64(2))})) + Expect(req.URL.Query()["start"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["limit"]).To(Equal([]string{fmt.Sprint(int64(10))})) + Expect(req.URL.Query()["tag"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["resource_group.id"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["name"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["source_volume.id"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["source_volume.crn"]).To(Equal([]string{"crn:v1:bluemix:public:is:us-south-1:a/123456::volume:1a6b7274-678d-4dfb-8981-c71dd9d4daa5"})) + Expect(req.URL.Query()["source_image.id"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["source_image.crn"]).To(Equal([]string{"crn:v1:bluemix:public:is:us-south:a/123456::image:72b27b5c-f4b0-48bb-b954-5becc7c1dcb8"})) + Expect(req.URL.Query()["sort"]).To(Equal([]string{"name"})) + Expect(req.URL.Query()["backup_policy_plan.id"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["copies[].id"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["copies[].name"]).To(Equal([]string{"my-snapshot-copy"})) + Expect(req.URL.Query()["copies[].crn"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["copies[].remote.region.name"]).To(Equal([]string{"us-south"})) + Expect(req.URL.Query()["source_snapshot.id"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["source_snapshot.remote.region.name"]).To(Equal([]string{"us-south"})) + Expect(req.URL.Query()["source_volume.remote.region.name"]).To(Equal([]string{"us-south"})) + Expect(req.URL.Query()["source_image.remote.region.name"]).To(Equal([]string{"us-south"})) + Expect(req.URL.Query()["clones[].zone.name"]).To(Equal([]string{"us-south-1"})) + Expect(req.URL.Query()["snapshot_consistency_group.id"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["snapshot_consistency_group.crn"]).To(Equal([]string{"crn:v1:bluemix:public:is:us-south:a/123456::snapshot-consistency-group:r134-fa329f6b-0e36-433f-a3bb-0df632e79263"})) res.Header().Set("Content-type", "application/json") res.WriteHeader(200) fmt.Fprint(res, `} this is not valid json {`) })) }) - It(`Invoke UpdateBareMetalServer with error: Operation response processing error`, func() { + It(`Invoke ListSnapshots with error: Operation response processing error`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -52820,32 +53253,40 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the BareMetalServerTrustedPlatformModulePatch model - bareMetalServerTrustedPlatformModulePatchModel := new(vpcv1.BareMetalServerTrustedPlatformModulePatch) - bareMetalServerTrustedPlatformModulePatchModel.Mode = core.StringPtr("disabled") - - // Construct an instance of the BareMetalServerPatch model - bareMetalServerPatchModel := new(vpcv1.BareMetalServerPatch) - bareMetalServerPatchModel.EnableSecureBoot = core.BoolPtr(false) - bareMetalServerPatchModel.Name = core.StringPtr("my-bare-metal-server") - bareMetalServerPatchModel.TrustedPlatformModule = bareMetalServerTrustedPlatformModulePatchModel - bareMetalServerPatchModelAsPatch, asPatchErr := bareMetalServerPatchModel.AsPatch() - Expect(asPatchErr).To(BeNil()) - - // Construct an instance of the UpdateBareMetalServerOptions model - updateBareMetalServerOptionsModel := new(vpcv1.UpdateBareMetalServerOptions) - updateBareMetalServerOptionsModel.ID = core.StringPtr("testString") - updateBareMetalServerOptionsModel.BareMetalServerPatch = bareMetalServerPatchModelAsPatch - updateBareMetalServerOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the ListSnapshotsOptions model + listSnapshotsOptionsModel := new(vpcv1.ListSnapshotsOptions) + listSnapshotsOptionsModel.Start = core.StringPtr("testString") + listSnapshotsOptionsModel.Limit = core.Int64Ptr(int64(10)) + listSnapshotsOptionsModel.Tag = core.StringPtr("testString") + listSnapshotsOptionsModel.ResourceGroupID = core.StringPtr("testString") + listSnapshotsOptionsModel.Name = core.StringPtr("testString") + listSnapshotsOptionsModel.SourceVolumeID = core.StringPtr("testString") + listSnapshotsOptionsModel.SourceVolumeCRN = core.StringPtr("crn:v1:bluemix:public:is:us-south-1:a/123456::volume:1a6b7274-678d-4dfb-8981-c71dd9d4daa5") + listSnapshotsOptionsModel.SourceImageID = core.StringPtr("testString") + listSnapshotsOptionsModel.SourceImageCRN = core.StringPtr("crn:v1:bluemix:public:is:us-south:a/123456::image:72b27b5c-f4b0-48bb-b954-5becc7c1dcb8") + listSnapshotsOptionsModel.Sort = core.StringPtr("name") + listSnapshotsOptionsModel.BackupPolicyPlanID = core.StringPtr("testString") + listSnapshotsOptionsModel.CopiesID = core.StringPtr("testString") + listSnapshotsOptionsModel.CopiesName = core.StringPtr("my-snapshot-copy") + listSnapshotsOptionsModel.CopiesCRN = core.StringPtr("testString") + listSnapshotsOptionsModel.CopiesRemoteRegionName = core.StringPtr("us-south") + listSnapshotsOptionsModel.SourceSnapshotID = core.StringPtr("testString") + listSnapshotsOptionsModel.SourceSnapshotRemoteRegionName = core.StringPtr("us-south") + listSnapshotsOptionsModel.SourceVolumeRemoteRegionName = core.StringPtr("us-south") + listSnapshotsOptionsModel.SourceImageRemoteRegionName = core.StringPtr("us-south") + listSnapshotsOptionsModel.ClonesZoneName = core.StringPtr("us-south-1") + listSnapshotsOptionsModel.SnapshotConsistencyGroupID = core.StringPtr("testString") + listSnapshotsOptionsModel.SnapshotConsistencyGroupCRN = core.StringPtr("crn:v1:bluemix:public:is:us-south:a/123456::snapshot-consistency-group:r134-fa329f6b-0e36-433f-a3bb-0df632e79263") + listSnapshotsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Expect response parsing to fail since we are receiving a text/plain response - result, response, operationErr := vpcService.UpdateBareMetalServer(updateBareMetalServerOptionsModel) + result, response, operationErr := vpcService.ListSnapshots(listSnapshotsOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).To(BeNil()) // Enable retries and test again vpcService.EnableRetries(0, 0) - result, response, operationErr = vpcService.UpdateBareMetalServer(updateBareMetalServerOptionsModel) + result, response, operationErr = vpcService.ListSnapshots(listSnapshotsOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).To(BeNil()) @@ -52855,46 +53296,52 @@ var _ = Describe(`VpcV1`, func() { }) }) }) - Describe(`UpdateBareMetalServer(updateBareMetalServerOptions *UpdateBareMetalServerOptions)`, func() { + Describe(`ListSnapshots(listSnapshotsOptions *ListSnapshotsOptions)`, func() { version := "testString" - updateBareMetalServerPath := "/bare_metal_servers/testString" + listSnapshotsPath := "/snapshots" Context(`Using mock server endpoint with timeout`, func() { BeforeEach(func() { testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(updateBareMetalServerPath)) - 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.URL.EscapedPath()).To(Equal(listSnapshotsPath)) + Expect(req.Method).To(Equal("GET")) Expect(req.URL.Query()["version"]).To(Equal([]string{"testString"})) Expect(req.URL.Query()["generation"]).To(Equal([]string{fmt.Sprint(int64(2))})) + Expect(req.URL.Query()["start"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["limit"]).To(Equal([]string{fmt.Sprint(int64(10))})) + Expect(req.URL.Query()["tag"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["resource_group.id"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["name"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["source_volume.id"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["source_volume.crn"]).To(Equal([]string{"crn:v1:bluemix:public:is:us-south-1:a/123456::volume:1a6b7274-678d-4dfb-8981-c71dd9d4daa5"})) + Expect(req.URL.Query()["source_image.id"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["source_image.crn"]).To(Equal([]string{"crn:v1:bluemix:public:is:us-south:a/123456::image:72b27b5c-f4b0-48bb-b954-5becc7c1dcb8"})) + Expect(req.URL.Query()["sort"]).To(Equal([]string{"name"})) + Expect(req.URL.Query()["backup_policy_plan.id"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["copies[].id"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["copies[].name"]).To(Equal([]string{"my-snapshot-copy"})) + Expect(req.URL.Query()["copies[].crn"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["copies[].remote.region.name"]).To(Equal([]string{"us-south"})) + Expect(req.URL.Query()["source_snapshot.id"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["source_snapshot.remote.region.name"]).To(Equal([]string{"us-south"})) + Expect(req.URL.Query()["source_volume.remote.region.name"]).To(Equal([]string{"us-south"})) + Expect(req.URL.Query()["source_image.remote.region.name"]).To(Equal([]string{"us-south"})) + Expect(req.URL.Query()["clones[].zone.name"]).To(Equal([]string{"us-south-1"})) + Expect(req.URL.Query()["snapshot_consistency_group.id"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["snapshot_consistency_group.crn"]).To(Equal([]string{"crn:v1:bluemix:public:is:us-south:a/123456::snapshot-consistency-group:r134-fa329f6b-0e36-433f-a3bb-0df632e79263"})) // Sleep a short time to support a timeout test time.Sleep(100 * time.Millisecond) // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"bandwidth": 20000, "boot_target": {"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/1e09281b-f177-46fb-baf1-bc152b2e391a/disks/10c02d81-0ecb-4dc5-897d-28392913b81e", "id": "10c02d81-0ecb-4dc5-897d-28392913b81e", "name": "my-bare-metal-server-disk", "resource_type": "bare_metal_server_disk"}, "cpu": {"architecture": "amd64", "core_count": 80, "socket_count": 4, "threads_per_core": 2}, "created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::bare-metal-server:1e09281b-f177-46fb-baf1-bc152b2e391a", "disks": [{"created_at": "2019-01-01T12:00:00.000Z", "href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/1e09281b-f177-46fb-baf1-bc152b2e391a/disks/10c02d81-0ecb-4dc5-897d-28392913b81e", "id": "10c02d81-0ecb-4dc5-897d-28392913b81e", "interface_type": "fcp", "name": "my-bare-metal-server-disk", "resource_type": "bare_metal_server_disk", "size": 100}], "enable_secure_boot": false, "href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/1e09281b-f177-46fb-baf1-bc152b2e391a", "id": "1e09281b-f177-46fb-baf1-bc152b2e391a", "lifecycle_reasons": [{"code": "resource_suspended_by_provider", "message": "The resource has been suspended. Contact IBM support with the CRN for next steps.", "more_info": "https://cloud.ibm.com/apidocs/vpc#resource-suspension"}], "lifecycle_state": "stable", "memory": 1536, "name": "my-bare-metal-server", "network_attachments": [{"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/2302-f7a2bf57-af7c-49d9-b599-b2c91293d30c/network_attachments/2302-da8c43ec-b6ca-4bd2-871e-72e288c66ee6", "id": "2302-da8c43ec-b6ca-4bd2-871e-72e288c66ee6", "name": "my-bare-metal-server-network-attachment", "primary_ip": {"address": "192.168.3.4", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e/reserved_ips/6d353a0f-aeb1-4ae1-832e-1110d10981bb", "id": "6d353a0f-aeb1-4ae1-832e-1110d10981bb", "name": "my-reserved-ip", "resource_type": "subnet_reserved_ip"}, "resource_type": "bare_metal_server_network_attachment", "subnet": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "id": "7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "name": "my-subnet", "resource_type": "subnet"}}], "network_interfaces": [{"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/1e09281b-f177-46fb-baf1-bc152b2e391a/network_interfaces/10c02d81-0ecb-4dc5-897d-28392913b81e", "id": "10c02d81-0ecb-4dc5-897d-28392913b81e", "name": "my-bare-metal-server-network-interface", "primary_ip": {"address": "192.168.3.4", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e/reserved_ips/6d353a0f-aeb1-4ae1-832e-1110d10981bb", "id": "6d353a0f-aeb1-4ae1-832e-1110d10981bb", "name": "my-reserved-ip", "resource_type": "subnet_reserved_ip"}, "resource_type": "network_interface", "subnet": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "id": "7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "name": "my-subnet", "resource_type": "subnet"}}], "primary_network_attachment": {"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/2302-f7a2bf57-af7c-49d9-b599-b2c91293d30c/network_attachments/2302-da8c43ec-b6ca-4bd2-871e-72e288c66ee6", "id": "2302-da8c43ec-b6ca-4bd2-871e-72e288c66ee6", "name": "my-bare-metal-server-network-attachment", "primary_ip": {"address": "192.168.3.4", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e/reserved_ips/6d353a0f-aeb1-4ae1-832e-1110d10981bb", "id": "6d353a0f-aeb1-4ae1-832e-1110d10981bb", "name": "my-reserved-ip", "resource_type": "subnet_reserved_ip"}, "resource_type": "bare_metal_server_network_attachment", "subnet": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "id": "7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "name": "my-subnet", "resource_type": "subnet"}}, "primary_network_interface": {"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/1e09281b-f177-46fb-baf1-bc152b2e391a/network_interfaces/10c02d81-0ecb-4dc5-897d-28392913b81e", "id": "10c02d81-0ecb-4dc5-897d-28392913b81e", "name": "my-bare-metal-server-network-interface", "primary_ip": {"address": "192.168.3.4", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e/reserved_ips/6d353a0f-aeb1-4ae1-832e-1110d10981bb", "id": "6d353a0f-aeb1-4ae1-832e-1110d10981bb", "name": "my-reserved-ip", "resource_type": "subnet_reserved_ip"}, "resource_type": "network_interface", "subnet": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "id": "7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "name": "my-subnet", "resource_type": "subnet"}}, "profile": {"href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/profiles/bx2-metal-192x768", "name": "bx2-metal-192x768", "resource_type": "bare_metal_server_profile"}, "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "resource_type": "bare_metal_server", "status": "deleting", "status_reasons": [{"code": "cannot_start_capacity", "message": "The bare metal server cannot start as there is no more capacity in this\nzone for a bare metal server with the requested profile.", "more_info": "https://console.bluemix.net/docs/iaas/bare_metal_server.html"}], "trusted_platform_module": {"enabled": true, "mode": "disabled", "supported_modes": ["disabled"]}, "vpc": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::vpc:4727d842-f94f-4a2d-824a-9bc9b02c523b", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/vpcs/4727d842-f94f-4a2d-824a-9bc9b02c523b", "id": "4727d842-f94f-4a2d-824a-9bc9b02c523b", "name": "my-vpc", "resource_type": "vpc"}, "zone": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south/zones/us-south-1", "name": "us-south-1"}}`) + fmt.Fprintf(res, "%s", `{"first": {"href": "https://us-south.iaas.cloud.ibm.com/v1/snapshots?limit=20"}, "limit": 20, "next": {"href": "https://us-south.iaas.cloud.ibm.com/v1/snapshots?start=9d5a91a3e2cbd233b5a5b33436855ed1&limit=20"}, "snapshots": [{"backup_policy_plan": {"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6/plans/r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "id": "r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "name": "my-policy-plan", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "backup_policy_plan"}, "bootable": true, "captured_at": "2019-01-01T12:00:00.000Z", "clones": [{"available": false, "created_at": "2019-01-01T12:00:00.000Z", "zone": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south/zones/us-south-1", "name": "us-south-1"}}], "copies": [{"crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "id": "r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "name": "my-snapshot", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "snapshot"}], "created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "deletable": false, "encryption": "provider_managed", "encryption_key": {"crn": "crn:v1:bluemix:public:kms:us-south:a/123456:e4a29d1a-2ef0-42a6-8fd2-350deb1c647e:key:5437653b-c4b1-447f-9646-b2a2a4cd6179"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "id": "r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "lifecycle_state": "stable", "minimum_capacity": 1, "name": "my-snapshot", "operating_system": {"architecture": "amd64", "dedicated_host_only": false, "display_name": "Ubuntu Server 16.04 LTS amd64", "family": "Ubuntu Server", "href": "https://us-south.iaas.cloud.ibm.com/v1/operating_systems/ubuntu-16-amd64", "name": "ubuntu-16-amd64", "vendor": "Canonical", "version": "16.04 LTS"}, "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "resource_type": "snapshot", "service_tags": ["ServiceTags"], "size": 1, "snapshot_consistency_group": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot-consistency-group:r134-fa329f6b-0e36-433f-a3bb-0df632e79263", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshot_consistency_groups/r134-fa329f6b-0e36-433f-a3bb-0df632e79263", "id": "r134-fa329f6b-0e36-433f-a3bb-0df632e79263", "name": "my-snapshot-consistency-group", "resource_type": "snapshot_consistency_group"}, "source_image": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::image:72b27b5c-f4b0-48bb-b954-5becc7c1dcb8", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/images/72b27b5c-f4b0-48bb-b954-5becc7c1dcb8", "id": "72b27b5c-f4b0-48bb-b954-5becc7c1dcb8", "name": "my-image", "remote": {"account": {"id": "aa2432b1fa4d4ace891e9b80fc104e34", "resource_type": "account"}, "region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "image"}, "source_snapshot": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "id": "r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "name": "my-snapshot", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "snapshot"}, "source_volume": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::volume:1a6b7274-678d-4dfb-8981-c71dd9d4daa5", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/volumes/1a6b7274-678d-4dfb-8981-c71dd9d4daa5", "id": "1a6b7274-678d-4dfb-8981-c71dd9d4daa5", "name": "my-volume", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "volume"}, "user_tags": ["UserTags"]}], "total_count": 132}`) })) }) - It(`Invoke UpdateBareMetalServer successfully with retries`, func() { + It(`Invoke ListSnapshots successfully with retries`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -52904,34 +53351,42 @@ var _ = Describe(`VpcV1`, func() { Expect(vpcService).ToNot(BeNil()) vpcService.EnableRetries(0, 0) - // Construct an instance of the BareMetalServerTrustedPlatformModulePatch model - bareMetalServerTrustedPlatformModulePatchModel := new(vpcv1.BareMetalServerTrustedPlatformModulePatch) - bareMetalServerTrustedPlatformModulePatchModel.Mode = core.StringPtr("disabled") - - // Construct an instance of the BareMetalServerPatch model - bareMetalServerPatchModel := new(vpcv1.BareMetalServerPatch) - bareMetalServerPatchModel.EnableSecureBoot = core.BoolPtr(false) - bareMetalServerPatchModel.Name = core.StringPtr("my-bare-metal-server") - bareMetalServerPatchModel.TrustedPlatformModule = bareMetalServerTrustedPlatformModulePatchModel - bareMetalServerPatchModelAsPatch, asPatchErr := bareMetalServerPatchModel.AsPatch() - Expect(asPatchErr).To(BeNil()) - - // Construct an instance of the UpdateBareMetalServerOptions model - updateBareMetalServerOptionsModel := new(vpcv1.UpdateBareMetalServerOptions) - updateBareMetalServerOptionsModel.ID = core.StringPtr("testString") - updateBareMetalServerOptionsModel.BareMetalServerPatch = bareMetalServerPatchModelAsPatch - updateBareMetalServerOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the ListSnapshotsOptions model + listSnapshotsOptionsModel := new(vpcv1.ListSnapshotsOptions) + listSnapshotsOptionsModel.Start = core.StringPtr("testString") + listSnapshotsOptionsModel.Limit = core.Int64Ptr(int64(10)) + listSnapshotsOptionsModel.Tag = core.StringPtr("testString") + listSnapshotsOptionsModel.ResourceGroupID = core.StringPtr("testString") + listSnapshotsOptionsModel.Name = core.StringPtr("testString") + listSnapshotsOptionsModel.SourceVolumeID = core.StringPtr("testString") + listSnapshotsOptionsModel.SourceVolumeCRN = core.StringPtr("crn:v1:bluemix:public:is:us-south-1:a/123456::volume:1a6b7274-678d-4dfb-8981-c71dd9d4daa5") + listSnapshotsOptionsModel.SourceImageID = core.StringPtr("testString") + listSnapshotsOptionsModel.SourceImageCRN = core.StringPtr("crn:v1:bluemix:public:is:us-south:a/123456::image:72b27b5c-f4b0-48bb-b954-5becc7c1dcb8") + listSnapshotsOptionsModel.Sort = core.StringPtr("name") + listSnapshotsOptionsModel.BackupPolicyPlanID = core.StringPtr("testString") + listSnapshotsOptionsModel.CopiesID = core.StringPtr("testString") + listSnapshotsOptionsModel.CopiesName = core.StringPtr("my-snapshot-copy") + listSnapshotsOptionsModel.CopiesCRN = core.StringPtr("testString") + listSnapshotsOptionsModel.CopiesRemoteRegionName = core.StringPtr("us-south") + listSnapshotsOptionsModel.SourceSnapshotID = core.StringPtr("testString") + listSnapshotsOptionsModel.SourceSnapshotRemoteRegionName = core.StringPtr("us-south") + listSnapshotsOptionsModel.SourceVolumeRemoteRegionName = core.StringPtr("us-south") + listSnapshotsOptionsModel.SourceImageRemoteRegionName = core.StringPtr("us-south") + listSnapshotsOptionsModel.ClonesZoneName = core.StringPtr("us-south-1") + listSnapshotsOptionsModel.SnapshotConsistencyGroupID = core.StringPtr("testString") + listSnapshotsOptionsModel.SnapshotConsistencyGroupCRN = core.StringPtr("crn:v1:bluemix:public:is:us-south:a/123456::snapshot-consistency-group:r134-fa329f6b-0e36-433f-a3bb-0df632e79263") + listSnapshotsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with a Context to test a timeout error ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond) defer cancelFunc() - _, _, operationErr := vpcService.UpdateBareMetalServerWithContext(ctx, updateBareMetalServerOptionsModel) + _, _, operationErr := vpcService.ListSnapshotsWithContext(ctx, listSnapshotsOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) // Disable retries and test again vpcService.DisableRetries() - result, response, operationErr := vpcService.UpdateBareMetalServer(updateBareMetalServerOptionsModel) + result, response, operationErr := vpcService.ListSnapshots(listSnapshotsOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) @@ -52939,7 +53394,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.UpdateBareMetalServerWithContext(ctx, updateBareMetalServerOptionsModel) + _, _, operationErr = vpcService.ListSnapshotsWithContext(ctx, listSnapshotsOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) }) @@ -52953,34 +53408,40 @@ var _ = Describe(`VpcV1`, func() { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(updateBareMetalServerPath)) - 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.URL.EscapedPath()).To(Equal(listSnapshotsPath)) + Expect(req.Method).To(Equal("GET")) Expect(req.URL.Query()["version"]).To(Equal([]string{"testString"})) Expect(req.URL.Query()["generation"]).To(Equal([]string{fmt.Sprint(int64(2))})) + Expect(req.URL.Query()["start"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["limit"]).To(Equal([]string{fmt.Sprint(int64(10))})) + Expect(req.URL.Query()["tag"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["resource_group.id"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["name"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["source_volume.id"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["source_volume.crn"]).To(Equal([]string{"crn:v1:bluemix:public:is:us-south-1:a/123456::volume:1a6b7274-678d-4dfb-8981-c71dd9d4daa5"})) + Expect(req.URL.Query()["source_image.id"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["source_image.crn"]).To(Equal([]string{"crn:v1:bluemix:public:is:us-south:a/123456::image:72b27b5c-f4b0-48bb-b954-5becc7c1dcb8"})) + Expect(req.URL.Query()["sort"]).To(Equal([]string{"name"})) + Expect(req.URL.Query()["backup_policy_plan.id"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["copies[].id"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["copies[].name"]).To(Equal([]string{"my-snapshot-copy"})) + Expect(req.URL.Query()["copies[].crn"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["copies[].remote.region.name"]).To(Equal([]string{"us-south"})) + Expect(req.URL.Query()["source_snapshot.id"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["source_snapshot.remote.region.name"]).To(Equal([]string{"us-south"})) + Expect(req.URL.Query()["source_volume.remote.region.name"]).To(Equal([]string{"us-south"})) + Expect(req.URL.Query()["source_image.remote.region.name"]).To(Equal([]string{"us-south"})) + Expect(req.URL.Query()["clones[].zone.name"]).To(Equal([]string{"us-south-1"})) + Expect(req.URL.Query()["snapshot_consistency_group.id"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["snapshot_consistency_group.crn"]).To(Equal([]string{"crn:v1:bluemix:public:is:us-south:a/123456::snapshot-consistency-group:r134-fa329f6b-0e36-433f-a3bb-0df632e79263"})) // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"bandwidth": 20000, "boot_target": {"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/1e09281b-f177-46fb-baf1-bc152b2e391a/disks/10c02d81-0ecb-4dc5-897d-28392913b81e", "id": "10c02d81-0ecb-4dc5-897d-28392913b81e", "name": "my-bare-metal-server-disk", "resource_type": "bare_metal_server_disk"}, "cpu": {"architecture": "amd64", "core_count": 80, "socket_count": 4, "threads_per_core": 2}, "created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::bare-metal-server:1e09281b-f177-46fb-baf1-bc152b2e391a", "disks": [{"created_at": "2019-01-01T12:00:00.000Z", "href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/1e09281b-f177-46fb-baf1-bc152b2e391a/disks/10c02d81-0ecb-4dc5-897d-28392913b81e", "id": "10c02d81-0ecb-4dc5-897d-28392913b81e", "interface_type": "fcp", "name": "my-bare-metal-server-disk", "resource_type": "bare_metal_server_disk", "size": 100}], "enable_secure_boot": false, "href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/1e09281b-f177-46fb-baf1-bc152b2e391a", "id": "1e09281b-f177-46fb-baf1-bc152b2e391a", "lifecycle_reasons": [{"code": "resource_suspended_by_provider", "message": "The resource has been suspended. Contact IBM support with the CRN for next steps.", "more_info": "https://cloud.ibm.com/apidocs/vpc#resource-suspension"}], "lifecycle_state": "stable", "memory": 1536, "name": "my-bare-metal-server", "network_attachments": [{"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/2302-f7a2bf57-af7c-49d9-b599-b2c91293d30c/network_attachments/2302-da8c43ec-b6ca-4bd2-871e-72e288c66ee6", "id": "2302-da8c43ec-b6ca-4bd2-871e-72e288c66ee6", "name": "my-bare-metal-server-network-attachment", "primary_ip": {"address": "192.168.3.4", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e/reserved_ips/6d353a0f-aeb1-4ae1-832e-1110d10981bb", "id": "6d353a0f-aeb1-4ae1-832e-1110d10981bb", "name": "my-reserved-ip", "resource_type": "subnet_reserved_ip"}, "resource_type": "bare_metal_server_network_attachment", "subnet": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "id": "7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "name": "my-subnet", "resource_type": "subnet"}}], "network_interfaces": [{"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/1e09281b-f177-46fb-baf1-bc152b2e391a/network_interfaces/10c02d81-0ecb-4dc5-897d-28392913b81e", "id": "10c02d81-0ecb-4dc5-897d-28392913b81e", "name": "my-bare-metal-server-network-interface", "primary_ip": {"address": "192.168.3.4", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e/reserved_ips/6d353a0f-aeb1-4ae1-832e-1110d10981bb", "id": "6d353a0f-aeb1-4ae1-832e-1110d10981bb", "name": "my-reserved-ip", "resource_type": "subnet_reserved_ip"}, "resource_type": "network_interface", "subnet": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "id": "7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "name": "my-subnet", "resource_type": "subnet"}}], "primary_network_attachment": {"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/2302-f7a2bf57-af7c-49d9-b599-b2c91293d30c/network_attachments/2302-da8c43ec-b6ca-4bd2-871e-72e288c66ee6", "id": "2302-da8c43ec-b6ca-4bd2-871e-72e288c66ee6", "name": "my-bare-metal-server-network-attachment", "primary_ip": {"address": "192.168.3.4", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e/reserved_ips/6d353a0f-aeb1-4ae1-832e-1110d10981bb", "id": "6d353a0f-aeb1-4ae1-832e-1110d10981bb", "name": "my-reserved-ip", "resource_type": "subnet_reserved_ip"}, "resource_type": "bare_metal_server_network_attachment", "subnet": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "id": "7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "name": "my-subnet", "resource_type": "subnet"}}, "primary_network_interface": {"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/1e09281b-f177-46fb-baf1-bc152b2e391a/network_interfaces/10c02d81-0ecb-4dc5-897d-28392913b81e", "id": "10c02d81-0ecb-4dc5-897d-28392913b81e", "name": "my-bare-metal-server-network-interface", "primary_ip": {"address": "192.168.3.4", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e/reserved_ips/6d353a0f-aeb1-4ae1-832e-1110d10981bb", "id": "6d353a0f-aeb1-4ae1-832e-1110d10981bb", "name": "my-reserved-ip", "resource_type": "subnet_reserved_ip"}, "resource_type": "network_interface", "subnet": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "id": "7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "name": "my-subnet", "resource_type": "subnet"}}, "profile": {"href": "https://us-south.iaas.cloud.ibm.com/v1/bare_metal_servers/profiles/bx2-metal-192x768", "name": "bx2-metal-192x768", "resource_type": "bare_metal_server_profile"}, "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "resource_type": "bare_metal_server", "status": "deleting", "status_reasons": [{"code": "cannot_start_capacity", "message": "The bare metal server cannot start as there is no more capacity in this\nzone for a bare metal server with the requested profile.", "more_info": "https://console.bluemix.net/docs/iaas/bare_metal_server.html"}], "trusted_platform_module": {"enabled": true, "mode": "disabled", "supported_modes": ["disabled"]}, "vpc": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::vpc:4727d842-f94f-4a2d-824a-9bc9b02c523b", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/vpcs/4727d842-f94f-4a2d-824a-9bc9b02c523b", "id": "4727d842-f94f-4a2d-824a-9bc9b02c523b", "name": "my-vpc", "resource_type": "vpc"}, "zone": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south/zones/us-south-1", "name": "us-south-1"}}`) + fmt.Fprintf(res, "%s", `{"first": {"href": "https://us-south.iaas.cloud.ibm.com/v1/snapshots?limit=20"}, "limit": 20, "next": {"href": "https://us-south.iaas.cloud.ibm.com/v1/snapshots?start=9d5a91a3e2cbd233b5a5b33436855ed1&limit=20"}, "snapshots": [{"backup_policy_plan": {"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6/plans/r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "id": "r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "name": "my-policy-plan", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "backup_policy_plan"}, "bootable": true, "captured_at": "2019-01-01T12:00:00.000Z", "clones": [{"available": false, "created_at": "2019-01-01T12:00:00.000Z", "zone": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south/zones/us-south-1", "name": "us-south-1"}}], "copies": [{"crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "id": "r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "name": "my-snapshot", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "snapshot"}], "created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "deletable": false, "encryption": "provider_managed", "encryption_key": {"crn": "crn:v1:bluemix:public:kms:us-south:a/123456:e4a29d1a-2ef0-42a6-8fd2-350deb1c647e:key:5437653b-c4b1-447f-9646-b2a2a4cd6179"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "id": "r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "lifecycle_state": "stable", "minimum_capacity": 1, "name": "my-snapshot", "operating_system": {"architecture": "amd64", "dedicated_host_only": false, "display_name": "Ubuntu Server 16.04 LTS amd64", "family": "Ubuntu Server", "href": "https://us-south.iaas.cloud.ibm.com/v1/operating_systems/ubuntu-16-amd64", "name": "ubuntu-16-amd64", "vendor": "Canonical", "version": "16.04 LTS"}, "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "resource_type": "snapshot", "service_tags": ["ServiceTags"], "size": 1, "snapshot_consistency_group": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot-consistency-group:r134-fa329f6b-0e36-433f-a3bb-0df632e79263", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshot_consistency_groups/r134-fa329f6b-0e36-433f-a3bb-0df632e79263", "id": "r134-fa329f6b-0e36-433f-a3bb-0df632e79263", "name": "my-snapshot-consistency-group", "resource_type": "snapshot_consistency_group"}, "source_image": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::image:72b27b5c-f4b0-48bb-b954-5becc7c1dcb8", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/images/72b27b5c-f4b0-48bb-b954-5becc7c1dcb8", "id": "72b27b5c-f4b0-48bb-b954-5becc7c1dcb8", "name": "my-image", "remote": {"account": {"id": "aa2432b1fa4d4ace891e9b80fc104e34", "resource_type": "account"}, "region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "image"}, "source_snapshot": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "id": "r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "name": "my-snapshot", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "snapshot"}, "source_volume": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::volume:1a6b7274-678d-4dfb-8981-c71dd9d4daa5", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/volumes/1a6b7274-678d-4dfb-8981-c71dd9d4daa5", "id": "1a6b7274-678d-4dfb-8981-c71dd9d4daa5", "name": "my-volume", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "volume"}, "user_tags": ["UserTags"]}], "total_count": 132}`) })) }) - It(`Invoke UpdateBareMetalServer successfully`, func() { + It(`Invoke ListSnapshots successfully`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -52990,37 +53451,45 @@ var _ = Describe(`VpcV1`, func() { Expect(vpcService).ToNot(BeNil()) // Invoke operation with nil options model (negative test) - result, response, operationErr := vpcService.UpdateBareMetalServer(nil) + result, response, operationErr := vpcService.ListSnapshots(nil) Expect(operationErr).NotTo(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) - // Construct an instance of the BareMetalServerTrustedPlatformModulePatch model - bareMetalServerTrustedPlatformModulePatchModel := new(vpcv1.BareMetalServerTrustedPlatformModulePatch) - bareMetalServerTrustedPlatformModulePatchModel.Mode = core.StringPtr("disabled") - - // Construct an instance of the BareMetalServerPatch model - bareMetalServerPatchModel := new(vpcv1.BareMetalServerPatch) - bareMetalServerPatchModel.EnableSecureBoot = core.BoolPtr(false) - bareMetalServerPatchModel.Name = core.StringPtr("my-bare-metal-server") - bareMetalServerPatchModel.TrustedPlatformModule = bareMetalServerTrustedPlatformModulePatchModel - bareMetalServerPatchModelAsPatch, asPatchErr := bareMetalServerPatchModel.AsPatch() - Expect(asPatchErr).To(BeNil()) - - // Construct an instance of the UpdateBareMetalServerOptions model - updateBareMetalServerOptionsModel := new(vpcv1.UpdateBareMetalServerOptions) - updateBareMetalServerOptionsModel.ID = core.StringPtr("testString") - updateBareMetalServerOptionsModel.BareMetalServerPatch = bareMetalServerPatchModelAsPatch - updateBareMetalServerOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the ListSnapshotsOptions model + listSnapshotsOptionsModel := new(vpcv1.ListSnapshotsOptions) + listSnapshotsOptionsModel.Start = core.StringPtr("testString") + listSnapshotsOptionsModel.Limit = core.Int64Ptr(int64(10)) + listSnapshotsOptionsModel.Tag = core.StringPtr("testString") + listSnapshotsOptionsModel.ResourceGroupID = core.StringPtr("testString") + listSnapshotsOptionsModel.Name = core.StringPtr("testString") + listSnapshotsOptionsModel.SourceVolumeID = core.StringPtr("testString") + listSnapshotsOptionsModel.SourceVolumeCRN = core.StringPtr("crn:v1:bluemix:public:is:us-south-1:a/123456::volume:1a6b7274-678d-4dfb-8981-c71dd9d4daa5") + listSnapshotsOptionsModel.SourceImageID = core.StringPtr("testString") + listSnapshotsOptionsModel.SourceImageCRN = core.StringPtr("crn:v1:bluemix:public:is:us-south:a/123456::image:72b27b5c-f4b0-48bb-b954-5becc7c1dcb8") + listSnapshotsOptionsModel.Sort = core.StringPtr("name") + listSnapshotsOptionsModel.BackupPolicyPlanID = core.StringPtr("testString") + listSnapshotsOptionsModel.CopiesID = core.StringPtr("testString") + listSnapshotsOptionsModel.CopiesName = core.StringPtr("my-snapshot-copy") + listSnapshotsOptionsModel.CopiesCRN = core.StringPtr("testString") + listSnapshotsOptionsModel.CopiesRemoteRegionName = core.StringPtr("us-south") + listSnapshotsOptionsModel.SourceSnapshotID = core.StringPtr("testString") + listSnapshotsOptionsModel.SourceSnapshotRemoteRegionName = core.StringPtr("us-south") + listSnapshotsOptionsModel.SourceVolumeRemoteRegionName = core.StringPtr("us-south") + listSnapshotsOptionsModel.SourceImageRemoteRegionName = core.StringPtr("us-south") + listSnapshotsOptionsModel.ClonesZoneName = core.StringPtr("us-south-1") + listSnapshotsOptionsModel.SnapshotConsistencyGroupID = core.StringPtr("testString") + listSnapshotsOptionsModel.SnapshotConsistencyGroupCRN = core.StringPtr("crn:v1:bluemix:public:is:us-south:a/123456::snapshot-consistency-group:r134-fa329f6b-0e36-433f-a3bb-0df632e79263") + listSnapshotsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with valid options model (positive test) - result, response, operationErr = vpcService.UpdateBareMetalServer(updateBareMetalServerOptionsModel) + result, response, operationErr = vpcService.ListSnapshots(listSnapshotsOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) }) - It(`Invoke UpdateBareMetalServer with error: Operation validation and request error`, func() { + It(`Invoke ListSnapshots with error: Operation request error`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -53029,38 +53498,39 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the BareMetalServerTrustedPlatformModulePatch model - bareMetalServerTrustedPlatformModulePatchModel := new(vpcv1.BareMetalServerTrustedPlatformModulePatch) - bareMetalServerTrustedPlatformModulePatchModel.Mode = core.StringPtr("disabled") - - // Construct an instance of the BareMetalServerPatch model - bareMetalServerPatchModel := new(vpcv1.BareMetalServerPatch) - bareMetalServerPatchModel.EnableSecureBoot = core.BoolPtr(false) - bareMetalServerPatchModel.Name = core.StringPtr("my-bare-metal-server") - bareMetalServerPatchModel.TrustedPlatformModule = bareMetalServerTrustedPlatformModulePatchModel - bareMetalServerPatchModelAsPatch, asPatchErr := bareMetalServerPatchModel.AsPatch() - Expect(asPatchErr).To(BeNil()) - - // Construct an instance of the UpdateBareMetalServerOptions model - updateBareMetalServerOptionsModel := new(vpcv1.UpdateBareMetalServerOptions) - updateBareMetalServerOptionsModel.ID = core.StringPtr("testString") - updateBareMetalServerOptionsModel.BareMetalServerPatch = bareMetalServerPatchModelAsPatch - updateBareMetalServerOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the ListSnapshotsOptions model + listSnapshotsOptionsModel := new(vpcv1.ListSnapshotsOptions) + listSnapshotsOptionsModel.Start = core.StringPtr("testString") + listSnapshotsOptionsModel.Limit = core.Int64Ptr(int64(10)) + listSnapshotsOptionsModel.Tag = core.StringPtr("testString") + listSnapshotsOptionsModel.ResourceGroupID = core.StringPtr("testString") + listSnapshotsOptionsModel.Name = core.StringPtr("testString") + listSnapshotsOptionsModel.SourceVolumeID = core.StringPtr("testString") + listSnapshotsOptionsModel.SourceVolumeCRN = core.StringPtr("crn:v1:bluemix:public:is:us-south-1:a/123456::volume:1a6b7274-678d-4dfb-8981-c71dd9d4daa5") + listSnapshotsOptionsModel.SourceImageID = core.StringPtr("testString") + listSnapshotsOptionsModel.SourceImageCRN = core.StringPtr("crn:v1:bluemix:public:is:us-south:a/123456::image:72b27b5c-f4b0-48bb-b954-5becc7c1dcb8") + listSnapshotsOptionsModel.Sort = core.StringPtr("name") + listSnapshotsOptionsModel.BackupPolicyPlanID = core.StringPtr("testString") + listSnapshotsOptionsModel.CopiesID = core.StringPtr("testString") + listSnapshotsOptionsModel.CopiesName = core.StringPtr("my-snapshot-copy") + listSnapshotsOptionsModel.CopiesCRN = core.StringPtr("testString") + listSnapshotsOptionsModel.CopiesRemoteRegionName = core.StringPtr("us-south") + listSnapshotsOptionsModel.SourceSnapshotID = core.StringPtr("testString") + listSnapshotsOptionsModel.SourceSnapshotRemoteRegionName = core.StringPtr("us-south") + listSnapshotsOptionsModel.SourceVolumeRemoteRegionName = core.StringPtr("us-south") + listSnapshotsOptionsModel.SourceImageRemoteRegionName = core.StringPtr("us-south") + listSnapshotsOptionsModel.ClonesZoneName = core.StringPtr("us-south-1") + listSnapshotsOptionsModel.SnapshotConsistencyGroupID = core.StringPtr("testString") + listSnapshotsOptionsModel.SnapshotConsistencyGroupCRN = core.StringPtr("crn:v1:bluemix:public:is:us-south:a/123456::snapshot-consistency-group:r134-fa329f6b-0e36-433f-a3bb-0df632e79263") + listSnapshotsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with empty URL (negative test) err := vpcService.SetServiceURL("") Expect(err).To(BeNil()) - result, response, operationErr := vpcService.UpdateBareMetalServer(updateBareMetalServerOptionsModel) + result, response, operationErr := vpcService.ListSnapshots(listSnapshotsOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING)) Expect(response).To(BeNil()) Expect(result).To(BeNil()) - // Construct a second instance of the UpdateBareMetalServerOptions model with no property values - updateBareMetalServerOptionsModelNew := new(vpcv1.UpdateBareMetalServerOptions) - // Invoke operation with invalid model (negative test) - result, response, operationErr = vpcService.UpdateBareMetalServer(updateBareMetalServerOptionsModelNew) - Expect(operationErr).ToNot(BeNil()) - Expect(response).To(BeNil()) - Expect(result).To(BeNil()) }) AfterEach(func() { testServer.Close() @@ -53075,7 +53545,7 @@ var _ = Describe(`VpcV1`, func() { res.WriteHeader(200) })) }) - It(`Invoke UpdateBareMetalServer successfully`, func() { + It(`Invoke ListSnapshots successfully`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -53084,26 +53554,34 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the BareMetalServerTrustedPlatformModulePatch model - bareMetalServerTrustedPlatformModulePatchModel := new(vpcv1.BareMetalServerTrustedPlatformModulePatch) - bareMetalServerTrustedPlatformModulePatchModel.Mode = core.StringPtr("disabled") - - // Construct an instance of the BareMetalServerPatch model - bareMetalServerPatchModel := new(vpcv1.BareMetalServerPatch) - bareMetalServerPatchModel.EnableSecureBoot = core.BoolPtr(false) - bareMetalServerPatchModel.Name = core.StringPtr("my-bare-metal-server") - bareMetalServerPatchModel.TrustedPlatformModule = bareMetalServerTrustedPlatformModulePatchModel - bareMetalServerPatchModelAsPatch, asPatchErr := bareMetalServerPatchModel.AsPatch() - Expect(asPatchErr).To(BeNil()) - - // Construct an instance of the UpdateBareMetalServerOptions model - updateBareMetalServerOptionsModel := new(vpcv1.UpdateBareMetalServerOptions) - updateBareMetalServerOptionsModel.ID = core.StringPtr("testString") - updateBareMetalServerOptionsModel.BareMetalServerPatch = bareMetalServerPatchModelAsPatch - updateBareMetalServerOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the ListSnapshotsOptions model + listSnapshotsOptionsModel := new(vpcv1.ListSnapshotsOptions) + listSnapshotsOptionsModel.Start = core.StringPtr("testString") + listSnapshotsOptionsModel.Limit = core.Int64Ptr(int64(10)) + listSnapshotsOptionsModel.Tag = core.StringPtr("testString") + listSnapshotsOptionsModel.ResourceGroupID = core.StringPtr("testString") + listSnapshotsOptionsModel.Name = core.StringPtr("testString") + listSnapshotsOptionsModel.SourceVolumeID = core.StringPtr("testString") + listSnapshotsOptionsModel.SourceVolumeCRN = core.StringPtr("crn:v1:bluemix:public:is:us-south-1:a/123456::volume:1a6b7274-678d-4dfb-8981-c71dd9d4daa5") + listSnapshotsOptionsModel.SourceImageID = core.StringPtr("testString") + listSnapshotsOptionsModel.SourceImageCRN = core.StringPtr("crn:v1:bluemix:public:is:us-south:a/123456::image:72b27b5c-f4b0-48bb-b954-5becc7c1dcb8") + listSnapshotsOptionsModel.Sort = core.StringPtr("name") + listSnapshotsOptionsModel.BackupPolicyPlanID = core.StringPtr("testString") + listSnapshotsOptionsModel.CopiesID = core.StringPtr("testString") + listSnapshotsOptionsModel.CopiesName = core.StringPtr("my-snapshot-copy") + listSnapshotsOptionsModel.CopiesCRN = core.StringPtr("testString") + listSnapshotsOptionsModel.CopiesRemoteRegionName = core.StringPtr("us-south") + listSnapshotsOptionsModel.SourceSnapshotID = core.StringPtr("testString") + listSnapshotsOptionsModel.SourceSnapshotRemoteRegionName = core.StringPtr("us-south") + listSnapshotsOptionsModel.SourceVolumeRemoteRegionName = core.StringPtr("us-south") + listSnapshotsOptionsModel.SourceImageRemoteRegionName = core.StringPtr("us-south") + listSnapshotsOptionsModel.ClonesZoneName = core.StringPtr("us-south-1") + listSnapshotsOptionsModel.SnapshotConsistencyGroupID = core.StringPtr("testString") + listSnapshotsOptionsModel.SnapshotConsistencyGroupCRN = core.StringPtr("crn:v1:bluemix:public:is:us-south:a/123456::snapshot-consistency-group:r134-fa329f6b-0e36-433f-a3bb-0df632e79263") + listSnapshotsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation - result, response, operationErr := vpcService.UpdateBareMetalServer(updateBareMetalServerOptionsModel) + result, response, operationErr := vpcService.ListSnapshots(listSnapshotsOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) @@ -53114,26 +53592,167 @@ var _ = Describe(`VpcV1`, func() { testServer.Close() }) }) + Context(`Test pagination helper method on response`, func() { + It(`Invoke GetNextStart successfully`, func() { + responseObject := new(vpcv1.SnapshotCollection) + nextObject := new(vpcv1.SnapshotCollectionNext) + nextObject.Href = core.StringPtr("ibm.com?start=abc-123") + responseObject.Next = nextObject + + value, err := responseObject.GetNextStart() + Expect(err).To(BeNil()) + Expect(value).To(Equal(core.StringPtr("abc-123"))) + }) + It(`Invoke GetNextStart without a "Next" property in the response`, func() { + responseObject := new(vpcv1.SnapshotCollection) + + value, err := responseObject.GetNextStart() + Expect(err).To(BeNil()) + Expect(value).To(BeNil()) + }) + It(`Invoke GetNextStart without any query params in the "Next" URL`, func() { + responseObject := new(vpcv1.SnapshotCollection) + nextObject := new(vpcv1.SnapshotCollectionNext) + nextObject.Href = core.StringPtr("ibm.com") + responseObject.Next = nextObject + + value, err := responseObject.GetNextStart() + Expect(err).To(BeNil()) + Expect(value).To(BeNil()) + }) + }) + Context(`Using mock server endpoint - paginated response`, func() { + BeforeEach(func() { + var requestNumber int = 0 + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Verify the contents of the request + Expect(req.URL.EscapedPath()).To(Equal(listSnapshotsPath)) + Expect(req.Method).To(Equal("GET")) + + // Set mock response + res.Header().Set("Content-type", "application/json") + res.WriteHeader(200) + requestNumber++ + if requestNumber == 1 { + fmt.Fprintf(res, "%s", `{"snapshots":[{"backup_policy_plan":{"deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6/plans/r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178","id":"r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178","name":"my-policy-plan","remote":{"region":{"href":"https://us-south.iaas.cloud.ibm.com/v1/regions/us-south","name":"us-south"}},"resource_type":"backup_policy_plan"},"bootable":true,"captured_at":"2019-01-01T12:00:00.000Z","clones":[{"available":false,"created_at":"2019-01-01T12:00:00.000Z","zone":{"href":"https://us-south.iaas.cloud.ibm.com/v1/regions/us-south/zones/us-south-1","name":"us-south-1"}}],"copies":[{"crn":"crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263","deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263","id":"r134-f6bfa329-0e36-433f-a3bb-0df632e79263","name":"my-snapshot","remote":{"region":{"href":"https://us-south.iaas.cloud.ibm.com/v1/regions/us-south","name":"us-south"}},"resource_type":"snapshot"}],"created_at":"2019-01-01T12:00:00.000Z","crn":"crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263","deletable":false,"encryption":"provider_managed","encryption_key":{"crn":"crn:v1:bluemix:public:kms:us-south:a/123456:e4a29d1a-2ef0-42a6-8fd2-350deb1c647e:key:5437653b-c4b1-447f-9646-b2a2a4cd6179"},"href":"https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263","id":"r134-f6bfa329-0e36-433f-a3bb-0df632e79263","lifecycle_state":"stable","minimum_capacity":1,"name":"my-snapshot","operating_system":{"architecture":"amd64","dedicated_host_only":false,"display_name":"Ubuntu Server 16.04 LTS amd64","family":"Ubuntu Server","href":"https://us-south.iaas.cloud.ibm.com/v1/operating_systems/ubuntu-16-amd64","name":"ubuntu-16-amd64","vendor":"Canonical","version":"16.04 LTS"},"resource_group":{"href":"https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345","id":"fee82deba12e4c0fb69c3b09d1f12345","name":"my-resource-group"},"resource_type":"snapshot","service_tags":["ServiceTags"],"size":1,"snapshot_consistency_group":{"crn":"crn:v1:bluemix:public:is:us-south:a/123456::snapshot-consistency-group:r134-fa329f6b-0e36-433f-a3bb-0df632e79263","deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/snapshot_consistency_groups/r134-fa329f6b-0e36-433f-a3bb-0df632e79263","id":"r134-fa329f6b-0e36-433f-a3bb-0df632e79263","name":"my-snapshot-consistency-group","resource_type":"snapshot_consistency_group"},"source_image":{"crn":"crn:v1:bluemix:public:is:us-south:a/123456::image:72b27b5c-f4b0-48bb-b954-5becc7c1dcb8","deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/images/72b27b5c-f4b0-48bb-b954-5becc7c1dcb8","id":"72b27b5c-f4b0-48bb-b954-5becc7c1dcb8","name":"my-image","remote":{"account":{"id":"aa2432b1fa4d4ace891e9b80fc104e34","resource_type":"account"},"region":{"href":"https://us-south.iaas.cloud.ibm.com/v1/regions/us-south","name":"us-south"}},"resource_type":"image"},"source_snapshot":{"crn":"crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263","deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263","id":"r134-f6bfa329-0e36-433f-a3bb-0df632e79263","name":"my-snapshot","remote":{"region":{"href":"https://us-south.iaas.cloud.ibm.com/v1/regions/us-south","name":"us-south"}},"resource_type":"snapshot"},"source_volume":{"crn":"crn:v1:bluemix:public:is:us-south-1:a/123456::volume:1a6b7274-678d-4dfb-8981-c71dd9d4daa5","deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/volumes/1a6b7274-678d-4dfb-8981-c71dd9d4daa5","id":"1a6b7274-678d-4dfb-8981-c71dd9d4daa5","name":"my-volume","remote":{"region":{"href":"https://us-south.iaas.cloud.ibm.com/v1/regions/us-south","name":"us-south"}},"resource_type":"volume"},"user_tags":["UserTags"]}],"next":{"href":"https://myhost.com/somePath?start=1"},"total_count":2,"limit":1}`) + } else if requestNumber == 2 { + fmt.Fprintf(res, "%s", `{"snapshots":[{"backup_policy_plan":{"deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6/plans/r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178","id":"r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178","name":"my-policy-plan","remote":{"region":{"href":"https://us-south.iaas.cloud.ibm.com/v1/regions/us-south","name":"us-south"}},"resource_type":"backup_policy_plan"},"bootable":true,"captured_at":"2019-01-01T12:00:00.000Z","clones":[{"available":false,"created_at":"2019-01-01T12:00:00.000Z","zone":{"href":"https://us-south.iaas.cloud.ibm.com/v1/regions/us-south/zones/us-south-1","name":"us-south-1"}}],"copies":[{"crn":"crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263","deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263","id":"r134-f6bfa329-0e36-433f-a3bb-0df632e79263","name":"my-snapshot","remote":{"region":{"href":"https://us-south.iaas.cloud.ibm.com/v1/regions/us-south","name":"us-south"}},"resource_type":"snapshot"}],"created_at":"2019-01-01T12:00:00.000Z","crn":"crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263","deletable":false,"encryption":"provider_managed","encryption_key":{"crn":"crn:v1:bluemix:public:kms:us-south:a/123456:e4a29d1a-2ef0-42a6-8fd2-350deb1c647e:key:5437653b-c4b1-447f-9646-b2a2a4cd6179"},"href":"https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263","id":"r134-f6bfa329-0e36-433f-a3bb-0df632e79263","lifecycle_state":"stable","minimum_capacity":1,"name":"my-snapshot","operating_system":{"architecture":"amd64","dedicated_host_only":false,"display_name":"Ubuntu Server 16.04 LTS amd64","family":"Ubuntu Server","href":"https://us-south.iaas.cloud.ibm.com/v1/operating_systems/ubuntu-16-amd64","name":"ubuntu-16-amd64","vendor":"Canonical","version":"16.04 LTS"},"resource_group":{"href":"https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345","id":"fee82deba12e4c0fb69c3b09d1f12345","name":"my-resource-group"},"resource_type":"snapshot","service_tags":["ServiceTags"],"size":1,"snapshot_consistency_group":{"crn":"crn:v1:bluemix:public:is:us-south:a/123456::snapshot-consistency-group:r134-fa329f6b-0e36-433f-a3bb-0df632e79263","deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/snapshot_consistency_groups/r134-fa329f6b-0e36-433f-a3bb-0df632e79263","id":"r134-fa329f6b-0e36-433f-a3bb-0df632e79263","name":"my-snapshot-consistency-group","resource_type":"snapshot_consistency_group"},"source_image":{"crn":"crn:v1:bluemix:public:is:us-south:a/123456::image:72b27b5c-f4b0-48bb-b954-5becc7c1dcb8","deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/images/72b27b5c-f4b0-48bb-b954-5becc7c1dcb8","id":"72b27b5c-f4b0-48bb-b954-5becc7c1dcb8","name":"my-image","remote":{"account":{"id":"aa2432b1fa4d4ace891e9b80fc104e34","resource_type":"account"},"region":{"href":"https://us-south.iaas.cloud.ibm.com/v1/regions/us-south","name":"us-south"}},"resource_type":"image"},"source_snapshot":{"crn":"crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263","deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263","id":"r134-f6bfa329-0e36-433f-a3bb-0df632e79263","name":"my-snapshot","remote":{"region":{"href":"https://us-south.iaas.cloud.ibm.com/v1/regions/us-south","name":"us-south"}},"resource_type":"snapshot"},"source_volume":{"crn":"crn:v1:bluemix:public:is:us-south-1:a/123456::volume:1a6b7274-678d-4dfb-8981-c71dd9d4daa5","deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/volumes/1a6b7274-678d-4dfb-8981-c71dd9d4daa5","id":"1a6b7274-678d-4dfb-8981-c71dd9d4daa5","name":"my-volume","remote":{"region":{"href":"https://us-south.iaas.cloud.ibm.com/v1/regions/us-south","name":"us-south"}},"resource_type":"volume"},"user_tags":["UserTags"]}],"total_count":2,"limit":1}`) + } else { + res.WriteHeader(400) + } + })) + }) + It(`Use SnapshotsPager.GetNext successfully`, func() { + vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + Version: core.StringPtr(version), + }) + Expect(serviceErr).To(BeNil()) + Expect(vpcService).ToNot(BeNil()) + + listSnapshotsOptionsModel := &vpcv1.ListSnapshotsOptions{ + Limit: core.Int64Ptr(int64(10)), + Tag: core.StringPtr("testString"), + ResourceGroupID: core.StringPtr("testString"), + Name: core.StringPtr("testString"), + SourceVolumeID: core.StringPtr("testString"), + SourceVolumeCRN: core.StringPtr("crn:v1:bluemix:public:is:us-south-1:a/123456::volume:1a6b7274-678d-4dfb-8981-c71dd9d4daa5"), + SourceImageID: core.StringPtr("testString"), + SourceImageCRN: core.StringPtr("crn:v1:bluemix:public:is:us-south:a/123456::image:72b27b5c-f4b0-48bb-b954-5becc7c1dcb8"), + Sort: core.StringPtr("name"), + BackupPolicyPlanID: core.StringPtr("testString"), + CopiesID: core.StringPtr("testString"), + CopiesName: core.StringPtr("my-snapshot-copy"), + CopiesCRN: core.StringPtr("testString"), + CopiesRemoteRegionName: core.StringPtr("us-south"), + SourceSnapshotID: core.StringPtr("testString"), + SourceSnapshotRemoteRegionName: core.StringPtr("us-south"), + SourceVolumeRemoteRegionName: core.StringPtr("us-south"), + SourceImageRemoteRegionName: core.StringPtr("us-south"), + ClonesZoneName: core.StringPtr("us-south-1"), + SnapshotConsistencyGroupID: core.StringPtr("testString"), + SnapshotConsistencyGroupCRN: core.StringPtr("crn:v1:bluemix:public:is:us-south:a/123456::snapshot-consistency-group:r134-fa329f6b-0e36-433f-a3bb-0df632e79263"), + } + + pager, err := vpcService.NewSnapshotsPager(listSnapshotsOptionsModel) + Expect(err).To(BeNil()) + Expect(pager).ToNot(BeNil()) + + var allResults []vpcv1.Snapshot + for pager.HasNext() { + nextPage, err := pager.GetNext() + Expect(err).To(BeNil()) + Expect(nextPage).ToNot(BeNil()) + allResults = append(allResults, nextPage...) + } + Expect(len(allResults)).To(Equal(2)) + }) + It(`Use SnapshotsPager.GetAll successfully`, func() { + vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + Version: core.StringPtr(version), + }) + Expect(serviceErr).To(BeNil()) + Expect(vpcService).ToNot(BeNil()) + + listSnapshotsOptionsModel := &vpcv1.ListSnapshotsOptions{ + Limit: core.Int64Ptr(int64(10)), + Tag: core.StringPtr("testString"), + ResourceGroupID: core.StringPtr("testString"), + Name: core.StringPtr("testString"), + SourceVolumeID: core.StringPtr("testString"), + SourceVolumeCRN: core.StringPtr("crn:v1:bluemix:public:is:us-south-1:a/123456::volume:1a6b7274-678d-4dfb-8981-c71dd9d4daa5"), + SourceImageID: core.StringPtr("testString"), + SourceImageCRN: core.StringPtr("crn:v1:bluemix:public:is:us-south:a/123456::image:72b27b5c-f4b0-48bb-b954-5becc7c1dcb8"), + Sort: core.StringPtr("name"), + BackupPolicyPlanID: core.StringPtr("testString"), + CopiesID: core.StringPtr("testString"), + CopiesName: core.StringPtr("my-snapshot-copy"), + CopiesCRN: core.StringPtr("testString"), + CopiesRemoteRegionName: core.StringPtr("us-south"), + SourceSnapshotID: core.StringPtr("testString"), + SourceSnapshotRemoteRegionName: core.StringPtr("us-south"), + SourceVolumeRemoteRegionName: core.StringPtr("us-south"), + SourceImageRemoteRegionName: core.StringPtr("us-south"), + ClonesZoneName: core.StringPtr("us-south-1"), + SnapshotConsistencyGroupID: core.StringPtr("testString"), + SnapshotConsistencyGroupCRN: core.StringPtr("crn:v1:bluemix:public:is:us-south:a/123456::snapshot-consistency-group:r134-fa329f6b-0e36-433f-a3bb-0df632e79263"), + } + + pager, err := vpcService.NewSnapshotsPager(listSnapshotsOptionsModel) + Expect(err).To(BeNil()) + Expect(pager).ToNot(BeNil()) + + allResults, err := pager.GetAll() + Expect(err).To(BeNil()) + Expect(allResults).ToNot(BeNil()) + Expect(len(allResults)).To(Equal(2)) + }) + }) }) - Describe(`GetBareMetalServerInitialization(getBareMetalServerInitializationOptions *GetBareMetalServerInitializationOptions) - Operation response error`, func() { + Describe(`CreateSnapshot(createSnapshotOptions *CreateSnapshotOptions) - Operation response error`, func() { version := "testString" - getBareMetalServerInitializationPath := "/bare_metal_servers/testString/initialization" + createSnapshotPath := "/snapshots" Context(`Using mock server endpoint with invalid JSON response`, func() { BeforeEach(func() { testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(getBareMetalServerInitializationPath)) - Expect(req.Method).To(Equal("GET")) + Expect(req.URL.EscapedPath()).To(Equal(createSnapshotPath)) + Expect(req.Method).To(Equal("POST")) Expect(req.URL.Query()["version"]).To(Equal([]string{"testString"})) Expect(req.URL.Query()["generation"]).To(Equal([]string{fmt.Sprint(int64(2))})) res.Header().Set("Content-type", "application/json") - res.WriteHeader(200) + res.WriteHeader(201) fmt.Fprint(res, `} this is not valid json {`) })) }) - It(`Invoke GetBareMetalServerInitialization with error: Operation response processing error`, func() { + It(`Invoke CreateSnapshot with error: Operation response processing error`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -53142,19 +53761,43 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the GetBareMetalServerInitializationOptions model - getBareMetalServerInitializationOptionsModel := new(vpcv1.GetBareMetalServerInitializationOptions) - getBareMetalServerInitializationOptionsModel.ID = core.StringPtr("testString") - getBareMetalServerInitializationOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the ZoneIdentityByName model + zoneIdentityModel := new(vpcv1.ZoneIdentityByName) + zoneIdentityModel.Name = core.StringPtr("us-south-1") + + // Construct an instance of the SnapshotClonePrototype model + snapshotClonePrototypeModel := new(vpcv1.SnapshotClonePrototype) + snapshotClonePrototypeModel.Zone = zoneIdentityModel + + // Construct an instance of the ResourceGroupIdentityByID model + resourceGroupIdentityModel := new(vpcv1.ResourceGroupIdentityByID) + resourceGroupIdentityModel.ID = core.StringPtr("fee82deba12e4c0fb69c3b09d1f12345") + + // Construct an instance of the VolumeIdentityByID model + volumeIdentityModel := new(vpcv1.VolumeIdentityByID) + volumeIdentityModel.ID = core.StringPtr("1a6b7274-678d-4dfb-8981-c71dd9d4daa5") + + // Construct an instance of the SnapshotPrototypeSnapshotBySourceVolume model + snapshotPrototypeModel := new(vpcv1.SnapshotPrototypeSnapshotBySourceVolume) + snapshotPrototypeModel.Clones = []vpcv1.SnapshotClonePrototype{*snapshotClonePrototypeModel} + snapshotPrototypeModel.Name = core.StringPtr("my-snapshot") + snapshotPrototypeModel.ResourceGroup = resourceGroupIdentityModel + snapshotPrototypeModel.UserTags = []string{} + snapshotPrototypeModel.SourceVolume = volumeIdentityModel + + // Construct an instance of the CreateSnapshotOptions model + createSnapshotOptionsModel := new(vpcv1.CreateSnapshotOptions) + createSnapshotOptionsModel.SnapshotPrototype = snapshotPrototypeModel + createSnapshotOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Expect response parsing to fail since we are receiving a text/plain response - result, response, operationErr := vpcService.GetBareMetalServerInitialization(getBareMetalServerInitializationOptionsModel) + result, response, operationErr := vpcService.CreateSnapshot(createSnapshotOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).To(BeNil()) // Enable retries and test again vpcService.EnableRetries(0, 0) - result, response, operationErr = vpcService.GetBareMetalServerInitialization(getBareMetalServerInitializationOptionsModel) + result, response, operationErr = vpcService.CreateSnapshot(createSnapshotOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).To(BeNil()) @@ -53164,17 +53807,33 @@ var _ = Describe(`VpcV1`, func() { }) }) }) - Describe(`GetBareMetalServerInitialization(getBareMetalServerInitializationOptions *GetBareMetalServerInitializationOptions)`, func() { + Describe(`CreateSnapshot(createSnapshotOptions *CreateSnapshotOptions)`, func() { version := "testString" - getBareMetalServerInitializationPath := "/bare_metal_servers/testString/initialization" + createSnapshotPath := "/snapshots" Context(`Using mock server endpoint with timeout`, func() { BeforeEach(func() { testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(getBareMetalServerInitializationPath)) - Expect(req.Method).To(Equal("GET")) + Expect(req.URL.EscapedPath()).To(Equal(createSnapshotPath)) + Expect(req.Method).To(Equal("POST")) + + // For gzip-disabled operation, verify Content-Encoding is not set. + Expect(req.Header.Get("Content-Encoding")).To(BeEmpty()) + + // If there is a body, then make sure we can read it + bodyBuf := new(bytes.Buffer) + if req.Header.Get("Content-Encoding") == "gzip" { + body, err := core.NewGzipDecompressionReader(req.Body) + Expect(err).To(BeNil()) + _, err = bodyBuf.ReadFrom(body) + Expect(err).To(BeNil()) + } else { + _, err := bodyBuf.ReadFrom(req.Body) + Expect(err).To(BeNil()) + } + fmt.Fprintf(GinkgoWriter, " Request body: %s", bodyBuf.String()) Expect(req.URL.Query()["version"]).To(Equal([]string{"testString"})) Expect(req.URL.Query()["generation"]).To(Equal([]string{fmt.Sprint(int64(2))})) @@ -53183,11 +53842,11 @@ var _ = Describe(`VpcV1`, func() { // Set mock response res.Header().Set("Content-type", "application/json") - res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"image": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::image:72b27b5c-f4b0-48bb-b954-5becc7c1dcb8", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/images/72b27b5c-f4b0-48bb-b954-5becc7c1dcb8", "id": "72b27b5c-f4b0-48bb-b954-5becc7c1dcb8", "name": "my-image", "remote": {"account": {"id": "aa2432b1fa4d4ace891e9b80fc104e34", "resource_type": "account"}, "region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "image"}, "keys": [{"crn": "crn:v1:bluemix:public:is:us-south:a/123456::key:a6b1a881-2ce8-41a3-80fc-36316a73f803", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "fingerprint": "SHA256:yxavE4CIOL2NlsqcurRO3xGjkP6m/0mp8ugojH5yxlY", "href": "https://us-south.iaas.cloud.ibm.com/v1/keys/a6b1a881-2ce8-41a3-80fc-36316a73f803", "id": "a6b1a881-2ce8-41a3-80fc-36316a73f803", "name": "my-key"}], "user_accounts": [{"encrypted_password": "qQ+/YEApnl1ZtEgIrfprzb065307thTkzlnLqL5ICpesdbBN03dyCQ==", "encryption_key": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::key:a6b1a881-2ce8-41a3-80fc-36316a73f803", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "fingerprint": "SHA256:yxavE4CIOL2NlsqcurRO3xGjkP6m/0mp8ugojH5yxlY", "href": "https://us-south.iaas.cloud.ibm.com/v1/keys/a6b1a881-2ce8-41a3-80fc-36316a73f803", "id": "a6b1a881-2ce8-41a3-80fc-36316a73f803", "name": "my-key"}, "resource_type": "host_user_account", "username": "Administrator"}]}`) + res.WriteHeader(201) + fmt.Fprintf(res, "%s", `{"backup_policy_plan": {"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6/plans/r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "id": "r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "name": "my-policy-plan", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "backup_policy_plan"}, "bootable": true, "captured_at": "2019-01-01T12:00:00.000Z", "clones": [{"available": false, "created_at": "2019-01-01T12:00:00.000Z", "zone": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south/zones/us-south-1", "name": "us-south-1"}}], "copies": [{"crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "id": "r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "name": "my-snapshot", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "snapshot"}], "created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "deletable": false, "encryption": "provider_managed", "encryption_key": {"crn": "crn:v1:bluemix:public:kms:us-south:a/123456:e4a29d1a-2ef0-42a6-8fd2-350deb1c647e:key:5437653b-c4b1-447f-9646-b2a2a4cd6179"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "id": "r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "lifecycle_state": "stable", "minimum_capacity": 1, "name": "my-snapshot", "operating_system": {"architecture": "amd64", "dedicated_host_only": false, "display_name": "Ubuntu Server 16.04 LTS amd64", "family": "Ubuntu Server", "href": "https://us-south.iaas.cloud.ibm.com/v1/operating_systems/ubuntu-16-amd64", "name": "ubuntu-16-amd64", "vendor": "Canonical", "version": "16.04 LTS"}, "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "resource_type": "snapshot", "service_tags": ["ServiceTags"], "size": 1, "snapshot_consistency_group": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot-consistency-group:r134-fa329f6b-0e36-433f-a3bb-0df632e79263", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshot_consistency_groups/r134-fa329f6b-0e36-433f-a3bb-0df632e79263", "id": "r134-fa329f6b-0e36-433f-a3bb-0df632e79263", "name": "my-snapshot-consistency-group", "resource_type": "snapshot_consistency_group"}, "source_image": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::image:72b27b5c-f4b0-48bb-b954-5becc7c1dcb8", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/images/72b27b5c-f4b0-48bb-b954-5becc7c1dcb8", "id": "72b27b5c-f4b0-48bb-b954-5becc7c1dcb8", "name": "my-image", "remote": {"account": {"id": "aa2432b1fa4d4ace891e9b80fc104e34", "resource_type": "account"}, "region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "image"}, "source_snapshot": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "id": "r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "name": "my-snapshot", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "snapshot"}, "source_volume": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::volume:1a6b7274-678d-4dfb-8981-c71dd9d4daa5", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/volumes/1a6b7274-678d-4dfb-8981-c71dd9d4daa5", "id": "1a6b7274-678d-4dfb-8981-c71dd9d4daa5", "name": "my-volume", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "volume"}, "user_tags": ["UserTags"]}`) })) }) - It(`Invoke GetBareMetalServerInitialization successfully with retries`, func() { + It(`Invoke CreateSnapshot successfully with retries`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -53197,21 +53856,45 @@ var _ = Describe(`VpcV1`, func() { Expect(vpcService).ToNot(BeNil()) vpcService.EnableRetries(0, 0) - // Construct an instance of the GetBareMetalServerInitializationOptions model - getBareMetalServerInitializationOptionsModel := new(vpcv1.GetBareMetalServerInitializationOptions) - getBareMetalServerInitializationOptionsModel.ID = core.StringPtr("testString") - getBareMetalServerInitializationOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the ZoneIdentityByName model + zoneIdentityModel := new(vpcv1.ZoneIdentityByName) + zoneIdentityModel.Name = core.StringPtr("us-south-1") + + // Construct an instance of the SnapshotClonePrototype model + snapshotClonePrototypeModel := new(vpcv1.SnapshotClonePrototype) + snapshotClonePrototypeModel.Zone = zoneIdentityModel + + // Construct an instance of the ResourceGroupIdentityByID model + resourceGroupIdentityModel := new(vpcv1.ResourceGroupIdentityByID) + resourceGroupIdentityModel.ID = core.StringPtr("fee82deba12e4c0fb69c3b09d1f12345") + + // Construct an instance of the VolumeIdentityByID model + volumeIdentityModel := new(vpcv1.VolumeIdentityByID) + volumeIdentityModel.ID = core.StringPtr("1a6b7274-678d-4dfb-8981-c71dd9d4daa5") + + // Construct an instance of the SnapshotPrototypeSnapshotBySourceVolume model + snapshotPrototypeModel := new(vpcv1.SnapshotPrototypeSnapshotBySourceVolume) + snapshotPrototypeModel.Clones = []vpcv1.SnapshotClonePrototype{*snapshotClonePrototypeModel} + snapshotPrototypeModel.Name = core.StringPtr("my-snapshot") + snapshotPrototypeModel.ResourceGroup = resourceGroupIdentityModel + snapshotPrototypeModel.UserTags = []string{} + snapshotPrototypeModel.SourceVolume = volumeIdentityModel + + // Construct an instance of the CreateSnapshotOptions model + createSnapshotOptionsModel := new(vpcv1.CreateSnapshotOptions) + createSnapshotOptionsModel.SnapshotPrototype = snapshotPrototypeModel + createSnapshotOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with a Context to test a timeout error ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond) defer cancelFunc() - _, _, operationErr := vpcService.GetBareMetalServerInitializationWithContext(ctx, getBareMetalServerInitializationOptionsModel) + _, _, operationErr := vpcService.CreateSnapshotWithContext(ctx, createSnapshotOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) // Disable retries and test again vpcService.DisableRetries() - result, response, operationErr := vpcService.GetBareMetalServerInitialization(getBareMetalServerInitializationOptionsModel) + result, response, operationErr := vpcService.CreateSnapshot(createSnapshotOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) @@ -53219,7 +53902,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.GetBareMetalServerInitializationWithContext(ctx, getBareMetalServerInitializationOptionsModel) + _, _, operationErr = vpcService.CreateSnapshotWithContext(ctx, createSnapshotOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) }) @@ -53233,18 +53916,34 @@ var _ = Describe(`VpcV1`, func() { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(getBareMetalServerInitializationPath)) - Expect(req.Method).To(Equal("GET")) + Expect(req.URL.EscapedPath()).To(Equal(createSnapshotPath)) + Expect(req.Method).To(Equal("POST")) + + // For gzip-disabled operation, verify Content-Encoding is not set. + Expect(req.Header.Get("Content-Encoding")).To(BeEmpty()) + + // If there is a body, then make sure we can read it + bodyBuf := new(bytes.Buffer) + if req.Header.Get("Content-Encoding") == "gzip" { + body, err := core.NewGzipDecompressionReader(req.Body) + Expect(err).To(BeNil()) + _, err = bodyBuf.ReadFrom(body) + Expect(err).To(BeNil()) + } else { + _, err := bodyBuf.ReadFrom(req.Body) + Expect(err).To(BeNil()) + } + fmt.Fprintf(GinkgoWriter, " Request body: %s", bodyBuf.String()) Expect(req.URL.Query()["version"]).To(Equal([]string{"testString"})) Expect(req.URL.Query()["generation"]).To(Equal([]string{fmt.Sprint(int64(2))})) // Set mock response res.Header().Set("Content-type", "application/json") - res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"image": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::image:72b27b5c-f4b0-48bb-b954-5becc7c1dcb8", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/images/72b27b5c-f4b0-48bb-b954-5becc7c1dcb8", "id": "72b27b5c-f4b0-48bb-b954-5becc7c1dcb8", "name": "my-image", "remote": {"account": {"id": "aa2432b1fa4d4ace891e9b80fc104e34", "resource_type": "account"}, "region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "image"}, "keys": [{"crn": "crn:v1:bluemix:public:is:us-south:a/123456::key:a6b1a881-2ce8-41a3-80fc-36316a73f803", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "fingerprint": "SHA256:yxavE4CIOL2NlsqcurRO3xGjkP6m/0mp8ugojH5yxlY", "href": "https://us-south.iaas.cloud.ibm.com/v1/keys/a6b1a881-2ce8-41a3-80fc-36316a73f803", "id": "a6b1a881-2ce8-41a3-80fc-36316a73f803", "name": "my-key"}], "user_accounts": [{"encrypted_password": "qQ+/YEApnl1ZtEgIrfprzb065307thTkzlnLqL5ICpesdbBN03dyCQ==", "encryption_key": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::key:a6b1a881-2ce8-41a3-80fc-36316a73f803", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "fingerprint": "SHA256:yxavE4CIOL2NlsqcurRO3xGjkP6m/0mp8ugojH5yxlY", "href": "https://us-south.iaas.cloud.ibm.com/v1/keys/a6b1a881-2ce8-41a3-80fc-36316a73f803", "id": "a6b1a881-2ce8-41a3-80fc-36316a73f803", "name": "my-key"}, "resource_type": "host_user_account", "username": "Administrator"}]}`) + res.WriteHeader(201) + fmt.Fprintf(res, "%s", `{"backup_policy_plan": {"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6/plans/r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "id": "r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "name": "my-policy-plan", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "backup_policy_plan"}, "bootable": true, "captured_at": "2019-01-01T12:00:00.000Z", "clones": [{"available": false, "created_at": "2019-01-01T12:00:00.000Z", "zone": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south/zones/us-south-1", "name": "us-south-1"}}], "copies": [{"crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "id": "r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "name": "my-snapshot", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "snapshot"}], "created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "deletable": false, "encryption": "provider_managed", "encryption_key": {"crn": "crn:v1:bluemix:public:kms:us-south:a/123456:e4a29d1a-2ef0-42a6-8fd2-350deb1c647e:key:5437653b-c4b1-447f-9646-b2a2a4cd6179"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "id": "r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "lifecycle_state": "stable", "minimum_capacity": 1, "name": "my-snapshot", "operating_system": {"architecture": "amd64", "dedicated_host_only": false, "display_name": "Ubuntu Server 16.04 LTS amd64", "family": "Ubuntu Server", "href": "https://us-south.iaas.cloud.ibm.com/v1/operating_systems/ubuntu-16-amd64", "name": "ubuntu-16-amd64", "vendor": "Canonical", "version": "16.04 LTS"}, "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "resource_type": "snapshot", "service_tags": ["ServiceTags"], "size": 1, "snapshot_consistency_group": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot-consistency-group:r134-fa329f6b-0e36-433f-a3bb-0df632e79263", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshot_consistency_groups/r134-fa329f6b-0e36-433f-a3bb-0df632e79263", "id": "r134-fa329f6b-0e36-433f-a3bb-0df632e79263", "name": "my-snapshot-consistency-group", "resource_type": "snapshot_consistency_group"}, "source_image": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::image:72b27b5c-f4b0-48bb-b954-5becc7c1dcb8", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/images/72b27b5c-f4b0-48bb-b954-5becc7c1dcb8", "id": "72b27b5c-f4b0-48bb-b954-5becc7c1dcb8", "name": "my-image", "remote": {"account": {"id": "aa2432b1fa4d4ace891e9b80fc104e34", "resource_type": "account"}, "region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "image"}, "source_snapshot": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "id": "r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "name": "my-snapshot", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "snapshot"}, "source_volume": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::volume:1a6b7274-678d-4dfb-8981-c71dd9d4daa5", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/volumes/1a6b7274-678d-4dfb-8981-c71dd9d4daa5", "id": "1a6b7274-678d-4dfb-8981-c71dd9d4daa5", "name": "my-volume", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "volume"}, "user_tags": ["UserTags"]}`) })) }) - It(`Invoke GetBareMetalServerInitialization successfully`, func() { + It(`Invoke CreateSnapshot successfully`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -53254,24 +53953,48 @@ var _ = Describe(`VpcV1`, func() { Expect(vpcService).ToNot(BeNil()) // Invoke operation with nil options model (negative test) - result, response, operationErr := vpcService.GetBareMetalServerInitialization(nil) + result, response, operationErr := vpcService.CreateSnapshot(nil) Expect(operationErr).NotTo(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) - // Construct an instance of the GetBareMetalServerInitializationOptions model - getBareMetalServerInitializationOptionsModel := new(vpcv1.GetBareMetalServerInitializationOptions) - getBareMetalServerInitializationOptionsModel.ID = core.StringPtr("testString") - getBareMetalServerInitializationOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the ZoneIdentityByName model + zoneIdentityModel := new(vpcv1.ZoneIdentityByName) + zoneIdentityModel.Name = core.StringPtr("us-south-1") + + // Construct an instance of the SnapshotClonePrototype model + snapshotClonePrototypeModel := new(vpcv1.SnapshotClonePrototype) + snapshotClonePrototypeModel.Zone = zoneIdentityModel + + // Construct an instance of the ResourceGroupIdentityByID model + resourceGroupIdentityModel := new(vpcv1.ResourceGroupIdentityByID) + resourceGroupIdentityModel.ID = core.StringPtr("fee82deba12e4c0fb69c3b09d1f12345") + + // Construct an instance of the VolumeIdentityByID model + volumeIdentityModel := new(vpcv1.VolumeIdentityByID) + volumeIdentityModel.ID = core.StringPtr("1a6b7274-678d-4dfb-8981-c71dd9d4daa5") + + // Construct an instance of the SnapshotPrototypeSnapshotBySourceVolume model + snapshotPrototypeModel := new(vpcv1.SnapshotPrototypeSnapshotBySourceVolume) + snapshotPrototypeModel.Clones = []vpcv1.SnapshotClonePrototype{*snapshotClonePrototypeModel} + snapshotPrototypeModel.Name = core.StringPtr("my-snapshot") + snapshotPrototypeModel.ResourceGroup = resourceGroupIdentityModel + snapshotPrototypeModel.UserTags = []string{} + snapshotPrototypeModel.SourceVolume = volumeIdentityModel + + // Construct an instance of the CreateSnapshotOptions model + createSnapshotOptionsModel := new(vpcv1.CreateSnapshotOptions) + createSnapshotOptionsModel.SnapshotPrototype = snapshotPrototypeModel + createSnapshotOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with valid options model (positive test) - result, response, operationErr = vpcService.GetBareMetalServerInitialization(getBareMetalServerInitializationOptionsModel) + result, response, operationErr = vpcService.CreateSnapshot(createSnapshotOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) }) - It(`Invoke GetBareMetalServerInitialization with error: Operation validation and request error`, func() { + It(`Invoke CreateSnapshot with error: Operation validation and request error`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -53280,22 +54003,46 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the GetBareMetalServerInitializationOptions model - getBareMetalServerInitializationOptionsModel := new(vpcv1.GetBareMetalServerInitializationOptions) - getBareMetalServerInitializationOptionsModel.ID = core.StringPtr("testString") - getBareMetalServerInitializationOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the ZoneIdentityByName model + zoneIdentityModel := new(vpcv1.ZoneIdentityByName) + zoneIdentityModel.Name = core.StringPtr("us-south-1") + + // Construct an instance of the SnapshotClonePrototype model + snapshotClonePrototypeModel := new(vpcv1.SnapshotClonePrototype) + snapshotClonePrototypeModel.Zone = zoneIdentityModel + + // Construct an instance of the ResourceGroupIdentityByID model + resourceGroupIdentityModel := new(vpcv1.ResourceGroupIdentityByID) + resourceGroupIdentityModel.ID = core.StringPtr("fee82deba12e4c0fb69c3b09d1f12345") + + // Construct an instance of the VolumeIdentityByID model + volumeIdentityModel := new(vpcv1.VolumeIdentityByID) + volumeIdentityModel.ID = core.StringPtr("1a6b7274-678d-4dfb-8981-c71dd9d4daa5") + + // Construct an instance of the SnapshotPrototypeSnapshotBySourceVolume model + snapshotPrototypeModel := new(vpcv1.SnapshotPrototypeSnapshotBySourceVolume) + snapshotPrototypeModel.Clones = []vpcv1.SnapshotClonePrototype{*snapshotClonePrototypeModel} + snapshotPrototypeModel.Name = core.StringPtr("my-snapshot") + snapshotPrototypeModel.ResourceGroup = resourceGroupIdentityModel + snapshotPrototypeModel.UserTags = []string{} + snapshotPrototypeModel.SourceVolume = volumeIdentityModel + + // Construct an instance of the CreateSnapshotOptions model + createSnapshotOptionsModel := new(vpcv1.CreateSnapshotOptions) + createSnapshotOptionsModel.SnapshotPrototype = snapshotPrototypeModel + createSnapshotOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with empty URL (negative test) err := vpcService.SetServiceURL("") Expect(err).To(BeNil()) - result, response, operationErr := vpcService.GetBareMetalServerInitialization(getBareMetalServerInitializationOptionsModel) + result, response, operationErr := vpcService.CreateSnapshot(createSnapshotOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING)) Expect(response).To(BeNil()) Expect(result).To(BeNil()) - // Construct a second instance of the GetBareMetalServerInitializationOptions model with no property values - getBareMetalServerInitializationOptionsModelNew := new(vpcv1.GetBareMetalServerInitializationOptions) + // Construct a second instance of the CreateSnapshotOptions model with no property values + createSnapshotOptionsModelNew := new(vpcv1.CreateSnapshotOptions) // Invoke operation with invalid model (negative test) - result, response, operationErr = vpcService.GetBareMetalServerInitialization(getBareMetalServerInitializationOptionsModelNew) + result, response, operationErr = vpcService.CreateSnapshot(createSnapshotOptionsModelNew) Expect(operationErr).ToNot(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) @@ -53310,10 +54057,10 @@ var _ = Describe(`VpcV1`, func() { defer GinkgoRecover() // Set success status code with no respoonse body - res.WriteHeader(200) + res.WriteHeader(201) })) }) - It(`Invoke GetBareMetalServerInitialization successfully`, func() { + It(`Invoke CreateSnapshot successfully`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -53322,13 +54069,37 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the GetBareMetalServerInitializationOptions model - getBareMetalServerInitializationOptionsModel := new(vpcv1.GetBareMetalServerInitializationOptions) - getBareMetalServerInitializationOptionsModel.ID = core.StringPtr("testString") - getBareMetalServerInitializationOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the ZoneIdentityByName model + zoneIdentityModel := new(vpcv1.ZoneIdentityByName) + zoneIdentityModel.Name = core.StringPtr("us-south-1") + + // Construct an instance of the SnapshotClonePrototype model + snapshotClonePrototypeModel := new(vpcv1.SnapshotClonePrototype) + snapshotClonePrototypeModel.Zone = zoneIdentityModel + + // Construct an instance of the ResourceGroupIdentityByID model + resourceGroupIdentityModel := new(vpcv1.ResourceGroupIdentityByID) + resourceGroupIdentityModel.ID = core.StringPtr("fee82deba12e4c0fb69c3b09d1f12345") + + // Construct an instance of the VolumeIdentityByID model + volumeIdentityModel := new(vpcv1.VolumeIdentityByID) + volumeIdentityModel.ID = core.StringPtr("1a6b7274-678d-4dfb-8981-c71dd9d4daa5") + + // Construct an instance of the SnapshotPrototypeSnapshotBySourceVolume model + snapshotPrototypeModel := new(vpcv1.SnapshotPrototypeSnapshotBySourceVolume) + snapshotPrototypeModel.Clones = []vpcv1.SnapshotClonePrototype{*snapshotClonePrototypeModel} + snapshotPrototypeModel.Name = core.StringPtr("my-snapshot") + snapshotPrototypeModel.ResourceGroup = resourceGroupIdentityModel + snapshotPrototypeModel.UserTags = []string{} + snapshotPrototypeModel.SourceVolume = volumeIdentityModel + + // Construct an instance of the CreateSnapshotOptions model + createSnapshotOptionsModel := new(vpcv1.CreateSnapshotOptions) + createSnapshotOptionsModel.SnapshotPrototype = snapshotPrototypeModel + createSnapshotOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation - result, response, operationErr := vpcService.GetBareMetalServerInitialization(getBareMetalServerInitializationOptionsModel) + result, response, operationErr := vpcService.CreateSnapshot(createSnapshotOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) @@ -53340,24 +54111,26 @@ var _ = Describe(`VpcV1`, func() { }) }) }) - Describe(`RestartBareMetalServer(restartBareMetalServerOptions *RestartBareMetalServerOptions)`, func() { + Describe(`DeleteSnapshot(deleteSnapshotOptions *DeleteSnapshotOptions)`, func() { version := "testString" - restartBareMetalServerPath := "/bare_metal_servers/testString/restart" + deleteSnapshotPath := "/snapshots/testString" Context(`Using mock server endpoint`, func() { BeforeEach(func() { testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(restartBareMetalServerPath)) - Expect(req.Method).To(Equal("POST")) + Expect(req.URL.EscapedPath()).To(Equal(deleteSnapshotPath)) + Expect(req.Method).To(Equal("DELETE")) + Expect(req.Header["If-Match"]).ToNot(BeNil()) + Expect(req.Header["If-Match"][0]).To(Equal(fmt.Sprintf("%v", "W/\"96d225c4-56bd-43d9-98fc-d7148e5c5028\""))) Expect(req.URL.Query()["version"]).To(Equal([]string{"testString"})) Expect(req.URL.Query()["generation"]).To(Equal([]string{fmt.Sprint(int64(2))})) res.WriteHeader(204) })) }) - It(`Invoke RestartBareMetalServer successfully`, func() { + It(`Invoke DeleteSnapshot successfully`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -53367,21 +54140,22 @@ var _ = Describe(`VpcV1`, func() { Expect(vpcService).ToNot(BeNil()) // Invoke operation with nil options model (negative test) - response, operationErr := vpcService.RestartBareMetalServer(nil) + response, operationErr := vpcService.DeleteSnapshot(nil) Expect(operationErr).NotTo(BeNil()) Expect(response).To(BeNil()) - // Construct an instance of the RestartBareMetalServerOptions model - restartBareMetalServerOptionsModel := new(vpcv1.RestartBareMetalServerOptions) - restartBareMetalServerOptionsModel.ID = core.StringPtr("testString") - restartBareMetalServerOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the DeleteSnapshotOptions model + deleteSnapshotOptionsModel := new(vpcv1.DeleteSnapshotOptions) + deleteSnapshotOptionsModel.ID = core.StringPtr("testString") + deleteSnapshotOptionsModel.IfMatch = core.StringPtr("W/\"96d225c4-56bd-43d9-98fc-d7148e5c5028\"") + deleteSnapshotOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with valid options model (positive test) - response, operationErr = vpcService.RestartBareMetalServer(restartBareMetalServerOptionsModel) + response, operationErr = vpcService.DeleteSnapshot(deleteSnapshotOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) }) - It(`Invoke RestartBareMetalServer with error: Operation validation and request error`, func() { + It(`Invoke DeleteSnapshot with error: Operation validation and request error`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -53390,21 +54164,22 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the RestartBareMetalServerOptions model - restartBareMetalServerOptionsModel := new(vpcv1.RestartBareMetalServerOptions) - restartBareMetalServerOptionsModel.ID = core.StringPtr("testString") - restartBareMetalServerOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the DeleteSnapshotOptions model + deleteSnapshotOptionsModel := new(vpcv1.DeleteSnapshotOptions) + deleteSnapshotOptionsModel.ID = core.StringPtr("testString") + deleteSnapshotOptionsModel.IfMatch = core.StringPtr("W/\"96d225c4-56bd-43d9-98fc-d7148e5c5028\"") + deleteSnapshotOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with empty URL (negative test) err := vpcService.SetServiceURL("") Expect(err).To(BeNil()) - response, operationErr := vpcService.RestartBareMetalServer(restartBareMetalServerOptionsModel) + response, operationErr := vpcService.DeleteSnapshot(deleteSnapshotOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING)) Expect(response).To(BeNil()) - // Construct a second instance of the RestartBareMetalServerOptions model with no property values - restartBareMetalServerOptionsModelNew := new(vpcv1.RestartBareMetalServerOptions) + // Construct a second instance of the DeleteSnapshotOptions model with no property values + deleteSnapshotOptionsModelNew := new(vpcv1.DeleteSnapshotOptions) // Invoke operation with invalid model (negative test) - response, operationErr = vpcService.RestartBareMetalServer(restartBareMetalServerOptionsModelNew) + response, operationErr = vpcService.DeleteSnapshot(deleteSnapshotOptionsModelNew) Expect(operationErr).ToNot(BeNil()) Expect(response).To(BeNil()) }) @@ -53413,24 +54188,25 @@ var _ = Describe(`VpcV1`, func() { }) }) }) - Describe(`StartBareMetalServer(startBareMetalServerOptions *StartBareMetalServerOptions)`, func() { + Describe(`GetSnapshot(getSnapshotOptions *GetSnapshotOptions) - Operation response error`, func() { version := "testString" - startBareMetalServerPath := "/bare_metal_servers/testString/start" - Context(`Using mock server endpoint`, func() { + getSnapshotPath := "/snapshots/testString" + Context(`Using mock server endpoint with invalid JSON response`, func() { BeforeEach(func() { testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(startBareMetalServerPath)) - Expect(req.Method).To(Equal("POST")) - + Expect(req.URL.EscapedPath()).To(Equal(getSnapshotPath)) + Expect(req.Method).To(Equal("GET")) Expect(req.URL.Query()["version"]).To(Equal([]string{"testString"})) Expect(req.URL.Query()["generation"]).To(Equal([]string{fmt.Sprint(int64(2))})) - res.WriteHeader(204) + res.Header().Set("Content-type", "application/json") + res.WriteHeader(200) + fmt.Fprint(res, `} this is not valid json {`) })) }) - It(`Invoke StartBareMetalServer successfully`, func() { + It(`Invoke GetSnapshot with error: Operation response processing error`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -53439,22 +54215,52 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Invoke operation with nil options model (negative test) - response, operationErr := vpcService.StartBareMetalServer(nil) - Expect(operationErr).NotTo(BeNil()) - Expect(response).To(BeNil()) - - // Construct an instance of the StartBareMetalServerOptions model - startBareMetalServerOptionsModel := new(vpcv1.StartBareMetalServerOptions) - startBareMetalServerOptionsModel.ID = core.StringPtr("testString") - startBareMetalServerOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the GetSnapshotOptions model + getSnapshotOptionsModel := new(vpcv1.GetSnapshotOptions) + getSnapshotOptionsModel.ID = core.StringPtr("testString") + getSnapshotOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Expect response parsing to fail since we are receiving a text/plain response + result, response, operationErr := vpcService.GetSnapshot(getSnapshotOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).To(BeNil()) - // Invoke operation with valid options model (positive test) - response, operationErr = vpcService.StartBareMetalServer(startBareMetalServerOptionsModel) - Expect(operationErr).To(BeNil()) + // Enable retries and test again + vpcService.EnableRetries(0, 0) + result, response, operationErr = vpcService.GetSnapshot(getSnapshotOptionsModel) + Expect(operationErr).ToNot(BeNil()) Expect(response).ToNot(BeNil()) + Expect(result).To(BeNil()) }) - It(`Invoke StartBareMetalServer with error: Operation validation and request error`, func() { + AfterEach(func() { + testServer.Close() + }) + }) + }) + Describe(`GetSnapshot(getSnapshotOptions *GetSnapshotOptions)`, func() { + version := "testString" + getSnapshotPath := "/snapshots/testString" + Context(`Using mock server endpoint with timeout`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Verify the contents of the request + Expect(req.URL.EscapedPath()).To(Equal(getSnapshotPath)) + Expect(req.Method).To(Equal("GET")) + + Expect(req.URL.Query()["version"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["generation"]).To(Equal([]string{fmt.Sprint(int64(2))})) + // Sleep a short time to support a timeout test + time.Sleep(100 * time.Millisecond) + + // Set mock response + res.Header().Set("Content-type", "application/json") + res.WriteHeader(200) + fmt.Fprintf(res, "%s", `{"backup_policy_plan": {"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6/plans/r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "id": "r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "name": "my-policy-plan", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "backup_policy_plan"}, "bootable": true, "captured_at": "2019-01-01T12:00:00.000Z", "clones": [{"available": false, "created_at": "2019-01-01T12:00:00.000Z", "zone": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south/zones/us-south-1", "name": "us-south-1"}}], "copies": [{"crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "id": "r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "name": "my-snapshot", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "snapshot"}], "created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "deletable": false, "encryption": "provider_managed", "encryption_key": {"crn": "crn:v1:bluemix:public:kms:us-south:a/123456:e4a29d1a-2ef0-42a6-8fd2-350deb1c647e:key:5437653b-c4b1-447f-9646-b2a2a4cd6179"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "id": "r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "lifecycle_state": "stable", "minimum_capacity": 1, "name": "my-snapshot", "operating_system": {"architecture": "amd64", "dedicated_host_only": false, "display_name": "Ubuntu Server 16.04 LTS amd64", "family": "Ubuntu Server", "href": "https://us-south.iaas.cloud.ibm.com/v1/operating_systems/ubuntu-16-amd64", "name": "ubuntu-16-amd64", "vendor": "Canonical", "version": "16.04 LTS"}, "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "resource_type": "snapshot", "service_tags": ["ServiceTags"], "size": 1, "snapshot_consistency_group": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot-consistency-group:r134-fa329f6b-0e36-433f-a3bb-0df632e79263", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshot_consistency_groups/r134-fa329f6b-0e36-433f-a3bb-0df632e79263", "id": "r134-fa329f6b-0e36-433f-a3bb-0df632e79263", "name": "my-snapshot-consistency-group", "resource_type": "snapshot_consistency_group"}, "source_image": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::image:72b27b5c-f4b0-48bb-b954-5becc7c1dcb8", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/images/72b27b5c-f4b0-48bb-b954-5becc7c1dcb8", "id": "72b27b5c-f4b0-48bb-b954-5becc7c1dcb8", "name": "my-image", "remote": {"account": {"id": "aa2432b1fa4d4ace891e9b80fc104e34", "resource_type": "account"}, "region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "image"}, "source_snapshot": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "id": "r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "name": "my-snapshot", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "snapshot"}, "source_volume": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::volume:1a6b7274-678d-4dfb-8981-c71dd9d4daa5", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/volumes/1a6b7274-678d-4dfb-8981-c71dd9d4daa5", "id": "1a6b7274-678d-4dfb-8981-c71dd9d4daa5", "name": "my-volume", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "volume"}, "user_tags": ["UserTags"]}`) + })) + }) + It(`Invoke GetSnapshot successfully with retries`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -53462,64 +54268,56 @@ var _ = Describe(`VpcV1`, func() { }) Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) + vpcService.EnableRetries(0, 0) - // Construct an instance of the StartBareMetalServerOptions model - startBareMetalServerOptionsModel := new(vpcv1.StartBareMetalServerOptions) - startBareMetalServerOptionsModel.ID = core.StringPtr("testString") - startBareMetalServerOptionsModel.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.StartBareMetalServer(startBareMetalServerOptionsModel) + // Construct an instance of the GetSnapshotOptions model + getSnapshotOptionsModel := new(vpcv1.GetSnapshotOptions) + getSnapshotOptionsModel.ID = core.StringPtr("testString") + getSnapshotOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation with a Context to test a timeout error + ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond) + defer cancelFunc() + _, _, operationErr := vpcService.GetSnapshotWithContext(ctx, getSnapshotOptionsModel) Expect(operationErr).ToNot(BeNil()) - Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING)) - Expect(response).To(BeNil()) - // Construct a second instance of the StartBareMetalServerOptions model with no property values - startBareMetalServerOptionsModelNew := new(vpcv1.StartBareMetalServerOptions) - // Invoke operation with invalid model (negative test) - response, operationErr = vpcService.StartBareMetalServer(startBareMetalServerOptionsModelNew) + Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) + + // Disable retries and test again + vpcService.DisableRetries() + result, response, operationErr := vpcService.GetSnapshot(getSnapshotOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).ToNot(BeNil()) + + // Re-test the timeout error with retries disabled + ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond) + defer cancelFunc2() + _, _, operationErr = vpcService.GetSnapshotWithContext(ctx, getSnapshotOptionsModel) Expect(operationErr).ToNot(BeNil()) - Expect(response).To(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) }) AfterEach(func() { testServer.Close() }) }) - }) - Describe(`StopBareMetalServer(stopBareMetalServerOptions *StopBareMetalServerOptions)`, func() { - version := "testString" - stopBareMetalServerPath := "/bare_metal_servers/testString/stop" 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(stopBareMetalServerPath)) - 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.EscapedPath()).To(Equal(getSnapshotPath)) + Expect(req.Method).To(Equal("GET")) Expect(req.URL.Query()["version"]).To(Equal([]string{"testString"})) Expect(req.URL.Query()["generation"]).To(Equal([]string{fmt.Sprint(int64(2))})) - res.WriteHeader(204) + // Set mock response + res.Header().Set("Content-type", "application/json") + res.WriteHeader(200) + fmt.Fprintf(res, "%s", `{"backup_policy_plan": {"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6/plans/r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "id": "r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "name": "my-policy-plan", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "backup_policy_plan"}, "bootable": true, "captured_at": "2019-01-01T12:00:00.000Z", "clones": [{"available": false, "created_at": "2019-01-01T12:00:00.000Z", "zone": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south/zones/us-south-1", "name": "us-south-1"}}], "copies": [{"crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "id": "r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "name": "my-snapshot", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "snapshot"}], "created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "deletable": false, "encryption": "provider_managed", "encryption_key": {"crn": "crn:v1:bluemix:public:kms:us-south:a/123456:e4a29d1a-2ef0-42a6-8fd2-350deb1c647e:key:5437653b-c4b1-447f-9646-b2a2a4cd6179"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "id": "r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "lifecycle_state": "stable", "minimum_capacity": 1, "name": "my-snapshot", "operating_system": {"architecture": "amd64", "dedicated_host_only": false, "display_name": "Ubuntu Server 16.04 LTS amd64", "family": "Ubuntu Server", "href": "https://us-south.iaas.cloud.ibm.com/v1/operating_systems/ubuntu-16-amd64", "name": "ubuntu-16-amd64", "vendor": "Canonical", "version": "16.04 LTS"}, "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "resource_type": "snapshot", "service_tags": ["ServiceTags"], "size": 1, "snapshot_consistency_group": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot-consistency-group:r134-fa329f6b-0e36-433f-a3bb-0df632e79263", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshot_consistency_groups/r134-fa329f6b-0e36-433f-a3bb-0df632e79263", "id": "r134-fa329f6b-0e36-433f-a3bb-0df632e79263", "name": "my-snapshot-consistency-group", "resource_type": "snapshot_consistency_group"}, "source_image": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::image:72b27b5c-f4b0-48bb-b954-5becc7c1dcb8", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/images/72b27b5c-f4b0-48bb-b954-5becc7c1dcb8", "id": "72b27b5c-f4b0-48bb-b954-5becc7c1dcb8", "name": "my-image", "remote": {"account": {"id": "aa2432b1fa4d4ace891e9b80fc104e34", "resource_type": "account"}, "region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "image"}, "source_snapshot": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "id": "r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "name": "my-snapshot", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "snapshot"}, "source_volume": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::volume:1a6b7274-678d-4dfb-8981-c71dd9d4daa5", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/volumes/1a6b7274-678d-4dfb-8981-c71dd9d4daa5", "id": "1a6b7274-678d-4dfb-8981-c71dd9d4daa5", "name": "my-volume", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "volume"}, "user_tags": ["UserTags"]}`) })) }) - It(`Invoke StopBareMetalServer successfully`, func() { + It(`Invoke GetSnapshot successfully`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -53529,22 +54327,24 @@ var _ = Describe(`VpcV1`, func() { Expect(vpcService).ToNot(BeNil()) // Invoke operation with nil options model (negative test) - response, operationErr := vpcService.StopBareMetalServer(nil) + result, response, operationErr := vpcService.GetSnapshot(nil) Expect(operationErr).NotTo(BeNil()) Expect(response).To(BeNil()) + Expect(result).To(BeNil()) - // Construct an instance of the StopBareMetalServerOptions model - stopBareMetalServerOptionsModel := new(vpcv1.StopBareMetalServerOptions) - stopBareMetalServerOptionsModel.ID = core.StringPtr("testString") - stopBareMetalServerOptionsModel.Type = core.StringPtr("hard") - stopBareMetalServerOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the GetSnapshotOptions model + getSnapshotOptionsModel := new(vpcv1.GetSnapshotOptions) + getSnapshotOptionsModel.ID = core.StringPtr("testString") + getSnapshotOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with valid options model (positive test) - response, operationErr = vpcService.StopBareMetalServer(stopBareMetalServerOptionsModel) + result, response, operationErr = vpcService.GetSnapshot(getSnapshotOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) + Expect(result).ToNot(BeNil()) + }) - It(`Invoke StopBareMetalServer with error: Operation validation and request error`, func() { + It(`Invoke GetSnapshot with error: Operation validation and request error`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -53553,51 +54353,87 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the StopBareMetalServerOptions model - stopBareMetalServerOptionsModel := new(vpcv1.StopBareMetalServerOptions) - stopBareMetalServerOptionsModel.ID = core.StringPtr("testString") - stopBareMetalServerOptionsModel.Type = core.StringPtr("hard") - stopBareMetalServerOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the GetSnapshotOptions model + getSnapshotOptionsModel := new(vpcv1.GetSnapshotOptions) + getSnapshotOptionsModel.ID = core.StringPtr("testString") + getSnapshotOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with empty URL (negative test) err := vpcService.SetServiceURL("") Expect(err).To(BeNil()) - response, operationErr := vpcService.StopBareMetalServer(stopBareMetalServerOptionsModel) + result, response, operationErr := vpcService.GetSnapshot(getSnapshotOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING)) Expect(response).To(BeNil()) - // Construct a second instance of the StopBareMetalServerOptions model with no property values - stopBareMetalServerOptionsModelNew := new(vpcv1.StopBareMetalServerOptions) + Expect(result).To(BeNil()) + // Construct a second instance of the GetSnapshotOptions model with no property values + getSnapshotOptionsModelNew := new(vpcv1.GetSnapshotOptions) // Invoke operation with invalid model (negative test) - response, operationErr = vpcService.StopBareMetalServer(stopBareMetalServerOptionsModelNew) + result, response, operationErr = vpcService.GetSnapshot(getSnapshotOptionsModelNew) Expect(operationErr).ToNot(BeNil()) Expect(response).To(BeNil()) + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + Context(`Using mock server endpoint with missing response body`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Set success status code with no respoonse body + res.WriteHeader(200) + })) + }) + It(`Invoke GetSnapshot successfully`, func() { + vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + Version: core.StringPtr(version), + }) + Expect(serviceErr).To(BeNil()) + Expect(vpcService).ToNot(BeNil()) + + // Construct an instance of the GetSnapshotOptions model + getSnapshotOptionsModel := new(vpcv1.GetSnapshotOptions) + getSnapshotOptionsModel.ID = core.StringPtr("testString") + getSnapshotOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation + result, response, operationErr := vpcService.GetSnapshot(getSnapshotOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + + // Verify a nil result + Expect(result).To(BeNil()) }) AfterEach(func() { testServer.Close() }) }) }) - Describe(`ListVolumeProfiles(listVolumeProfilesOptions *ListVolumeProfilesOptions) - Operation response error`, func() { + Describe(`UpdateSnapshot(updateSnapshotOptions *UpdateSnapshotOptions) - Operation response error`, func() { version := "testString" - listVolumeProfilesPath := "/volume/profiles" + updateSnapshotPath := "/snapshots/testString" Context(`Using mock server endpoint with invalid JSON response`, func() { BeforeEach(func() { testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(listVolumeProfilesPath)) - Expect(req.Method).To(Equal("GET")) + Expect(req.URL.EscapedPath()).To(Equal(updateSnapshotPath)) + Expect(req.Method).To(Equal("PATCH")) + Expect(req.Header["If-Match"]).ToNot(BeNil()) + Expect(req.Header["If-Match"][0]).To(Equal(fmt.Sprintf("%v", "W/\"96d225c4-56bd-43d9-98fc-d7148e5c5028\""))) Expect(req.URL.Query()["version"]).To(Equal([]string{"testString"})) Expect(req.URL.Query()["generation"]).To(Equal([]string{fmt.Sprint(int64(2))})) - Expect(req.URL.Query()["start"]).To(Equal([]string{"testString"})) - Expect(req.URL.Query()["limit"]).To(Equal([]string{fmt.Sprint(int64(10))})) res.Header().Set("Content-type", "application/json") res.WriteHeader(200) fmt.Fprint(res, `} this is not valid json {`) })) }) - It(`Invoke ListVolumeProfiles with error: Operation response processing error`, func() { + It(`Invoke UpdateSnapshot with error: Operation response processing error`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -53606,20 +54442,28 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the ListVolumeProfilesOptions model - listVolumeProfilesOptionsModel := new(vpcv1.ListVolumeProfilesOptions) - listVolumeProfilesOptionsModel.Start = core.StringPtr("testString") - listVolumeProfilesOptionsModel.Limit = core.Int64Ptr(int64(10)) - listVolumeProfilesOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the SnapshotPatch model + snapshotPatchModel := new(vpcv1.SnapshotPatch) + snapshotPatchModel.Name = core.StringPtr("my-snapshot") + snapshotPatchModel.UserTags = []string{"testString"} + snapshotPatchModelAsPatch, asPatchErr := snapshotPatchModel.AsPatch() + Expect(asPatchErr).To(BeNil()) + + // Construct an instance of the UpdateSnapshotOptions model + updateSnapshotOptionsModel := new(vpcv1.UpdateSnapshotOptions) + updateSnapshotOptionsModel.ID = core.StringPtr("testString") + updateSnapshotOptionsModel.SnapshotPatch = snapshotPatchModelAsPatch + updateSnapshotOptionsModel.IfMatch = core.StringPtr("W/\"96d225c4-56bd-43d9-98fc-d7148e5c5028\"") + updateSnapshotOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Expect response parsing to fail since we are receiving a text/plain response - result, response, operationErr := vpcService.ListVolumeProfiles(listVolumeProfilesOptionsModel) + result, response, operationErr := vpcService.UpdateSnapshot(updateSnapshotOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).To(BeNil()) // Enable retries and test again vpcService.EnableRetries(0, 0) - result, response, operationErr = vpcService.ListVolumeProfiles(listVolumeProfilesOptionsModel) + result, response, operationErr = vpcService.UpdateSnapshot(updateSnapshotOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).To(BeNil()) @@ -53629,32 +54473,48 @@ var _ = Describe(`VpcV1`, func() { }) }) }) - Describe(`ListVolumeProfiles(listVolumeProfilesOptions *ListVolumeProfilesOptions)`, func() { + Describe(`UpdateSnapshot(updateSnapshotOptions *UpdateSnapshotOptions)`, func() { version := "testString" - listVolumeProfilesPath := "/volume/profiles" + updateSnapshotPath := "/snapshots/testString" Context(`Using mock server endpoint with timeout`, func() { BeforeEach(func() { testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(listVolumeProfilesPath)) - Expect(req.Method).To(Equal("GET")) + Expect(req.URL.EscapedPath()).To(Equal(updateSnapshotPath)) + Expect(req.Method).To(Equal("PATCH")) + + // For gzip-disabled operation, verify Content-Encoding is not set. + Expect(req.Header.Get("Content-Encoding")).To(BeEmpty()) + + // If there is a body, then make sure we can read it + bodyBuf := new(bytes.Buffer) + if req.Header.Get("Content-Encoding") == "gzip" { + body, err := core.NewGzipDecompressionReader(req.Body) + Expect(err).To(BeNil()) + _, err = bodyBuf.ReadFrom(body) + Expect(err).To(BeNil()) + } else { + _, err := bodyBuf.ReadFrom(req.Body) + Expect(err).To(BeNil()) + } + fmt.Fprintf(GinkgoWriter, " Request body: %s", bodyBuf.String()) + Expect(req.Header["If-Match"]).ToNot(BeNil()) + Expect(req.Header["If-Match"][0]).To(Equal(fmt.Sprintf("%v", "W/\"96d225c4-56bd-43d9-98fc-d7148e5c5028\""))) Expect(req.URL.Query()["version"]).To(Equal([]string{"testString"})) Expect(req.URL.Query()["generation"]).To(Equal([]string{fmt.Sprint(int64(2))})) - Expect(req.URL.Query()["start"]).To(Equal([]string{"testString"})) - Expect(req.URL.Query()["limit"]).To(Equal([]string{fmt.Sprint(int64(10))})) // 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/volume/profiles?limit=20"}, "limit": 20, "next": {"href": "https://us-south.iaas.cloud.ibm.com/v1/volume/profiles?start=9d5a91a3e2cbd233b5a5b33436855ed1&limit=20"}, "profiles": [{"family": "tiered", "href": "https://us-south.iaas.cloud.ibm.com/v1/volume/profiles/general-purpose", "name": "general-purpose"}], "total_count": 132}`) + fmt.Fprintf(res, "%s", `{"backup_policy_plan": {"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6/plans/r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "id": "r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "name": "my-policy-plan", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "backup_policy_plan"}, "bootable": true, "captured_at": "2019-01-01T12:00:00.000Z", "clones": [{"available": false, "created_at": "2019-01-01T12:00:00.000Z", "zone": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south/zones/us-south-1", "name": "us-south-1"}}], "copies": [{"crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "id": "r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "name": "my-snapshot", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "snapshot"}], "created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "deletable": false, "encryption": "provider_managed", "encryption_key": {"crn": "crn:v1:bluemix:public:kms:us-south:a/123456:e4a29d1a-2ef0-42a6-8fd2-350deb1c647e:key:5437653b-c4b1-447f-9646-b2a2a4cd6179"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "id": "r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "lifecycle_state": "stable", "minimum_capacity": 1, "name": "my-snapshot", "operating_system": {"architecture": "amd64", "dedicated_host_only": false, "display_name": "Ubuntu Server 16.04 LTS amd64", "family": "Ubuntu Server", "href": "https://us-south.iaas.cloud.ibm.com/v1/operating_systems/ubuntu-16-amd64", "name": "ubuntu-16-amd64", "vendor": "Canonical", "version": "16.04 LTS"}, "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "resource_type": "snapshot", "service_tags": ["ServiceTags"], "size": 1, "snapshot_consistency_group": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot-consistency-group:r134-fa329f6b-0e36-433f-a3bb-0df632e79263", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshot_consistency_groups/r134-fa329f6b-0e36-433f-a3bb-0df632e79263", "id": "r134-fa329f6b-0e36-433f-a3bb-0df632e79263", "name": "my-snapshot-consistency-group", "resource_type": "snapshot_consistency_group"}, "source_image": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::image:72b27b5c-f4b0-48bb-b954-5becc7c1dcb8", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/images/72b27b5c-f4b0-48bb-b954-5becc7c1dcb8", "id": "72b27b5c-f4b0-48bb-b954-5becc7c1dcb8", "name": "my-image", "remote": {"account": {"id": "aa2432b1fa4d4ace891e9b80fc104e34", "resource_type": "account"}, "region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "image"}, "source_snapshot": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "id": "r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "name": "my-snapshot", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "snapshot"}, "source_volume": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::volume:1a6b7274-678d-4dfb-8981-c71dd9d4daa5", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/volumes/1a6b7274-678d-4dfb-8981-c71dd9d4daa5", "id": "1a6b7274-678d-4dfb-8981-c71dd9d4daa5", "name": "my-volume", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "volume"}, "user_tags": ["UserTags"]}`) })) }) - It(`Invoke ListVolumeProfiles successfully with retries`, func() { + It(`Invoke UpdateSnapshot successfully with retries`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -53664,22 +54524,30 @@ var _ = Describe(`VpcV1`, func() { Expect(vpcService).ToNot(BeNil()) vpcService.EnableRetries(0, 0) - // Construct an instance of the ListVolumeProfilesOptions model - listVolumeProfilesOptionsModel := new(vpcv1.ListVolumeProfilesOptions) - listVolumeProfilesOptionsModel.Start = core.StringPtr("testString") - listVolumeProfilesOptionsModel.Limit = core.Int64Ptr(int64(10)) - listVolumeProfilesOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the SnapshotPatch model + snapshotPatchModel := new(vpcv1.SnapshotPatch) + snapshotPatchModel.Name = core.StringPtr("my-snapshot") + snapshotPatchModel.UserTags = []string{"testString"} + snapshotPatchModelAsPatch, asPatchErr := snapshotPatchModel.AsPatch() + Expect(asPatchErr).To(BeNil()) + + // Construct an instance of the UpdateSnapshotOptions model + updateSnapshotOptionsModel := new(vpcv1.UpdateSnapshotOptions) + updateSnapshotOptionsModel.ID = core.StringPtr("testString") + updateSnapshotOptionsModel.SnapshotPatch = snapshotPatchModelAsPatch + updateSnapshotOptionsModel.IfMatch = core.StringPtr("W/\"96d225c4-56bd-43d9-98fc-d7148e5c5028\"") + updateSnapshotOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with a Context to test a timeout error ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond) defer cancelFunc() - _, _, operationErr := vpcService.ListVolumeProfilesWithContext(ctx, listVolumeProfilesOptionsModel) + _, _, operationErr := vpcService.UpdateSnapshotWithContext(ctx, updateSnapshotOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) // Disable retries and test again vpcService.DisableRetries() - result, response, operationErr := vpcService.ListVolumeProfiles(listVolumeProfilesOptionsModel) + result, response, operationErr := vpcService.UpdateSnapshot(updateSnapshotOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) @@ -53687,7 +54555,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.ListVolumeProfilesWithContext(ctx, listVolumeProfilesOptionsModel) + _, _, operationErr = vpcService.UpdateSnapshotWithContext(ctx, updateSnapshotOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) }) @@ -53701,20 +54569,36 @@ var _ = Describe(`VpcV1`, func() { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(listVolumeProfilesPath)) - Expect(req.Method).To(Equal("GET")) + Expect(req.URL.EscapedPath()).To(Equal(updateSnapshotPath)) + Expect(req.Method).To(Equal("PATCH")) + + // For gzip-disabled operation, verify Content-Encoding is not set. + Expect(req.Header.Get("Content-Encoding")).To(BeEmpty()) + + // If there is a body, then make sure we can read it + bodyBuf := new(bytes.Buffer) + if req.Header.Get("Content-Encoding") == "gzip" { + body, err := core.NewGzipDecompressionReader(req.Body) + Expect(err).To(BeNil()) + _, err = bodyBuf.ReadFrom(body) + Expect(err).To(BeNil()) + } else { + _, err := bodyBuf.ReadFrom(req.Body) + Expect(err).To(BeNil()) + } + fmt.Fprintf(GinkgoWriter, " Request body: %s", bodyBuf.String()) + Expect(req.Header["If-Match"]).ToNot(BeNil()) + Expect(req.Header["If-Match"][0]).To(Equal(fmt.Sprintf("%v", "W/\"96d225c4-56bd-43d9-98fc-d7148e5c5028\""))) Expect(req.URL.Query()["version"]).To(Equal([]string{"testString"})) Expect(req.URL.Query()["generation"]).To(Equal([]string{fmt.Sprint(int64(2))})) - Expect(req.URL.Query()["start"]).To(Equal([]string{"testString"})) - Expect(req.URL.Query()["limit"]).To(Equal([]string{fmt.Sprint(int64(10))})) // 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/volume/profiles?limit=20"}, "limit": 20, "next": {"href": "https://us-south.iaas.cloud.ibm.com/v1/volume/profiles?start=9d5a91a3e2cbd233b5a5b33436855ed1&limit=20"}, "profiles": [{"family": "tiered", "href": "https://us-south.iaas.cloud.ibm.com/v1/volume/profiles/general-purpose", "name": "general-purpose"}], "total_count": 132}`) + fmt.Fprintf(res, "%s", `{"backup_policy_plan": {"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6/plans/r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "id": "r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "name": "my-policy-plan", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "backup_policy_plan"}, "bootable": true, "captured_at": "2019-01-01T12:00:00.000Z", "clones": [{"available": false, "created_at": "2019-01-01T12:00:00.000Z", "zone": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south/zones/us-south-1", "name": "us-south-1"}}], "copies": [{"crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "id": "r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "name": "my-snapshot", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "snapshot"}], "created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "deletable": false, "encryption": "provider_managed", "encryption_key": {"crn": "crn:v1:bluemix:public:kms:us-south:a/123456:e4a29d1a-2ef0-42a6-8fd2-350deb1c647e:key:5437653b-c4b1-447f-9646-b2a2a4cd6179"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "id": "r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "lifecycle_state": "stable", "minimum_capacity": 1, "name": "my-snapshot", "operating_system": {"architecture": "amd64", "dedicated_host_only": false, "display_name": "Ubuntu Server 16.04 LTS amd64", "family": "Ubuntu Server", "href": "https://us-south.iaas.cloud.ibm.com/v1/operating_systems/ubuntu-16-amd64", "name": "ubuntu-16-amd64", "vendor": "Canonical", "version": "16.04 LTS"}, "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "resource_type": "snapshot", "service_tags": ["ServiceTags"], "size": 1, "snapshot_consistency_group": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot-consistency-group:r134-fa329f6b-0e36-433f-a3bb-0df632e79263", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshot_consistency_groups/r134-fa329f6b-0e36-433f-a3bb-0df632e79263", "id": "r134-fa329f6b-0e36-433f-a3bb-0df632e79263", "name": "my-snapshot-consistency-group", "resource_type": "snapshot_consistency_group"}, "source_image": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::image:72b27b5c-f4b0-48bb-b954-5becc7c1dcb8", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/images/72b27b5c-f4b0-48bb-b954-5becc7c1dcb8", "id": "72b27b5c-f4b0-48bb-b954-5becc7c1dcb8", "name": "my-image", "remote": {"account": {"id": "aa2432b1fa4d4ace891e9b80fc104e34", "resource_type": "account"}, "region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "image"}, "source_snapshot": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "id": "r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "name": "my-snapshot", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "snapshot"}, "source_volume": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::volume:1a6b7274-678d-4dfb-8981-c71dd9d4daa5", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/volumes/1a6b7274-678d-4dfb-8981-c71dd9d4daa5", "id": "1a6b7274-678d-4dfb-8981-c71dd9d4daa5", "name": "my-volume", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "volume"}, "user_tags": ["UserTags"]}`) })) }) - It(`Invoke ListVolumeProfiles successfully`, func() { + It(`Invoke UpdateSnapshot successfully`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -53724,25 +54608,33 @@ var _ = Describe(`VpcV1`, func() { Expect(vpcService).ToNot(BeNil()) // Invoke operation with nil options model (negative test) - result, response, operationErr := vpcService.ListVolumeProfiles(nil) + result, response, operationErr := vpcService.UpdateSnapshot(nil) Expect(operationErr).NotTo(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) - // Construct an instance of the ListVolumeProfilesOptions model - listVolumeProfilesOptionsModel := new(vpcv1.ListVolumeProfilesOptions) - listVolumeProfilesOptionsModel.Start = core.StringPtr("testString") - listVolumeProfilesOptionsModel.Limit = core.Int64Ptr(int64(10)) - listVolumeProfilesOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the SnapshotPatch model + snapshotPatchModel := new(vpcv1.SnapshotPatch) + snapshotPatchModel.Name = core.StringPtr("my-snapshot") + snapshotPatchModel.UserTags = []string{"testString"} + snapshotPatchModelAsPatch, asPatchErr := snapshotPatchModel.AsPatch() + Expect(asPatchErr).To(BeNil()) + + // Construct an instance of the UpdateSnapshotOptions model + updateSnapshotOptionsModel := new(vpcv1.UpdateSnapshotOptions) + updateSnapshotOptionsModel.ID = core.StringPtr("testString") + updateSnapshotOptionsModel.SnapshotPatch = snapshotPatchModelAsPatch + updateSnapshotOptionsModel.IfMatch = core.StringPtr("W/\"96d225c4-56bd-43d9-98fc-d7148e5c5028\"") + updateSnapshotOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with valid options model (positive test) - result, response, operationErr = vpcService.ListVolumeProfiles(listVolumeProfilesOptionsModel) + result, response, operationErr = vpcService.UpdateSnapshot(updateSnapshotOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) }) - It(`Invoke ListVolumeProfiles with error: Operation request error`, func() { + It(`Invoke UpdateSnapshot with error: Operation validation and request error`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -53751,113 +54643,49 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the ListVolumeProfilesOptions model - listVolumeProfilesOptionsModel := new(vpcv1.ListVolumeProfilesOptions) - listVolumeProfilesOptionsModel.Start = core.StringPtr("testString") - listVolumeProfilesOptionsModel.Limit = core.Int64Ptr(int64(10)) - listVolumeProfilesOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the SnapshotPatch model + snapshotPatchModel := new(vpcv1.SnapshotPatch) + snapshotPatchModel.Name = core.StringPtr("my-snapshot") + snapshotPatchModel.UserTags = []string{"testString"} + snapshotPatchModelAsPatch, asPatchErr := snapshotPatchModel.AsPatch() + Expect(asPatchErr).To(BeNil()) + + // Construct an instance of the UpdateSnapshotOptions model + updateSnapshotOptionsModel := new(vpcv1.UpdateSnapshotOptions) + updateSnapshotOptionsModel.ID = core.StringPtr("testString") + updateSnapshotOptionsModel.SnapshotPatch = snapshotPatchModelAsPatch + updateSnapshotOptionsModel.IfMatch = core.StringPtr("W/\"96d225c4-56bd-43d9-98fc-d7148e5c5028\"") + updateSnapshotOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with empty URL (negative test) err := vpcService.SetServiceURL("") Expect(err).To(BeNil()) - result, response, operationErr := vpcService.ListVolumeProfiles(listVolumeProfilesOptionsModel) + result, response, operationErr := vpcService.UpdateSnapshot(updateSnapshotOptionsModel) 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 ListVolumeProfiles 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 ListVolumeProfilesOptions model - listVolumeProfilesOptionsModel := new(vpcv1.ListVolumeProfilesOptions) - listVolumeProfilesOptionsModel.Start = core.StringPtr("testString") - listVolumeProfilesOptionsModel.Limit = core.Int64Ptr(int64(10)) - listVolumeProfilesOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} - - // Invoke operation - result, response, operationErr := vpcService.ListVolumeProfiles(listVolumeProfilesOptionsModel) - Expect(operationErr).To(BeNil()) - Expect(response).ToNot(BeNil()) - - // Verify a nil result + // Construct a second instance of the UpdateSnapshotOptions model with no property values + updateSnapshotOptionsModelNew := new(vpcv1.UpdateSnapshotOptions) + // Invoke operation with invalid model (negative test) + result, response, operationErr = vpcService.UpdateSnapshot(updateSnapshotOptionsModelNew) + Expect(operationErr).ToNot(BeNil()) + Expect(response).To(BeNil()) Expect(result).To(BeNil()) }) AfterEach(func() { testServer.Close() }) }) - Context(`Test pagination helper method on response`, func() { - It(`Invoke GetNextStart successfully`, func() { - responseObject := new(vpcv1.VolumeProfileCollection) - nextObject := new(vpcv1.VolumeProfileCollectionNext) - 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.VolumeProfileCollection) - - 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.VolumeProfileCollection) - nextObject := new(vpcv1.VolumeProfileCollectionNext) - nextObject.Href = core.StringPtr("ibm.com") - responseObject.Next = nextObject - - value, err := responseObject.GetNextStart() - Expect(err).To(BeNil()) - Expect(value).To(BeNil()) - }) - }) - Context(`Using mock server endpoint - paginated response`, func() { - BeforeEach(func() { - var requestNumber int = 0 - testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { - defer GinkgoRecover() - - // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(listVolumeProfilesPath)) - Expect(req.Method).To(Equal("GET")) - - // Set mock response - res.Header().Set("Content-type", "application/json") - res.WriteHeader(200) - requestNumber++ - if requestNumber == 1 { - fmt.Fprintf(res, "%s", `{"next":{"href":"https://myhost.com/somePath?start=1"},"total_count":2,"limit":1,"profiles":[{"family":"tiered","href":"https://us-south.iaas.cloud.ibm.com/v1/volume/profiles/general-purpose","name":"general-purpose"}]}`) - } else if requestNumber == 2 { - fmt.Fprintf(res, "%s", `{"total_count":2,"limit":1,"profiles":[{"family":"tiered","href":"https://us-south.iaas.cloud.ibm.com/v1/volume/profiles/general-purpose","name":"general-purpose"}]}`) - } else { - res.WriteHeader(400) - } + 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(`Use VolumeProfilesPager.GetNext successfully`, func() { + It(`Invoke UpdateSnapshot successfully`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -53866,57 +54694,43 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - listVolumeProfilesOptionsModel := &vpcv1.ListVolumeProfilesOptions{ - Limit: core.Int64Ptr(int64(10)), - } - - pager, err := vpcService.NewVolumeProfilesPager(listVolumeProfilesOptionsModel) - Expect(err).To(BeNil()) - Expect(pager).ToNot(BeNil()) - - var allResults []vpcv1.VolumeProfile - for pager.HasNext() { - nextPage, err := pager.GetNext() - Expect(err).To(BeNil()) - Expect(nextPage).ToNot(BeNil()) - allResults = append(allResults, nextPage...) - } - Expect(len(allResults)).To(Equal(2)) - }) - It(`Use VolumeProfilesPager.GetAll successfully`, func() { - vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ - URL: testServer.URL, - Authenticator: &core.NoAuthAuthenticator{}, - Version: core.StringPtr(version), - }) - Expect(serviceErr).To(BeNil()) - Expect(vpcService).ToNot(BeNil()) + // Construct an instance of the SnapshotPatch model + snapshotPatchModel := new(vpcv1.SnapshotPatch) + snapshotPatchModel.Name = core.StringPtr("my-snapshot") + snapshotPatchModel.UserTags = []string{"testString"} + snapshotPatchModelAsPatch, asPatchErr := snapshotPatchModel.AsPatch() + Expect(asPatchErr).To(BeNil()) - listVolumeProfilesOptionsModel := &vpcv1.ListVolumeProfilesOptions{ - Limit: core.Int64Ptr(int64(10)), - } + // Construct an instance of the UpdateSnapshotOptions model + updateSnapshotOptionsModel := new(vpcv1.UpdateSnapshotOptions) + updateSnapshotOptionsModel.ID = core.StringPtr("testString") + updateSnapshotOptionsModel.SnapshotPatch = snapshotPatchModelAsPatch + updateSnapshotOptionsModel.IfMatch = core.StringPtr("W/\"96d225c4-56bd-43d9-98fc-d7148e5c5028\"") + updateSnapshotOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} - pager, err := vpcService.NewVolumeProfilesPager(listVolumeProfilesOptionsModel) - Expect(err).To(BeNil()) - Expect(pager).ToNot(BeNil()) + // Invoke operation + result, response, operationErr := vpcService.UpdateSnapshot(updateSnapshotOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) - allResults, err := pager.GetAll() - Expect(err).To(BeNil()) - Expect(allResults).ToNot(BeNil()) - Expect(len(allResults)).To(Equal(2)) + // Verify a nil result + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() }) }) }) - Describe(`GetVolumeProfile(getVolumeProfileOptions *GetVolumeProfileOptions) - Operation response error`, func() { + Describe(`ListSnapshotClones(listSnapshotClonesOptions *ListSnapshotClonesOptions) - Operation response error`, func() { version := "testString" - getVolumeProfilePath := "/volume/profiles/testString" + listSnapshotClonesPath := "/snapshots/testString/clones" 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(getVolumeProfilePath)) + Expect(req.URL.EscapedPath()).To(Equal(listSnapshotClonesPath)) 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))})) @@ -53925,7 +54739,7 @@ var _ = Describe(`VpcV1`, func() { fmt.Fprint(res, `} this is not valid json {`) })) }) - It(`Invoke GetVolumeProfile with error: Operation response processing error`, func() { + It(`Invoke ListSnapshotClones with error: Operation response processing error`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -53934,19 +54748,19 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the GetVolumeProfileOptions model - getVolumeProfileOptionsModel := new(vpcv1.GetVolumeProfileOptions) - getVolumeProfileOptionsModel.Name = core.StringPtr("testString") - getVolumeProfileOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the ListSnapshotClonesOptions model + listSnapshotClonesOptionsModel := new(vpcv1.ListSnapshotClonesOptions) + listSnapshotClonesOptionsModel.ID = core.StringPtr("testString") + listSnapshotClonesOptionsModel.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.GetVolumeProfile(getVolumeProfileOptionsModel) + result, response, operationErr := vpcService.ListSnapshotClones(listSnapshotClonesOptionsModel) 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.GetVolumeProfile(getVolumeProfileOptionsModel) + result, response, operationErr = vpcService.ListSnapshotClones(listSnapshotClonesOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).To(BeNil()) @@ -53956,16 +54770,16 @@ var _ = Describe(`VpcV1`, func() { }) }) }) - Describe(`GetVolumeProfile(getVolumeProfileOptions *GetVolumeProfileOptions)`, func() { + Describe(`ListSnapshotClones(listSnapshotClonesOptions *ListSnapshotClonesOptions)`, func() { version := "testString" - getVolumeProfilePath := "/volume/profiles/testString" + listSnapshotClonesPath := "/snapshots/testString/clones" 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(getVolumeProfilePath)) + Expect(req.URL.EscapedPath()).To(Equal(listSnapshotClonesPath)) Expect(req.Method).To(Equal("GET")) Expect(req.URL.Query()["version"]).To(Equal([]string{"testString"})) @@ -53976,10 +54790,10 @@ var _ = Describe(`VpcV1`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"family": "tiered", "href": "https://us-south.iaas.cloud.ibm.com/v1/volume/profiles/general-purpose", "name": "general-purpose"}`) + fmt.Fprintf(res, "%s", `{"clones": [{"available": false, "created_at": "2019-01-01T12:00:00.000Z", "zone": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south/zones/us-south-1", "name": "us-south-1"}}]}`) })) }) - It(`Invoke GetVolumeProfile successfully with retries`, func() { + It(`Invoke ListSnapshotClones successfully with retries`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -53989,21 +54803,21 @@ var _ = Describe(`VpcV1`, func() { Expect(vpcService).ToNot(BeNil()) vpcService.EnableRetries(0, 0) - // Construct an instance of the GetVolumeProfileOptions model - getVolumeProfileOptionsModel := new(vpcv1.GetVolumeProfileOptions) - getVolumeProfileOptionsModel.Name = core.StringPtr("testString") - getVolumeProfileOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the ListSnapshotClonesOptions model + listSnapshotClonesOptionsModel := new(vpcv1.ListSnapshotClonesOptions) + listSnapshotClonesOptionsModel.ID = core.StringPtr("testString") + listSnapshotClonesOptionsModel.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.GetVolumeProfileWithContext(ctx, getVolumeProfileOptionsModel) + _, _, operationErr := vpcService.ListSnapshotClonesWithContext(ctx, listSnapshotClonesOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) // Disable retries and test again vpcService.DisableRetries() - result, response, operationErr := vpcService.GetVolumeProfile(getVolumeProfileOptionsModel) + result, response, operationErr := vpcService.ListSnapshotClones(listSnapshotClonesOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) @@ -54011,7 +54825,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.GetVolumeProfileWithContext(ctx, getVolumeProfileOptionsModel) + _, _, operationErr = vpcService.ListSnapshotClonesWithContext(ctx, listSnapshotClonesOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) }) @@ -54025,7 +54839,7 @@ var _ = Describe(`VpcV1`, func() { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(getVolumeProfilePath)) + Expect(req.URL.EscapedPath()).To(Equal(listSnapshotClonesPath)) Expect(req.Method).To(Equal("GET")) Expect(req.URL.Query()["version"]).To(Equal([]string{"testString"})) @@ -54033,10 +54847,10 @@ var _ = Describe(`VpcV1`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"family": "tiered", "href": "https://us-south.iaas.cloud.ibm.com/v1/volume/profiles/general-purpose", "name": "general-purpose"}`) + fmt.Fprintf(res, "%s", `{"clones": [{"available": false, "created_at": "2019-01-01T12:00:00.000Z", "zone": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south/zones/us-south-1", "name": "us-south-1"}}]}`) })) }) - It(`Invoke GetVolumeProfile successfully`, func() { + It(`Invoke ListSnapshotClones successfully`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -54046,24 +54860,24 @@ var _ = Describe(`VpcV1`, func() { Expect(vpcService).ToNot(BeNil()) // Invoke operation with nil options model (negative test) - result, response, operationErr := vpcService.GetVolumeProfile(nil) + result, response, operationErr := vpcService.ListSnapshotClones(nil) Expect(operationErr).NotTo(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) - // Construct an instance of the GetVolumeProfileOptions model - getVolumeProfileOptionsModel := new(vpcv1.GetVolumeProfileOptions) - getVolumeProfileOptionsModel.Name = core.StringPtr("testString") - getVolumeProfileOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the ListSnapshotClonesOptions model + listSnapshotClonesOptionsModel := new(vpcv1.ListSnapshotClonesOptions) + listSnapshotClonesOptionsModel.ID = core.StringPtr("testString") + listSnapshotClonesOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with valid options model (positive test) - result, response, operationErr = vpcService.GetVolumeProfile(getVolumeProfileOptionsModel) + result, response, operationErr = vpcService.ListSnapshotClones(listSnapshotClonesOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) }) - It(`Invoke GetVolumeProfile with error: Operation validation and request error`, func() { + It(`Invoke ListSnapshotClones with error: Operation validation and request error`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -54072,22 +54886,22 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the GetVolumeProfileOptions model - getVolumeProfileOptionsModel := new(vpcv1.GetVolumeProfileOptions) - getVolumeProfileOptionsModel.Name = core.StringPtr("testString") - getVolumeProfileOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the ListSnapshotClonesOptions model + listSnapshotClonesOptionsModel := new(vpcv1.ListSnapshotClonesOptions) + listSnapshotClonesOptionsModel.ID = core.StringPtr("testString") + listSnapshotClonesOptionsModel.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.GetVolumeProfile(getVolumeProfileOptionsModel) + result, response, operationErr := vpcService.ListSnapshotClones(listSnapshotClonesOptionsModel) 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 GetVolumeProfileOptions model with no property values - getVolumeProfileOptionsModelNew := new(vpcv1.GetVolumeProfileOptions) + // Construct a second instance of the ListSnapshotClonesOptions model with no property values + listSnapshotClonesOptionsModelNew := new(vpcv1.ListSnapshotClonesOptions) // Invoke operation with invalid model (negative test) - result, response, operationErr = vpcService.GetVolumeProfile(getVolumeProfileOptionsModelNew) + result, response, operationErr = vpcService.ListSnapshotClones(listSnapshotClonesOptionsModelNew) Expect(operationErr).ToNot(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) @@ -54105,7 +54919,7 @@ var _ = Describe(`VpcV1`, func() { res.WriteHeader(200) })) }) - It(`Invoke GetVolumeProfile successfully`, func() { + It(`Invoke ListSnapshotClones successfully`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -54114,13 +54928,13 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the GetVolumeProfileOptions model - getVolumeProfileOptionsModel := new(vpcv1.GetVolumeProfileOptions) - getVolumeProfileOptionsModel.Name = core.StringPtr("testString") - getVolumeProfileOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the ListSnapshotClonesOptions model + listSnapshotClonesOptionsModel := new(vpcv1.ListSnapshotClonesOptions) + listSnapshotClonesOptionsModel.ID = core.StringPtr("testString") + listSnapshotClonesOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation - result, response, operationErr := vpcService.GetVolumeProfile(getVolumeProfileOptionsModel) + result, response, operationErr := vpcService.ListSnapshotClones(listSnapshotClonesOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) @@ -54132,33 +54946,100 @@ var _ = Describe(`VpcV1`, func() { }) }) }) - Describe(`ListVolumes(listVolumesOptions *ListVolumesOptions) - Operation response error`, func() { + Describe(`DeleteSnapshotClone(deleteSnapshotCloneOptions *DeleteSnapshotCloneOptions)`, func() { version := "testString" - listVolumesPath := "/volumes" + deleteSnapshotClonePath := "/snapshots/testString/clones/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(deleteSnapshotClonePath)) + 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 DeleteSnapshotClone 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.DeleteSnapshotClone(nil) + Expect(operationErr).NotTo(BeNil()) + Expect(response).To(BeNil()) + + // Construct an instance of the DeleteSnapshotCloneOptions model + deleteSnapshotCloneOptionsModel := new(vpcv1.DeleteSnapshotCloneOptions) + deleteSnapshotCloneOptionsModel.ID = core.StringPtr("testString") + deleteSnapshotCloneOptionsModel.ZoneName = core.StringPtr("testString") + deleteSnapshotCloneOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation with valid options model (positive test) + response, operationErr = vpcService.DeleteSnapshotClone(deleteSnapshotCloneOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + }) + It(`Invoke DeleteSnapshotClone 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 DeleteSnapshotCloneOptions model + deleteSnapshotCloneOptionsModel := new(vpcv1.DeleteSnapshotCloneOptions) + deleteSnapshotCloneOptionsModel.ID = core.StringPtr("testString") + deleteSnapshotCloneOptionsModel.ZoneName = core.StringPtr("testString") + deleteSnapshotCloneOptionsModel.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.DeleteSnapshotClone(deleteSnapshotCloneOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING)) + Expect(response).To(BeNil()) + // Construct a second instance of the DeleteSnapshotCloneOptions model with no property values + deleteSnapshotCloneOptionsModelNew := new(vpcv1.DeleteSnapshotCloneOptions) + // Invoke operation with invalid model (negative test) + response, operationErr = vpcService.DeleteSnapshotClone(deleteSnapshotCloneOptionsModelNew) + Expect(operationErr).ToNot(BeNil()) + Expect(response).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + }) + Describe(`GetSnapshotClone(getSnapshotCloneOptions *GetSnapshotCloneOptions) - Operation response error`, func() { + version := "testString" + getSnapshotClonePath := "/snapshots/testString/clones/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(listVolumesPath)) + Expect(req.URL.EscapedPath()).To(Equal(getSnapshotClonePath)) Expect(req.Method).To(Equal("GET")) Expect(req.URL.Query()["version"]).To(Equal([]string{"testString"})) Expect(req.URL.Query()["generation"]).To(Equal([]string{fmt.Sprint(int64(2))})) - Expect(req.URL.Query()["start"]).To(Equal([]string{"testString"})) - Expect(req.URL.Query()["limit"]).To(Equal([]string{fmt.Sprint(int64(10))})) - Expect(req.URL.Query()["name"]).To(Equal([]string{"testString"})) - Expect(req.URL.Query()["attachment_state"]).To(Equal([]string{"attached"})) - Expect(req.URL.Query()["encryption"]).To(Equal([]string{"provider_managed"})) - Expect(req.URL.Query()["operating_system.family"]).To(Equal([]string{"Ubuntu Server"})) - Expect(req.URL.Query()["operating_system.architecture"]).To(Equal([]string{"amd64"})) - Expect(req.URL.Query()["zone.name"]).To(Equal([]string{"us-south-1"})) res.Header().Set("Content-type", "application/json") res.WriteHeader(200) fmt.Fprint(res, `} this is not valid json {`) })) }) - It(`Invoke ListVolumes with error: Operation response processing error`, func() { + It(`Invoke GetSnapshotClone with error: Operation response processing error`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -54167,26 +55048,20 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the ListVolumesOptions model - listVolumesOptionsModel := new(vpcv1.ListVolumesOptions) - listVolumesOptionsModel.Start = core.StringPtr("testString") - listVolumesOptionsModel.Limit = core.Int64Ptr(int64(10)) - listVolumesOptionsModel.Name = core.StringPtr("testString") - listVolumesOptionsModel.AttachmentState = core.StringPtr("attached") - listVolumesOptionsModel.Encryption = core.StringPtr("provider_managed") - listVolumesOptionsModel.OperatingSystemFamily = core.StringPtr("Ubuntu Server") - listVolumesOptionsModel.OperatingSystemArchitecture = core.StringPtr("amd64") - listVolumesOptionsModel.ZoneName = core.StringPtr("us-south-1") - listVolumesOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the GetSnapshotCloneOptions model + getSnapshotCloneOptionsModel := new(vpcv1.GetSnapshotCloneOptions) + getSnapshotCloneOptionsModel.ID = core.StringPtr("testString") + getSnapshotCloneOptionsModel.ZoneName = core.StringPtr("testString") + getSnapshotCloneOptionsModel.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.ListVolumes(listVolumesOptionsModel) + result, response, operationErr := vpcService.GetSnapshotClone(getSnapshotCloneOptionsModel) 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.ListVolumes(listVolumesOptionsModel) + result, response, operationErr = vpcService.GetSnapshotClone(getSnapshotCloneOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).To(BeNil()) @@ -54196,38 +55071,30 @@ var _ = Describe(`VpcV1`, func() { }) }) }) - Describe(`ListVolumes(listVolumesOptions *ListVolumesOptions)`, func() { + Describe(`GetSnapshotClone(getSnapshotCloneOptions *GetSnapshotCloneOptions)`, func() { version := "testString" - listVolumesPath := "/volumes" + getSnapshotClonePath := "/snapshots/testString/clones/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(listVolumesPath)) + Expect(req.URL.EscapedPath()).To(Equal(getSnapshotClonePath)) Expect(req.Method).To(Equal("GET")) Expect(req.URL.Query()["version"]).To(Equal([]string{"testString"})) Expect(req.URL.Query()["generation"]).To(Equal([]string{fmt.Sprint(int64(2))})) - Expect(req.URL.Query()["start"]).To(Equal([]string{"testString"})) - Expect(req.URL.Query()["limit"]).To(Equal([]string{fmt.Sprint(int64(10))})) - Expect(req.URL.Query()["name"]).To(Equal([]string{"testString"})) - Expect(req.URL.Query()["attachment_state"]).To(Equal([]string{"attached"})) - Expect(req.URL.Query()["encryption"]).To(Equal([]string{"provider_managed"})) - Expect(req.URL.Query()["operating_system.family"]).To(Equal([]string{"Ubuntu Server"})) - Expect(req.URL.Query()["operating_system.architecture"]).To(Equal([]string{"amd64"})) - Expect(req.URL.Query()["zone.name"]).To(Equal([]string{"us-south-1"})) // Sleep a short time to support a timeout test time.Sleep(100 * time.Millisecond) // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"first": {"href": "https://us-south.iaas.cloud.ibm.com/v1/volumes?limit=20"}, "limit": 20, "next": {"href": "https://us-south.iaas.cloud.ibm.com/v1/volumes?start=9d5a91a3e2cbd233b5a5b33436855ed1&limit=20"}, "total_count": 132, "volumes": [{"active": true, "attachment_state": "attached", "bandwidth": 1000, "busy": true, "capacity": 1000, "created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::volume:1a6b7274-678d-4dfb-8981-c71dd9d4daa5", "encryption": "provider_managed", "encryption_key": {"crn": "crn:v1:bluemix:public:kms:us-south:a/123456:e4a29d1a-2ef0-42a6-8fd2-350deb1c647e:key:5437653b-c4b1-447f-9646-b2a2a4cd6179"}, "health_reasons": [{"code": "initializing_from_snapshot", "message": "Performance will be degraded while this volume is being initialized from its snapshot", "more_info": "https://cloud.ibm.com/docs/vpc?topic=vpc-snapshots-vpc-troubleshooting&interface=ui#snapshot_ts_degraded_perf"}], "health_state": "ok", "href": "https://us-south.iaas.cloud.ibm.com/v1/volumes/1a6b7274-678d-4dfb-8981-c71dd9d4daa5", "id": "1a6b7274-678d-4dfb-8981-c71dd9d4daa5", "iops": 10000, "name": "my-volume", "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"}, "profile": {"href": "https://us-south.iaas.cloud.ibm.com/v1/volume/profiles/general-purpose", "name": "general-purpose"}, "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "resource_type": "volume", "source_image": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::image:72b27b5c-f4b0-48bb-b954-5becc7c1dcb8", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/images/72b27b5c-f4b0-48bb-b954-5becc7c1dcb8", "id": "72b27b5c-f4b0-48bb-b954-5becc7c1dcb8", "name": "my-image", "remote": {"account": {"id": "aa2432b1fa4d4ace891e9b80fc104e34", "resource_type": "account"}, "region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "image"}, "source_snapshot": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "id": "r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "name": "my-snapshot", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "snapshot"}, "status": "available", "status_reasons": [{"code": "encryption_key_deleted", "message": "Message", "more_info": "https://cloud.ibm.com/docs/key-protect?topic=key-protect-restore-keys"}], "user_tags": ["UserTags"], "volume_attachments": [{"delete_volume_on_instance_delete": true, "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "device": {"id": "80b3e36e-41f4-40e9-bd56-beae81792a68"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/instances/1e09281b-f177-46fb-baf1-bc152b2e391a/volume_attachments/82cbf856-9cbb-45fb-b62f-d7bcef32399a", "id": "82cbf856-9cbb-45fb-b62f-d7bcef32399a", "instance": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::instance:1e09281b-f177-46fb-baf1-bc152b2e391a", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/instances/1e09281b-f177-46fb-baf1-bc152b2e391a", "id": "1e09281b-f177-46fb-baf1-bc152b2e391a", "name": "my-instance"}, "name": "my-volume-attachment", "type": "boot"}], "zone": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south/zones/us-south-1", "name": "us-south-1"}}]}`) + fmt.Fprintf(res, "%s", `{"available": false, "created_at": "2019-01-01T12:00:00.000Z", "zone": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south/zones/us-south-1", "name": "us-south-1"}}`) })) }) - It(`Invoke ListVolumes successfully with retries`, func() { + It(`Invoke GetSnapshotClone successfully with retries`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -54237,28 +55104,22 @@ var _ = Describe(`VpcV1`, func() { Expect(vpcService).ToNot(BeNil()) vpcService.EnableRetries(0, 0) - // Construct an instance of the ListVolumesOptions model - listVolumesOptionsModel := new(vpcv1.ListVolumesOptions) - listVolumesOptionsModel.Start = core.StringPtr("testString") - listVolumesOptionsModel.Limit = core.Int64Ptr(int64(10)) - listVolumesOptionsModel.Name = core.StringPtr("testString") - listVolumesOptionsModel.AttachmentState = core.StringPtr("attached") - listVolumesOptionsModel.Encryption = core.StringPtr("provider_managed") - listVolumesOptionsModel.OperatingSystemFamily = core.StringPtr("Ubuntu Server") - listVolumesOptionsModel.OperatingSystemArchitecture = core.StringPtr("amd64") - listVolumesOptionsModel.ZoneName = core.StringPtr("us-south-1") - listVolumesOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the GetSnapshotCloneOptions model + getSnapshotCloneOptionsModel := new(vpcv1.GetSnapshotCloneOptions) + getSnapshotCloneOptionsModel.ID = core.StringPtr("testString") + getSnapshotCloneOptionsModel.ZoneName = core.StringPtr("testString") + getSnapshotCloneOptionsModel.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.ListVolumesWithContext(ctx, listVolumesOptionsModel) + _, _, operationErr := vpcService.GetSnapshotCloneWithContext(ctx, getSnapshotCloneOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) // Disable retries and test again vpcService.DisableRetries() - result, response, operationErr := vpcService.ListVolumes(listVolumesOptionsModel) + result, response, operationErr := vpcService.GetSnapshotClone(getSnapshotCloneOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) @@ -54266,7 +55127,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.ListVolumesWithContext(ctx, listVolumesOptionsModel) + _, _, operationErr = vpcService.GetSnapshotCloneWithContext(ctx, getSnapshotCloneOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) }) @@ -54280,26 +55141,18 @@ var _ = Describe(`VpcV1`, func() { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(listVolumesPath)) + Expect(req.URL.EscapedPath()).To(Equal(getSnapshotClonePath)) Expect(req.Method).To(Equal("GET")) Expect(req.URL.Query()["version"]).To(Equal([]string{"testString"})) Expect(req.URL.Query()["generation"]).To(Equal([]string{fmt.Sprint(int64(2))})) - Expect(req.URL.Query()["start"]).To(Equal([]string{"testString"})) - Expect(req.URL.Query()["limit"]).To(Equal([]string{fmt.Sprint(int64(10))})) - Expect(req.URL.Query()["name"]).To(Equal([]string{"testString"})) - Expect(req.URL.Query()["attachment_state"]).To(Equal([]string{"attached"})) - Expect(req.URL.Query()["encryption"]).To(Equal([]string{"provider_managed"})) - Expect(req.URL.Query()["operating_system.family"]).To(Equal([]string{"Ubuntu Server"})) - Expect(req.URL.Query()["operating_system.architecture"]).To(Equal([]string{"amd64"})) - Expect(req.URL.Query()["zone.name"]).To(Equal([]string{"us-south-1"})) // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"first": {"href": "https://us-south.iaas.cloud.ibm.com/v1/volumes?limit=20"}, "limit": 20, "next": {"href": "https://us-south.iaas.cloud.ibm.com/v1/volumes?start=9d5a91a3e2cbd233b5a5b33436855ed1&limit=20"}, "total_count": 132, "volumes": [{"active": true, "attachment_state": "attached", "bandwidth": 1000, "busy": true, "capacity": 1000, "created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::volume:1a6b7274-678d-4dfb-8981-c71dd9d4daa5", "encryption": "provider_managed", "encryption_key": {"crn": "crn:v1:bluemix:public:kms:us-south:a/123456:e4a29d1a-2ef0-42a6-8fd2-350deb1c647e:key:5437653b-c4b1-447f-9646-b2a2a4cd6179"}, "health_reasons": [{"code": "initializing_from_snapshot", "message": "Performance will be degraded while this volume is being initialized from its snapshot", "more_info": "https://cloud.ibm.com/docs/vpc?topic=vpc-snapshots-vpc-troubleshooting&interface=ui#snapshot_ts_degraded_perf"}], "health_state": "ok", "href": "https://us-south.iaas.cloud.ibm.com/v1/volumes/1a6b7274-678d-4dfb-8981-c71dd9d4daa5", "id": "1a6b7274-678d-4dfb-8981-c71dd9d4daa5", "iops": 10000, "name": "my-volume", "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"}, "profile": {"href": "https://us-south.iaas.cloud.ibm.com/v1/volume/profiles/general-purpose", "name": "general-purpose"}, "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "resource_type": "volume", "source_image": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::image:72b27b5c-f4b0-48bb-b954-5becc7c1dcb8", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/images/72b27b5c-f4b0-48bb-b954-5becc7c1dcb8", "id": "72b27b5c-f4b0-48bb-b954-5becc7c1dcb8", "name": "my-image", "remote": {"account": {"id": "aa2432b1fa4d4ace891e9b80fc104e34", "resource_type": "account"}, "region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "image"}, "source_snapshot": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "id": "r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "name": "my-snapshot", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "snapshot"}, "status": "available", "status_reasons": [{"code": "encryption_key_deleted", "message": "Message", "more_info": "https://cloud.ibm.com/docs/key-protect?topic=key-protect-restore-keys"}], "user_tags": ["UserTags"], "volume_attachments": [{"delete_volume_on_instance_delete": true, "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "device": {"id": "80b3e36e-41f4-40e9-bd56-beae81792a68"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/instances/1e09281b-f177-46fb-baf1-bc152b2e391a/volume_attachments/82cbf856-9cbb-45fb-b62f-d7bcef32399a", "id": "82cbf856-9cbb-45fb-b62f-d7bcef32399a", "instance": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::instance:1e09281b-f177-46fb-baf1-bc152b2e391a", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/instances/1e09281b-f177-46fb-baf1-bc152b2e391a", "id": "1e09281b-f177-46fb-baf1-bc152b2e391a", "name": "my-instance"}, "name": "my-volume-attachment", "type": "boot"}], "zone": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south/zones/us-south-1", "name": "us-south-1"}}]}`) + fmt.Fprintf(res, "%s", `{"available": false, "created_at": "2019-01-01T12:00:00.000Z", "zone": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south/zones/us-south-1", "name": "us-south-1"}}`) })) }) - It(`Invoke ListVolumes successfully`, func() { + It(`Invoke GetSnapshotClone successfully`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -54309,31 +55162,25 @@ var _ = Describe(`VpcV1`, func() { Expect(vpcService).ToNot(BeNil()) // Invoke operation with nil options model (negative test) - result, response, operationErr := vpcService.ListVolumes(nil) + result, response, operationErr := vpcService.GetSnapshotClone(nil) Expect(operationErr).NotTo(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) - // Construct an instance of the ListVolumesOptions model - listVolumesOptionsModel := new(vpcv1.ListVolumesOptions) - listVolumesOptionsModel.Start = core.StringPtr("testString") - listVolumesOptionsModel.Limit = core.Int64Ptr(int64(10)) - listVolumesOptionsModel.Name = core.StringPtr("testString") - listVolumesOptionsModel.AttachmentState = core.StringPtr("attached") - listVolumesOptionsModel.Encryption = core.StringPtr("provider_managed") - listVolumesOptionsModel.OperatingSystemFamily = core.StringPtr("Ubuntu Server") - listVolumesOptionsModel.OperatingSystemArchitecture = core.StringPtr("amd64") - listVolumesOptionsModel.ZoneName = core.StringPtr("us-south-1") - listVolumesOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the GetSnapshotCloneOptions model + getSnapshotCloneOptionsModel := new(vpcv1.GetSnapshotCloneOptions) + getSnapshotCloneOptionsModel.ID = core.StringPtr("testString") + getSnapshotCloneOptionsModel.ZoneName = core.StringPtr("testString") + getSnapshotCloneOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with valid options model (positive test) - result, response, operationErr = vpcService.ListVolumes(listVolumesOptionsModel) + result, response, operationErr = vpcService.GetSnapshotClone(getSnapshotCloneOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) }) - It(`Invoke ListVolumes with error: Operation request error`, func() { + It(`Invoke GetSnapshotClone with error: Operation validation and request error`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -54342,25 +55189,26 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the ListVolumesOptions model - listVolumesOptionsModel := new(vpcv1.ListVolumesOptions) - listVolumesOptionsModel.Start = core.StringPtr("testString") - listVolumesOptionsModel.Limit = core.Int64Ptr(int64(10)) - listVolumesOptionsModel.Name = core.StringPtr("testString") - listVolumesOptionsModel.AttachmentState = core.StringPtr("attached") - listVolumesOptionsModel.Encryption = core.StringPtr("provider_managed") - listVolumesOptionsModel.OperatingSystemFamily = core.StringPtr("Ubuntu Server") - listVolumesOptionsModel.OperatingSystemArchitecture = core.StringPtr("amd64") - listVolumesOptionsModel.ZoneName = core.StringPtr("us-south-1") - listVolumesOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the GetSnapshotCloneOptions model + getSnapshotCloneOptionsModel := new(vpcv1.GetSnapshotCloneOptions) + getSnapshotCloneOptionsModel.ID = core.StringPtr("testString") + getSnapshotCloneOptionsModel.ZoneName = core.StringPtr("testString") + getSnapshotCloneOptionsModel.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.ListVolumes(listVolumesOptionsModel) + result, response, operationErr := vpcService.GetSnapshotClone(getSnapshotCloneOptionsModel) 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 GetSnapshotCloneOptions model with no property values + getSnapshotCloneOptionsModelNew := new(vpcv1.GetSnapshotCloneOptions) + // Invoke operation with invalid model (negative test) + result, response, operationErr = vpcService.GetSnapshotClone(getSnapshotCloneOptionsModelNew) + Expect(operationErr).ToNot(BeNil()) + Expect(response).To(BeNil()) + Expect(result).To(BeNil()) }) AfterEach(func() { testServer.Close() @@ -54375,7 +55223,7 @@ var _ = Describe(`VpcV1`, func() { res.WriteHeader(200) })) }) - It(`Invoke ListVolumes successfully`, func() { + It(`Invoke GetSnapshotClone successfully`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -54384,20 +55232,14 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the ListVolumesOptions model - listVolumesOptionsModel := new(vpcv1.ListVolumesOptions) - listVolumesOptionsModel.Start = core.StringPtr("testString") - listVolumesOptionsModel.Limit = core.Int64Ptr(int64(10)) - listVolumesOptionsModel.Name = core.StringPtr("testString") - listVolumesOptionsModel.AttachmentState = core.StringPtr("attached") - listVolumesOptionsModel.Encryption = core.StringPtr("provider_managed") - listVolumesOptionsModel.OperatingSystemFamily = core.StringPtr("Ubuntu Server") - listVolumesOptionsModel.OperatingSystemArchitecture = core.StringPtr("amd64") - listVolumesOptionsModel.ZoneName = core.StringPtr("us-south-1") - listVolumesOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the GetSnapshotCloneOptions model + getSnapshotCloneOptionsModel := new(vpcv1.GetSnapshotCloneOptions) + getSnapshotCloneOptionsModel.ID = core.StringPtr("testString") + getSnapshotCloneOptionsModel.ZoneName = core.StringPtr("testString") + getSnapshotCloneOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation - result, response, operationErr := vpcService.ListVolumes(listVolumesOptionsModel) + result, response, operationErr := vpcService.GetSnapshotClone(getSnapshotCloneOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) @@ -54408,139 +55250,26 @@ var _ = Describe(`VpcV1`, func() { testServer.Close() }) }) - Context(`Test pagination helper method on response`, func() { - It(`Invoke GetNextStart successfully`, func() { - responseObject := new(vpcv1.VolumeCollection) - nextObject := new(vpcv1.VolumeCollectionNext) - 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.VolumeCollection) - - 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.VolumeCollection) - nextObject := new(vpcv1.VolumeCollectionNext) - nextObject.Href = core.StringPtr("ibm.com") - responseObject.Next = nextObject - - value, err := responseObject.GetNextStart() - Expect(err).To(BeNil()) - Expect(value).To(BeNil()) - }) - }) - Context(`Using mock server endpoint - paginated response`, func() { - BeforeEach(func() { - var requestNumber int = 0 - testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { - defer GinkgoRecover() - - // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(listVolumesPath)) - Expect(req.Method).To(Equal("GET")) - - // Set mock response - res.Header().Set("Content-type", "application/json") - res.WriteHeader(200) - requestNumber++ - if requestNumber == 1 { - fmt.Fprintf(res, "%s", `{"next":{"href":"https://myhost.com/somePath?start=1"},"total_count":2,"limit":1,"volumes":[{"active":true,"attachment_state":"attached","bandwidth":1000,"busy":true,"capacity":1000,"created_at":"2019-01-01T12:00:00.000Z","crn":"crn:v1:bluemix:public:is:us-south-1:a/123456::volume:1a6b7274-678d-4dfb-8981-c71dd9d4daa5","encryption":"provider_managed","encryption_key":{"crn":"crn:v1:bluemix:public:kms:us-south:a/123456:e4a29d1a-2ef0-42a6-8fd2-350deb1c647e:key:5437653b-c4b1-447f-9646-b2a2a4cd6179"},"health_reasons":[{"code":"initializing_from_snapshot","message":"Performance will be degraded while this volume is being initialized from its snapshot","more_info":"https://cloud.ibm.com/docs/vpc?topic=vpc-snapshots-vpc-troubleshooting&interface=ui#snapshot_ts_degraded_perf"}],"health_state":"ok","href":"https://us-south.iaas.cloud.ibm.com/v1/volumes/1a6b7274-678d-4dfb-8981-c71dd9d4daa5","id":"1a6b7274-678d-4dfb-8981-c71dd9d4daa5","iops":10000,"name":"my-volume","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"},"profile":{"href":"https://us-south.iaas.cloud.ibm.com/v1/volume/profiles/general-purpose","name":"general-purpose"},"resource_group":{"href":"https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345","id":"fee82deba12e4c0fb69c3b09d1f12345","name":"my-resource-group"},"resource_type":"volume","source_image":{"crn":"crn:v1:bluemix:public:is:us-south:a/123456::image:72b27b5c-f4b0-48bb-b954-5becc7c1dcb8","deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/images/72b27b5c-f4b0-48bb-b954-5becc7c1dcb8","id":"72b27b5c-f4b0-48bb-b954-5becc7c1dcb8","name":"my-image","remote":{"account":{"id":"aa2432b1fa4d4ace891e9b80fc104e34","resource_type":"account"},"region":{"href":"https://us-south.iaas.cloud.ibm.com/v1/regions/us-south","name":"us-south"}},"resource_type":"image"},"source_snapshot":{"crn":"crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263","deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263","id":"r134-f6bfa329-0e36-433f-a3bb-0df632e79263","name":"my-snapshot","remote":{"region":{"href":"https://us-south.iaas.cloud.ibm.com/v1/regions/us-south","name":"us-south"}},"resource_type":"snapshot"},"status":"available","status_reasons":[{"code":"encryption_key_deleted","message":"Message","more_info":"https://cloud.ibm.com/docs/key-protect?topic=key-protect-restore-keys"}],"user_tags":["UserTags"],"volume_attachments":[{"delete_volume_on_instance_delete":true,"deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"device":{"id":"80b3e36e-41f4-40e9-bd56-beae81792a68"},"href":"https://us-south.iaas.cloud.ibm.com/v1/instances/1e09281b-f177-46fb-baf1-bc152b2e391a/volume_attachments/82cbf856-9cbb-45fb-b62f-d7bcef32399a","id":"82cbf856-9cbb-45fb-b62f-d7bcef32399a","instance":{"crn":"crn:v1:bluemix:public:is:us-south-1:a/123456::instance:1e09281b-f177-46fb-baf1-bc152b2e391a","deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/instances/1e09281b-f177-46fb-baf1-bc152b2e391a","id":"1e09281b-f177-46fb-baf1-bc152b2e391a","name":"my-instance"},"name":"my-volume-attachment","type":"boot"}],"zone":{"href":"https://us-south.iaas.cloud.ibm.com/v1/regions/us-south/zones/us-south-1","name":"us-south-1"}}]}`) - } else if requestNumber == 2 { - fmt.Fprintf(res, "%s", `{"total_count":2,"limit":1,"volumes":[{"active":true,"attachment_state":"attached","bandwidth":1000,"busy":true,"capacity":1000,"created_at":"2019-01-01T12:00:00.000Z","crn":"crn:v1:bluemix:public:is:us-south-1:a/123456::volume:1a6b7274-678d-4dfb-8981-c71dd9d4daa5","encryption":"provider_managed","encryption_key":{"crn":"crn:v1:bluemix:public:kms:us-south:a/123456:e4a29d1a-2ef0-42a6-8fd2-350deb1c647e:key:5437653b-c4b1-447f-9646-b2a2a4cd6179"},"health_reasons":[{"code":"initializing_from_snapshot","message":"Performance will be degraded while this volume is being initialized from its snapshot","more_info":"https://cloud.ibm.com/docs/vpc?topic=vpc-snapshots-vpc-troubleshooting&interface=ui#snapshot_ts_degraded_perf"}],"health_state":"ok","href":"https://us-south.iaas.cloud.ibm.com/v1/volumes/1a6b7274-678d-4dfb-8981-c71dd9d4daa5","id":"1a6b7274-678d-4dfb-8981-c71dd9d4daa5","iops":10000,"name":"my-volume","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"},"profile":{"href":"https://us-south.iaas.cloud.ibm.com/v1/volume/profiles/general-purpose","name":"general-purpose"},"resource_group":{"href":"https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345","id":"fee82deba12e4c0fb69c3b09d1f12345","name":"my-resource-group"},"resource_type":"volume","source_image":{"crn":"crn:v1:bluemix:public:is:us-south:a/123456::image:72b27b5c-f4b0-48bb-b954-5becc7c1dcb8","deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/images/72b27b5c-f4b0-48bb-b954-5becc7c1dcb8","id":"72b27b5c-f4b0-48bb-b954-5becc7c1dcb8","name":"my-image","remote":{"account":{"id":"aa2432b1fa4d4ace891e9b80fc104e34","resource_type":"account"},"region":{"href":"https://us-south.iaas.cloud.ibm.com/v1/regions/us-south","name":"us-south"}},"resource_type":"image"},"source_snapshot":{"crn":"crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263","deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263","id":"r134-f6bfa329-0e36-433f-a3bb-0df632e79263","name":"my-snapshot","remote":{"region":{"href":"https://us-south.iaas.cloud.ibm.com/v1/regions/us-south","name":"us-south"}},"resource_type":"snapshot"},"status":"available","status_reasons":[{"code":"encryption_key_deleted","message":"Message","more_info":"https://cloud.ibm.com/docs/key-protect?topic=key-protect-restore-keys"}],"user_tags":["UserTags"],"volume_attachments":[{"delete_volume_on_instance_delete":true,"deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"device":{"id":"80b3e36e-41f4-40e9-bd56-beae81792a68"},"href":"https://us-south.iaas.cloud.ibm.com/v1/instances/1e09281b-f177-46fb-baf1-bc152b2e391a/volume_attachments/82cbf856-9cbb-45fb-b62f-d7bcef32399a","id":"82cbf856-9cbb-45fb-b62f-d7bcef32399a","instance":{"crn":"crn:v1:bluemix:public:is:us-south-1:a/123456::instance:1e09281b-f177-46fb-baf1-bc152b2e391a","deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/instances/1e09281b-f177-46fb-baf1-bc152b2e391a","id":"1e09281b-f177-46fb-baf1-bc152b2e391a","name":"my-instance"},"name":"my-volume-attachment","type":"boot"}],"zone":{"href":"https://us-south.iaas.cloud.ibm.com/v1/regions/us-south/zones/us-south-1","name":"us-south-1"}}]}`) - } else { - res.WriteHeader(400) - } - })) - }) - It(`Use VolumesPager.GetNext successfully`, func() { - vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ - URL: testServer.URL, - Authenticator: &core.NoAuthAuthenticator{}, - Version: core.StringPtr(version), - }) - Expect(serviceErr).To(BeNil()) - Expect(vpcService).ToNot(BeNil()) - - listVolumesOptionsModel := &vpcv1.ListVolumesOptions{ - Limit: core.Int64Ptr(int64(10)), - Name: core.StringPtr("testString"), - AttachmentState: core.StringPtr("attached"), - Encryption: core.StringPtr("provider_managed"), - OperatingSystemFamily: core.StringPtr("Ubuntu Server"), - OperatingSystemArchitecture: core.StringPtr("amd64"), - ZoneName: core.StringPtr("us-south-1"), - } - - pager, err := vpcService.NewVolumesPager(listVolumesOptionsModel) - Expect(err).To(BeNil()) - Expect(pager).ToNot(BeNil()) - - var allResults []vpcv1.Volume - for pager.HasNext() { - nextPage, err := pager.GetNext() - Expect(err).To(BeNil()) - Expect(nextPage).ToNot(BeNil()) - allResults = append(allResults, nextPage...) - } - Expect(len(allResults)).To(Equal(2)) - }) - It(`Use VolumesPager.GetAll successfully`, func() { - vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ - URL: testServer.URL, - Authenticator: &core.NoAuthAuthenticator{}, - Version: core.StringPtr(version), - }) - Expect(serviceErr).To(BeNil()) - Expect(vpcService).ToNot(BeNil()) - - listVolumesOptionsModel := &vpcv1.ListVolumesOptions{ - Limit: core.Int64Ptr(int64(10)), - Name: core.StringPtr("testString"), - AttachmentState: core.StringPtr("attached"), - Encryption: core.StringPtr("provider_managed"), - OperatingSystemFamily: core.StringPtr("Ubuntu Server"), - OperatingSystemArchitecture: core.StringPtr("amd64"), - ZoneName: core.StringPtr("us-south-1"), - } - - pager, err := vpcService.NewVolumesPager(listVolumesOptionsModel) - Expect(err).To(BeNil()) - Expect(pager).ToNot(BeNil()) - - allResults, err := pager.GetAll() - Expect(err).To(BeNil()) - Expect(allResults).ToNot(BeNil()) - Expect(len(allResults)).To(Equal(2)) - }) - }) }) - Describe(`CreateVolume(createVolumeOptions *CreateVolumeOptions) - Operation response error`, func() { + Describe(`CreateSnapshotClone(createSnapshotCloneOptions *CreateSnapshotCloneOptions) - Operation response error`, func() { version := "testString" - createVolumePath := "/volumes" + createSnapshotClonePath := "/snapshots/testString/clones/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(createVolumePath)) - Expect(req.Method).To(Equal("POST")) + Expect(req.URL.EscapedPath()).To(Equal(createSnapshotClonePath)) + Expect(req.Method).To(Equal("PUT")) 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) + res.WriteHeader(200) fmt.Fprint(res, `} this is not valid json {`) })) }) - It(`Invoke CreateVolume with error: Operation response processing error`, func() { + It(`Invoke CreateSnapshotClone with error: Operation response processing error`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -54549,46 +55278,20 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the VolumeProfileIdentityByName model - volumeProfileIdentityModel := new(vpcv1.VolumeProfileIdentityByName) - volumeProfileIdentityModel.Name = core.StringPtr("5iops-tier") - - // Construct an instance of the ResourceGroupIdentityByID model - resourceGroupIdentityModel := new(vpcv1.ResourceGroupIdentityByID) - resourceGroupIdentityModel.ID = core.StringPtr("fee82deba12e4c0fb69c3b09d1f12345") - - // Construct an instance of the ZoneIdentityByName model - zoneIdentityModel := new(vpcv1.ZoneIdentityByName) - zoneIdentityModel.Name = core.StringPtr("us-south-1") - - // Construct an instance of the EncryptionKeyIdentityByCRN model - encryptionKeyIdentityModel := new(vpcv1.EncryptionKeyIdentityByCRN) - encryptionKeyIdentityModel.CRN = core.StringPtr("crn:v1:bluemix:public:kms:us-south:a/123456:e4a29d1a-2ef0-42a6-8fd2-350deb1c647e:key:5437653b-c4b1-447f-9646-b2a2a4cd6179") - - // Construct an instance of the VolumePrototypeVolumeByCapacity model - volumePrototypeModel := new(vpcv1.VolumePrototypeVolumeByCapacity) - volumePrototypeModel.Iops = core.Int64Ptr(int64(10000)) - volumePrototypeModel.Name = core.StringPtr("my-volume") - volumePrototypeModel.Profile = volumeProfileIdentityModel - volumePrototypeModel.ResourceGroup = resourceGroupIdentityModel - volumePrototypeModel.UserTags = []string{} - volumePrototypeModel.Zone = zoneIdentityModel - volumePrototypeModel.Capacity = core.Int64Ptr(int64(100)) - volumePrototypeModel.EncryptionKey = encryptionKeyIdentityModel - - // Construct an instance of the CreateVolumeOptions model - createVolumeOptionsModel := new(vpcv1.CreateVolumeOptions) - createVolumeOptionsModel.VolumePrototype = volumePrototypeModel - createVolumeOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the CreateSnapshotCloneOptions model + createSnapshotCloneOptionsModel := new(vpcv1.CreateSnapshotCloneOptions) + createSnapshotCloneOptionsModel.ID = core.StringPtr("testString") + createSnapshotCloneOptionsModel.ZoneName = core.StringPtr("testString") + createSnapshotCloneOptionsModel.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.CreateVolume(createVolumeOptionsModel) + result, response, operationErr := vpcService.CreateSnapshotClone(createSnapshotCloneOptionsModel) 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.CreateVolume(createVolumeOptionsModel) + result, response, operationErr = vpcService.CreateSnapshotClone(createSnapshotCloneOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).To(BeNil()) @@ -54598,33 +55301,17 @@ var _ = Describe(`VpcV1`, func() { }) }) }) - Describe(`CreateVolume(createVolumeOptions *CreateVolumeOptions)`, func() { + Describe(`CreateSnapshotClone(createSnapshotCloneOptions *CreateSnapshotCloneOptions)`, func() { version := "testString" - createVolumePath := "/volumes" + createSnapshotClonePath := "/snapshots/testString/clones/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(createVolumePath)) - 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.EscapedPath()).To(Equal(createSnapshotClonePath)) + Expect(req.Method).To(Equal("PUT")) Expect(req.URL.Query()["version"]).To(Equal([]string{"testString"})) Expect(req.URL.Query()["generation"]).To(Equal([]string{fmt.Sprint(int64(2))})) @@ -54633,11 +55320,11 @@ var _ = Describe(`VpcV1`, func() { // Set mock response res.Header().Set("Content-type", "application/json") - res.WriteHeader(201) - fmt.Fprintf(res, "%s", `{"active": true, "attachment_state": "attached", "bandwidth": 1000, "busy": true, "capacity": 1000, "created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::volume:1a6b7274-678d-4dfb-8981-c71dd9d4daa5", "encryption": "provider_managed", "encryption_key": {"crn": "crn:v1:bluemix:public:kms:us-south:a/123456:e4a29d1a-2ef0-42a6-8fd2-350deb1c647e:key:5437653b-c4b1-447f-9646-b2a2a4cd6179"}, "health_reasons": [{"code": "initializing_from_snapshot", "message": "Performance will be degraded while this volume is being initialized from its snapshot", "more_info": "https://cloud.ibm.com/docs/vpc?topic=vpc-snapshots-vpc-troubleshooting&interface=ui#snapshot_ts_degraded_perf"}], "health_state": "ok", "href": "https://us-south.iaas.cloud.ibm.com/v1/volumes/1a6b7274-678d-4dfb-8981-c71dd9d4daa5", "id": "1a6b7274-678d-4dfb-8981-c71dd9d4daa5", "iops": 10000, "name": "my-volume", "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"}, "profile": {"href": "https://us-south.iaas.cloud.ibm.com/v1/volume/profiles/general-purpose", "name": "general-purpose"}, "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "resource_type": "volume", "source_image": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::image:72b27b5c-f4b0-48bb-b954-5becc7c1dcb8", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/images/72b27b5c-f4b0-48bb-b954-5becc7c1dcb8", "id": "72b27b5c-f4b0-48bb-b954-5becc7c1dcb8", "name": "my-image", "remote": {"account": {"id": "aa2432b1fa4d4ace891e9b80fc104e34", "resource_type": "account"}, "region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "image"}, "source_snapshot": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "id": "r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "name": "my-snapshot", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "snapshot"}, "status": "available", "status_reasons": [{"code": "encryption_key_deleted", "message": "Message", "more_info": "https://cloud.ibm.com/docs/key-protect?topic=key-protect-restore-keys"}], "user_tags": ["UserTags"], "volume_attachments": [{"delete_volume_on_instance_delete": true, "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "device": {"id": "80b3e36e-41f4-40e9-bd56-beae81792a68"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/instances/1e09281b-f177-46fb-baf1-bc152b2e391a/volume_attachments/82cbf856-9cbb-45fb-b62f-d7bcef32399a", "id": "82cbf856-9cbb-45fb-b62f-d7bcef32399a", "instance": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::instance:1e09281b-f177-46fb-baf1-bc152b2e391a", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/instances/1e09281b-f177-46fb-baf1-bc152b2e391a", "id": "1e09281b-f177-46fb-baf1-bc152b2e391a", "name": "my-instance"}, "name": "my-volume-attachment", "type": "boot"}], "zone": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south/zones/us-south-1", "name": "us-south-1"}}`) + res.WriteHeader(200) + fmt.Fprintf(res, "%s", `{"available": false, "created_at": "2019-01-01T12:00:00.000Z", "zone": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south/zones/us-south-1", "name": "us-south-1"}}`) })) }) - It(`Invoke CreateVolume successfully with retries`, func() { + It(`Invoke CreateSnapshotClone successfully with retries`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -54647,48 +55334,22 @@ var _ = Describe(`VpcV1`, func() { Expect(vpcService).ToNot(BeNil()) vpcService.EnableRetries(0, 0) - // Construct an instance of the VolumeProfileIdentityByName model - volumeProfileIdentityModel := new(vpcv1.VolumeProfileIdentityByName) - volumeProfileIdentityModel.Name = core.StringPtr("5iops-tier") - - // Construct an instance of the ResourceGroupIdentityByID model - resourceGroupIdentityModel := new(vpcv1.ResourceGroupIdentityByID) - resourceGroupIdentityModel.ID = core.StringPtr("fee82deba12e4c0fb69c3b09d1f12345") - - // Construct an instance of the ZoneIdentityByName model - zoneIdentityModel := new(vpcv1.ZoneIdentityByName) - zoneIdentityModel.Name = core.StringPtr("us-south-1") - - // Construct an instance of the EncryptionKeyIdentityByCRN model - encryptionKeyIdentityModel := new(vpcv1.EncryptionKeyIdentityByCRN) - encryptionKeyIdentityModel.CRN = core.StringPtr("crn:v1:bluemix:public:kms:us-south:a/123456:e4a29d1a-2ef0-42a6-8fd2-350deb1c647e:key:5437653b-c4b1-447f-9646-b2a2a4cd6179") - - // Construct an instance of the VolumePrototypeVolumeByCapacity model - volumePrototypeModel := new(vpcv1.VolumePrototypeVolumeByCapacity) - volumePrototypeModel.Iops = core.Int64Ptr(int64(10000)) - volumePrototypeModel.Name = core.StringPtr("my-volume") - volumePrototypeModel.Profile = volumeProfileIdentityModel - volumePrototypeModel.ResourceGroup = resourceGroupIdentityModel - volumePrototypeModel.UserTags = []string{} - volumePrototypeModel.Zone = zoneIdentityModel - volumePrototypeModel.Capacity = core.Int64Ptr(int64(100)) - volumePrototypeModel.EncryptionKey = encryptionKeyIdentityModel - - // Construct an instance of the CreateVolumeOptions model - createVolumeOptionsModel := new(vpcv1.CreateVolumeOptions) - createVolumeOptionsModel.VolumePrototype = volumePrototypeModel - createVolumeOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the CreateSnapshotCloneOptions model + createSnapshotCloneOptionsModel := new(vpcv1.CreateSnapshotCloneOptions) + createSnapshotCloneOptionsModel.ID = core.StringPtr("testString") + createSnapshotCloneOptionsModel.ZoneName = core.StringPtr("testString") + createSnapshotCloneOptionsModel.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.CreateVolumeWithContext(ctx, createVolumeOptionsModel) + _, _, operationErr := vpcService.CreateSnapshotCloneWithContext(ctx, createSnapshotCloneOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) // Disable retries and test again vpcService.DisableRetries() - result, response, operationErr := vpcService.CreateVolume(createVolumeOptionsModel) + result, response, operationErr := vpcService.CreateSnapshotClone(createSnapshotCloneOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) @@ -54696,7 +55357,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.CreateVolumeWithContext(ctx, createVolumeOptionsModel) + _, _, operationErr = vpcService.CreateSnapshotCloneWithContext(ctx, createSnapshotCloneOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) }) @@ -54710,34 +55371,18 @@ var _ = Describe(`VpcV1`, func() { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(createVolumePath)) - 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.EscapedPath()).To(Equal(createSnapshotClonePath)) + Expect(req.Method).To(Equal("PUT")) 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, "attachment_state": "attached", "bandwidth": 1000, "busy": true, "capacity": 1000, "created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::volume:1a6b7274-678d-4dfb-8981-c71dd9d4daa5", "encryption": "provider_managed", "encryption_key": {"crn": "crn:v1:bluemix:public:kms:us-south:a/123456:e4a29d1a-2ef0-42a6-8fd2-350deb1c647e:key:5437653b-c4b1-447f-9646-b2a2a4cd6179"}, "health_reasons": [{"code": "initializing_from_snapshot", "message": "Performance will be degraded while this volume is being initialized from its snapshot", "more_info": "https://cloud.ibm.com/docs/vpc?topic=vpc-snapshots-vpc-troubleshooting&interface=ui#snapshot_ts_degraded_perf"}], "health_state": "ok", "href": "https://us-south.iaas.cloud.ibm.com/v1/volumes/1a6b7274-678d-4dfb-8981-c71dd9d4daa5", "id": "1a6b7274-678d-4dfb-8981-c71dd9d4daa5", "iops": 10000, "name": "my-volume", "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"}, "profile": {"href": "https://us-south.iaas.cloud.ibm.com/v1/volume/profiles/general-purpose", "name": "general-purpose"}, "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "resource_type": "volume", "source_image": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::image:72b27b5c-f4b0-48bb-b954-5becc7c1dcb8", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/images/72b27b5c-f4b0-48bb-b954-5becc7c1dcb8", "id": "72b27b5c-f4b0-48bb-b954-5becc7c1dcb8", "name": "my-image", "remote": {"account": {"id": "aa2432b1fa4d4ace891e9b80fc104e34", "resource_type": "account"}, "region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "image"}, "source_snapshot": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "id": "r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "name": "my-snapshot", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "snapshot"}, "status": "available", "status_reasons": [{"code": "encryption_key_deleted", "message": "Message", "more_info": "https://cloud.ibm.com/docs/key-protect?topic=key-protect-restore-keys"}], "user_tags": ["UserTags"], "volume_attachments": [{"delete_volume_on_instance_delete": true, "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "device": {"id": "80b3e36e-41f4-40e9-bd56-beae81792a68"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/instances/1e09281b-f177-46fb-baf1-bc152b2e391a/volume_attachments/82cbf856-9cbb-45fb-b62f-d7bcef32399a", "id": "82cbf856-9cbb-45fb-b62f-d7bcef32399a", "instance": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::instance:1e09281b-f177-46fb-baf1-bc152b2e391a", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/instances/1e09281b-f177-46fb-baf1-bc152b2e391a", "id": "1e09281b-f177-46fb-baf1-bc152b2e391a", "name": "my-instance"}, "name": "my-volume-attachment", "type": "boot"}], "zone": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south/zones/us-south-1", "name": "us-south-1"}}`) + res.WriteHeader(200) + fmt.Fprintf(res, "%s", `{"available": false, "created_at": "2019-01-01T12:00:00.000Z", "zone": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south/zones/us-south-1", "name": "us-south-1"}}`) })) }) - It(`Invoke CreateVolume successfully`, func() { + It(`Invoke CreateSnapshotClone successfully`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -54747,51 +55392,25 @@ var _ = Describe(`VpcV1`, func() { Expect(vpcService).ToNot(BeNil()) // Invoke operation with nil options model (negative test) - result, response, operationErr := vpcService.CreateVolume(nil) + result, response, operationErr := vpcService.CreateSnapshotClone(nil) Expect(operationErr).NotTo(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) - // Construct an instance of the VolumeProfileIdentityByName model - volumeProfileIdentityModel := new(vpcv1.VolumeProfileIdentityByName) - volumeProfileIdentityModel.Name = core.StringPtr("5iops-tier") - - // Construct an instance of the ResourceGroupIdentityByID model - resourceGroupIdentityModel := new(vpcv1.ResourceGroupIdentityByID) - resourceGroupIdentityModel.ID = core.StringPtr("fee82deba12e4c0fb69c3b09d1f12345") - - // Construct an instance of the ZoneIdentityByName model - zoneIdentityModel := new(vpcv1.ZoneIdentityByName) - zoneIdentityModel.Name = core.StringPtr("us-south-1") - - // Construct an instance of the EncryptionKeyIdentityByCRN model - encryptionKeyIdentityModel := new(vpcv1.EncryptionKeyIdentityByCRN) - encryptionKeyIdentityModel.CRN = core.StringPtr("crn:v1:bluemix:public:kms:us-south:a/123456:e4a29d1a-2ef0-42a6-8fd2-350deb1c647e:key:5437653b-c4b1-447f-9646-b2a2a4cd6179") - - // Construct an instance of the VolumePrototypeVolumeByCapacity model - volumePrototypeModel := new(vpcv1.VolumePrototypeVolumeByCapacity) - volumePrototypeModel.Iops = core.Int64Ptr(int64(10000)) - volumePrototypeModel.Name = core.StringPtr("my-volume") - volumePrototypeModel.Profile = volumeProfileIdentityModel - volumePrototypeModel.ResourceGroup = resourceGroupIdentityModel - volumePrototypeModel.UserTags = []string{} - volumePrototypeModel.Zone = zoneIdentityModel - volumePrototypeModel.Capacity = core.Int64Ptr(int64(100)) - volumePrototypeModel.EncryptionKey = encryptionKeyIdentityModel - - // Construct an instance of the CreateVolumeOptions model - createVolumeOptionsModel := new(vpcv1.CreateVolumeOptions) - createVolumeOptionsModel.VolumePrototype = volumePrototypeModel - createVolumeOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the CreateSnapshotCloneOptions model + createSnapshotCloneOptionsModel := new(vpcv1.CreateSnapshotCloneOptions) + createSnapshotCloneOptionsModel.ID = core.StringPtr("testString") + createSnapshotCloneOptionsModel.ZoneName = core.StringPtr("testString") + createSnapshotCloneOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with valid options model (positive test) - result, response, operationErr = vpcService.CreateVolume(createVolumeOptionsModel) + result, response, operationErr = vpcService.CreateSnapshotClone(createSnapshotCloneOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) }) - It(`Invoke CreateVolume with error: Operation validation and request error`, func() { + It(`Invoke CreateSnapshotClone with error: Operation validation and request error`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -54800,49 +55419,23 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the VolumeProfileIdentityByName model - volumeProfileIdentityModel := new(vpcv1.VolumeProfileIdentityByName) - volumeProfileIdentityModel.Name = core.StringPtr("5iops-tier") - - // Construct an instance of the ResourceGroupIdentityByID model - resourceGroupIdentityModel := new(vpcv1.ResourceGroupIdentityByID) - resourceGroupIdentityModel.ID = core.StringPtr("fee82deba12e4c0fb69c3b09d1f12345") - - // Construct an instance of the ZoneIdentityByName model - zoneIdentityModel := new(vpcv1.ZoneIdentityByName) - zoneIdentityModel.Name = core.StringPtr("us-south-1") - - // Construct an instance of the EncryptionKeyIdentityByCRN model - encryptionKeyIdentityModel := new(vpcv1.EncryptionKeyIdentityByCRN) - encryptionKeyIdentityModel.CRN = core.StringPtr("crn:v1:bluemix:public:kms:us-south:a/123456:e4a29d1a-2ef0-42a6-8fd2-350deb1c647e:key:5437653b-c4b1-447f-9646-b2a2a4cd6179") - - // Construct an instance of the VolumePrototypeVolumeByCapacity model - volumePrototypeModel := new(vpcv1.VolumePrototypeVolumeByCapacity) - volumePrototypeModel.Iops = core.Int64Ptr(int64(10000)) - volumePrototypeModel.Name = core.StringPtr("my-volume") - volumePrototypeModel.Profile = volumeProfileIdentityModel - volumePrototypeModel.ResourceGroup = resourceGroupIdentityModel - volumePrototypeModel.UserTags = []string{} - volumePrototypeModel.Zone = zoneIdentityModel - volumePrototypeModel.Capacity = core.Int64Ptr(int64(100)) - volumePrototypeModel.EncryptionKey = encryptionKeyIdentityModel - - // Construct an instance of the CreateVolumeOptions model - createVolumeOptionsModel := new(vpcv1.CreateVolumeOptions) - createVolumeOptionsModel.VolumePrototype = volumePrototypeModel - createVolumeOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the CreateSnapshotCloneOptions model + createSnapshotCloneOptionsModel := new(vpcv1.CreateSnapshotCloneOptions) + createSnapshotCloneOptionsModel.ID = core.StringPtr("testString") + createSnapshotCloneOptionsModel.ZoneName = core.StringPtr("testString") + createSnapshotCloneOptionsModel.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.CreateVolume(createVolumeOptionsModel) + result, response, operationErr := vpcService.CreateSnapshotClone(createSnapshotCloneOptionsModel) 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 CreateVolumeOptions model with no property values - createVolumeOptionsModelNew := new(vpcv1.CreateVolumeOptions) + // Construct a second instance of the CreateSnapshotCloneOptions model with no property values + createSnapshotCloneOptionsModelNew := new(vpcv1.CreateSnapshotCloneOptions) // Invoke operation with invalid model (negative test) - result, response, operationErr = vpcService.CreateVolume(createVolumeOptionsModelNew) + result, response, operationErr = vpcService.CreateSnapshotClone(createSnapshotCloneOptionsModelNew) Expect(operationErr).ToNot(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) @@ -54857,10 +55450,10 @@ var _ = Describe(`VpcV1`, func() { defer GinkgoRecover() // Set success status code with no respoonse body - res.WriteHeader(201) + res.WriteHeader(200) })) }) - It(`Invoke CreateVolume successfully`, func() { + It(`Invoke CreateSnapshotClone successfully`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -54869,40 +55462,14 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the VolumeProfileIdentityByName model - volumeProfileIdentityModel := new(vpcv1.VolumeProfileIdentityByName) - volumeProfileIdentityModel.Name = core.StringPtr("5iops-tier") - - // Construct an instance of the ResourceGroupIdentityByID model - resourceGroupIdentityModel := new(vpcv1.ResourceGroupIdentityByID) - resourceGroupIdentityModel.ID = core.StringPtr("fee82deba12e4c0fb69c3b09d1f12345") - - // Construct an instance of the ZoneIdentityByName model - zoneIdentityModel := new(vpcv1.ZoneIdentityByName) - zoneIdentityModel.Name = core.StringPtr("us-south-1") - - // Construct an instance of the EncryptionKeyIdentityByCRN model - encryptionKeyIdentityModel := new(vpcv1.EncryptionKeyIdentityByCRN) - encryptionKeyIdentityModel.CRN = core.StringPtr("crn:v1:bluemix:public:kms:us-south:a/123456:e4a29d1a-2ef0-42a6-8fd2-350deb1c647e:key:5437653b-c4b1-447f-9646-b2a2a4cd6179") - - // Construct an instance of the VolumePrototypeVolumeByCapacity model - volumePrototypeModel := new(vpcv1.VolumePrototypeVolumeByCapacity) - volumePrototypeModel.Iops = core.Int64Ptr(int64(10000)) - volumePrototypeModel.Name = core.StringPtr("my-volume") - volumePrototypeModel.Profile = volumeProfileIdentityModel - volumePrototypeModel.ResourceGroup = resourceGroupIdentityModel - volumePrototypeModel.UserTags = []string{} - volumePrototypeModel.Zone = zoneIdentityModel - volumePrototypeModel.Capacity = core.Int64Ptr(int64(100)) - volumePrototypeModel.EncryptionKey = encryptionKeyIdentityModel - - // Construct an instance of the CreateVolumeOptions model - createVolumeOptionsModel := new(vpcv1.CreateVolumeOptions) - createVolumeOptionsModel.VolumePrototype = volumePrototypeModel - createVolumeOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the CreateSnapshotCloneOptions model + createSnapshotCloneOptionsModel := new(vpcv1.CreateSnapshotCloneOptions) + createSnapshotCloneOptionsModel.ID = core.StringPtr("testString") + createSnapshotCloneOptionsModel.ZoneName = core.StringPtr("testString") + createSnapshotCloneOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation - result, response, operationErr := vpcService.CreateVolume(createVolumeOptionsModel) + result, response, operationErr := vpcService.CreateSnapshotClone(createSnapshotCloneOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) @@ -54914,102 +55481,28 @@ var _ = Describe(`VpcV1`, func() { }) }) }) - Describe(`DeleteVolume(deleteVolumeOptions *DeleteVolumeOptions)`, func() { - version := "testString" - deleteVolumePath := "/volumes/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(deleteVolumePath)) - Expect(req.Method).To(Equal("DELETE")) - - Expect(req.Header["If-Match"]).ToNot(BeNil()) - Expect(req.Header["If-Match"][0]).To(Equal(fmt.Sprintf("%v", `W/"96d225c4-56bd-43d9-98fc-d7148e5c5028"`))) - Expect(req.URL.Query()["version"]).To(Equal([]string{"testString"})) - Expect(req.URL.Query()["generation"]).To(Equal([]string{fmt.Sprint(int64(2))})) - res.WriteHeader(204) - })) - }) - It(`Invoke DeleteVolume 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.DeleteVolume(nil) - Expect(operationErr).NotTo(BeNil()) - Expect(response).To(BeNil()) - - // Construct an instance of the DeleteVolumeOptions model - deleteVolumeOptionsModel := new(vpcv1.DeleteVolumeOptions) - deleteVolumeOptionsModel.ID = core.StringPtr("testString") - deleteVolumeOptionsModel.IfMatch = core.StringPtr(`W/"96d225c4-56bd-43d9-98fc-d7148e5c5028"`) - deleteVolumeOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} - - // Invoke operation with valid options model (positive test) - response, operationErr = vpcService.DeleteVolume(deleteVolumeOptionsModel) - Expect(operationErr).To(BeNil()) - Expect(response).ToNot(BeNil()) - }) - It(`Invoke DeleteVolume 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 DeleteVolumeOptions model - deleteVolumeOptionsModel := new(vpcv1.DeleteVolumeOptions) - deleteVolumeOptionsModel.ID = core.StringPtr("testString") - deleteVolumeOptionsModel.IfMatch = core.StringPtr(`W/"96d225c4-56bd-43d9-98fc-d7148e5c5028"`) - deleteVolumeOptionsModel.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.DeleteVolume(deleteVolumeOptionsModel) - Expect(operationErr).ToNot(BeNil()) - Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING)) - Expect(response).To(BeNil()) - // Construct a second instance of the DeleteVolumeOptions model with no property values - deleteVolumeOptionsModelNew := new(vpcv1.DeleteVolumeOptions) - // Invoke operation with invalid model (negative test) - response, operationErr = vpcService.DeleteVolume(deleteVolumeOptionsModelNew) - Expect(operationErr).ToNot(BeNil()) - Expect(response).To(BeNil()) - }) - AfterEach(func() { - testServer.Close() - }) - }) - }) - Describe(`GetVolume(getVolumeOptions *GetVolumeOptions) - Operation response error`, func() { + Describe(`ListShareProfiles(listShareProfilesOptions *ListShareProfilesOptions) - Operation response error`, func() { version := "testString" - getVolumePath := "/volumes/testString" + listShareProfilesPath := "/share/profiles" 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(getVolumePath)) + Expect(req.URL.EscapedPath()).To(Equal(listShareProfilesPath)) Expect(req.Method).To(Equal("GET")) Expect(req.URL.Query()["version"]).To(Equal([]string{"testString"})) Expect(req.URL.Query()["generation"]).To(Equal([]string{fmt.Sprint(int64(2))})) + Expect(req.URL.Query()["start"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["limit"]).To(Equal([]string{fmt.Sprint(int64(10))})) + Expect(req.URL.Query()["sort"]).To(Equal([]string{"name"})) res.Header().Set("Content-type", "application/json") res.WriteHeader(200) fmt.Fprint(res, `} this is not valid json {`) })) }) - It(`Invoke GetVolume with error: Operation response processing error`, func() { + It(`Invoke ListShareProfiles with error: Operation response processing error`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -55018,19 +55511,21 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the GetVolumeOptions model - getVolumeOptionsModel := new(vpcv1.GetVolumeOptions) - getVolumeOptionsModel.ID = core.StringPtr("testString") - getVolumeOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the ListShareProfilesOptions model + listShareProfilesOptionsModel := new(vpcv1.ListShareProfilesOptions) + listShareProfilesOptionsModel.Start = core.StringPtr("testString") + listShareProfilesOptionsModel.Limit = core.Int64Ptr(int64(10)) + listShareProfilesOptionsModel.Sort = core.StringPtr("name") + listShareProfilesOptionsModel.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.GetVolume(getVolumeOptionsModel) + result, response, operationErr := vpcService.ListShareProfiles(listShareProfilesOptionsModel) 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.GetVolume(getVolumeOptionsModel) + result, response, operationErr = vpcService.ListShareProfiles(listShareProfilesOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).To(BeNil()) @@ -55040,30 +55535,33 @@ var _ = Describe(`VpcV1`, func() { }) }) }) - Describe(`GetVolume(getVolumeOptions *GetVolumeOptions)`, func() { + Describe(`ListShareProfiles(listShareProfilesOptions *ListShareProfilesOptions)`, func() { version := "testString" - getVolumePath := "/volumes/testString" + listShareProfilesPath := "/share/profiles" 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(getVolumePath)) + Expect(req.URL.EscapedPath()).To(Equal(listShareProfilesPath)) Expect(req.Method).To(Equal("GET")) Expect(req.URL.Query()["version"]).To(Equal([]string{"testString"})) Expect(req.URL.Query()["generation"]).To(Equal([]string{fmt.Sprint(int64(2))})) + Expect(req.URL.Query()["start"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["limit"]).To(Equal([]string{fmt.Sprint(int64(10))})) + Expect(req.URL.Query()["sort"]).To(Equal([]string{"name"})) // 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, "attachment_state": "attached", "bandwidth": 1000, "busy": true, "capacity": 1000, "created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::volume:1a6b7274-678d-4dfb-8981-c71dd9d4daa5", "encryption": "provider_managed", "encryption_key": {"crn": "crn:v1:bluemix:public:kms:us-south:a/123456:e4a29d1a-2ef0-42a6-8fd2-350deb1c647e:key:5437653b-c4b1-447f-9646-b2a2a4cd6179"}, "health_reasons": [{"code": "initializing_from_snapshot", "message": "Performance will be degraded while this volume is being initialized from its snapshot", "more_info": "https://cloud.ibm.com/docs/vpc?topic=vpc-snapshots-vpc-troubleshooting&interface=ui#snapshot_ts_degraded_perf"}], "health_state": "ok", "href": "https://us-south.iaas.cloud.ibm.com/v1/volumes/1a6b7274-678d-4dfb-8981-c71dd9d4daa5", "id": "1a6b7274-678d-4dfb-8981-c71dd9d4daa5", "iops": 10000, "name": "my-volume", "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"}, "profile": {"href": "https://us-south.iaas.cloud.ibm.com/v1/volume/profiles/general-purpose", "name": "general-purpose"}, "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "resource_type": "volume", "source_image": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::image:72b27b5c-f4b0-48bb-b954-5becc7c1dcb8", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/images/72b27b5c-f4b0-48bb-b954-5becc7c1dcb8", "id": "72b27b5c-f4b0-48bb-b954-5becc7c1dcb8", "name": "my-image", "remote": {"account": {"id": "aa2432b1fa4d4ace891e9b80fc104e34", "resource_type": "account"}, "region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "image"}, "source_snapshot": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "id": "r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "name": "my-snapshot", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "snapshot"}, "status": "available", "status_reasons": [{"code": "encryption_key_deleted", "message": "Message", "more_info": "https://cloud.ibm.com/docs/key-protect?topic=key-protect-restore-keys"}], "user_tags": ["UserTags"], "volume_attachments": [{"delete_volume_on_instance_delete": true, "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "device": {"id": "80b3e36e-41f4-40e9-bd56-beae81792a68"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/instances/1e09281b-f177-46fb-baf1-bc152b2e391a/volume_attachments/82cbf856-9cbb-45fb-b62f-d7bcef32399a", "id": "82cbf856-9cbb-45fb-b62f-d7bcef32399a", "instance": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::instance:1e09281b-f177-46fb-baf1-bc152b2e391a", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/instances/1e09281b-f177-46fb-baf1-bc152b2e391a", "id": "1e09281b-f177-46fb-baf1-bc152b2e391a", "name": "my-instance"}, "name": "my-volume-attachment", "type": "boot"}], "zone": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south/zones/us-south-1", "name": "us-south-1"}}`) + fmt.Fprintf(res, "%s", `{"first": {"href": "https://us-south.iaas.cloud.ibm.com/v1/share/profiles?limit=20"}, "limit": 20, "next": {"href": "https://us-south.iaas.cloud.ibm.com/v1/share/profiles?start=9d5a91a3e2cbd233b5a5b33436855ed1&limit=20"}, "profiles": [{"capacity": {"type": "fixed", "value": 4800}, "family": "defined_performance", "href": "https://us-south.iaas.cloud.ibm.com/v1/share/profiles/tier-3iops", "iops": {"type": "fixed", "value": 4000}, "name": "tier-3iops", "resource_type": "share_profile"}], "total_count": 132}`) })) }) - It(`Invoke GetVolume successfully with retries`, func() { + It(`Invoke ListShareProfiles successfully with retries`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -55073,21 +55571,23 @@ var _ = Describe(`VpcV1`, func() { Expect(vpcService).ToNot(BeNil()) vpcService.EnableRetries(0, 0) - // Construct an instance of the GetVolumeOptions model - getVolumeOptionsModel := new(vpcv1.GetVolumeOptions) - getVolumeOptionsModel.ID = core.StringPtr("testString") - getVolumeOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the ListShareProfilesOptions model + listShareProfilesOptionsModel := new(vpcv1.ListShareProfilesOptions) + listShareProfilesOptionsModel.Start = core.StringPtr("testString") + listShareProfilesOptionsModel.Limit = core.Int64Ptr(int64(10)) + listShareProfilesOptionsModel.Sort = core.StringPtr("name") + listShareProfilesOptionsModel.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.GetVolumeWithContext(ctx, getVolumeOptionsModel) + _, _, operationErr := vpcService.ListShareProfilesWithContext(ctx, listShareProfilesOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) // Disable retries and test again vpcService.DisableRetries() - result, response, operationErr := vpcService.GetVolume(getVolumeOptionsModel) + result, response, operationErr := vpcService.ListShareProfiles(listShareProfilesOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) @@ -55095,7 +55595,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.GetVolumeWithContext(ctx, getVolumeOptionsModel) + _, _, operationErr = vpcService.ListShareProfilesWithContext(ctx, listShareProfilesOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) }) @@ -55109,18 +55609,21 @@ var _ = Describe(`VpcV1`, func() { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(getVolumePath)) + Expect(req.URL.EscapedPath()).To(Equal(listShareProfilesPath)) Expect(req.Method).To(Equal("GET")) Expect(req.URL.Query()["version"]).To(Equal([]string{"testString"})) Expect(req.URL.Query()["generation"]).To(Equal([]string{fmt.Sprint(int64(2))})) + Expect(req.URL.Query()["start"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["limit"]).To(Equal([]string{fmt.Sprint(int64(10))})) + Expect(req.URL.Query()["sort"]).To(Equal([]string{"name"})) // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"active": true, "attachment_state": "attached", "bandwidth": 1000, "busy": true, "capacity": 1000, "created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::volume:1a6b7274-678d-4dfb-8981-c71dd9d4daa5", "encryption": "provider_managed", "encryption_key": {"crn": "crn:v1:bluemix:public:kms:us-south:a/123456:e4a29d1a-2ef0-42a6-8fd2-350deb1c647e:key:5437653b-c4b1-447f-9646-b2a2a4cd6179"}, "health_reasons": [{"code": "initializing_from_snapshot", "message": "Performance will be degraded while this volume is being initialized from its snapshot", "more_info": "https://cloud.ibm.com/docs/vpc?topic=vpc-snapshots-vpc-troubleshooting&interface=ui#snapshot_ts_degraded_perf"}], "health_state": "ok", "href": "https://us-south.iaas.cloud.ibm.com/v1/volumes/1a6b7274-678d-4dfb-8981-c71dd9d4daa5", "id": "1a6b7274-678d-4dfb-8981-c71dd9d4daa5", "iops": 10000, "name": "my-volume", "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"}, "profile": {"href": "https://us-south.iaas.cloud.ibm.com/v1/volume/profiles/general-purpose", "name": "general-purpose"}, "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "resource_type": "volume", "source_image": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::image:72b27b5c-f4b0-48bb-b954-5becc7c1dcb8", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/images/72b27b5c-f4b0-48bb-b954-5becc7c1dcb8", "id": "72b27b5c-f4b0-48bb-b954-5becc7c1dcb8", "name": "my-image", "remote": {"account": {"id": "aa2432b1fa4d4ace891e9b80fc104e34", "resource_type": "account"}, "region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "image"}, "source_snapshot": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "id": "r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "name": "my-snapshot", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "snapshot"}, "status": "available", "status_reasons": [{"code": "encryption_key_deleted", "message": "Message", "more_info": "https://cloud.ibm.com/docs/key-protect?topic=key-protect-restore-keys"}], "user_tags": ["UserTags"], "volume_attachments": [{"delete_volume_on_instance_delete": true, "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "device": {"id": "80b3e36e-41f4-40e9-bd56-beae81792a68"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/instances/1e09281b-f177-46fb-baf1-bc152b2e391a/volume_attachments/82cbf856-9cbb-45fb-b62f-d7bcef32399a", "id": "82cbf856-9cbb-45fb-b62f-d7bcef32399a", "instance": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::instance:1e09281b-f177-46fb-baf1-bc152b2e391a", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/instances/1e09281b-f177-46fb-baf1-bc152b2e391a", "id": "1e09281b-f177-46fb-baf1-bc152b2e391a", "name": "my-instance"}, "name": "my-volume-attachment", "type": "boot"}], "zone": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south/zones/us-south-1", "name": "us-south-1"}}`) + fmt.Fprintf(res, "%s", `{"first": {"href": "https://us-south.iaas.cloud.ibm.com/v1/share/profiles?limit=20"}, "limit": 20, "next": {"href": "https://us-south.iaas.cloud.ibm.com/v1/share/profiles?start=9d5a91a3e2cbd233b5a5b33436855ed1&limit=20"}, "profiles": [{"capacity": {"type": "fixed", "value": 4800}, "family": "defined_performance", "href": "https://us-south.iaas.cloud.ibm.com/v1/share/profiles/tier-3iops", "iops": {"type": "fixed", "value": 4000}, "name": "tier-3iops", "resource_type": "share_profile"}], "total_count": 132}`) })) }) - It(`Invoke GetVolume successfully`, func() { + It(`Invoke ListShareProfiles successfully`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -55130,24 +55633,26 @@ var _ = Describe(`VpcV1`, func() { Expect(vpcService).ToNot(BeNil()) // Invoke operation with nil options model (negative test) - result, response, operationErr := vpcService.GetVolume(nil) + result, response, operationErr := vpcService.ListShareProfiles(nil) Expect(operationErr).NotTo(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) - // Construct an instance of the GetVolumeOptions model - getVolumeOptionsModel := new(vpcv1.GetVolumeOptions) - getVolumeOptionsModel.ID = core.StringPtr("testString") - getVolumeOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the ListShareProfilesOptions model + listShareProfilesOptionsModel := new(vpcv1.ListShareProfilesOptions) + listShareProfilesOptionsModel.Start = core.StringPtr("testString") + listShareProfilesOptionsModel.Limit = core.Int64Ptr(int64(10)) + listShareProfilesOptionsModel.Sort = core.StringPtr("name") + listShareProfilesOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with valid options model (positive test) - result, response, operationErr = vpcService.GetVolume(getVolumeOptionsModel) + result, response, operationErr = vpcService.ListShareProfiles(listShareProfilesOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) }) - It(`Invoke GetVolume with error: Operation validation and request error`, func() { + It(`Invoke ListShareProfiles with error: Operation request error`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -55156,25 +55661,20 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the GetVolumeOptions model - getVolumeOptionsModel := new(vpcv1.GetVolumeOptions) - getVolumeOptionsModel.ID = core.StringPtr("testString") - getVolumeOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the ListShareProfilesOptions model + listShareProfilesOptionsModel := new(vpcv1.ListShareProfilesOptions) + listShareProfilesOptionsModel.Start = core.StringPtr("testString") + listShareProfilesOptionsModel.Limit = core.Int64Ptr(int64(10)) + listShareProfilesOptionsModel.Sort = core.StringPtr("name") + listShareProfilesOptionsModel.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.GetVolume(getVolumeOptionsModel) + result, response, operationErr := vpcService.ListShareProfiles(listShareProfilesOptionsModel) 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 GetVolumeOptions model with no property values - getVolumeOptionsModelNew := new(vpcv1.GetVolumeOptions) - // Invoke operation with invalid model (negative test) - result, response, operationErr = vpcService.GetVolume(getVolumeOptionsModelNew) - Expect(operationErr).ToNot(BeNil()) - Expect(response).To(BeNil()) - Expect(result).To(BeNil()) }) AfterEach(func() { testServer.Close() @@ -55189,7 +55689,87 @@ var _ = Describe(`VpcV1`, func() { res.WriteHeader(200) })) }) - It(`Invoke GetVolume successfully`, func() { + It(`Invoke ListShareProfiles 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 ListShareProfilesOptions model + listShareProfilesOptionsModel := new(vpcv1.ListShareProfilesOptions) + listShareProfilesOptionsModel.Start = core.StringPtr("testString") + listShareProfilesOptionsModel.Limit = core.Int64Ptr(int64(10)) + listShareProfilesOptionsModel.Sort = core.StringPtr("name") + listShareProfilesOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation + result, response, operationErr := vpcService.ListShareProfiles(listShareProfilesOptionsModel) + 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.ShareProfileCollection) + nextObject := new(vpcv1.ShareProfileCollectionNext) + 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.ShareProfileCollection) + + 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.ShareProfileCollection) + nextObject := new(vpcv1.ShareProfileCollectionNext) + nextObject.Href = core.StringPtr("ibm.com") + responseObject.Next = nextObject + + value, err := responseObject.GetNextStart() + Expect(err).To(BeNil()) + Expect(value).To(BeNil()) + }) + }) + Context(`Using mock server endpoint - paginated response`, func() { + BeforeEach(func() { + var requestNumber int = 0 + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Verify the contents of the request + Expect(req.URL.EscapedPath()).To(Equal(listShareProfilesPath)) + Expect(req.Method).To(Equal("GET")) + + // Set mock response + res.Header().Set("Content-type", "application/json") + res.WriteHeader(200) + requestNumber++ + if requestNumber == 1 { + fmt.Fprintf(res, "%s", `{"next":{"href":"https://myhost.com/somePath?start=1"},"total_count":2,"limit":1,"profiles":[{"capacity":{"type":"fixed","value":4800},"family":"defined_performance","href":"https://us-south.iaas.cloud.ibm.com/v1/share/profiles/tier-3iops","iops":{"type":"fixed","value":4000},"name":"tier-3iops","resource_type":"share_profile"}]}`) + } else if requestNumber == 2 { + fmt.Fprintf(res, "%s", `{"total_count":2,"limit":1,"profiles":[{"capacity":{"type":"fixed","value":4800},"family":"defined_performance","href":"https://us-south.iaas.cloud.ibm.com/v1/share/profiles/tier-3iops","iops":{"type":"fixed","value":4000},"name":"tier-3iops","resource_type":"share_profile"}]}`) + } else { + res.WriteHeader(400) + } + })) + }) + It(`Use ShareProfilesPager.GetNext successfully`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -55198,37 +55778,60 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the GetVolumeOptions model - getVolumeOptionsModel := new(vpcv1.GetVolumeOptions) - getVolumeOptionsModel.ID = core.StringPtr("testString") - getVolumeOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + listShareProfilesOptionsModel := &vpcv1.ListShareProfilesOptions{ + Limit: core.Int64Ptr(int64(10)), + Sort: core.StringPtr("name"), + } - // Invoke operation - result, response, operationErr := vpcService.GetVolume(getVolumeOptionsModel) - Expect(operationErr).To(BeNil()) - Expect(response).ToNot(BeNil()) + pager, err := vpcService.NewShareProfilesPager(listShareProfilesOptionsModel) + Expect(err).To(BeNil()) + Expect(pager).ToNot(BeNil()) - // Verify a nil result - Expect(result).To(BeNil()) + var allResults []vpcv1.ShareProfile + for pager.HasNext() { + nextPage, err := pager.GetNext() + Expect(err).To(BeNil()) + Expect(nextPage).ToNot(BeNil()) + allResults = append(allResults, nextPage...) + } + Expect(len(allResults)).To(Equal(2)) }) - AfterEach(func() { - testServer.Close() + It(`Use ShareProfilesPager.GetAll successfully`, func() { + vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + Version: core.StringPtr(version), + }) + Expect(serviceErr).To(BeNil()) + Expect(vpcService).ToNot(BeNil()) + + listShareProfilesOptionsModel := &vpcv1.ListShareProfilesOptions{ + Limit: core.Int64Ptr(int64(10)), + Sort: core.StringPtr("name"), + } + + pager, err := vpcService.NewShareProfilesPager(listShareProfilesOptionsModel) + Expect(err).To(BeNil()) + Expect(pager).ToNot(BeNil()) + + allResults, err := pager.GetAll() + Expect(err).To(BeNil()) + Expect(allResults).ToNot(BeNil()) + Expect(len(allResults)).To(Equal(2)) }) }) }) - Describe(`UpdateVolume(updateVolumeOptions *UpdateVolumeOptions) - Operation response error`, func() { + Describe(`GetShareProfile(getShareProfileOptions *GetShareProfileOptions) - Operation response error`, func() { version := "testString" - updateVolumePath := "/volumes/testString" + getShareProfilePath := "/share/profiles/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(updateVolumePath)) - 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.EscapedPath()).To(Equal(getShareProfilePath)) + 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") @@ -55236,7 +55839,7 @@ var _ = Describe(`VpcV1`, func() { fmt.Fprint(res, `} this is not valid json {`) })) }) - It(`Invoke UpdateVolume with error: Operation response processing error`, func() { + It(`Invoke GetShareProfile with error: Operation response processing error`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -55245,35 +55848,19 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the VolumeProfileIdentityByName model - volumeProfileIdentityModel := new(vpcv1.VolumeProfileIdentityByName) - volumeProfileIdentityModel.Name = core.StringPtr("general-purpose") - - // Construct an instance of the VolumePatch model - volumePatchModel := new(vpcv1.VolumePatch) - volumePatchModel.Capacity = core.Int64Ptr(int64(100)) - volumePatchModel.Iops = core.Int64Ptr(int64(10000)) - volumePatchModel.Name = core.StringPtr("my-volume") - volumePatchModel.Profile = volumeProfileIdentityModel - volumePatchModel.UserTags = []string{"testString"} - volumePatchModelAsPatch, asPatchErr := volumePatchModel.AsPatch() - Expect(asPatchErr).To(BeNil()) - - // Construct an instance of the UpdateVolumeOptions model - updateVolumeOptionsModel := new(vpcv1.UpdateVolumeOptions) - updateVolumeOptionsModel.ID = core.StringPtr("testString") - updateVolumeOptionsModel.VolumePatch = volumePatchModelAsPatch - updateVolumeOptionsModel.IfMatch = core.StringPtr(`W/"96d225c4-56bd-43d9-98fc-d7148e5c5028"`) - updateVolumeOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the GetShareProfileOptions model + getShareProfileOptionsModel := new(vpcv1.GetShareProfileOptions) + getShareProfileOptionsModel.Name = core.StringPtr("testString") + getShareProfileOptionsModel.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.UpdateVolume(updateVolumeOptionsModel) + result, response, operationErr := vpcService.GetShareProfile(getShareProfileOptionsModel) 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.UpdateVolume(updateVolumeOptionsModel) + result, response, operationErr = vpcService.GetShareProfile(getShareProfileOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).To(BeNil()) @@ -55283,36 +55870,18 @@ var _ = Describe(`VpcV1`, func() { }) }) }) - Describe(`UpdateVolume(updateVolumeOptions *UpdateVolumeOptions)`, func() { + Describe(`GetShareProfile(getShareProfileOptions *GetShareProfileOptions)`, func() { version := "testString" - updateVolumePath := "/volumes/testString" + getShareProfilePath := "/share/profiles/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(updateVolumePath)) - 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.URL.EscapedPath()).To(Equal(getShareProfilePath)) + Expect(req.Method).To(Equal("GET")) - 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 @@ -55321,10 +55890,10 @@ var _ = Describe(`VpcV1`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"active": true, "attachment_state": "attached", "bandwidth": 1000, "busy": true, "capacity": 1000, "created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::volume:1a6b7274-678d-4dfb-8981-c71dd9d4daa5", "encryption": "provider_managed", "encryption_key": {"crn": "crn:v1:bluemix:public:kms:us-south:a/123456:e4a29d1a-2ef0-42a6-8fd2-350deb1c647e:key:5437653b-c4b1-447f-9646-b2a2a4cd6179"}, "health_reasons": [{"code": "initializing_from_snapshot", "message": "Performance will be degraded while this volume is being initialized from its snapshot", "more_info": "https://cloud.ibm.com/docs/vpc?topic=vpc-snapshots-vpc-troubleshooting&interface=ui#snapshot_ts_degraded_perf"}], "health_state": "ok", "href": "https://us-south.iaas.cloud.ibm.com/v1/volumes/1a6b7274-678d-4dfb-8981-c71dd9d4daa5", "id": "1a6b7274-678d-4dfb-8981-c71dd9d4daa5", "iops": 10000, "name": "my-volume", "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"}, "profile": {"href": "https://us-south.iaas.cloud.ibm.com/v1/volume/profiles/general-purpose", "name": "general-purpose"}, "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "resource_type": "volume", "source_image": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::image:72b27b5c-f4b0-48bb-b954-5becc7c1dcb8", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/images/72b27b5c-f4b0-48bb-b954-5becc7c1dcb8", "id": "72b27b5c-f4b0-48bb-b954-5becc7c1dcb8", "name": "my-image", "remote": {"account": {"id": "aa2432b1fa4d4ace891e9b80fc104e34", "resource_type": "account"}, "region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "image"}, "source_snapshot": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "id": "r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "name": "my-snapshot", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "snapshot"}, "status": "available", "status_reasons": [{"code": "encryption_key_deleted", "message": "Message", "more_info": "https://cloud.ibm.com/docs/key-protect?topic=key-protect-restore-keys"}], "user_tags": ["UserTags"], "volume_attachments": [{"delete_volume_on_instance_delete": true, "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "device": {"id": "80b3e36e-41f4-40e9-bd56-beae81792a68"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/instances/1e09281b-f177-46fb-baf1-bc152b2e391a/volume_attachments/82cbf856-9cbb-45fb-b62f-d7bcef32399a", "id": "82cbf856-9cbb-45fb-b62f-d7bcef32399a", "instance": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::instance:1e09281b-f177-46fb-baf1-bc152b2e391a", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/instances/1e09281b-f177-46fb-baf1-bc152b2e391a", "id": "1e09281b-f177-46fb-baf1-bc152b2e391a", "name": "my-instance"}, "name": "my-volume-attachment", "type": "boot"}], "zone": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south/zones/us-south-1", "name": "us-south-1"}}`) + fmt.Fprintf(res, "%s", `{"capacity": {"type": "fixed", "value": 4800}, "family": "defined_performance", "href": "https://us-south.iaas.cloud.ibm.com/v1/share/profiles/tier-3iops", "iops": {"type": "fixed", "value": 4000}, "name": "tier-3iops", "resource_type": "share_profile"}`) })) }) - It(`Invoke UpdateVolume successfully with retries`, func() { + It(`Invoke GetShareProfile successfully with retries`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -55334,37 +55903,21 @@ var _ = Describe(`VpcV1`, func() { Expect(vpcService).ToNot(BeNil()) vpcService.EnableRetries(0, 0) - // Construct an instance of the VolumeProfileIdentityByName model - volumeProfileIdentityModel := new(vpcv1.VolumeProfileIdentityByName) - volumeProfileIdentityModel.Name = core.StringPtr("general-purpose") - - // Construct an instance of the VolumePatch model - volumePatchModel := new(vpcv1.VolumePatch) - volumePatchModel.Capacity = core.Int64Ptr(int64(100)) - volumePatchModel.Iops = core.Int64Ptr(int64(10000)) - volumePatchModel.Name = core.StringPtr("my-volume") - volumePatchModel.Profile = volumeProfileIdentityModel - volumePatchModel.UserTags = []string{"testString"} - volumePatchModelAsPatch, asPatchErr := volumePatchModel.AsPatch() - Expect(asPatchErr).To(BeNil()) - - // Construct an instance of the UpdateVolumeOptions model - updateVolumeOptionsModel := new(vpcv1.UpdateVolumeOptions) - updateVolumeOptionsModel.ID = core.StringPtr("testString") - updateVolumeOptionsModel.VolumePatch = volumePatchModelAsPatch - updateVolumeOptionsModel.IfMatch = core.StringPtr(`W/"96d225c4-56bd-43d9-98fc-d7148e5c5028"`) - updateVolumeOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the GetShareProfileOptions model + getShareProfileOptionsModel := new(vpcv1.GetShareProfileOptions) + getShareProfileOptionsModel.Name = core.StringPtr("testString") + getShareProfileOptionsModel.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.UpdateVolumeWithContext(ctx, updateVolumeOptionsModel) + _, _, operationErr := vpcService.GetShareProfileWithContext(ctx, getShareProfileOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) // Disable retries and test again vpcService.DisableRetries() - result, response, operationErr := vpcService.UpdateVolume(updateVolumeOptionsModel) + result, response, operationErr := vpcService.GetShareProfile(getShareProfileOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) @@ -55372,7 +55925,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.UpdateVolumeWithContext(ctx, updateVolumeOptionsModel) + _, _, operationErr = vpcService.GetShareProfileWithContext(ctx, getShareProfileOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) }) @@ -55386,36 +55939,18 @@ var _ = Describe(`VpcV1`, func() { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(updateVolumePath)) - 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.URL.EscapedPath()).To(Equal(getShareProfilePath)) + Expect(req.Method).To(Equal("GET")) - 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, "attachment_state": "attached", "bandwidth": 1000, "busy": true, "capacity": 1000, "created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::volume:1a6b7274-678d-4dfb-8981-c71dd9d4daa5", "encryption": "provider_managed", "encryption_key": {"crn": "crn:v1:bluemix:public:kms:us-south:a/123456:e4a29d1a-2ef0-42a6-8fd2-350deb1c647e:key:5437653b-c4b1-447f-9646-b2a2a4cd6179"}, "health_reasons": [{"code": "initializing_from_snapshot", "message": "Performance will be degraded while this volume is being initialized from its snapshot", "more_info": "https://cloud.ibm.com/docs/vpc?topic=vpc-snapshots-vpc-troubleshooting&interface=ui#snapshot_ts_degraded_perf"}], "health_state": "ok", "href": "https://us-south.iaas.cloud.ibm.com/v1/volumes/1a6b7274-678d-4dfb-8981-c71dd9d4daa5", "id": "1a6b7274-678d-4dfb-8981-c71dd9d4daa5", "iops": 10000, "name": "my-volume", "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"}, "profile": {"href": "https://us-south.iaas.cloud.ibm.com/v1/volume/profiles/general-purpose", "name": "general-purpose"}, "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "resource_type": "volume", "source_image": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::image:72b27b5c-f4b0-48bb-b954-5becc7c1dcb8", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/images/72b27b5c-f4b0-48bb-b954-5becc7c1dcb8", "id": "72b27b5c-f4b0-48bb-b954-5becc7c1dcb8", "name": "my-image", "remote": {"account": {"id": "aa2432b1fa4d4ace891e9b80fc104e34", "resource_type": "account"}, "region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "image"}, "source_snapshot": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "id": "r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "name": "my-snapshot", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "snapshot"}, "status": "available", "status_reasons": [{"code": "encryption_key_deleted", "message": "Message", "more_info": "https://cloud.ibm.com/docs/key-protect?topic=key-protect-restore-keys"}], "user_tags": ["UserTags"], "volume_attachments": [{"delete_volume_on_instance_delete": true, "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "device": {"id": "80b3e36e-41f4-40e9-bd56-beae81792a68"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/instances/1e09281b-f177-46fb-baf1-bc152b2e391a/volume_attachments/82cbf856-9cbb-45fb-b62f-d7bcef32399a", "id": "82cbf856-9cbb-45fb-b62f-d7bcef32399a", "instance": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::instance:1e09281b-f177-46fb-baf1-bc152b2e391a", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/instances/1e09281b-f177-46fb-baf1-bc152b2e391a", "id": "1e09281b-f177-46fb-baf1-bc152b2e391a", "name": "my-instance"}, "name": "my-volume-attachment", "type": "boot"}], "zone": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south/zones/us-south-1", "name": "us-south-1"}}`) + fmt.Fprintf(res, "%s", `{"capacity": {"type": "fixed", "value": 4800}, "family": "defined_performance", "href": "https://us-south.iaas.cloud.ibm.com/v1/share/profiles/tier-3iops", "iops": {"type": "fixed", "value": 4000}, "name": "tier-3iops", "resource_type": "share_profile"}`) })) }) - It(`Invoke UpdateVolume successfully`, func() { + It(`Invoke GetShareProfile successfully`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -55425,40 +55960,24 @@ var _ = Describe(`VpcV1`, func() { Expect(vpcService).ToNot(BeNil()) // Invoke operation with nil options model (negative test) - result, response, operationErr := vpcService.UpdateVolume(nil) + result, response, operationErr := vpcService.GetShareProfile(nil) Expect(operationErr).NotTo(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) - // Construct an instance of the VolumeProfileIdentityByName model - volumeProfileIdentityModel := new(vpcv1.VolumeProfileIdentityByName) - volumeProfileIdentityModel.Name = core.StringPtr("general-purpose") - - // Construct an instance of the VolumePatch model - volumePatchModel := new(vpcv1.VolumePatch) - volumePatchModel.Capacity = core.Int64Ptr(int64(100)) - volumePatchModel.Iops = core.Int64Ptr(int64(10000)) - volumePatchModel.Name = core.StringPtr("my-volume") - volumePatchModel.Profile = volumeProfileIdentityModel - volumePatchModel.UserTags = []string{"testString"} - volumePatchModelAsPatch, asPatchErr := volumePatchModel.AsPatch() - Expect(asPatchErr).To(BeNil()) - - // Construct an instance of the UpdateVolumeOptions model - updateVolumeOptionsModel := new(vpcv1.UpdateVolumeOptions) - updateVolumeOptionsModel.ID = core.StringPtr("testString") - updateVolumeOptionsModel.VolumePatch = volumePatchModelAsPatch - updateVolumeOptionsModel.IfMatch = core.StringPtr(`W/"96d225c4-56bd-43d9-98fc-d7148e5c5028"`) - updateVolumeOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the GetShareProfileOptions model + getShareProfileOptionsModel := new(vpcv1.GetShareProfileOptions) + getShareProfileOptionsModel.Name = core.StringPtr("testString") + getShareProfileOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with valid options model (positive test) - result, response, operationErr = vpcService.UpdateVolume(updateVolumeOptionsModel) + result, response, operationErr = vpcService.GetShareProfile(getShareProfileOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) }) - It(`Invoke UpdateVolume with error: Operation validation and request error`, func() { + It(`Invoke GetShareProfile with error: Operation validation and request error`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -55467,38 +55986,22 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the VolumeProfileIdentityByName model - volumeProfileIdentityModel := new(vpcv1.VolumeProfileIdentityByName) - volumeProfileIdentityModel.Name = core.StringPtr("general-purpose") - - // Construct an instance of the VolumePatch model - volumePatchModel := new(vpcv1.VolumePatch) - volumePatchModel.Capacity = core.Int64Ptr(int64(100)) - volumePatchModel.Iops = core.Int64Ptr(int64(10000)) - volumePatchModel.Name = core.StringPtr("my-volume") - volumePatchModel.Profile = volumeProfileIdentityModel - volumePatchModel.UserTags = []string{"testString"} - volumePatchModelAsPatch, asPatchErr := volumePatchModel.AsPatch() - Expect(asPatchErr).To(BeNil()) - - // Construct an instance of the UpdateVolumeOptions model - updateVolumeOptionsModel := new(vpcv1.UpdateVolumeOptions) - updateVolumeOptionsModel.ID = core.StringPtr("testString") - updateVolumeOptionsModel.VolumePatch = volumePatchModelAsPatch - updateVolumeOptionsModel.IfMatch = core.StringPtr(`W/"96d225c4-56bd-43d9-98fc-d7148e5c5028"`) - updateVolumeOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the GetShareProfileOptions model + getShareProfileOptionsModel := new(vpcv1.GetShareProfileOptions) + getShareProfileOptionsModel.Name = core.StringPtr("testString") + getShareProfileOptionsModel.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.UpdateVolume(updateVolumeOptionsModel) + result, response, operationErr := vpcService.GetShareProfile(getShareProfileOptionsModel) 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 UpdateVolumeOptions model with no property values - updateVolumeOptionsModelNew := new(vpcv1.UpdateVolumeOptions) + // Construct a second instance of the GetShareProfileOptions model with no property values + getShareProfileOptionsModelNew := new(vpcv1.GetShareProfileOptions) // Invoke operation with invalid model (negative test) - result, response, operationErr = vpcService.UpdateVolume(updateVolumeOptionsModelNew) + result, response, operationErr = vpcService.GetShareProfile(getShareProfileOptionsModelNew) Expect(operationErr).ToNot(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) @@ -55516,7 +56019,7 @@ var _ = Describe(`VpcV1`, func() { res.WriteHeader(200) })) }) - It(`Invoke UpdateVolume successfully`, func() { + It(`Invoke GetShareProfile successfully`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -55525,29 +56028,13 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the VolumeProfileIdentityByName model - volumeProfileIdentityModel := new(vpcv1.VolumeProfileIdentityByName) - volumeProfileIdentityModel.Name = core.StringPtr("general-purpose") - - // Construct an instance of the VolumePatch model - volumePatchModel := new(vpcv1.VolumePatch) - volumePatchModel.Capacity = core.Int64Ptr(int64(100)) - volumePatchModel.Iops = core.Int64Ptr(int64(10000)) - volumePatchModel.Name = core.StringPtr("my-volume") - volumePatchModel.Profile = volumeProfileIdentityModel - volumePatchModel.UserTags = []string{"testString"} - volumePatchModelAsPatch, asPatchErr := volumePatchModel.AsPatch() - Expect(asPatchErr).To(BeNil()) - - // Construct an instance of the UpdateVolumeOptions model - updateVolumeOptionsModel := new(vpcv1.UpdateVolumeOptions) - updateVolumeOptionsModel.ID = core.StringPtr("testString") - updateVolumeOptionsModel.VolumePatch = volumePatchModelAsPatch - updateVolumeOptionsModel.IfMatch = core.StringPtr(`W/"96d225c4-56bd-43d9-98fc-d7148e5c5028"`) - updateVolumeOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the GetShareProfileOptions model + getShareProfileOptionsModel := new(vpcv1.GetShareProfileOptions) + getShareProfileOptionsModel.Name = core.StringPtr("testString") + getShareProfileOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation - result, response, operationErr := vpcService.UpdateVolume(updateVolumeOptionsModel) + result, response, operationErr := vpcService.GetShareProfile(getShareProfileOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) @@ -55559,16 +56046,16 @@ var _ = Describe(`VpcV1`, func() { }) }) }) - Describe(`ListSnapshotConsistencyGroups(listSnapshotConsistencyGroupsOptions *ListSnapshotConsistencyGroupsOptions) - Operation response error`, func() { + Describe(`ListShares(listSharesOptions *ListSharesOptions) - Operation response error`, func() { version := "testString" - listSnapshotConsistencyGroupsPath := "/snapshot_consistency_groups" + listSharesPath := "/shares" 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(listSnapshotConsistencyGroupsPath)) + Expect(req.URL.EscapedPath()).To(Equal(listSharesPath)) 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))})) @@ -55577,13 +56064,13 @@ var _ = Describe(`VpcV1`, func() { Expect(req.URL.Query()["resource_group.id"]).To(Equal([]string{"testString"})) Expect(req.URL.Query()["name"]).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"})) + Expect(req.URL.Query()["replication_role"]).To(Equal([]string{"none"})) res.Header().Set("Content-type", "application/json") res.WriteHeader(200) fmt.Fprint(res, `} this is not valid json {`) })) }) - It(`Invoke ListSnapshotConsistencyGroups with error: Operation response processing error`, func() { + It(`Invoke ListShares with error: Operation response processing error`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -55592,24 +56079,24 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the ListSnapshotConsistencyGroupsOptions model - listSnapshotConsistencyGroupsOptionsModel := new(vpcv1.ListSnapshotConsistencyGroupsOptions) - listSnapshotConsistencyGroupsOptionsModel.Start = core.StringPtr("testString") - listSnapshotConsistencyGroupsOptionsModel.Limit = core.Int64Ptr(int64(10)) - listSnapshotConsistencyGroupsOptionsModel.ResourceGroupID = core.StringPtr("testString") - listSnapshotConsistencyGroupsOptionsModel.Name = core.StringPtr("testString") - listSnapshotConsistencyGroupsOptionsModel.Sort = core.StringPtr("name") - listSnapshotConsistencyGroupsOptionsModel.BackupPolicyPlanID = core.StringPtr("testString") - listSnapshotConsistencyGroupsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the ListSharesOptions model + listSharesOptionsModel := new(vpcv1.ListSharesOptions) + listSharesOptionsModel.Start = core.StringPtr("testString") + listSharesOptionsModel.Limit = core.Int64Ptr(int64(10)) + listSharesOptionsModel.ResourceGroupID = core.StringPtr("testString") + listSharesOptionsModel.Name = core.StringPtr("testString") + listSharesOptionsModel.Sort = core.StringPtr("name") + listSharesOptionsModel.ReplicationRole = core.StringPtr("none") + listSharesOptionsModel.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.ListSnapshotConsistencyGroups(listSnapshotConsistencyGroupsOptionsModel) + result, response, operationErr := vpcService.ListShares(listSharesOptionsModel) 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.ListSnapshotConsistencyGroups(listSnapshotConsistencyGroupsOptionsModel) + result, response, operationErr = vpcService.ListShares(listSharesOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).To(BeNil()) @@ -55619,16 +56106,16 @@ var _ = Describe(`VpcV1`, func() { }) }) }) - Describe(`ListSnapshotConsistencyGroups(listSnapshotConsistencyGroupsOptions *ListSnapshotConsistencyGroupsOptions)`, func() { + Describe(`ListShares(listSharesOptions *ListSharesOptions)`, func() { version := "testString" - listSnapshotConsistencyGroupsPath := "/snapshot_consistency_groups" + listSharesPath := "/shares" 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(listSnapshotConsistencyGroupsPath)) + Expect(req.URL.EscapedPath()).To(Equal(listSharesPath)) Expect(req.Method).To(Equal("GET")) Expect(req.URL.Query()["version"]).To(Equal([]string{"testString"})) @@ -55638,17 +56125,17 @@ var _ = Describe(`VpcV1`, func() { Expect(req.URL.Query()["resource_group.id"]).To(Equal([]string{"testString"})) Expect(req.URL.Query()["name"]).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"})) + Expect(req.URL.Query()["replication_role"]).To(Equal([]string{"none"})) // 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/snapshot_consistency_groups?limit=20"}, "limit": 20, "next": {"href": "https://us-south.iaas.cloud.ibm.com/v1/snapshot_consistency_groups?start=9d5a91a3e2cbd233b5a5b33436855ed1&limit=20"}, "snapshot_consistency_groups": [{"backup_policy_plan": {"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6/plans/r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "id": "r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "name": "my-policy-plan", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "backup_policy_plan"}, "created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot-consistency-group:r134-fa329f6b-0e36-433f-a3bb-0df632e79263", "delete_snapshots_on_delete": false, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshot_consistency_groups/r134-fa329f6b-0e36-433f-a3bb-0df632e79263", "id": "r134-fa329f6b-0e36-433f-a3bb-0df632e79263", "lifecycle_state": "stable", "name": "my-snapshot-consistency-group", "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "resource_type": "snapshot_consistency_group", "service_tags": ["ServiceTags"], "snapshots": [{"crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "id": "r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "name": "my-snapshot", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "snapshot"}]}], "total_count": 132}`) + fmt.Fprintf(res, "%s", `{"first": {"href": "https://us-south.iaas.cloud.ibm.com/v1/shares?limit=20"}, "limit": 20, "next": {"href": "https://us-south.iaas.cloud.ibm.com/v1/shares?start=9d5a91a3e2cbd233b5a5b33436855ed1&limit=20"}, "shares": [{"access_control_mode": "security_group", "created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::share:0fe9e5d8-0a4d-4818-96ec-e99708644a58", "encryption": "provider_managed", "encryption_key": {"crn": "crn:v1:bluemix:public:kms:us-south:a/123456:e4a29d1a-2ef0-42a6-8fd2-350deb1c647e:key:5437653b-c4b1-447f-9646-b2a2a4cd6179"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/shares/0fe9e5d8-0a4d-4818-96ec-e99708644a58", "id": "0fe9e5d8-0a4d-4818-96ec-e99708644a58", "iops": 100, "latest_job": {"status": "cancelled", "status_reasons": [{"code": "cannot_reach_source_share", "message": "The replication failover failed because the source share cannot be reached.", "more_info": "https://cloud.ibm.com/docs/vpc?topic=vpc-file-storage-planning"}], "type": "replication_failover"}, "latest_sync": {"completed_at": "2019-01-01T12:00:00.000Z", "data_transferred": 0, "started_at": "2019-01-01T12:00:00.000Z"}, "lifecycle_state": "stable", "mount_targets": [{"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/shares/0fe9e5d8-0a4d-4818-96ec-e99708644a58/mount_targets/4cf9171a-0043-4434-8727-15b53dbc374c", "id": "4cf9171a-0043-4434-8727-15b53dbc374c", "name": "my-share-mount-target", "resource_type": "share_mount_target"}], "name": "my-share", "profile": {"href": "https://us-south.iaas.cloud.ibm.com/v1/share/profiles/tier-3iops", "name": "tier-3iops", "resource_type": "share_profile"}, "replica_share": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::share:0fe9e5d8-0a4d-4818-96ec-e99708644a58", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/shares/0fe9e5d8-0a4d-4818-96ec-e99708644a58", "id": "0fe9e5d8-0a4d-4818-96ec-e99708644a58", "name": "my-share", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "share"}, "replication_cron_spec": "0 */5 * * *", "replication_role": "none", "replication_status": "active", "replication_status_reasons": [{"code": "cannot_reach_source_share", "message": "The replication failover failed because the source share cannot be reached.", "more_info": "https://cloud.ibm.com/docs/vpc?topic=vpc-file-storage-planning"}], "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "resource_type": "share", "size": 200, "source_share": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::share:0fe9e5d8-0a4d-4818-96ec-e99708644a58", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/shares/0fe9e5d8-0a4d-4818-96ec-e99708644a58", "id": "0fe9e5d8-0a4d-4818-96ec-e99708644a58", "name": "my-share", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "share"}, "user_tags": ["UserTags"], "zone": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south/zones/us-south-1", "name": "us-south-1"}}], "total_count": 132}`) })) }) - It(`Invoke ListSnapshotConsistencyGroups successfully with retries`, func() { + It(`Invoke ListShares successfully with retries`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -55658,26 +56145,26 @@ var _ = Describe(`VpcV1`, func() { Expect(vpcService).ToNot(BeNil()) vpcService.EnableRetries(0, 0) - // Construct an instance of the ListSnapshotConsistencyGroupsOptions model - listSnapshotConsistencyGroupsOptionsModel := new(vpcv1.ListSnapshotConsistencyGroupsOptions) - listSnapshotConsistencyGroupsOptionsModel.Start = core.StringPtr("testString") - listSnapshotConsistencyGroupsOptionsModel.Limit = core.Int64Ptr(int64(10)) - listSnapshotConsistencyGroupsOptionsModel.ResourceGroupID = core.StringPtr("testString") - listSnapshotConsistencyGroupsOptionsModel.Name = core.StringPtr("testString") - listSnapshotConsistencyGroupsOptionsModel.Sort = core.StringPtr("name") - listSnapshotConsistencyGroupsOptionsModel.BackupPolicyPlanID = core.StringPtr("testString") - listSnapshotConsistencyGroupsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the ListSharesOptions model + listSharesOptionsModel := new(vpcv1.ListSharesOptions) + listSharesOptionsModel.Start = core.StringPtr("testString") + listSharesOptionsModel.Limit = core.Int64Ptr(int64(10)) + listSharesOptionsModel.ResourceGroupID = core.StringPtr("testString") + listSharesOptionsModel.Name = core.StringPtr("testString") + listSharesOptionsModel.Sort = core.StringPtr("name") + listSharesOptionsModel.ReplicationRole = core.StringPtr("none") + listSharesOptionsModel.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.ListSnapshotConsistencyGroupsWithContext(ctx, listSnapshotConsistencyGroupsOptionsModel) + _, _, operationErr := vpcService.ListSharesWithContext(ctx, listSharesOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) // Disable retries and test again vpcService.DisableRetries() - result, response, operationErr := vpcService.ListSnapshotConsistencyGroups(listSnapshotConsistencyGroupsOptionsModel) + result, response, operationErr := vpcService.ListShares(listSharesOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) @@ -55685,7 +56172,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.ListSnapshotConsistencyGroupsWithContext(ctx, listSnapshotConsistencyGroupsOptionsModel) + _, _, operationErr = vpcService.ListSharesWithContext(ctx, listSharesOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) }) @@ -55699,7 +56186,7 @@ var _ = Describe(`VpcV1`, func() { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(listSnapshotConsistencyGroupsPath)) + Expect(req.URL.EscapedPath()).To(Equal(listSharesPath)) Expect(req.Method).To(Equal("GET")) Expect(req.URL.Query()["version"]).To(Equal([]string{"testString"})) @@ -55709,14 +56196,14 @@ var _ = Describe(`VpcV1`, func() { Expect(req.URL.Query()["resource_group.id"]).To(Equal([]string{"testString"})) Expect(req.URL.Query()["name"]).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"})) + Expect(req.URL.Query()["replication_role"]).To(Equal([]string{"none"})) // 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/snapshot_consistency_groups?limit=20"}, "limit": 20, "next": {"href": "https://us-south.iaas.cloud.ibm.com/v1/snapshot_consistency_groups?start=9d5a91a3e2cbd233b5a5b33436855ed1&limit=20"}, "snapshot_consistency_groups": [{"backup_policy_plan": {"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6/plans/r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "id": "r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "name": "my-policy-plan", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "backup_policy_plan"}, "created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot-consistency-group:r134-fa329f6b-0e36-433f-a3bb-0df632e79263", "delete_snapshots_on_delete": false, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshot_consistency_groups/r134-fa329f6b-0e36-433f-a3bb-0df632e79263", "id": "r134-fa329f6b-0e36-433f-a3bb-0df632e79263", "lifecycle_state": "stable", "name": "my-snapshot-consistency-group", "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "resource_type": "snapshot_consistency_group", "service_tags": ["ServiceTags"], "snapshots": [{"crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "id": "r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "name": "my-snapshot", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "snapshot"}]}], "total_count": 132}`) + fmt.Fprintf(res, "%s", `{"first": {"href": "https://us-south.iaas.cloud.ibm.com/v1/shares?limit=20"}, "limit": 20, "next": {"href": "https://us-south.iaas.cloud.ibm.com/v1/shares?start=9d5a91a3e2cbd233b5a5b33436855ed1&limit=20"}, "shares": [{"access_control_mode": "security_group", "created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::share:0fe9e5d8-0a4d-4818-96ec-e99708644a58", "encryption": "provider_managed", "encryption_key": {"crn": "crn:v1:bluemix:public:kms:us-south:a/123456:e4a29d1a-2ef0-42a6-8fd2-350deb1c647e:key:5437653b-c4b1-447f-9646-b2a2a4cd6179"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/shares/0fe9e5d8-0a4d-4818-96ec-e99708644a58", "id": "0fe9e5d8-0a4d-4818-96ec-e99708644a58", "iops": 100, "latest_job": {"status": "cancelled", "status_reasons": [{"code": "cannot_reach_source_share", "message": "The replication failover failed because the source share cannot be reached.", "more_info": "https://cloud.ibm.com/docs/vpc?topic=vpc-file-storage-planning"}], "type": "replication_failover"}, "latest_sync": {"completed_at": "2019-01-01T12:00:00.000Z", "data_transferred": 0, "started_at": "2019-01-01T12:00:00.000Z"}, "lifecycle_state": "stable", "mount_targets": [{"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/shares/0fe9e5d8-0a4d-4818-96ec-e99708644a58/mount_targets/4cf9171a-0043-4434-8727-15b53dbc374c", "id": "4cf9171a-0043-4434-8727-15b53dbc374c", "name": "my-share-mount-target", "resource_type": "share_mount_target"}], "name": "my-share", "profile": {"href": "https://us-south.iaas.cloud.ibm.com/v1/share/profiles/tier-3iops", "name": "tier-3iops", "resource_type": "share_profile"}, "replica_share": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::share:0fe9e5d8-0a4d-4818-96ec-e99708644a58", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/shares/0fe9e5d8-0a4d-4818-96ec-e99708644a58", "id": "0fe9e5d8-0a4d-4818-96ec-e99708644a58", "name": "my-share", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "share"}, "replication_cron_spec": "0 */5 * * *", "replication_role": "none", "replication_status": "active", "replication_status_reasons": [{"code": "cannot_reach_source_share", "message": "The replication failover failed because the source share cannot be reached.", "more_info": "https://cloud.ibm.com/docs/vpc?topic=vpc-file-storage-planning"}], "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "resource_type": "share", "size": 200, "source_share": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::share:0fe9e5d8-0a4d-4818-96ec-e99708644a58", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/shares/0fe9e5d8-0a4d-4818-96ec-e99708644a58", "id": "0fe9e5d8-0a4d-4818-96ec-e99708644a58", "name": "my-share", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "share"}, "user_tags": ["UserTags"], "zone": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south/zones/us-south-1", "name": "us-south-1"}}], "total_count": 132}`) })) }) - It(`Invoke ListSnapshotConsistencyGroups successfully`, func() { + It(`Invoke ListShares successfully`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -55726,29 +56213,29 @@ var _ = Describe(`VpcV1`, func() { Expect(vpcService).ToNot(BeNil()) // Invoke operation with nil options model (negative test) - result, response, operationErr := vpcService.ListSnapshotConsistencyGroups(nil) + result, response, operationErr := vpcService.ListShares(nil) Expect(operationErr).NotTo(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) - // Construct an instance of the ListSnapshotConsistencyGroupsOptions model - listSnapshotConsistencyGroupsOptionsModel := new(vpcv1.ListSnapshotConsistencyGroupsOptions) - listSnapshotConsistencyGroupsOptionsModel.Start = core.StringPtr("testString") - listSnapshotConsistencyGroupsOptionsModel.Limit = core.Int64Ptr(int64(10)) - listSnapshotConsistencyGroupsOptionsModel.ResourceGroupID = core.StringPtr("testString") - listSnapshotConsistencyGroupsOptionsModel.Name = core.StringPtr("testString") - listSnapshotConsistencyGroupsOptionsModel.Sort = core.StringPtr("name") - listSnapshotConsistencyGroupsOptionsModel.BackupPolicyPlanID = core.StringPtr("testString") - listSnapshotConsistencyGroupsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the ListSharesOptions model + listSharesOptionsModel := new(vpcv1.ListSharesOptions) + listSharesOptionsModel.Start = core.StringPtr("testString") + listSharesOptionsModel.Limit = core.Int64Ptr(int64(10)) + listSharesOptionsModel.ResourceGroupID = core.StringPtr("testString") + listSharesOptionsModel.Name = core.StringPtr("testString") + listSharesOptionsModel.Sort = core.StringPtr("name") + listSharesOptionsModel.ReplicationRole = core.StringPtr("none") + listSharesOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with valid options model (positive test) - result, response, operationErr = vpcService.ListSnapshotConsistencyGroups(listSnapshotConsistencyGroupsOptionsModel) + result, response, operationErr = vpcService.ListShares(listSharesOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) }) - It(`Invoke ListSnapshotConsistencyGroups with error: Operation request error`, func() { + It(`Invoke ListShares with error: Operation request error`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -55757,19 +56244,19 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the ListSnapshotConsistencyGroupsOptions model - listSnapshotConsistencyGroupsOptionsModel := new(vpcv1.ListSnapshotConsistencyGroupsOptions) - listSnapshotConsistencyGroupsOptionsModel.Start = core.StringPtr("testString") - listSnapshotConsistencyGroupsOptionsModel.Limit = core.Int64Ptr(int64(10)) - listSnapshotConsistencyGroupsOptionsModel.ResourceGroupID = core.StringPtr("testString") - listSnapshotConsistencyGroupsOptionsModel.Name = core.StringPtr("testString") - listSnapshotConsistencyGroupsOptionsModel.Sort = core.StringPtr("name") - listSnapshotConsistencyGroupsOptionsModel.BackupPolicyPlanID = core.StringPtr("testString") - listSnapshotConsistencyGroupsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the ListSharesOptions model + listSharesOptionsModel := new(vpcv1.ListSharesOptions) + listSharesOptionsModel.Start = core.StringPtr("testString") + listSharesOptionsModel.Limit = core.Int64Ptr(int64(10)) + listSharesOptionsModel.ResourceGroupID = core.StringPtr("testString") + listSharesOptionsModel.Name = core.StringPtr("testString") + listSharesOptionsModel.Sort = core.StringPtr("name") + listSharesOptionsModel.ReplicationRole = core.StringPtr("none") + listSharesOptionsModel.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.ListSnapshotConsistencyGroups(listSnapshotConsistencyGroupsOptionsModel) + result, response, operationErr := vpcService.ListShares(listSharesOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING)) Expect(response).To(BeNil()) @@ -55788,7 +56275,7 @@ var _ = Describe(`VpcV1`, func() { res.WriteHeader(200) })) }) - It(`Invoke ListSnapshotConsistencyGroups successfully`, func() { + It(`Invoke ListShares successfully`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -55797,18 +56284,18 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the ListSnapshotConsistencyGroupsOptions model - listSnapshotConsistencyGroupsOptionsModel := new(vpcv1.ListSnapshotConsistencyGroupsOptions) - listSnapshotConsistencyGroupsOptionsModel.Start = core.StringPtr("testString") - listSnapshotConsistencyGroupsOptionsModel.Limit = core.Int64Ptr(int64(10)) - listSnapshotConsistencyGroupsOptionsModel.ResourceGroupID = core.StringPtr("testString") - listSnapshotConsistencyGroupsOptionsModel.Name = core.StringPtr("testString") - listSnapshotConsistencyGroupsOptionsModel.Sort = core.StringPtr("name") - listSnapshotConsistencyGroupsOptionsModel.BackupPolicyPlanID = core.StringPtr("testString") - listSnapshotConsistencyGroupsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the ListSharesOptions model + listSharesOptionsModel := new(vpcv1.ListSharesOptions) + listSharesOptionsModel.Start = core.StringPtr("testString") + listSharesOptionsModel.Limit = core.Int64Ptr(int64(10)) + listSharesOptionsModel.ResourceGroupID = core.StringPtr("testString") + listSharesOptionsModel.Name = core.StringPtr("testString") + listSharesOptionsModel.Sort = core.StringPtr("name") + listSharesOptionsModel.ReplicationRole = core.StringPtr("none") + listSharesOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation - result, response, operationErr := vpcService.ListSnapshotConsistencyGroups(listSnapshotConsistencyGroupsOptionsModel) + result, response, operationErr := vpcService.ListShares(listSharesOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) @@ -55821,8 +56308,8 @@ var _ = Describe(`VpcV1`, func() { }) Context(`Test pagination helper method on response`, func() { It(`Invoke GetNextStart successfully`, func() { - responseObject := new(vpcv1.SnapshotConsistencyGroupCollection) - nextObject := new(vpcv1.SnapshotConsistencyGroupCollectionNext) + responseObject := new(vpcv1.ShareCollection) + nextObject := new(vpcv1.ShareCollectionNext) nextObject.Href = core.StringPtr("ibm.com?start=abc-123") responseObject.Next = nextObject @@ -55831,15 +56318,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.SnapshotConsistencyGroupCollection) + responseObject := new(vpcv1.ShareCollection) 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.SnapshotConsistencyGroupCollection) - nextObject := new(vpcv1.SnapshotConsistencyGroupCollectionNext) + responseObject := new(vpcv1.ShareCollection) + nextObject := new(vpcv1.ShareCollectionNext) nextObject.Href = core.StringPtr("ibm.com") responseObject.Next = nextObject @@ -55855,7 +56342,7 @@ var _ = Describe(`VpcV1`, func() { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(listSnapshotConsistencyGroupsPath)) + Expect(req.URL.EscapedPath()).To(Equal(listSharesPath)) Expect(req.Method).To(Equal("GET")) // Set mock response @@ -55863,15 +56350,15 @@ var _ = Describe(`VpcV1`, func() { res.WriteHeader(200) requestNumber++ if requestNumber == 1 { - fmt.Fprintf(res, "%s", `{"next":{"href":"https://myhost.com/somePath?start=1"},"snapshot_consistency_groups":[{"backup_policy_plan":{"deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6/plans/r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178","id":"r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178","name":"my-policy-plan","remote":{"region":{"href":"https://us-south.iaas.cloud.ibm.com/v1/regions/us-south","name":"us-south"}},"resource_type":"backup_policy_plan"},"created_at":"2019-01-01T12:00:00.000Z","crn":"crn:v1:bluemix:public:is:us-south:a/123456::snapshot-consistency-group:r134-fa329f6b-0e36-433f-a3bb-0df632e79263","delete_snapshots_on_delete":false,"href":"https://us-south.iaas.cloud.ibm.com/v1/snapshot_consistency_groups/r134-fa329f6b-0e36-433f-a3bb-0df632e79263","id":"r134-fa329f6b-0e36-433f-a3bb-0df632e79263","lifecycle_state":"stable","name":"my-snapshot-consistency-group","resource_group":{"href":"https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345","id":"fee82deba12e4c0fb69c3b09d1f12345","name":"my-resource-group"},"resource_type":"snapshot_consistency_group","service_tags":["ServiceTags"],"snapshots":[{"crn":"crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263","deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263","id":"r134-f6bfa329-0e36-433f-a3bb-0df632e79263","name":"my-snapshot","remote":{"region":{"href":"https://us-south.iaas.cloud.ibm.com/v1/regions/us-south","name":"us-south"}},"resource_type":"snapshot"}]}],"total_count":2,"limit":1}`) + fmt.Fprintf(res, "%s", `{"shares":[{"access_control_mode":"security_group","created_at":"2019-01-01T12:00:00.000Z","crn":"crn:v1:bluemix:public:is:us-south-1:a/123456::share:0fe9e5d8-0a4d-4818-96ec-e99708644a58","encryption":"provider_managed","encryption_key":{"crn":"crn:v1:bluemix:public:kms:us-south:a/123456:e4a29d1a-2ef0-42a6-8fd2-350deb1c647e:key:5437653b-c4b1-447f-9646-b2a2a4cd6179"},"href":"https://us-south.iaas.cloud.ibm.com/v1/shares/0fe9e5d8-0a4d-4818-96ec-e99708644a58","id":"0fe9e5d8-0a4d-4818-96ec-e99708644a58","iops":100,"latest_job":{"status":"cancelled","status_reasons":[{"code":"cannot_reach_source_share","message":"The replication failover failed because the source share cannot be reached.","more_info":"https://cloud.ibm.com/docs/vpc?topic=vpc-file-storage-planning"}],"type":"replication_failover"},"latest_sync":{"completed_at":"2019-01-01T12:00:00.000Z","data_transferred":0,"started_at":"2019-01-01T12:00:00.000Z"},"lifecycle_state":"stable","mount_targets":[{"deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/shares/0fe9e5d8-0a4d-4818-96ec-e99708644a58/mount_targets/4cf9171a-0043-4434-8727-15b53dbc374c","id":"4cf9171a-0043-4434-8727-15b53dbc374c","name":"my-share-mount-target","resource_type":"share_mount_target"}],"name":"my-share","profile":{"href":"https://us-south.iaas.cloud.ibm.com/v1/share/profiles/tier-3iops","name":"tier-3iops","resource_type":"share_profile"},"replica_share":{"crn":"crn:v1:bluemix:public:is:us-south-1:a/123456::share:0fe9e5d8-0a4d-4818-96ec-e99708644a58","deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/shares/0fe9e5d8-0a4d-4818-96ec-e99708644a58","id":"0fe9e5d8-0a4d-4818-96ec-e99708644a58","name":"my-share","remote":{"region":{"href":"https://us-south.iaas.cloud.ibm.com/v1/regions/us-south","name":"us-south"}},"resource_type":"share"},"replication_cron_spec":"0 */5 * * *","replication_role":"none","replication_status":"active","replication_status_reasons":[{"code":"cannot_reach_source_share","message":"The replication failover failed because the source share cannot be reached.","more_info":"https://cloud.ibm.com/docs/vpc?topic=vpc-file-storage-planning"}],"resource_group":{"href":"https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345","id":"fee82deba12e4c0fb69c3b09d1f12345","name":"my-resource-group"},"resource_type":"share","size":200,"source_share":{"crn":"crn:v1:bluemix:public:is:us-south-1:a/123456::share:0fe9e5d8-0a4d-4818-96ec-e99708644a58","deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/shares/0fe9e5d8-0a4d-4818-96ec-e99708644a58","id":"0fe9e5d8-0a4d-4818-96ec-e99708644a58","name":"my-share","remote":{"region":{"href":"https://us-south.iaas.cloud.ibm.com/v1/regions/us-south","name":"us-south"}},"resource_type":"share"},"user_tags":["UserTags"],"zone":{"href":"https://us-south.iaas.cloud.ibm.com/v1/regions/us-south/zones/us-south-1","name":"us-south-1"}}],"next":{"href":"https://myhost.com/somePath?start=1"},"total_count":2,"limit":1}`) } else if requestNumber == 2 { - fmt.Fprintf(res, "%s", `{"snapshot_consistency_groups":[{"backup_policy_plan":{"deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6/plans/r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178","id":"r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178","name":"my-policy-plan","remote":{"region":{"href":"https://us-south.iaas.cloud.ibm.com/v1/regions/us-south","name":"us-south"}},"resource_type":"backup_policy_plan"},"created_at":"2019-01-01T12:00:00.000Z","crn":"crn:v1:bluemix:public:is:us-south:a/123456::snapshot-consistency-group:r134-fa329f6b-0e36-433f-a3bb-0df632e79263","delete_snapshots_on_delete":false,"href":"https://us-south.iaas.cloud.ibm.com/v1/snapshot_consistency_groups/r134-fa329f6b-0e36-433f-a3bb-0df632e79263","id":"r134-fa329f6b-0e36-433f-a3bb-0df632e79263","lifecycle_state":"stable","name":"my-snapshot-consistency-group","resource_group":{"href":"https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345","id":"fee82deba12e4c0fb69c3b09d1f12345","name":"my-resource-group"},"resource_type":"snapshot_consistency_group","service_tags":["ServiceTags"],"snapshots":[{"crn":"crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263","deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263","id":"r134-f6bfa329-0e36-433f-a3bb-0df632e79263","name":"my-snapshot","remote":{"region":{"href":"https://us-south.iaas.cloud.ibm.com/v1/regions/us-south","name":"us-south"}},"resource_type":"snapshot"}]}],"total_count":2,"limit":1}`) + fmt.Fprintf(res, "%s", `{"shares":[{"access_control_mode":"security_group","created_at":"2019-01-01T12:00:00.000Z","crn":"crn:v1:bluemix:public:is:us-south-1:a/123456::share:0fe9e5d8-0a4d-4818-96ec-e99708644a58","encryption":"provider_managed","encryption_key":{"crn":"crn:v1:bluemix:public:kms:us-south:a/123456:e4a29d1a-2ef0-42a6-8fd2-350deb1c647e:key:5437653b-c4b1-447f-9646-b2a2a4cd6179"},"href":"https://us-south.iaas.cloud.ibm.com/v1/shares/0fe9e5d8-0a4d-4818-96ec-e99708644a58","id":"0fe9e5d8-0a4d-4818-96ec-e99708644a58","iops":100,"latest_job":{"status":"cancelled","status_reasons":[{"code":"cannot_reach_source_share","message":"The replication failover failed because the source share cannot be reached.","more_info":"https://cloud.ibm.com/docs/vpc?topic=vpc-file-storage-planning"}],"type":"replication_failover"},"latest_sync":{"completed_at":"2019-01-01T12:00:00.000Z","data_transferred":0,"started_at":"2019-01-01T12:00:00.000Z"},"lifecycle_state":"stable","mount_targets":[{"deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/shares/0fe9e5d8-0a4d-4818-96ec-e99708644a58/mount_targets/4cf9171a-0043-4434-8727-15b53dbc374c","id":"4cf9171a-0043-4434-8727-15b53dbc374c","name":"my-share-mount-target","resource_type":"share_mount_target"}],"name":"my-share","profile":{"href":"https://us-south.iaas.cloud.ibm.com/v1/share/profiles/tier-3iops","name":"tier-3iops","resource_type":"share_profile"},"replica_share":{"crn":"crn:v1:bluemix:public:is:us-south-1:a/123456::share:0fe9e5d8-0a4d-4818-96ec-e99708644a58","deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/shares/0fe9e5d8-0a4d-4818-96ec-e99708644a58","id":"0fe9e5d8-0a4d-4818-96ec-e99708644a58","name":"my-share","remote":{"region":{"href":"https://us-south.iaas.cloud.ibm.com/v1/regions/us-south","name":"us-south"}},"resource_type":"share"},"replication_cron_spec":"0 */5 * * *","replication_role":"none","replication_status":"active","replication_status_reasons":[{"code":"cannot_reach_source_share","message":"The replication failover failed because the source share cannot be reached.","more_info":"https://cloud.ibm.com/docs/vpc?topic=vpc-file-storage-planning"}],"resource_group":{"href":"https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345","id":"fee82deba12e4c0fb69c3b09d1f12345","name":"my-resource-group"},"resource_type":"share","size":200,"source_share":{"crn":"crn:v1:bluemix:public:is:us-south-1:a/123456::share:0fe9e5d8-0a4d-4818-96ec-e99708644a58","deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/shares/0fe9e5d8-0a4d-4818-96ec-e99708644a58","id":"0fe9e5d8-0a4d-4818-96ec-e99708644a58","name":"my-share","remote":{"region":{"href":"https://us-south.iaas.cloud.ibm.com/v1/regions/us-south","name":"us-south"}},"resource_type":"share"},"user_tags":["UserTags"],"zone":{"href":"https://us-south.iaas.cloud.ibm.com/v1/regions/us-south/zones/us-south-1","name":"us-south-1"}}],"total_count":2,"limit":1}`) } else { res.WriteHeader(400) } })) }) - It(`Use SnapshotConsistencyGroupsPager.GetNext successfully`, func() { + It(`Use SharesPager.GetNext successfully`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -55880,19 +56367,19 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - listSnapshotConsistencyGroupsOptionsModel := &vpcv1.ListSnapshotConsistencyGroupsOptions{ - Limit: core.Int64Ptr(int64(10)), - ResourceGroupID: core.StringPtr("testString"), - Name: core.StringPtr("testString"), - Sort: core.StringPtr("name"), - BackupPolicyPlanID: core.StringPtr("testString"), + listSharesOptionsModel := &vpcv1.ListSharesOptions{ + Limit: core.Int64Ptr(int64(10)), + ResourceGroupID: core.StringPtr("testString"), + Name: core.StringPtr("testString"), + Sort: core.StringPtr("name"), + ReplicationRole: core.StringPtr("none"), } - pager, err := vpcService.NewSnapshotConsistencyGroupsPager(listSnapshotConsistencyGroupsOptionsModel) + pager, err := vpcService.NewSharesPager(listSharesOptionsModel) Expect(err).To(BeNil()) Expect(pager).ToNot(BeNil()) - var allResults []vpcv1.SnapshotConsistencyGroup + var allResults []vpcv1.Share for pager.HasNext() { nextPage, err := pager.GetNext() Expect(err).To(BeNil()) @@ -55901,7 +56388,7 @@ var _ = Describe(`VpcV1`, func() { } Expect(len(allResults)).To(Equal(2)) }) - It(`Use SnapshotConsistencyGroupsPager.GetAll successfully`, func() { + It(`Use SharesPager.GetAll successfully`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -55910,15 +56397,15 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - listSnapshotConsistencyGroupsOptionsModel := &vpcv1.ListSnapshotConsistencyGroupsOptions{ - Limit: core.Int64Ptr(int64(10)), - ResourceGroupID: core.StringPtr("testString"), - Name: core.StringPtr("testString"), - Sort: core.StringPtr("name"), - BackupPolicyPlanID: core.StringPtr("testString"), + listSharesOptionsModel := &vpcv1.ListSharesOptions{ + Limit: core.Int64Ptr(int64(10)), + ResourceGroupID: core.StringPtr("testString"), + Name: core.StringPtr("testString"), + Sort: core.StringPtr("name"), + ReplicationRole: core.StringPtr("none"), } - pager, err := vpcService.NewSnapshotConsistencyGroupsPager(listSnapshotConsistencyGroupsOptionsModel) + pager, err := vpcService.NewSharesPager(listSharesOptionsModel) Expect(err).To(BeNil()) Expect(pager).ToNot(BeNil()) @@ -55929,16 +56416,16 @@ var _ = Describe(`VpcV1`, func() { }) }) }) - Describe(`CreateSnapshotConsistencyGroup(createSnapshotConsistencyGroupOptions *CreateSnapshotConsistencyGroupOptions) - Operation response error`, func() { + Describe(`CreateShare(createShareOptions *CreateShareOptions) - Operation response error`, func() { version := "testString" - createSnapshotConsistencyGroupPath := "/snapshot_consistency_groups" + createSharePath := "/shares" 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(createSnapshotConsistencyGroupPath)) + Expect(req.URL.EscapedPath()).To(Equal(createSharePath)) 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))})) @@ -55947,7 +56434,7 @@ var _ = Describe(`VpcV1`, func() { fmt.Fprint(res, `} this is not valid json {`) })) }) - It(`Invoke CreateSnapshotConsistencyGroup with error: Operation response processing error`, func() { + It(`Invoke CreateShare with error: Operation response processing error`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -55956,40 +56443,104 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) + // Construct an instance of the VirtualNetworkInterfaceIPPrototypeReservedIPPrototypeVirtualNetworkInterfaceIPsContext model + virtualNetworkInterfaceIPPrototypeModel := new(vpcv1.VirtualNetworkInterfaceIPPrototypeReservedIPPrototypeVirtualNetworkInterfaceIPsContext) + virtualNetworkInterfaceIPPrototypeModel.Address = core.StringPtr("10.0.0.5") + virtualNetworkInterfaceIPPrototypeModel.AutoDelete = core.BoolPtr(false) + virtualNetworkInterfaceIPPrototypeModel.Name = core.StringPtr("my-reserved-ip") + + // Construct an instance of the VirtualNetworkInterfacePrimaryIPPrototypeReservedIPPrototypeVirtualNetworkInterfacePrimaryIPContext model + virtualNetworkInterfacePrimaryIPPrototypeModel := new(vpcv1.VirtualNetworkInterfacePrimaryIPPrototypeReservedIPPrototypeVirtualNetworkInterfacePrimaryIPContext) + virtualNetworkInterfacePrimaryIPPrototypeModel.Address = core.StringPtr("10.0.0.5") + virtualNetworkInterfacePrimaryIPPrototypeModel.AutoDelete = core.BoolPtr(false) + virtualNetworkInterfacePrimaryIPPrototypeModel.Name = core.StringPtr("my-reserved-ip") + // Construct an instance of the ResourceGroupIdentityByID model resourceGroupIdentityModel := new(vpcv1.ResourceGroupIdentityByID) resourceGroupIdentityModel.ID = core.StringPtr("fee82deba12e4c0fb69c3b09d1f12345") - // Construct an instance of the VolumeIdentityByID model - volumeIdentityModel := new(vpcv1.VolumeIdentityByID) - volumeIdentityModel.ID = core.StringPtr("1a6b7274-678d-4dfb-8981-c71dd9d4daa5") + // Construct an instance of the SecurityGroupIdentityByID model + securityGroupIdentityModel := new(vpcv1.SecurityGroupIdentityByID) + securityGroupIdentityModel.ID = core.StringPtr("be5df5ca-12a0-494b-907e-aa6ec2bfa271") + + // Construct an instance of the SubnetIdentityByID model + subnetIdentityModel := new(vpcv1.SubnetIdentityByID) + subnetIdentityModel.ID = core.StringPtr("7ec86020-1c6e-4889-b3f0-a15f2e50f87e") + + // Construct an instance of the ShareMountTargetVirtualNetworkInterfacePrototypeVirtualNetworkInterfacePrototypeShareMountTargetContext model + shareMountTargetVirtualNetworkInterfacePrototypeModel := new(vpcv1.ShareMountTargetVirtualNetworkInterfacePrototypeVirtualNetworkInterfacePrototypeShareMountTargetContext) + shareMountTargetVirtualNetworkInterfacePrototypeModel.AllowIPSpoofing = core.BoolPtr(true) + shareMountTargetVirtualNetworkInterfacePrototypeModel.AutoDelete = core.BoolPtr(false) + shareMountTargetVirtualNetworkInterfacePrototypeModel.EnableInfrastructureNat = core.BoolPtr(true) + shareMountTargetVirtualNetworkInterfacePrototypeModel.Ips = []vpcv1.VirtualNetworkInterfaceIPPrototypeIntf{virtualNetworkInterfaceIPPrototypeModel} + shareMountTargetVirtualNetworkInterfacePrototypeModel.Name = core.StringPtr("my-virtual-network-interface") + shareMountTargetVirtualNetworkInterfacePrototypeModel.PrimaryIP = virtualNetworkInterfacePrimaryIPPrototypeModel + shareMountTargetVirtualNetworkInterfacePrototypeModel.ResourceGroup = resourceGroupIdentityModel + shareMountTargetVirtualNetworkInterfacePrototypeModel.SecurityGroups = []vpcv1.SecurityGroupIdentityIntf{securityGroupIdentityModel} + shareMountTargetVirtualNetworkInterfacePrototypeModel.Subnet = subnetIdentityModel + + // Construct an instance of the ShareMountTargetPrototypeShareMountTargetByAccessControlModeSecurityGroup model + shareMountTargetPrototypeModel := new(vpcv1.ShareMountTargetPrototypeShareMountTargetByAccessControlModeSecurityGroup) + shareMountTargetPrototypeModel.Name = core.StringPtr("my-share-mount-target") + shareMountTargetPrototypeModel.TransitEncryption = core.StringPtr("none") + shareMountTargetPrototypeModel.VirtualNetworkInterface = shareMountTargetVirtualNetworkInterfacePrototypeModel + + // Construct an instance of the ShareProfileIdentityByName model + shareProfileIdentityModel := new(vpcv1.ShareProfileIdentityByName) + shareProfileIdentityModel.Name = core.StringPtr("tier-3iops") + + // Construct an instance of the ZoneIdentityByName model + zoneIdentityModel := new(vpcv1.ZoneIdentityByName) + zoneIdentityModel.Name = core.StringPtr("us-south-1") + + // Construct an instance of the SharePrototypeShareContext model + sharePrototypeShareContextModel := new(vpcv1.SharePrototypeShareContext) + sharePrototypeShareContextModel.Iops = core.Int64Ptr(int64(100)) + sharePrototypeShareContextModel.MountTargets = []vpcv1.ShareMountTargetPrototypeIntf{shareMountTargetPrototypeModel} + sharePrototypeShareContextModel.Name = core.StringPtr("my-share") + sharePrototypeShareContextModel.Profile = shareProfileIdentityModel + sharePrototypeShareContextModel.ReplicationCronSpec = core.StringPtr("0 */5 * * *") + sharePrototypeShareContextModel.ResourceGroup = resourceGroupIdentityModel + sharePrototypeShareContextModel.UserTags = []string{} + sharePrototypeShareContextModel.Zone = zoneIdentityModel + + // Construct an instance of the EncryptionKeyIdentityByCRN model + encryptionKeyIdentityModel := new(vpcv1.EncryptionKeyIdentityByCRN) + encryptionKeyIdentityModel.CRN = core.StringPtr("crn:v1:bluemix:public:kms:us-south:a/123456:e4a29d1a-2ef0-42a6-8fd2-350deb1c647e:key:5437653b-c4b1-447f-9646-b2a2a4cd6179") - // Construct an instance of the SnapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshotsSnapshotsItem model - snapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshotsSnapshotsItemModel := new(vpcv1.SnapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshotsSnapshotsItem) - snapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshotsSnapshotsItemModel.Name = core.StringPtr("my-snapshot") - snapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshotsSnapshotsItemModel.SourceVolume = volumeIdentityModel - snapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshotsSnapshotsItemModel.UserTags = []string{"testString"} + // Construct an instance of the ShareInitialOwner model + shareInitialOwnerModel := new(vpcv1.ShareInitialOwner) + shareInitialOwnerModel.Gid = core.Int64Ptr(int64(50)) + shareInitialOwnerModel.Uid = core.Int64Ptr(int64(50)) - // Construct an instance of the SnapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshots model - snapshotConsistencyGroupPrototypeModel := new(vpcv1.SnapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshots) - snapshotConsistencyGroupPrototypeModel.DeleteSnapshotsOnDelete = core.BoolPtr(true) - snapshotConsistencyGroupPrototypeModel.Name = core.StringPtr("my-snapshot-consistency-group") - snapshotConsistencyGroupPrototypeModel.ResourceGroup = resourceGroupIdentityModel - snapshotConsistencyGroupPrototypeModel.Snapshots = []vpcv1.SnapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshotsSnapshotsItem{*snapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshotsSnapshotsItemModel} + // Construct an instance of the SharePrototypeShareBySize model + sharePrototypeModel := new(vpcv1.SharePrototypeShareBySize) + sharePrototypeModel.Iops = core.Int64Ptr(int64(100)) + sharePrototypeModel.MountTargets = []vpcv1.ShareMountTargetPrototypeIntf{shareMountTargetPrototypeModel} + sharePrototypeModel.Name = core.StringPtr("my-share") + sharePrototypeModel.Profile = shareProfileIdentityModel + sharePrototypeModel.ReplicaShare = sharePrototypeShareContextModel + sharePrototypeModel.UserTags = []string{} + sharePrototypeModel.Zone = zoneIdentityModel + sharePrototypeModel.AccessControlMode = core.StringPtr("security_group") + sharePrototypeModel.EncryptionKey = encryptionKeyIdentityModel + sharePrototypeModel.InitialOwner = shareInitialOwnerModel + sharePrototypeModel.ResourceGroup = resourceGroupIdentityModel + sharePrototypeModel.Size = core.Int64Ptr(int64(200)) - // Construct an instance of the CreateSnapshotConsistencyGroupOptions model - createSnapshotConsistencyGroupOptionsModel := new(vpcv1.CreateSnapshotConsistencyGroupOptions) - createSnapshotConsistencyGroupOptionsModel.SnapshotConsistencyGroupPrototype = snapshotConsistencyGroupPrototypeModel - createSnapshotConsistencyGroupOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the CreateShareOptions model + createShareOptionsModel := new(vpcv1.CreateShareOptions) + createShareOptionsModel.SharePrototype = sharePrototypeModel + createShareOptionsModel.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.CreateSnapshotConsistencyGroup(createSnapshotConsistencyGroupOptionsModel) + result, response, operationErr := vpcService.CreateShare(createShareOptionsModel) 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.CreateSnapshotConsistencyGroup(createSnapshotConsistencyGroupOptionsModel) + result, response, operationErr = vpcService.CreateShare(createShareOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).To(BeNil()) @@ -55999,16 +56550,16 @@ var _ = Describe(`VpcV1`, func() { }) }) }) - Describe(`CreateSnapshotConsistencyGroup(createSnapshotConsistencyGroupOptions *CreateSnapshotConsistencyGroupOptions)`, func() { + Describe(`CreateShare(createShareOptions *CreateShareOptions)`, func() { version := "testString" - createSnapshotConsistencyGroupPath := "/snapshot_consistency_groups" + createSharePath := "/shares" 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(createSnapshotConsistencyGroupPath)) + Expect(req.URL.EscapedPath()).To(Equal(createSharePath)) Expect(req.Method).To(Equal("POST")) // For gzip-disabled operation, verify Content-Encoding is not set. @@ -56035,10 +56586,10 @@ var _ = Describe(`VpcV1`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(201) - fmt.Fprintf(res, "%s", `{"backup_policy_plan": {"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6/plans/r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "id": "r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "name": "my-policy-plan", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "backup_policy_plan"}, "created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot-consistency-group:r134-fa329f6b-0e36-433f-a3bb-0df632e79263", "delete_snapshots_on_delete": false, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshot_consistency_groups/r134-fa329f6b-0e36-433f-a3bb-0df632e79263", "id": "r134-fa329f6b-0e36-433f-a3bb-0df632e79263", "lifecycle_state": "stable", "name": "my-snapshot-consistency-group", "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "resource_type": "snapshot_consistency_group", "service_tags": ["ServiceTags"], "snapshots": [{"crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "id": "r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "name": "my-snapshot", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "snapshot"}]}`) + fmt.Fprintf(res, "%s", `{"access_control_mode": "security_group", "created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::share:0fe9e5d8-0a4d-4818-96ec-e99708644a58", "encryption": "provider_managed", "encryption_key": {"crn": "crn:v1:bluemix:public:kms:us-south:a/123456:e4a29d1a-2ef0-42a6-8fd2-350deb1c647e:key:5437653b-c4b1-447f-9646-b2a2a4cd6179"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/shares/0fe9e5d8-0a4d-4818-96ec-e99708644a58", "id": "0fe9e5d8-0a4d-4818-96ec-e99708644a58", "iops": 100, "latest_job": {"status": "cancelled", "status_reasons": [{"code": "cannot_reach_source_share", "message": "The replication failover failed because the source share cannot be reached.", "more_info": "https://cloud.ibm.com/docs/vpc?topic=vpc-file-storage-planning"}], "type": "replication_failover"}, "latest_sync": {"completed_at": "2019-01-01T12:00:00.000Z", "data_transferred": 0, "started_at": "2019-01-01T12:00:00.000Z"}, "lifecycle_state": "stable", "mount_targets": [{"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/shares/0fe9e5d8-0a4d-4818-96ec-e99708644a58/mount_targets/4cf9171a-0043-4434-8727-15b53dbc374c", "id": "4cf9171a-0043-4434-8727-15b53dbc374c", "name": "my-share-mount-target", "resource_type": "share_mount_target"}], "name": "my-share", "profile": {"href": "https://us-south.iaas.cloud.ibm.com/v1/share/profiles/tier-3iops", "name": "tier-3iops", "resource_type": "share_profile"}, "replica_share": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::share:0fe9e5d8-0a4d-4818-96ec-e99708644a58", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/shares/0fe9e5d8-0a4d-4818-96ec-e99708644a58", "id": "0fe9e5d8-0a4d-4818-96ec-e99708644a58", "name": "my-share", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "share"}, "replication_cron_spec": "0 */5 * * *", "replication_role": "none", "replication_status": "active", "replication_status_reasons": [{"code": "cannot_reach_source_share", "message": "The replication failover failed because the source share cannot be reached.", "more_info": "https://cloud.ibm.com/docs/vpc?topic=vpc-file-storage-planning"}], "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "resource_type": "share", "size": 200, "source_share": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::share:0fe9e5d8-0a4d-4818-96ec-e99708644a58", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/shares/0fe9e5d8-0a4d-4818-96ec-e99708644a58", "id": "0fe9e5d8-0a4d-4818-96ec-e99708644a58", "name": "my-share", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "share"}, "user_tags": ["UserTags"], "zone": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south/zones/us-south-1", "name": "us-south-1"}}`) })) }) - It(`Invoke CreateSnapshotConsistencyGroup successfully with retries`, func() { + It(`Invoke CreateShare successfully with retries`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -56048,42 +56599,106 @@ var _ = Describe(`VpcV1`, func() { Expect(vpcService).ToNot(BeNil()) vpcService.EnableRetries(0, 0) + // Construct an instance of the VirtualNetworkInterfaceIPPrototypeReservedIPPrototypeVirtualNetworkInterfaceIPsContext model + virtualNetworkInterfaceIPPrototypeModel := new(vpcv1.VirtualNetworkInterfaceIPPrototypeReservedIPPrototypeVirtualNetworkInterfaceIPsContext) + virtualNetworkInterfaceIPPrototypeModel.Address = core.StringPtr("10.0.0.5") + virtualNetworkInterfaceIPPrototypeModel.AutoDelete = core.BoolPtr(false) + virtualNetworkInterfaceIPPrototypeModel.Name = core.StringPtr("my-reserved-ip") + + // Construct an instance of the VirtualNetworkInterfacePrimaryIPPrototypeReservedIPPrototypeVirtualNetworkInterfacePrimaryIPContext model + virtualNetworkInterfacePrimaryIPPrototypeModel := new(vpcv1.VirtualNetworkInterfacePrimaryIPPrototypeReservedIPPrototypeVirtualNetworkInterfacePrimaryIPContext) + virtualNetworkInterfacePrimaryIPPrototypeModel.Address = core.StringPtr("10.0.0.5") + virtualNetworkInterfacePrimaryIPPrototypeModel.AutoDelete = core.BoolPtr(false) + virtualNetworkInterfacePrimaryIPPrototypeModel.Name = core.StringPtr("my-reserved-ip") + // Construct an instance of the ResourceGroupIdentityByID model resourceGroupIdentityModel := new(vpcv1.ResourceGroupIdentityByID) resourceGroupIdentityModel.ID = core.StringPtr("fee82deba12e4c0fb69c3b09d1f12345") - // Construct an instance of the VolumeIdentityByID model - volumeIdentityModel := new(vpcv1.VolumeIdentityByID) - volumeIdentityModel.ID = core.StringPtr("1a6b7274-678d-4dfb-8981-c71dd9d4daa5") + // Construct an instance of the SecurityGroupIdentityByID model + securityGroupIdentityModel := new(vpcv1.SecurityGroupIdentityByID) + securityGroupIdentityModel.ID = core.StringPtr("be5df5ca-12a0-494b-907e-aa6ec2bfa271") - // Construct an instance of the SnapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshotsSnapshotsItem model - snapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshotsSnapshotsItemModel := new(vpcv1.SnapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshotsSnapshotsItem) - snapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshotsSnapshotsItemModel.Name = core.StringPtr("my-snapshot") - snapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshotsSnapshotsItemModel.SourceVolume = volumeIdentityModel - snapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshotsSnapshotsItemModel.UserTags = []string{"testString"} + // Construct an instance of the SubnetIdentityByID model + subnetIdentityModel := new(vpcv1.SubnetIdentityByID) + subnetIdentityModel.ID = core.StringPtr("7ec86020-1c6e-4889-b3f0-a15f2e50f87e") - // Construct an instance of the SnapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshots model - snapshotConsistencyGroupPrototypeModel := new(vpcv1.SnapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshots) - snapshotConsistencyGroupPrototypeModel.DeleteSnapshotsOnDelete = core.BoolPtr(true) - snapshotConsistencyGroupPrototypeModel.Name = core.StringPtr("my-snapshot-consistency-group") - snapshotConsistencyGroupPrototypeModel.ResourceGroup = resourceGroupIdentityModel - snapshotConsistencyGroupPrototypeModel.Snapshots = []vpcv1.SnapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshotsSnapshotsItem{*snapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshotsSnapshotsItemModel} + // Construct an instance of the ShareMountTargetVirtualNetworkInterfacePrototypeVirtualNetworkInterfacePrototypeShareMountTargetContext model + shareMountTargetVirtualNetworkInterfacePrototypeModel := new(vpcv1.ShareMountTargetVirtualNetworkInterfacePrototypeVirtualNetworkInterfacePrototypeShareMountTargetContext) + shareMountTargetVirtualNetworkInterfacePrototypeModel.AllowIPSpoofing = core.BoolPtr(true) + shareMountTargetVirtualNetworkInterfacePrototypeModel.AutoDelete = core.BoolPtr(false) + shareMountTargetVirtualNetworkInterfacePrototypeModel.EnableInfrastructureNat = core.BoolPtr(true) + shareMountTargetVirtualNetworkInterfacePrototypeModel.Ips = []vpcv1.VirtualNetworkInterfaceIPPrototypeIntf{virtualNetworkInterfaceIPPrototypeModel} + shareMountTargetVirtualNetworkInterfacePrototypeModel.Name = core.StringPtr("my-virtual-network-interface") + shareMountTargetVirtualNetworkInterfacePrototypeModel.PrimaryIP = virtualNetworkInterfacePrimaryIPPrototypeModel + shareMountTargetVirtualNetworkInterfacePrototypeModel.ResourceGroup = resourceGroupIdentityModel + shareMountTargetVirtualNetworkInterfacePrototypeModel.SecurityGroups = []vpcv1.SecurityGroupIdentityIntf{securityGroupIdentityModel} + shareMountTargetVirtualNetworkInterfacePrototypeModel.Subnet = subnetIdentityModel - // Construct an instance of the CreateSnapshotConsistencyGroupOptions model - createSnapshotConsistencyGroupOptionsModel := new(vpcv1.CreateSnapshotConsistencyGroupOptions) - createSnapshotConsistencyGroupOptionsModel.SnapshotConsistencyGroupPrototype = snapshotConsistencyGroupPrototypeModel - createSnapshotConsistencyGroupOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the ShareMountTargetPrototypeShareMountTargetByAccessControlModeSecurityGroup model + shareMountTargetPrototypeModel := new(vpcv1.ShareMountTargetPrototypeShareMountTargetByAccessControlModeSecurityGroup) + shareMountTargetPrototypeModel.Name = core.StringPtr("my-share-mount-target") + shareMountTargetPrototypeModel.TransitEncryption = core.StringPtr("none") + shareMountTargetPrototypeModel.VirtualNetworkInterface = shareMountTargetVirtualNetworkInterfacePrototypeModel + + // Construct an instance of the ShareProfileIdentityByName model + shareProfileIdentityModel := new(vpcv1.ShareProfileIdentityByName) + shareProfileIdentityModel.Name = core.StringPtr("tier-3iops") + + // Construct an instance of the ZoneIdentityByName model + zoneIdentityModel := new(vpcv1.ZoneIdentityByName) + zoneIdentityModel.Name = core.StringPtr("us-south-1") + + // Construct an instance of the SharePrototypeShareContext model + sharePrototypeShareContextModel := new(vpcv1.SharePrototypeShareContext) + sharePrototypeShareContextModel.Iops = core.Int64Ptr(int64(100)) + sharePrototypeShareContextModel.MountTargets = []vpcv1.ShareMountTargetPrototypeIntf{shareMountTargetPrototypeModel} + sharePrototypeShareContextModel.Name = core.StringPtr("my-share") + sharePrototypeShareContextModel.Profile = shareProfileIdentityModel + sharePrototypeShareContextModel.ReplicationCronSpec = core.StringPtr("0 */5 * * *") + sharePrototypeShareContextModel.ResourceGroup = resourceGroupIdentityModel + sharePrototypeShareContextModel.UserTags = []string{} + sharePrototypeShareContextModel.Zone = zoneIdentityModel + + // Construct an instance of the EncryptionKeyIdentityByCRN model + encryptionKeyIdentityModel := new(vpcv1.EncryptionKeyIdentityByCRN) + encryptionKeyIdentityModel.CRN = core.StringPtr("crn:v1:bluemix:public:kms:us-south:a/123456:e4a29d1a-2ef0-42a6-8fd2-350deb1c647e:key:5437653b-c4b1-447f-9646-b2a2a4cd6179") + + // Construct an instance of the ShareInitialOwner model + shareInitialOwnerModel := new(vpcv1.ShareInitialOwner) + shareInitialOwnerModel.Gid = core.Int64Ptr(int64(50)) + shareInitialOwnerModel.Uid = core.Int64Ptr(int64(50)) + + // Construct an instance of the SharePrototypeShareBySize model + sharePrototypeModel := new(vpcv1.SharePrototypeShareBySize) + sharePrototypeModel.Iops = core.Int64Ptr(int64(100)) + sharePrototypeModel.MountTargets = []vpcv1.ShareMountTargetPrototypeIntf{shareMountTargetPrototypeModel} + sharePrototypeModel.Name = core.StringPtr("my-share") + sharePrototypeModel.Profile = shareProfileIdentityModel + sharePrototypeModel.ReplicaShare = sharePrototypeShareContextModel + sharePrototypeModel.UserTags = []string{} + sharePrototypeModel.Zone = zoneIdentityModel + sharePrototypeModel.AccessControlMode = core.StringPtr("security_group") + sharePrototypeModel.EncryptionKey = encryptionKeyIdentityModel + sharePrototypeModel.InitialOwner = shareInitialOwnerModel + sharePrototypeModel.ResourceGroup = resourceGroupIdentityModel + sharePrototypeModel.Size = core.Int64Ptr(int64(200)) + + // Construct an instance of the CreateShareOptions model + createShareOptionsModel := new(vpcv1.CreateShareOptions) + createShareOptionsModel.SharePrototype = sharePrototypeModel + createShareOptionsModel.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.CreateSnapshotConsistencyGroupWithContext(ctx, createSnapshotConsistencyGroupOptionsModel) + _, _, operationErr := vpcService.CreateShareWithContext(ctx, createShareOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) // Disable retries and test again vpcService.DisableRetries() - result, response, operationErr := vpcService.CreateSnapshotConsistencyGroup(createSnapshotConsistencyGroupOptionsModel) + result, response, operationErr := vpcService.CreateShare(createShareOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) @@ -56091,7 +56706,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.CreateSnapshotConsistencyGroupWithContext(ctx, createSnapshotConsistencyGroupOptionsModel) + _, _, operationErr = vpcService.CreateShareWithContext(ctx, createShareOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) }) @@ -56105,7 +56720,7 @@ var _ = Describe(`VpcV1`, func() { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(createSnapshotConsistencyGroupPath)) + Expect(req.URL.EscapedPath()).To(Equal(createSharePath)) Expect(req.Method).To(Equal("POST")) // For gzip-disabled operation, verify Content-Encoding is not set. @@ -56129,10 +56744,10 @@ var _ = Describe(`VpcV1`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(201) - fmt.Fprintf(res, "%s", `{"backup_policy_plan": {"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6/plans/r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "id": "r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "name": "my-policy-plan", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "backup_policy_plan"}, "created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot-consistency-group:r134-fa329f6b-0e36-433f-a3bb-0df632e79263", "delete_snapshots_on_delete": false, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshot_consistency_groups/r134-fa329f6b-0e36-433f-a3bb-0df632e79263", "id": "r134-fa329f6b-0e36-433f-a3bb-0df632e79263", "lifecycle_state": "stable", "name": "my-snapshot-consistency-group", "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "resource_type": "snapshot_consistency_group", "service_tags": ["ServiceTags"], "snapshots": [{"crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "id": "r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "name": "my-snapshot", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "snapshot"}]}`) + fmt.Fprintf(res, "%s", `{"access_control_mode": "security_group", "created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::share:0fe9e5d8-0a4d-4818-96ec-e99708644a58", "encryption": "provider_managed", "encryption_key": {"crn": "crn:v1:bluemix:public:kms:us-south:a/123456:e4a29d1a-2ef0-42a6-8fd2-350deb1c647e:key:5437653b-c4b1-447f-9646-b2a2a4cd6179"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/shares/0fe9e5d8-0a4d-4818-96ec-e99708644a58", "id": "0fe9e5d8-0a4d-4818-96ec-e99708644a58", "iops": 100, "latest_job": {"status": "cancelled", "status_reasons": [{"code": "cannot_reach_source_share", "message": "The replication failover failed because the source share cannot be reached.", "more_info": "https://cloud.ibm.com/docs/vpc?topic=vpc-file-storage-planning"}], "type": "replication_failover"}, "latest_sync": {"completed_at": "2019-01-01T12:00:00.000Z", "data_transferred": 0, "started_at": "2019-01-01T12:00:00.000Z"}, "lifecycle_state": "stable", "mount_targets": [{"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/shares/0fe9e5d8-0a4d-4818-96ec-e99708644a58/mount_targets/4cf9171a-0043-4434-8727-15b53dbc374c", "id": "4cf9171a-0043-4434-8727-15b53dbc374c", "name": "my-share-mount-target", "resource_type": "share_mount_target"}], "name": "my-share", "profile": {"href": "https://us-south.iaas.cloud.ibm.com/v1/share/profiles/tier-3iops", "name": "tier-3iops", "resource_type": "share_profile"}, "replica_share": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::share:0fe9e5d8-0a4d-4818-96ec-e99708644a58", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/shares/0fe9e5d8-0a4d-4818-96ec-e99708644a58", "id": "0fe9e5d8-0a4d-4818-96ec-e99708644a58", "name": "my-share", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "share"}, "replication_cron_spec": "0 */5 * * *", "replication_role": "none", "replication_status": "active", "replication_status_reasons": [{"code": "cannot_reach_source_share", "message": "The replication failover failed because the source share cannot be reached.", "more_info": "https://cloud.ibm.com/docs/vpc?topic=vpc-file-storage-planning"}], "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "resource_type": "share", "size": 200, "source_share": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::share:0fe9e5d8-0a4d-4818-96ec-e99708644a58", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/shares/0fe9e5d8-0a4d-4818-96ec-e99708644a58", "id": "0fe9e5d8-0a4d-4818-96ec-e99708644a58", "name": "my-share", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "share"}, "user_tags": ["UserTags"], "zone": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south/zones/us-south-1", "name": "us-south-1"}}`) })) }) - It(`Invoke CreateSnapshotConsistencyGroup successfully`, func() { + It(`Invoke CreateShare successfully`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -56142,174 +56757,109 @@ var _ = Describe(`VpcV1`, func() { Expect(vpcService).ToNot(BeNil()) // Invoke operation with nil options model (negative test) - result, response, operationErr := vpcService.CreateSnapshotConsistencyGroup(nil) + result, response, operationErr := vpcService.CreateShare(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 VolumeIdentityByID model - volumeIdentityModel := new(vpcv1.VolumeIdentityByID) - volumeIdentityModel.ID = core.StringPtr("1a6b7274-678d-4dfb-8981-c71dd9d4daa5") - - // Construct an instance of the SnapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshotsSnapshotsItem model - snapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshotsSnapshotsItemModel := new(vpcv1.SnapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshotsSnapshotsItem) - snapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshotsSnapshotsItemModel.Name = core.StringPtr("my-snapshot") - snapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshotsSnapshotsItemModel.SourceVolume = volumeIdentityModel - snapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshotsSnapshotsItemModel.UserTags = []string{"testString"} - - // Construct an instance of the SnapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshots model - snapshotConsistencyGroupPrototypeModel := new(vpcv1.SnapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshots) - snapshotConsistencyGroupPrototypeModel.DeleteSnapshotsOnDelete = core.BoolPtr(true) - snapshotConsistencyGroupPrototypeModel.Name = core.StringPtr("my-snapshot-consistency-group") - snapshotConsistencyGroupPrototypeModel.ResourceGroup = resourceGroupIdentityModel - snapshotConsistencyGroupPrototypeModel.Snapshots = []vpcv1.SnapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshotsSnapshotsItem{*snapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshotsSnapshotsItemModel} - - // Construct an instance of the CreateSnapshotConsistencyGroupOptions model - createSnapshotConsistencyGroupOptionsModel := new(vpcv1.CreateSnapshotConsistencyGroupOptions) - createSnapshotConsistencyGroupOptionsModel.SnapshotConsistencyGroupPrototype = snapshotConsistencyGroupPrototypeModel - createSnapshotConsistencyGroupOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} - - // Invoke operation with valid options model (positive test) - result, response, operationErr = vpcService.CreateSnapshotConsistencyGroup(createSnapshotConsistencyGroupOptionsModel) - Expect(operationErr).To(BeNil()) - Expect(response).ToNot(BeNil()) - Expect(result).ToNot(BeNil()) + // Construct an instance of the VirtualNetworkInterfaceIPPrototypeReservedIPPrototypeVirtualNetworkInterfaceIPsContext model + virtualNetworkInterfaceIPPrototypeModel := new(vpcv1.VirtualNetworkInterfaceIPPrototypeReservedIPPrototypeVirtualNetworkInterfaceIPsContext) + virtualNetworkInterfaceIPPrototypeModel.Address = core.StringPtr("10.0.0.5") + virtualNetworkInterfaceIPPrototypeModel.AutoDelete = core.BoolPtr(false) + virtualNetworkInterfaceIPPrototypeModel.Name = core.StringPtr("my-reserved-ip") - }) - It(`Invoke CreateSnapshotConsistencyGroup 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 VirtualNetworkInterfacePrimaryIPPrototypeReservedIPPrototypeVirtualNetworkInterfacePrimaryIPContext model + virtualNetworkInterfacePrimaryIPPrototypeModel := new(vpcv1.VirtualNetworkInterfacePrimaryIPPrototypeReservedIPPrototypeVirtualNetworkInterfacePrimaryIPContext) + virtualNetworkInterfacePrimaryIPPrototypeModel.Address = core.StringPtr("10.0.0.5") + virtualNetworkInterfacePrimaryIPPrototypeModel.AutoDelete = core.BoolPtr(false) + virtualNetworkInterfacePrimaryIPPrototypeModel.Name = core.StringPtr("my-reserved-ip") // Construct an instance of the ResourceGroupIdentityByID model resourceGroupIdentityModel := new(vpcv1.ResourceGroupIdentityByID) resourceGroupIdentityModel.ID = core.StringPtr("fee82deba12e4c0fb69c3b09d1f12345") - // Construct an instance of the VolumeIdentityByID model - volumeIdentityModel := new(vpcv1.VolumeIdentityByID) - volumeIdentityModel.ID = core.StringPtr("1a6b7274-678d-4dfb-8981-c71dd9d4daa5") + // Construct an instance of the SecurityGroupIdentityByID model + securityGroupIdentityModel := new(vpcv1.SecurityGroupIdentityByID) + securityGroupIdentityModel.ID = core.StringPtr("be5df5ca-12a0-494b-907e-aa6ec2bfa271") - // Construct an instance of the SnapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshotsSnapshotsItem model - snapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshotsSnapshotsItemModel := new(vpcv1.SnapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshotsSnapshotsItem) - snapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshotsSnapshotsItemModel.Name = core.StringPtr("my-snapshot") - snapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshotsSnapshotsItemModel.SourceVolume = volumeIdentityModel - snapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshotsSnapshotsItemModel.UserTags = []string{"testString"} + // Construct an instance of the SubnetIdentityByID model + subnetIdentityModel := new(vpcv1.SubnetIdentityByID) + subnetIdentityModel.ID = core.StringPtr("7ec86020-1c6e-4889-b3f0-a15f2e50f87e") - // Construct an instance of the SnapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshots model - snapshotConsistencyGroupPrototypeModel := new(vpcv1.SnapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshots) - snapshotConsistencyGroupPrototypeModel.DeleteSnapshotsOnDelete = core.BoolPtr(true) - snapshotConsistencyGroupPrototypeModel.Name = core.StringPtr("my-snapshot-consistency-group") - snapshotConsistencyGroupPrototypeModel.ResourceGroup = resourceGroupIdentityModel - snapshotConsistencyGroupPrototypeModel.Snapshots = []vpcv1.SnapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshotsSnapshotsItem{*snapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshotsSnapshotsItemModel} + // Construct an instance of the ShareMountTargetVirtualNetworkInterfacePrototypeVirtualNetworkInterfacePrototypeShareMountTargetContext model + shareMountTargetVirtualNetworkInterfacePrototypeModel := new(vpcv1.ShareMountTargetVirtualNetworkInterfacePrototypeVirtualNetworkInterfacePrototypeShareMountTargetContext) + shareMountTargetVirtualNetworkInterfacePrototypeModel.AllowIPSpoofing = core.BoolPtr(true) + shareMountTargetVirtualNetworkInterfacePrototypeModel.AutoDelete = core.BoolPtr(false) + shareMountTargetVirtualNetworkInterfacePrototypeModel.EnableInfrastructureNat = core.BoolPtr(true) + shareMountTargetVirtualNetworkInterfacePrototypeModel.Ips = []vpcv1.VirtualNetworkInterfaceIPPrototypeIntf{virtualNetworkInterfaceIPPrototypeModel} + shareMountTargetVirtualNetworkInterfacePrototypeModel.Name = core.StringPtr("my-virtual-network-interface") + shareMountTargetVirtualNetworkInterfacePrototypeModel.PrimaryIP = virtualNetworkInterfacePrimaryIPPrototypeModel + shareMountTargetVirtualNetworkInterfacePrototypeModel.ResourceGroup = resourceGroupIdentityModel + shareMountTargetVirtualNetworkInterfacePrototypeModel.SecurityGroups = []vpcv1.SecurityGroupIdentityIntf{securityGroupIdentityModel} + shareMountTargetVirtualNetworkInterfacePrototypeModel.Subnet = subnetIdentityModel - // Construct an instance of the CreateSnapshotConsistencyGroupOptions model - createSnapshotConsistencyGroupOptionsModel := new(vpcv1.CreateSnapshotConsistencyGroupOptions) - createSnapshotConsistencyGroupOptionsModel.SnapshotConsistencyGroupPrototype = snapshotConsistencyGroupPrototypeModel - createSnapshotConsistencyGroupOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} - // Invoke operation with empty URL (negative test) - err := vpcService.SetServiceURL("") - Expect(err).To(BeNil()) - result, response, operationErr := vpcService.CreateSnapshotConsistencyGroup(createSnapshotConsistencyGroupOptionsModel) - Expect(operationErr).ToNot(BeNil()) - Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING)) - Expect(response).To(BeNil()) - Expect(result).To(BeNil()) - // Construct a second instance of the CreateSnapshotConsistencyGroupOptions model with no property values - createSnapshotConsistencyGroupOptionsModelNew := new(vpcv1.CreateSnapshotConsistencyGroupOptions) - // Invoke operation with invalid model (negative test) - result, response, operationErr = vpcService.CreateSnapshotConsistencyGroup(createSnapshotConsistencyGroupOptionsModelNew) - 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() + // Construct an instance of the ShareMountTargetPrototypeShareMountTargetByAccessControlModeSecurityGroup model + shareMountTargetPrototypeModel := new(vpcv1.ShareMountTargetPrototypeShareMountTargetByAccessControlModeSecurityGroup) + shareMountTargetPrototypeModel.Name = core.StringPtr("my-share-mount-target") + shareMountTargetPrototypeModel.TransitEncryption = core.StringPtr("none") + shareMountTargetPrototypeModel.VirtualNetworkInterface = shareMountTargetVirtualNetworkInterfacePrototypeModel - // Set success status code with no respoonse body - res.WriteHeader(201) - })) - }) - It(`Invoke CreateSnapshotConsistencyGroup 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 ShareProfileIdentityByName model + shareProfileIdentityModel := new(vpcv1.ShareProfileIdentityByName) + shareProfileIdentityModel.Name = core.StringPtr("tier-3iops") - // Construct an instance of the ResourceGroupIdentityByID model - resourceGroupIdentityModel := new(vpcv1.ResourceGroupIdentityByID) - resourceGroupIdentityModel.ID = core.StringPtr("fee82deba12e4c0fb69c3b09d1f12345") + // Construct an instance of the ZoneIdentityByName model + zoneIdentityModel := new(vpcv1.ZoneIdentityByName) + zoneIdentityModel.Name = core.StringPtr("us-south-1") - // Construct an instance of the VolumeIdentityByID model - volumeIdentityModel := new(vpcv1.VolumeIdentityByID) - volumeIdentityModel.ID = core.StringPtr("1a6b7274-678d-4dfb-8981-c71dd9d4daa5") + // Construct an instance of the SharePrototypeShareContext model + sharePrototypeShareContextModel := new(vpcv1.SharePrototypeShareContext) + sharePrototypeShareContextModel.Iops = core.Int64Ptr(int64(100)) + sharePrototypeShareContextModel.MountTargets = []vpcv1.ShareMountTargetPrototypeIntf{shareMountTargetPrototypeModel} + sharePrototypeShareContextModel.Name = core.StringPtr("my-share") + sharePrototypeShareContextModel.Profile = shareProfileIdentityModel + sharePrototypeShareContextModel.ReplicationCronSpec = core.StringPtr("0 */5 * * *") + sharePrototypeShareContextModel.ResourceGroup = resourceGroupIdentityModel + sharePrototypeShareContextModel.UserTags = []string{} + sharePrototypeShareContextModel.Zone = zoneIdentityModel - // Construct an instance of the SnapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshotsSnapshotsItem model - snapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshotsSnapshotsItemModel := new(vpcv1.SnapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshotsSnapshotsItem) - snapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshotsSnapshotsItemModel.Name = core.StringPtr("my-snapshot") - snapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshotsSnapshotsItemModel.SourceVolume = volumeIdentityModel - snapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshotsSnapshotsItemModel.UserTags = []string{"testString"} + // Construct an instance of the EncryptionKeyIdentityByCRN model + encryptionKeyIdentityModel := new(vpcv1.EncryptionKeyIdentityByCRN) + encryptionKeyIdentityModel.CRN = core.StringPtr("crn:v1:bluemix:public:kms:us-south:a/123456:e4a29d1a-2ef0-42a6-8fd2-350deb1c647e:key:5437653b-c4b1-447f-9646-b2a2a4cd6179") - // Construct an instance of the SnapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshots model - snapshotConsistencyGroupPrototypeModel := new(vpcv1.SnapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshots) - snapshotConsistencyGroupPrototypeModel.DeleteSnapshotsOnDelete = core.BoolPtr(true) - snapshotConsistencyGroupPrototypeModel.Name = core.StringPtr("my-snapshot-consistency-group") - snapshotConsistencyGroupPrototypeModel.ResourceGroup = resourceGroupIdentityModel - snapshotConsistencyGroupPrototypeModel.Snapshots = []vpcv1.SnapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshotsSnapshotsItem{*snapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshotsSnapshotsItemModel} + // Construct an instance of the ShareInitialOwner model + shareInitialOwnerModel := new(vpcv1.ShareInitialOwner) + shareInitialOwnerModel.Gid = core.Int64Ptr(int64(50)) + shareInitialOwnerModel.Uid = core.Int64Ptr(int64(50)) - // Construct an instance of the CreateSnapshotConsistencyGroupOptions model - createSnapshotConsistencyGroupOptionsModel := new(vpcv1.CreateSnapshotConsistencyGroupOptions) - createSnapshotConsistencyGroupOptionsModel.SnapshotConsistencyGroupPrototype = snapshotConsistencyGroupPrototypeModel - createSnapshotConsistencyGroupOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the SharePrototypeShareBySize model + sharePrototypeModel := new(vpcv1.SharePrototypeShareBySize) + sharePrototypeModel.Iops = core.Int64Ptr(int64(100)) + sharePrototypeModel.MountTargets = []vpcv1.ShareMountTargetPrototypeIntf{shareMountTargetPrototypeModel} + sharePrototypeModel.Name = core.StringPtr("my-share") + sharePrototypeModel.Profile = shareProfileIdentityModel + sharePrototypeModel.ReplicaShare = sharePrototypeShareContextModel + sharePrototypeModel.UserTags = []string{} + sharePrototypeModel.Zone = zoneIdentityModel + sharePrototypeModel.AccessControlMode = core.StringPtr("security_group") + sharePrototypeModel.EncryptionKey = encryptionKeyIdentityModel + sharePrototypeModel.InitialOwner = shareInitialOwnerModel + sharePrototypeModel.ResourceGroup = resourceGroupIdentityModel + sharePrototypeModel.Size = core.Int64Ptr(int64(200)) - // Invoke operation - result, response, operationErr := vpcService.CreateSnapshotConsistencyGroup(createSnapshotConsistencyGroupOptionsModel) + // Construct an instance of the CreateShareOptions model + createShareOptionsModel := new(vpcv1.CreateShareOptions) + createShareOptionsModel.SharePrototype = sharePrototypeModel + createShareOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation with valid options model (positive test) + result, response, operationErr = vpcService.CreateShare(createShareOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) + Expect(result).ToNot(BeNil()) - // Verify a nil result - Expect(result).To(BeNil()) - }) - AfterEach(func() { - testServer.Close() - }) - }) - }) - Describe(`DeleteSnapshotConsistencyGroup(deleteSnapshotConsistencyGroupOptions *DeleteSnapshotConsistencyGroupOptions) - Operation response error`, func() { - version := "testString" - deleteSnapshotConsistencyGroupPath := "/snapshot_consistency_groups/testString" - Context(`Using mock server endpoint with invalid JSON response`, func() { - BeforeEach(func() { - testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { - defer GinkgoRecover() - - // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(deleteSnapshotConsistencyGroupPath)) - Expect(req.Method).To(Equal("DELETE")) - Expect(req.URL.Query()["version"]).To(Equal([]string{"testString"})) - Expect(req.URL.Query()["generation"]).To(Equal([]string{fmt.Sprint(int64(2))})) - res.Header().Set("Content-type", "application/json") - res.WriteHeader(202) - fmt.Fprint(res, `} this is not valid json {`) - })) }) - It(`Invoke DeleteSnapshotConsistencyGroup with error: Operation response processing error`, func() { + It(`Invoke CreateShare with error: Operation validation and request error`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -56318,160 +56868,107 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the DeleteSnapshotConsistencyGroupOptions model - deleteSnapshotConsistencyGroupOptionsModel := new(vpcv1.DeleteSnapshotConsistencyGroupOptions) - deleteSnapshotConsistencyGroupOptionsModel.ID = core.StringPtr("testString") - deleteSnapshotConsistencyGroupOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} - // Expect response parsing to fail since we are receiving a text/plain response - result, response, operationErr := vpcService.DeleteSnapshotConsistencyGroup(deleteSnapshotConsistencyGroupOptionsModel) - Expect(operationErr).ToNot(BeNil()) - Expect(response).ToNot(BeNil()) - Expect(result).To(BeNil()) - - // Enable retries and test again - vpcService.EnableRetries(0, 0) - result, response, operationErr = vpcService.DeleteSnapshotConsistencyGroup(deleteSnapshotConsistencyGroupOptionsModel) - Expect(operationErr).ToNot(BeNil()) - Expect(response).ToNot(BeNil()) - Expect(result).To(BeNil()) - }) - AfterEach(func() { - testServer.Close() - }) - }) - }) - Describe(`DeleteSnapshotConsistencyGroup(deleteSnapshotConsistencyGroupOptions *DeleteSnapshotConsistencyGroupOptions)`, func() { - version := "testString" - deleteSnapshotConsistencyGroupPath := "/snapshot_consistency_groups/testString" - Context(`Using mock server endpoint with timeout`, func() { - BeforeEach(func() { - testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { - defer GinkgoRecover() - - // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(deleteSnapshotConsistencyGroupPath)) - Expect(req.Method).To(Equal("DELETE")) + // Construct an instance of the VirtualNetworkInterfaceIPPrototypeReservedIPPrototypeVirtualNetworkInterfaceIPsContext model + virtualNetworkInterfaceIPPrototypeModel := new(vpcv1.VirtualNetworkInterfaceIPPrototypeReservedIPPrototypeVirtualNetworkInterfaceIPsContext) + virtualNetworkInterfaceIPPrototypeModel.Address = core.StringPtr("10.0.0.5") + virtualNetworkInterfaceIPPrototypeModel.AutoDelete = core.BoolPtr(false) + virtualNetworkInterfaceIPPrototypeModel.Name = core.StringPtr("my-reserved-ip") - 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) + // Construct an instance of the VirtualNetworkInterfacePrimaryIPPrototypeReservedIPPrototypeVirtualNetworkInterfacePrimaryIPContext model + virtualNetworkInterfacePrimaryIPPrototypeModel := new(vpcv1.VirtualNetworkInterfacePrimaryIPPrototypeReservedIPPrototypeVirtualNetworkInterfacePrimaryIPContext) + virtualNetworkInterfacePrimaryIPPrototypeModel.Address = core.StringPtr("10.0.0.5") + virtualNetworkInterfacePrimaryIPPrototypeModel.AutoDelete = core.BoolPtr(false) + virtualNetworkInterfacePrimaryIPPrototypeModel.Name = core.StringPtr("my-reserved-ip") - // Set mock response - res.Header().Set("Content-type", "application/json") - res.WriteHeader(202) - fmt.Fprintf(res, "%s", `{"backup_policy_plan": {"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6/plans/r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "id": "r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "name": "my-policy-plan", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "backup_policy_plan"}, "created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot-consistency-group:r134-fa329f6b-0e36-433f-a3bb-0df632e79263", "delete_snapshots_on_delete": false, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshot_consistency_groups/r134-fa329f6b-0e36-433f-a3bb-0df632e79263", "id": "r134-fa329f6b-0e36-433f-a3bb-0df632e79263", "lifecycle_state": "stable", "name": "my-snapshot-consistency-group", "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "resource_type": "snapshot_consistency_group", "service_tags": ["ServiceTags"], "snapshots": [{"crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "id": "r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "name": "my-snapshot", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "snapshot"}]}`) - })) - }) - It(`Invoke DeleteSnapshotConsistencyGroup successfully with retries`, func() { - vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ - URL: testServer.URL, - Authenticator: &core.NoAuthAuthenticator{}, - Version: core.StringPtr(version), - }) - Expect(serviceErr).To(BeNil()) - Expect(vpcService).ToNot(BeNil()) - vpcService.EnableRetries(0, 0) + // Construct an instance of the ResourceGroupIdentityByID model + resourceGroupIdentityModel := new(vpcv1.ResourceGroupIdentityByID) + resourceGroupIdentityModel.ID = core.StringPtr("fee82deba12e4c0fb69c3b09d1f12345") - // Construct an instance of the DeleteSnapshotConsistencyGroupOptions model - deleteSnapshotConsistencyGroupOptionsModel := new(vpcv1.DeleteSnapshotConsistencyGroupOptions) - deleteSnapshotConsistencyGroupOptionsModel.ID = core.StringPtr("testString") - deleteSnapshotConsistencyGroupOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the SecurityGroupIdentityByID model + securityGroupIdentityModel := new(vpcv1.SecurityGroupIdentityByID) + securityGroupIdentityModel.ID = core.StringPtr("be5df5ca-12a0-494b-907e-aa6ec2bfa271") - // Invoke operation with a Context to test a timeout error - ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond) - defer cancelFunc() - _, _, operationErr := vpcService.DeleteSnapshotConsistencyGroupWithContext(ctx, deleteSnapshotConsistencyGroupOptionsModel) - Expect(operationErr).ToNot(BeNil()) - Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) + // Construct an instance of the SubnetIdentityByID model + subnetIdentityModel := new(vpcv1.SubnetIdentityByID) + subnetIdentityModel.ID = core.StringPtr("7ec86020-1c6e-4889-b3f0-a15f2e50f87e") - // Disable retries and test again - vpcService.DisableRetries() - result, response, operationErr := vpcService.DeleteSnapshotConsistencyGroup(deleteSnapshotConsistencyGroupOptionsModel) - Expect(operationErr).To(BeNil()) - Expect(response).ToNot(BeNil()) - Expect(result).ToNot(BeNil()) + // Construct an instance of the ShareMountTargetVirtualNetworkInterfacePrototypeVirtualNetworkInterfacePrototypeShareMountTargetContext model + shareMountTargetVirtualNetworkInterfacePrototypeModel := new(vpcv1.ShareMountTargetVirtualNetworkInterfacePrototypeVirtualNetworkInterfacePrototypeShareMountTargetContext) + shareMountTargetVirtualNetworkInterfacePrototypeModel.AllowIPSpoofing = core.BoolPtr(true) + shareMountTargetVirtualNetworkInterfacePrototypeModel.AutoDelete = core.BoolPtr(false) + shareMountTargetVirtualNetworkInterfacePrototypeModel.EnableInfrastructureNat = core.BoolPtr(true) + shareMountTargetVirtualNetworkInterfacePrototypeModel.Ips = []vpcv1.VirtualNetworkInterfaceIPPrototypeIntf{virtualNetworkInterfaceIPPrototypeModel} + shareMountTargetVirtualNetworkInterfacePrototypeModel.Name = core.StringPtr("my-virtual-network-interface") + shareMountTargetVirtualNetworkInterfacePrototypeModel.PrimaryIP = virtualNetworkInterfacePrimaryIPPrototypeModel + shareMountTargetVirtualNetworkInterfacePrototypeModel.ResourceGroup = resourceGroupIdentityModel + shareMountTargetVirtualNetworkInterfacePrototypeModel.SecurityGroups = []vpcv1.SecurityGroupIdentityIntf{securityGroupIdentityModel} + shareMountTargetVirtualNetworkInterfacePrototypeModel.Subnet = subnetIdentityModel - // Re-test the timeout error with retries disabled - ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond) - defer cancelFunc2() - _, _, operationErr = vpcService.DeleteSnapshotConsistencyGroupWithContext(ctx, deleteSnapshotConsistencyGroupOptionsModel) - Expect(operationErr).ToNot(BeNil()) - Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) - }) - AfterEach(func() { - testServer.Close() - }) - }) - Context(`Using mock server endpoint`, func() { - BeforeEach(func() { - testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { - defer GinkgoRecover() + // Construct an instance of the ShareMountTargetPrototypeShareMountTargetByAccessControlModeSecurityGroup model + shareMountTargetPrototypeModel := new(vpcv1.ShareMountTargetPrototypeShareMountTargetByAccessControlModeSecurityGroup) + shareMountTargetPrototypeModel.Name = core.StringPtr("my-share-mount-target") + shareMountTargetPrototypeModel.TransitEncryption = core.StringPtr("none") + shareMountTargetPrototypeModel.VirtualNetworkInterface = shareMountTargetVirtualNetworkInterfacePrototypeModel - // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(deleteSnapshotConsistencyGroupPath)) - Expect(req.Method).To(Equal("DELETE")) + // Construct an instance of the ShareProfileIdentityByName model + shareProfileIdentityModel := new(vpcv1.ShareProfileIdentityByName) + shareProfileIdentityModel.Name = core.StringPtr("tier-3iops") - 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", `{"backup_policy_plan": {"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6/plans/r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "id": "r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "name": "my-policy-plan", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "backup_policy_plan"}, "created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot-consistency-group:r134-fa329f6b-0e36-433f-a3bb-0df632e79263", "delete_snapshots_on_delete": false, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshot_consistency_groups/r134-fa329f6b-0e36-433f-a3bb-0df632e79263", "id": "r134-fa329f6b-0e36-433f-a3bb-0df632e79263", "lifecycle_state": "stable", "name": "my-snapshot-consistency-group", "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "resource_type": "snapshot_consistency_group", "service_tags": ["ServiceTags"], "snapshots": [{"crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "id": "r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "name": "my-snapshot", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "snapshot"}]}`) - })) - }) - It(`Invoke DeleteSnapshotConsistencyGroup successfully`, func() { - vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ - URL: testServer.URL, - Authenticator: &core.NoAuthAuthenticator{}, - Version: core.StringPtr(version), - }) - Expect(serviceErr).To(BeNil()) - Expect(vpcService).ToNot(BeNil()) + // Construct an instance of the ZoneIdentityByName model + zoneIdentityModel := new(vpcv1.ZoneIdentityByName) + zoneIdentityModel.Name = core.StringPtr("us-south-1") - // Invoke operation with nil options model (negative test) - result, response, operationErr := vpcService.DeleteSnapshotConsistencyGroup(nil) - Expect(operationErr).NotTo(BeNil()) - Expect(response).To(BeNil()) - Expect(result).To(BeNil()) + // Construct an instance of the SharePrototypeShareContext model + sharePrototypeShareContextModel := new(vpcv1.SharePrototypeShareContext) + sharePrototypeShareContextModel.Iops = core.Int64Ptr(int64(100)) + sharePrototypeShareContextModel.MountTargets = []vpcv1.ShareMountTargetPrototypeIntf{shareMountTargetPrototypeModel} + sharePrototypeShareContextModel.Name = core.StringPtr("my-share") + sharePrototypeShareContextModel.Profile = shareProfileIdentityModel + sharePrototypeShareContextModel.ReplicationCronSpec = core.StringPtr("0 */5 * * *") + sharePrototypeShareContextModel.ResourceGroup = resourceGroupIdentityModel + sharePrototypeShareContextModel.UserTags = []string{} + sharePrototypeShareContextModel.Zone = zoneIdentityModel - // Construct an instance of the DeleteSnapshotConsistencyGroupOptions model - deleteSnapshotConsistencyGroupOptionsModel := new(vpcv1.DeleteSnapshotConsistencyGroupOptions) - deleteSnapshotConsistencyGroupOptionsModel.ID = core.StringPtr("testString") - deleteSnapshotConsistencyGroupOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the EncryptionKeyIdentityByCRN model + encryptionKeyIdentityModel := new(vpcv1.EncryptionKeyIdentityByCRN) + encryptionKeyIdentityModel.CRN = core.StringPtr("crn:v1:bluemix:public:kms:us-south:a/123456:e4a29d1a-2ef0-42a6-8fd2-350deb1c647e:key:5437653b-c4b1-447f-9646-b2a2a4cd6179") - // Invoke operation with valid options model (positive test) - result, response, operationErr = vpcService.DeleteSnapshotConsistencyGroup(deleteSnapshotConsistencyGroupOptionsModel) - Expect(operationErr).To(BeNil()) - Expect(response).ToNot(BeNil()) - Expect(result).ToNot(BeNil()) + // Construct an instance of the ShareInitialOwner model + shareInitialOwnerModel := new(vpcv1.ShareInitialOwner) + shareInitialOwnerModel.Gid = core.Int64Ptr(int64(50)) + shareInitialOwnerModel.Uid = core.Int64Ptr(int64(50)) - }) - It(`Invoke DeleteSnapshotConsistencyGroup 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 SharePrototypeShareBySize model + sharePrototypeModel := new(vpcv1.SharePrototypeShareBySize) + sharePrototypeModel.Iops = core.Int64Ptr(int64(100)) + sharePrototypeModel.MountTargets = []vpcv1.ShareMountTargetPrototypeIntf{shareMountTargetPrototypeModel} + sharePrototypeModel.Name = core.StringPtr("my-share") + sharePrototypeModel.Profile = shareProfileIdentityModel + sharePrototypeModel.ReplicaShare = sharePrototypeShareContextModel + sharePrototypeModel.UserTags = []string{} + sharePrototypeModel.Zone = zoneIdentityModel + sharePrototypeModel.AccessControlMode = core.StringPtr("security_group") + sharePrototypeModel.EncryptionKey = encryptionKeyIdentityModel + sharePrototypeModel.InitialOwner = shareInitialOwnerModel + sharePrototypeModel.ResourceGroup = resourceGroupIdentityModel + sharePrototypeModel.Size = core.Int64Ptr(int64(200)) - // Construct an instance of the DeleteSnapshotConsistencyGroupOptions model - deleteSnapshotConsistencyGroupOptionsModel := new(vpcv1.DeleteSnapshotConsistencyGroupOptions) - deleteSnapshotConsistencyGroupOptionsModel.ID = core.StringPtr("testString") - deleteSnapshotConsistencyGroupOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the CreateShareOptions model + createShareOptionsModel := new(vpcv1.CreateShareOptions) + createShareOptionsModel.SharePrototype = sharePrototypeModel + createShareOptionsModel.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.DeleteSnapshotConsistencyGroup(deleteSnapshotConsistencyGroupOptionsModel) + result, response, operationErr := vpcService.CreateShare(createShareOptionsModel) 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 DeleteSnapshotConsistencyGroupOptions model with no property values - deleteSnapshotConsistencyGroupOptionsModelNew := new(vpcv1.DeleteSnapshotConsistencyGroupOptions) + // Construct a second instance of the CreateShareOptions model with no property values + createShareOptionsModelNew := new(vpcv1.CreateShareOptions) // Invoke operation with invalid model (negative test) - result, response, operationErr = vpcService.DeleteSnapshotConsistencyGroup(deleteSnapshotConsistencyGroupOptionsModelNew) + result, response, operationErr = vpcService.CreateShare(createShareOptionsModelNew) Expect(operationErr).ToNot(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) @@ -56486,10 +56983,10 @@ var _ = Describe(`VpcV1`, func() { defer GinkgoRecover() // Set success status code with no respoonse body - res.WriteHeader(202) + res.WriteHeader(201) })) }) - It(`Invoke DeleteSnapshotConsistencyGroup successfully`, func() { + It(`Invoke CreateShare successfully`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -56498,13 +56995,98 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the DeleteSnapshotConsistencyGroupOptions model - deleteSnapshotConsistencyGroupOptionsModel := new(vpcv1.DeleteSnapshotConsistencyGroupOptions) - deleteSnapshotConsistencyGroupOptionsModel.ID = core.StringPtr("testString") - deleteSnapshotConsistencyGroupOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the VirtualNetworkInterfaceIPPrototypeReservedIPPrototypeVirtualNetworkInterfaceIPsContext model + virtualNetworkInterfaceIPPrototypeModel := new(vpcv1.VirtualNetworkInterfaceIPPrototypeReservedIPPrototypeVirtualNetworkInterfaceIPsContext) + virtualNetworkInterfaceIPPrototypeModel.Address = core.StringPtr("10.0.0.5") + virtualNetworkInterfaceIPPrototypeModel.AutoDelete = core.BoolPtr(false) + virtualNetworkInterfaceIPPrototypeModel.Name = core.StringPtr("my-reserved-ip") + + // Construct an instance of the VirtualNetworkInterfacePrimaryIPPrototypeReservedIPPrototypeVirtualNetworkInterfacePrimaryIPContext model + virtualNetworkInterfacePrimaryIPPrototypeModel := new(vpcv1.VirtualNetworkInterfacePrimaryIPPrototypeReservedIPPrototypeVirtualNetworkInterfacePrimaryIPContext) + virtualNetworkInterfacePrimaryIPPrototypeModel.Address = core.StringPtr("10.0.0.5") + virtualNetworkInterfacePrimaryIPPrototypeModel.AutoDelete = core.BoolPtr(false) + virtualNetworkInterfacePrimaryIPPrototypeModel.Name = core.StringPtr("my-reserved-ip") + + // Construct an instance of the ResourceGroupIdentityByID model + resourceGroupIdentityModel := new(vpcv1.ResourceGroupIdentityByID) + resourceGroupIdentityModel.ID = core.StringPtr("fee82deba12e4c0fb69c3b09d1f12345") + + // Construct an instance of the SecurityGroupIdentityByID model + securityGroupIdentityModel := new(vpcv1.SecurityGroupIdentityByID) + securityGroupIdentityModel.ID = core.StringPtr("be5df5ca-12a0-494b-907e-aa6ec2bfa271") + + // Construct an instance of the SubnetIdentityByID model + subnetIdentityModel := new(vpcv1.SubnetIdentityByID) + subnetIdentityModel.ID = core.StringPtr("7ec86020-1c6e-4889-b3f0-a15f2e50f87e") + + // Construct an instance of the ShareMountTargetVirtualNetworkInterfacePrototypeVirtualNetworkInterfacePrototypeShareMountTargetContext model + shareMountTargetVirtualNetworkInterfacePrototypeModel := new(vpcv1.ShareMountTargetVirtualNetworkInterfacePrototypeVirtualNetworkInterfacePrototypeShareMountTargetContext) + shareMountTargetVirtualNetworkInterfacePrototypeModel.AllowIPSpoofing = core.BoolPtr(true) + shareMountTargetVirtualNetworkInterfacePrototypeModel.AutoDelete = core.BoolPtr(false) + shareMountTargetVirtualNetworkInterfacePrototypeModel.EnableInfrastructureNat = core.BoolPtr(true) + shareMountTargetVirtualNetworkInterfacePrototypeModel.Ips = []vpcv1.VirtualNetworkInterfaceIPPrototypeIntf{virtualNetworkInterfaceIPPrototypeModel} + shareMountTargetVirtualNetworkInterfacePrototypeModel.Name = core.StringPtr("my-virtual-network-interface") + shareMountTargetVirtualNetworkInterfacePrototypeModel.PrimaryIP = virtualNetworkInterfacePrimaryIPPrototypeModel + shareMountTargetVirtualNetworkInterfacePrototypeModel.ResourceGroup = resourceGroupIdentityModel + shareMountTargetVirtualNetworkInterfacePrototypeModel.SecurityGroups = []vpcv1.SecurityGroupIdentityIntf{securityGroupIdentityModel} + shareMountTargetVirtualNetworkInterfacePrototypeModel.Subnet = subnetIdentityModel + + // Construct an instance of the ShareMountTargetPrototypeShareMountTargetByAccessControlModeSecurityGroup model + shareMountTargetPrototypeModel := new(vpcv1.ShareMountTargetPrototypeShareMountTargetByAccessControlModeSecurityGroup) + shareMountTargetPrototypeModel.Name = core.StringPtr("my-share-mount-target") + shareMountTargetPrototypeModel.TransitEncryption = core.StringPtr("none") + shareMountTargetPrototypeModel.VirtualNetworkInterface = shareMountTargetVirtualNetworkInterfacePrototypeModel + + // Construct an instance of the ShareProfileIdentityByName model + shareProfileIdentityModel := new(vpcv1.ShareProfileIdentityByName) + shareProfileIdentityModel.Name = core.StringPtr("tier-3iops") + + // Construct an instance of the ZoneIdentityByName model + zoneIdentityModel := new(vpcv1.ZoneIdentityByName) + zoneIdentityModel.Name = core.StringPtr("us-south-1") + + // Construct an instance of the SharePrototypeShareContext model + sharePrototypeShareContextModel := new(vpcv1.SharePrototypeShareContext) + sharePrototypeShareContextModel.Iops = core.Int64Ptr(int64(100)) + sharePrototypeShareContextModel.MountTargets = []vpcv1.ShareMountTargetPrototypeIntf{shareMountTargetPrototypeModel} + sharePrototypeShareContextModel.Name = core.StringPtr("my-share") + sharePrototypeShareContextModel.Profile = shareProfileIdentityModel + sharePrototypeShareContextModel.ReplicationCronSpec = core.StringPtr("0 */5 * * *") + sharePrototypeShareContextModel.ResourceGroup = resourceGroupIdentityModel + sharePrototypeShareContextModel.UserTags = []string{} + sharePrototypeShareContextModel.Zone = zoneIdentityModel + + // Construct an instance of the EncryptionKeyIdentityByCRN model + encryptionKeyIdentityModel := new(vpcv1.EncryptionKeyIdentityByCRN) + encryptionKeyIdentityModel.CRN = core.StringPtr("crn:v1:bluemix:public:kms:us-south:a/123456:e4a29d1a-2ef0-42a6-8fd2-350deb1c647e:key:5437653b-c4b1-447f-9646-b2a2a4cd6179") + + // Construct an instance of the ShareInitialOwner model + shareInitialOwnerModel := new(vpcv1.ShareInitialOwner) + shareInitialOwnerModel.Gid = core.Int64Ptr(int64(50)) + shareInitialOwnerModel.Uid = core.Int64Ptr(int64(50)) + + // Construct an instance of the SharePrototypeShareBySize model + sharePrototypeModel := new(vpcv1.SharePrototypeShareBySize) + sharePrototypeModel.Iops = core.Int64Ptr(int64(100)) + sharePrototypeModel.MountTargets = []vpcv1.ShareMountTargetPrototypeIntf{shareMountTargetPrototypeModel} + sharePrototypeModel.Name = core.StringPtr("my-share") + sharePrototypeModel.Profile = shareProfileIdentityModel + sharePrototypeModel.ReplicaShare = sharePrototypeShareContextModel + sharePrototypeModel.UserTags = []string{} + sharePrototypeModel.Zone = zoneIdentityModel + sharePrototypeModel.AccessControlMode = core.StringPtr("security_group") + sharePrototypeModel.EncryptionKey = encryptionKeyIdentityModel + sharePrototypeModel.InitialOwner = shareInitialOwnerModel + sharePrototypeModel.ResourceGroup = resourceGroupIdentityModel + sharePrototypeModel.Size = core.Int64Ptr(int64(200)) + + // Construct an instance of the CreateShareOptions model + createShareOptionsModel := new(vpcv1.CreateShareOptions) + createShareOptionsModel.SharePrototype = sharePrototypeModel + createShareOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation - result, response, operationErr := vpcService.DeleteSnapshotConsistencyGroup(deleteSnapshotConsistencyGroupOptionsModel) + result, response, operationErr := vpcService.CreateShare(createShareOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) @@ -56516,25 +57098,27 @@ var _ = Describe(`VpcV1`, func() { }) }) }) - Describe(`GetSnapshotConsistencyGroup(getSnapshotConsistencyGroupOptions *GetSnapshotConsistencyGroupOptions) - Operation response error`, func() { + Describe(`DeleteShare(deleteShareOptions *DeleteShareOptions) - Operation response error`, func() { version := "testString" - getSnapshotConsistencyGroupPath := "/snapshot_consistency_groups/testString" + deleteSharePath := "/shares/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(getSnapshotConsistencyGroupPath)) - Expect(req.Method).To(Equal("GET")) + Expect(req.URL.EscapedPath()).To(Equal(deleteSharePath)) + 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(200) + res.WriteHeader(202) fmt.Fprint(res, `} this is not valid json {`) })) }) - It(`Invoke GetSnapshotConsistencyGroup with error: Operation response processing error`, func() { + It(`Invoke DeleteShare with error: Operation response processing error`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -56543,19 +57127,20 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the GetSnapshotConsistencyGroupOptions model - getSnapshotConsistencyGroupOptionsModel := new(vpcv1.GetSnapshotConsistencyGroupOptions) - getSnapshotConsistencyGroupOptionsModel.ID = core.StringPtr("testString") - getSnapshotConsistencyGroupOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the DeleteShareOptions model + deleteShareOptionsModel := new(vpcv1.DeleteShareOptions) + deleteShareOptionsModel.ID = core.StringPtr("testString") + deleteShareOptionsModel.IfMatch = core.StringPtr("W/\"96d225c4-56bd-43d9-98fc-d7148e5c5028\"") + deleteShareOptionsModel.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.GetSnapshotConsistencyGroup(getSnapshotConsistencyGroupOptionsModel) + result, response, operationErr := vpcService.DeleteShare(deleteShareOptionsModel) 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.GetSnapshotConsistencyGroup(getSnapshotConsistencyGroupOptionsModel) + result, response, operationErr = vpcService.DeleteShare(deleteShareOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).To(BeNil()) @@ -56565,18 +57150,20 @@ var _ = Describe(`VpcV1`, func() { }) }) }) - Describe(`GetSnapshotConsistencyGroup(getSnapshotConsistencyGroupOptions *GetSnapshotConsistencyGroupOptions)`, func() { + Describe(`DeleteShare(deleteShareOptions *DeleteShareOptions)`, func() { version := "testString" - getSnapshotConsistencyGroupPath := "/snapshot_consistency_groups/testString" + deleteSharePath := "/shares/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(getSnapshotConsistencyGroupPath)) - Expect(req.Method).To(Equal("GET")) + Expect(req.URL.EscapedPath()).To(Equal(deleteSharePath)) + 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 @@ -56584,11 +57171,11 @@ var _ = Describe(`VpcV1`, func() { // Set mock response res.Header().Set("Content-type", "application/json") - res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"backup_policy_plan": {"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6/plans/r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "id": "r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "name": "my-policy-plan", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "backup_policy_plan"}, "created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot-consistency-group:r134-fa329f6b-0e36-433f-a3bb-0df632e79263", "delete_snapshots_on_delete": false, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshot_consistency_groups/r134-fa329f6b-0e36-433f-a3bb-0df632e79263", "id": "r134-fa329f6b-0e36-433f-a3bb-0df632e79263", "lifecycle_state": "stable", "name": "my-snapshot-consistency-group", "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "resource_type": "snapshot_consistency_group", "service_tags": ["ServiceTags"], "snapshots": [{"crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "id": "r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "name": "my-snapshot", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "snapshot"}]}`) + res.WriteHeader(202) + fmt.Fprintf(res, "%s", `{"access_control_mode": "security_group", "created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::share:0fe9e5d8-0a4d-4818-96ec-e99708644a58", "encryption": "provider_managed", "encryption_key": {"crn": "crn:v1:bluemix:public:kms:us-south:a/123456:e4a29d1a-2ef0-42a6-8fd2-350deb1c647e:key:5437653b-c4b1-447f-9646-b2a2a4cd6179"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/shares/0fe9e5d8-0a4d-4818-96ec-e99708644a58", "id": "0fe9e5d8-0a4d-4818-96ec-e99708644a58", "iops": 100, "latest_job": {"status": "cancelled", "status_reasons": [{"code": "cannot_reach_source_share", "message": "The replication failover failed because the source share cannot be reached.", "more_info": "https://cloud.ibm.com/docs/vpc?topic=vpc-file-storage-planning"}], "type": "replication_failover"}, "latest_sync": {"completed_at": "2019-01-01T12:00:00.000Z", "data_transferred": 0, "started_at": "2019-01-01T12:00:00.000Z"}, "lifecycle_state": "stable", "mount_targets": [{"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/shares/0fe9e5d8-0a4d-4818-96ec-e99708644a58/mount_targets/4cf9171a-0043-4434-8727-15b53dbc374c", "id": "4cf9171a-0043-4434-8727-15b53dbc374c", "name": "my-share-mount-target", "resource_type": "share_mount_target"}], "name": "my-share", "profile": {"href": "https://us-south.iaas.cloud.ibm.com/v1/share/profiles/tier-3iops", "name": "tier-3iops", "resource_type": "share_profile"}, "replica_share": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::share:0fe9e5d8-0a4d-4818-96ec-e99708644a58", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/shares/0fe9e5d8-0a4d-4818-96ec-e99708644a58", "id": "0fe9e5d8-0a4d-4818-96ec-e99708644a58", "name": "my-share", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "share"}, "replication_cron_spec": "0 */5 * * *", "replication_role": "none", "replication_status": "active", "replication_status_reasons": [{"code": "cannot_reach_source_share", "message": "The replication failover failed because the source share cannot be reached.", "more_info": "https://cloud.ibm.com/docs/vpc?topic=vpc-file-storage-planning"}], "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "resource_type": "share", "size": 200, "source_share": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::share:0fe9e5d8-0a4d-4818-96ec-e99708644a58", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/shares/0fe9e5d8-0a4d-4818-96ec-e99708644a58", "id": "0fe9e5d8-0a4d-4818-96ec-e99708644a58", "name": "my-share", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "share"}, "user_tags": ["UserTags"], "zone": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south/zones/us-south-1", "name": "us-south-1"}}`) })) }) - It(`Invoke GetSnapshotConsistencyGroup successfully with retries`, func() { + It(`Invoke DeleteShare successfully with retries`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -56598,21 +57185,22 @@ var _ = Describe(`VpcV1`, func() { Expect(vpcService).ToNot(BeNil()) vpcService.EnableRetries(0, 0) - // Construct an instance of the GetSnapshotConsistencyGroupOptions model - getSnapshotConsistencyGroupOptionsModel := new(vpcv1.GetSnapshotConsistencyGroupOptions) - getSnapshotConsistencyGroupOptionsModel.ID = core.StringPtr("testString") - getSnapshotConsistencyGroupOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the DeleteShareOptions model + deleteShareOptionsModel := new(vpcv1.DeleteShareOptions) + deleteShareOptionsModel.ID = core.StringPtr("testString") + deleteShareOptionsModel.IfMatch = core.StringPtr("W/\"96d225c4-56bd-43d9-98fc-d7148e5c5028\"") + deleteShareOptionsModel.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.GetSnapshotConsistencyGroupWithContext(ctx, getSnapshotConsistencyGroupOptionsModel) + _, _, operationErr := vpcService.DeleteShareWithContext(ctx, deleteShareOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) // Disable retries and test again vpcService.DisableRetries() - result, response, operationErr := vpcService.GetSnapshotConsistencyGroup(getSnapshotConsistencyGroupOptionsModel) + result, response, operationErr := vpcService.DeleteShare(deleteShareOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) @@ -56620,7 +57208,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.GetSnapshotConsistencyGroupWithContext(ctx, getSnapshotConsistencyGroupOptionsModel) + _, _, operationErr = vpcService.DeleteShareWithContext(ctx, deleteShareOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) }) @@ -56634,18 +57222,20 @@ var _ = Describe(`VpcV1`, func() { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(getSnapshotConsistencyGroupPath)) - Expect(req.Method).To(Equal("GET")) + Expect(req.URL.EscapedPath()).To(Equal(deleteSharePath)) + 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(200) - fmt.Fprintf(res, "%s", `{"backup_policy_plan": {"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6/plans/r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "id": "r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "name": "my-policy-plan", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "backup_policy_plan"}, "created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot-consistency-group:r134-fa329f6b-0e36-433f-a3bb-0df632e79263", "delete_snapshots_on_delete": false, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshot_consistency_groups/r134-fa329f6b-0e36-433f-a3bb-0df632e79263", "id": "r134-fa329f6b-0e36-433f-a3bb-0df632e79263", "lifecycle_state": "stable", "name": "my-snapshot-consistency-group", "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "resource_type": "snapshot_consistency_group", "service_tags": ["ServiceTags"], "snapshots": [{"crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "id": "r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "name": "my-snapshot", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "snapshot"}]}`) + res.WriteHeader(202) + fmt.Fprintf(res, "%s", `{"access_control_mode": "security_group", "created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::share:0fe9e5d8-0a4d-4818-96ec-e99708644a58", "encryption": "provider_managed", "encryption_key": {"crn": "crn:v1:bluemix:public:kms:us-south:a/123456:e4a29d1a-2ef0-42a6-8fd2-350deb1c647e:key:5437653b-c4b1-447f-9646-b2a2a4cd6179"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/shares/0fe9e5d8-0a4d-4818-96ec-e99708644a58", "id": "0fe9e5d8-0a4d-4818-96ec-e99708644a58", "iops": 100, "latest_job": {"status": "cancelled", "status_reasons": [{"code": "cannot_reach_source_share", "message": "The replication failover failed because the source share cannot be reached.", "more_info": "https://cloud.ibm.com/docs/vpc?topic=vpc-file-storage-planning"}], "type": "replication_failover"}, "latest_sync": {"completed_at": "2019-01-01T12:00:00.000Z", "data_transferred": 0, "started_at": "2019-01-01T12:00:00.000Z"}, "lifecycle_state": "stable", "mount_targets": [{"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/shares/0fe9e5d8-0a4d-4818-96ec-e99708644a58/mount_targets/4cf9171a-0043-4434-8727-15b53dbc374c", "id": "4cf9171a-0043-4434-8727-15b53dbc374c", "name": "my-share-mount-target", "resource_type": "share_mount_target"}], "name": "my-share", "profile": {"href": "https://us-south.iaas.cloud.ibm.com/v1/share/profiles/tier-3iops", "name": "tier-3iops", "resource_type": "share_profile"}, "replica_share": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::share:0fe9e5d8-0a4d-4818-96ec-e99708644a58", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/shares/0fe9e5d8-0a4d-4818-96ec-e99708644a58", "id": "0fe9e5d8-0a4d-4818-96ec-e99708644a58", "name": "my-share", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "share"}, "replication_cron_spec": "0 */5 * * *", "replication_role": "none", "replication_status": "active", "replication_status_reasons": [{"code": "cannot_reach_source_share", "message": "The replication failover failed because the source share cannot be reached.", "more_info": "https://cloud.ibm.com/docs/vpc?topic=vpc-file-storage-planning"}], "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "resource_type": "share", "size": 200, "source_share": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::share:0fe9e5d8-0a4d-4818-96ec-e99708644a58", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/shares/0fe9e5d8-0a4d-4818-96ec-e99708644a58", "id": "0fe9e5d8-0a4d-4818-96ec-e99708644a58", "name": "my-share", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "share"}, "user_tags": ["UserTags"], "zone": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south/zones/us-south-1", "name": "us-south-1"}}`) })) }) - It(`Invoke GetSnapshotConsistencyGroup successfully`, func() { + It(`Invoke DeleteShare successfully`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -56655,24 +57245,25 @@ var _ = Describe(`VpcV1`, func() { Expect(vpcService).ToNot(BeNil()) // Invoke operation with nil options model (negative test) - result, response, operationErr := vpcService.GetSnapshotConsistencyGroup(nil) + result, response, operationErr := vpcService.DeleteShare(nil) Expect(operationErr).NotTo(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) - // Construct an instance of the GetSnapshotConsistencyGroupOptions model - getSnapshotConsistencyGroupOptionsModel := new(vpcv1.GetSnapshotConsistencyGroupOptions) - getSnapshotConsistencyGroupOptionsModel.ID = core.StringPtr("testString") - getSnapshotConsistencyGroupOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the DeleteShareOptions model + deleteShareOptionsModel := new(vpcv1.DeleteShareOptions) + deleteShareOptionsModel.ID = core.StringPtr("testString") + deleteShareOptionsModel.IfMatch = core.StringPtr("W/\"96d225c4-56bd-43d9-98fc-d7148e5c5028\"") + deleteShareOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with valid options model (positive test) - result, response, operationErr = vpcService.GetSnapshotConsistencyGroup(getSnapshotConsistencyGroupOptionsModel) + result, response, operationErr = vpcService.DeleteShare(deleteShareOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) }) - It(`Invoke GetSnapshotConsistencyGroup with error: Operation validation and request error`, func() { + It(`Invoke DeleteShare with error: Operation validation and request error`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -56681,22 +57272,23 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the GetSnapshotConsistencyGroupOptions model - getSnapshotConsistencyGroupOptionsModel := new(vpcv1.GetSnapshotConsistencyGroupOptions) - getSnapshotConsistencyGroupOptionsModel.ID = core.StringPtr("testString") - getSnapshotConsistencyGroupOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the DeleteShareOptions model + deleteShareOptionsModel := new(vpcv1.DeleteShareOptions) + deleteShareOptionsModel.ID = core.StringPtr("testString") + deleteShareOptionsModel.IfMatch = core.StringPtr("W/\"96d225c4-56bd-43d9-98fc-d7148e5c5028\"") + deleteShareOptionsModel.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.GetSnapshotConsistencyGroup(getSnapshotConsistencyGroupOptionsModel) + result, response, operationErr := vpcService.DeleteShare(deleteShareOptionsModel) 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 GetSnapshotConsistencyGroupOptions model with no property values - getSnapshotConsistencyGroupOptionsModelNew := new(vpcv1.GetSnapshotConsistencyGroupOptions) + // Construct a second instance of the DeleteShareOptions model with no property values + deleteShareOptionsModelNew := new(vpcv1.DeleteShareOptions) // Invoke operation with invalid model (negative test) - result, response, operationErr = vpcService.GetSnapshotConsistencyGroup(getSnapshotConsistencyGroupOptionsModelNew) + result, response, operationErr = vpcService.DeleteShare(deleteShareOptionsModelNew) Expect(operationErr).ToNot(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) @@ -56711,10 +57303,10 @@ var _ = Describe(`VpcV1`, func() { defer GinkgoRecover() // Set success status code with no respoonse body - res.WriteHeader(200) + res.WriteHeader(202) })) }) - It(`Invoke GetSnapshotConsistencyGroup successfully`, func() { + It(`Invoke DeleteShare successfully`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -56723,13 +57315,14 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the GetSnapshotConsistencyGroupOptions model - getSnapshotConsistencyGroupOptionsModel := new(vpcv1.GetSnapshotConsistencyGroupOptions) - getSnapshotConsistencyGroupOptionsModel.ID = core.StringPtr("testString") - getSnapshotConsistencyGroupOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the DeleteShareOptions model + deleteShareOptionsModel := new(vpcv1.DeleteShareOptions) + deleteShareOptionsModel.ID = core.StringPtr("testString") + deleteShareOptionsModel.IfMatch = core.StringPtr("W/\"96d225c4-56bd-43d9-98fc-d7148e5c5028\"") + deleteShareOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation - result, response, operationErr := vpcService.GetSnapshotConsistencyGroup(getSnapshotConsistencyGroupOptionsModel) + result, response, operationErr := vpcService.DeleteShare(deleteShareOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) @@ -56741,19 +57334,17 @@ var _ = Describe(`VpcV1`, func() { }) }) }) - Describe(`UpdateSnapshotConsistencyGroup(updateSnapshotConsistencyGroupOptions *UpdateSnapshotConsistencyGroupOptions) - Operation response error`, func() { + Describe(`GetShare(getShareOptions *GetShareOptions) - Operation response error`, func() { version := "testString" - updateSnapshotConsistencyGroupPath := "/snapshot_consistency_groups/testString" + getSharePath := "/shares/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(updateSnapshotConsistencyGroupPath)) - Expect(req.Method).To(Equal("PATCH")) - Expect(req.Header["If-Match"]).ToNot(BeNil()) - Expect(req.Header["If-Match"][0]).To(Equal(fmt.Sprintf("%v", `W/"96d225c4-56bd-43d9-98fc-d7148e5c5028"`))) + Expect(req.URL.EscapedPath()).To(Equal(getSharePath)) + 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") @@ -56761,7 +57352,7 @@ var _ = Describe(`VpcV1`, func() { fmt.Fprint(res, `} this is not valid json {`) })) }) - It(`Invoke UpdateSnapshotConsistencyGroup with error: Operation response processing error`, func() { + It(`Invoke GetShare with error: Operation response processing error`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -56770,250 +57361,52 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the SnapshotConsistencyGroupPatch model - snapshotConsistencyGroupPatchModel := new(vpcv1.SnapshotConsistencyGroupPatch) - snapshotConsistencyGroupPatchModel.DeleteSnapshotsOnDelete = core.BoolPtr(true) - snapshotConsistencyGroupPatchModel.Name = core.StringPtr("my-snapshot-consistency-group") - snapshotConsistencyGroupPatchModelAsPatch, asPatchErr := snapshotConsistencyGroupPatchModel.AsPatch() - Expect(asPatchErr).To(BeNil()) - - // Construct an instance of the UpdateSnapshotConsistencyGroupOptions model - updateSnapshotConsistencyGroupOptionsModel := new(vpcv1.UpdateSnapshotConsistencyGroupOptions) - updateSnapshotConsistencyGroupOptionsModel.ID = core.StringPtr("testString") - updateSnapshotConsistencyGroupOptionsModel.SnapshotConsistencyGroupPatch = snapshotConsistencyGroupPatchModelAsPatch - updateSnapshotConsistencyGroupOptionsModel.IfMatch = core.StringPtr(`W/"96d225c4-56bd-43d9-98fc-d7148e5c5028"`) - updateSnapshotConsistencyGroupOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the GetShareOptions model + getShareOptionsModel := new(vpcv1.GetShareOptions) + getShareOptionsModel.ID = core.StringPtr("testString") + getShareOptionsModel.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.UpdateSnapshotConsistencyGroup(updateSnapshotConsistencyGroupOptionsModel) + result, response, operationErr := vpcService.GetShare(getShareOptionsModel) 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.UpdateSnapshotConsistencyGroup(updateSnapshotConsistencyGroupOptionsModel) - Expect(operationErr).ToNot(BeNil()) - Expect(response).ToNot(BeNil()) - Expect(result).To(BeNil()) - }) - AfterEach(func() { - testServer.Close() - }) - }) - }) - Describe(`UpdateSnapshotConsistencyGroup(updateSnapshotConsistencyGroupOptions *UpdateSnapshotConsistencyGroupOptions)`, func() { - version := "testString" - updateSnapshotConsistencyGroupPath := "/snapshot_consistency_groups/testString" - Context(`Using mock server endpoint with timeout`, func() { - BeforeEach(func() { - testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { - defer GinkgoRecover() - - // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(updateSnapshotConsistencyGroupPath)) - Expect(req.Method).To(Equal("PATCH")) - - // For gzip-disabled operation, verify Content-Encoding is not set. - Expect(req.Header.Get("Content-Encoding")).To(BeEmpty()) - - // If there is a body, then make sure we can read it - bodyBuf := new(bytes.Buffer) - if req.Header.Get("Content-Encoding") == "gzip" { - body, err := core.NewGzipDecompressionReader(req.Body) - Expect(err).To(BeNil()) - _, err = bodyBuf.ReadFrom(body) - Expect(err).To(BeNil()) - } else { - _, err := bodyBuf.ReadFrom(req.Body) - Expect(err).To(BeNil()) - } - fmt.Fprintf(GinkgoWriter, " Request body: %s", bodyBuf.String()) - - Expect(req.Header["If-Match"]).ToNot(BeNil()) - Expect(req.Header["If-Match"][0]).To(Equal(fmt.Sprintf("%v", `W/"96d225c4-56bd-43d9-98fc-d7148e5c5028"`))) - Expect(req.URL.Query()["version"]).To(Equal([]string{"testString"})) - Expect(req.URL.Query()["generation"]).To(Equal([]string{fmt.Sprint(int64(2))})) - // Sleep a short time to support a timeout test - time.Sleep(100 * time.Millisecond) - - // Set mock response - res.Header().Set("Content-type", "application/json") - res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"backup_policy_plan": {"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6/plans/r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "id": "r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "name": "my-policy-plan", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "backup_policy_plan"}, "created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot-consistency-group:r134-fa329f6b-0e36-433f-a3bb-0df632e79263", "delete_snapshots_on_delete": false, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshot_consistency_groups/r134-fa329f6b-0e36-433f-a3bb-0df632e79263", "id": "r134-fa329f6b-0e36-433f-a3bb-0df632e79263", "lifecycle_state": "stable", "name": "my-snapshot-consistency-group", "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "resource_type": "snapshot_consistency_group", "service_tags": ["ServiceTags"], "snapshots": [{"crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "id": "r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "name": "my-snapshot", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "snapshot"}]}`) - })) - }) - It(`Invoke UpdateSnapshotConsistencyGroup successfully 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 SnapshotConsistencyGroupPatch model - snapshotConsistencyGroupPatchModel := new(vpcv1.SnapshotConsistencyGroupPatch) - snapshotConsistencyGroupPatchModel.DeleteSnapshotsOnDelete = core.BoolPtr(true) - snapshotConsistencyGroupPatchModel.Name = core.StringPtr("my-snapshot-consistency-group") - snapshotConsistencyGroupPatchModelAsPatch, asPatchErr := snapshotConsistencyGroupPatchModel.AsPatch() - Expect(asPatchErr).To(BeNil()) - - // Construct an instance of the UpdateSnapshotConsistencyGroupOptions model - updateSnapshotConsistencyGroupOptionsModel := new(vpcv1.UpdateSnapshotConsistencyGroupOptions) - updateSnapshotConsistencyGroupOptionsModel.ID = core.StringPtr("testString") - updateSnapshotConsistencyGroupOptionsModel.SnapshotConsistencyGroupPatch = snapshotConsistencyGroupPatchModelAsPatch - updateSnapshotConsistencyGroupOptionsModel.IfMatch = core.StringPtr(`W/"96d225c4-56bd-43d9-98fc-d7148e5c5028"`) - updateSnapshotConsistencyGroupOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} - - // Invoke operation with a Context to test a timeout error - ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond) - defer cancelFunc() - _, _, operationErr := vpcService.UpdateSnapshotConsistencyGroupWithContext(ctx, updateSnapshotConsistencyGroupOptionsModel) - Expect(operationErr).ToNot(BeNil()) - Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) - - // Disable retries and test again - vpcService.DisableRetries() - result, response, operationErr := vpcService.UpdateSnapshotConsistencyGroup(updateSnapshotConsistencyGroupOptionsModel) - 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.UpdateSnapshotConsistencyGroupWithContext(ctx, updateSnapshotConsistencyGroupOptionsModel) - 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(updateSnapshotConsistencyGroupPath)) - Expect(req.Method).To(Equal("PATCH")) - - // For gzip-disabled operation, verify Content-Encoding is not set. - Expect(req.Header.Get("Content-Encoding")).To(BeEmpty()) - - // If there is a body, then make sure we can read it - bodyBuf := new(bytes.Buffer) - if req.Header.Get("Content-Encoding") == "gzip" { - body, err := core.NewGzipDecompressionReader(req.Body) - Expect(err).To(BeNil()) - _, err = bodyBuf.ReadFrom(body) - Expect(err).To(BeNil()) - } else { - _, err := bodyBuf.ReadFrom(req.Body) - Expect(err).To(BeNil()) - } - fmt.Fprintf(GinkgoWriter, " Request body: %s", bodyBuf.String()) - - Expect(req.Header["If-Match"]).ToNot(BeNil()) - Expect(req.Header["If-Match"][0]).To(Equal(fmt.Sprintf("%v", `W/"96d225c4-56bd-43d9-98fc-d7148e5c5028"`))) - Expect(req.URL.Query()["version"]).To(Equal([]string{"testString"})) - Expect(req.URL.Query()["generation"]).To(Equal([]string{fmt.Sprint(int64(2))})) - // Set mock response - res.Header().Set("Content-type", "application/json") - res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"backup_policy_plan": {"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6/plans/r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "id": "r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "name": "my-policy-plan", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "backup_policy_plan"}, "created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot-consistency-group:r134-fa329f6b-0e36-433f-a3bb-0df632e79263", "delete_snapshots_on_delete": false, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshot_consistency_groups/r134-fa329f6b-0e36-433f-a3bb-0df632e79263", "id": "r134-fa329f6b-0e36-433f-a3bb-0df632e79263", "lifecycle_state": "stable", "name": "my-snapshot-consistency-group", "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "resource_type": "snapshot_consistency_group", "service_tags": ["ServiceTags"], "snapshots": [{"crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "id": "r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "name": "my-snapshot", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "snapshot"}]}`) - })) - }) - It(`Invoke UpdateSnapshotConsistencyGroup successfully`, func() { - vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ - URL: testServer.URL, - Authenticator: &core.NoAuthAuthenticator{}, - Version: core.StringPtr(version), - }) - Expect(serviceErr).To(BeNil()) - Expect(vpcService).ToNot(BeNil()) - - // Invoke operation with nil options model (negative test) - result, response, operationErr := vpcService.UpdateSnapshotConsistencyGroup(nil) - Expect(operationErr).NotTo(BeNil()) - Expect(response).To(BeNil()) - Expect(result).To(BeNil()) - - // Construct an instance of the SnapshotConsistencyGroupPatch model - snapshotConsistencyGroupPatchModel := new(vpcv1.SnapshotConsistencyGroupPatch) - snapshotConsistencyGroupPatchModel.DeleteSnapshotsOnDelete = core.BoolPtr(true) - snapshotConsistencyGroupPatchModel.Name = core.StringPtr("my-snapshot-consistency-group") - snapshotConsistencyGroupPatchModelAsPatch, asPatchErr := snapshotConsistencyGroupPatchModel.AsPatch() - Expect(asPatchErr).To(BeNil()) - - // Construct an instance of the UpdateSnapshotConsistencyGroupOptions model - updateSnapshotConsistencyGroupOptionsModel := new(vpcv1.UpdateSnapshotConsistencyGroupOptions) - updateSnapshotConsistencyGroupOptionsModel.ID = core.StringPtr("testString") - updateSnapshotConsistencyGroupOptionsModel.SnapshotConsistencyGroupPatch = snapshotConsistencyGroupPatchModelAsPatch - updateSnapshotConsistencyGroupOptionsModel.IfMatch = core.StringPtr(`W/"96d225c4-56bd-43d9-98fc-d7148e5c5028"`) - updateSnapshotConsistencyGroupOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} - - // Invoke operation with valid options model (positive test) - result, response, operationErr = vpcService.UpdateSnapshotConsistencyGroup(updateSnapshotConsistencyGroupOptionsModel) - Expect(operationErr).To(BeNil()) - Expect(response).ToNot(BeNil()) - Expect(result).ToNot(BeNil()) - - }) - It(`Invoke UpdateSnapshotConsistencyGroup with error: Operation validation and request error`, func() { - vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ - URL: testServer.URL, - Authenticator: &core.NoAuthAuthenticator{}, - Version: core.StringPtr(version), - }) - Expect(serviceErr).To(BeNil()) - Expect(vpcService).ToNot(BeNil()) - - // Construct an instance of the SnapshotConsistencyGroupPatch model - snapshotConsistencyGroupPatchModel := new(vpcv1.SnapshotConsistencyGroupPatch) - snapshotConsistencyGroupPatchModel.DeleteSnapshotsOnDelete = core.BoolPtr(true) - snapshotConsistencyGroupPatchModel.Name = core.StringPtr("my-snapshot-consistency-group") - snapshotConsistencyGroupPatchModelAsPatch, asPatchErr := snapshotConsistencyGroupPatchModel.AsPatch() - Expect(asPatchErr).To(BeNil()) - - // Construct an instance of the UpdateSnapshotConsistencyGroupOptions model - updateSnapshotConsistencyGroupOptionsModel := new(vpcv1.UpdateSnapshotConsistencyGroupOptions) - updateSnapshotConsistencyGroupOptionsModel.ID = core.StringPtr("testString") - updateSnapshotConsistencyGroupOptionsModel.SnapshotConsistencyGroupPatch = snapshotConsistencyGroupPatchModelAsPatch - updateSnapshotConsistencyGroupOptionsModel.IfMatch = core.StringPtr(`W/"96d225c4-56bd-43d9-98fc-d7148e5c5028"`) - updateSnapshotConsistencyGroupOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} - // Invoke operation with empty URL (negative test) - err := vpcService.SetServiceURL("") - Expect(err).To(BeNil()) - result, response, operationErr := vpcService.UpdateSnapshotConsistencyGroup(updateSnapshotConsistencyGroupOptionsModel) - Expect(operationErr).ToNot(BeNil()) - Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING)) - Expect(response).To(BeNil()) - Expect(result).To(BeNil()) - // Construct a second instance of the UpdateSnapshotConsistencyGroupOptions model with no property values - updateSnapshotConsistencyGroupOptionsModelNew := new(vpcv1.UpdateSnapshotConsistencyGroupOptions) - // Invoke operation with invalid model (negative test) - result, response, operationErr = vpcService.UpdateSnapshotConsistencyGroup(updateSnapshotConsistencyGroupOptionsModelNew) + result, response, operationErr = vpcService.GetShare(getShareOptionsModel) Expect(operationErr).ToNot(BeNil()) - Expect(response).To(BeNil()) + Expect(response).ToNot(BeNil()) Expect(result).To(BeNil()) }) AfterEach(func() { testServer.Close() }) }) - Context(`Using mock server endpoint with missing response body`, func() { + }) + Describe(`GetShare(getShareOptions *GetShareOptions)`, func() { + version := "testString" + getSharePath := "/shares/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() - // Set success status code with no respoonse body + // Verify the contents of the request + Expect(req.URL.EscapedPath()).To(Equal(getSharePath)) + 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", `{"access_control_mode": "security_group", "created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::share:0fe9e5d8-0a4d-4818-96ec-e99708644a58", "encryption": "provider_managed", "encryption_key": {"crn": "crn:v1:bluemix:public:kms:us-south:a/123456:e4a29d1a-2ef0-42a6-8fd2-350deb1c647e:key:5437653b-c4b1-447f-9646-b2a2a4cd6179"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/shares/0fe9e5d8-0a4d-4818-96ec-e99708644a58", "id": "0fe9e5d8-0a4d-4818-96ec-e99708644a58", "iops": 100, "latest_job": {"status": "cancelled", "status_reasons": [{"code": "cannot_reach_source_share", "message": "The replication failover failed because the source share cannot be reached.", "more_info": "https://cloud.ibm.com/docs/vpc?topic=vpc-file-storage-planning"}], "type": "replication_failover"}, "latest_sync": {"completed_at": "2019-01-01T12:00:00.000Z", "data_transferred": 0, "started_at": "2019-01-01T12:00:00.000Z"}, "lifecycle_state": "stable", "mount_targets": [{"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/shares/0fe9e5d8-0a4d-4818-96ec-e99708644a58/mount_targets/4cf9171a-0043-4434-8727-15b53dbc374c", "id": "4cf9171a-0043-4434-8727-15b53dbc374c", "name": "my-share-mount-target", "resource_type": "share_mount_target"}], "name": "my-share", "profile": {"href": "https://us-south.iaas.cloud.ibm.com/v1/share/profiles/tier-3iops", "name": "tier-3iops", "resource_type": "share_profile"}, "replica_share": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::share:0fe9e5d8-0a4d-4818-96ec-e99708644a58", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/shares/0fe9e5d8-0a4d-4818-96ec-e99708644a58", "id": "0fe9e5d8-0a4d-4818-96ec-e99708644a58", "name": "my-share", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "share"}, "replication_cron_spec": "0 */5 * * *", "replication_role": "none", "replication_status": "active", "replication_status_reasons": [{"code": "cannot_reach_source_share", "message": "The replication failover failed because the source share cannot be reached.", "more_info": "https://cloud.ibm.com/docs/vpc?topic=vpc-file-storage-planning"}], "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "resource_type": "share", "size": 200, "source_share": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::share:0fe9e5d8-0a4d-4818-96ec-e99708644a58", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/shares/0fe9e5d8-0a4d-4818-96ec-e99708644a58", "id": "0fe9e5d8-0a4d-4818-96ec-e99708644a58", "name": "my-share", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "share"}, "user_tags": ["UserTags"], "zone": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south/zones/us-south-1", "name": "us-south-1"}}`) })) }) - It(`Invoke UpdateSnapshotConsistencyGroup successfully`, func() { + It(`Invoke GetShare successfully with retries`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -57021,53 +57414,56 @@ var _ = Describe(`VpcV1`, func() { }) Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) + vpcService.EnableRetries(0, 0) - // Construct an instance of the SnapshotConsistencyGroupPatch model - snapshotConsistencyGroupPatchModel := new(vpcv1.SnapshotConsistencyGroupPatch) - snapshotConsistencyGroupPatchModel.DeleteSnapshotsOnDelete = core.BoolPtr(true) - snapshotConsistencyGroupPatchModel.Name = core.StringPtr("my-snapshot-consistency-group") - snapshotConsistencyGroupPatchModelAsPatch, asPatchErr := snapshotConsistencyGroupPatchModel.AsPatch() - Expect(asPatchErr).To(BeNil()) + // Construct an instance of the GetShareOptions model + getShareOptionsModel := new(vpcv1.GetShareOptions) + getShareOptionsModel.ID = core.StringPtr("testString") + getShareOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} - // Construct an instance of the UpdateSnapshotConsistencyGroupOptions model - updateSnapshotConsistencyGroupOptionsModel := new(vpcv1.UpdateSnapshotConsistencyGroupOptions) - updateSnapshotConsistencyGroupOptionsModel.ID = core.StringPtr("testString") - updateSnapshotConsistencyGroupOptionsModel.SnapshotConsistencyGroupPatch = snapshotConsistencyGroupPatchModelAsPatch - updateSnapshotConsistencyGroupOptionsModel.IfMatch = core.StringPtr(`W/"96d225c4-56bd-43d9-98fc-d7148e5c5028"`) - updateSnapshotConsistencyGroupOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Invoke operation with a Context to test a timeout error + ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond) + defer cancelFunc() + _, _, operationErr := vpcService.GetShareWithContext(ctx, getShareOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) - // Invoke operation - result, response, operationErr := vpcService.UpdateSnapshotConsistencyGroup(updateSnapshotConsistencyGroupOptionsModel) + // Disable retries and test again + vpcService.DisableRetries() + result, response, operationErr := vpcService.GetShare(getShareOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) + Expect(result).ToNot(BeNil()) - // Verify a nil result - Expect(result).To(BeNil()) + // Re-test the timeout error with retries disabled + ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond) + defer cancelFunc2() + _, _, operationErr = vpcService.GetShareWithContext(ctx, getShareOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) }) AfterEach(func() { testServer.Close() }) }) - }) - Describe(`DeleteSnapshots(deleteSnapshotsOptions *DeleteSnapshotsOptions)`, func() { - version := "testString" - deleteSnapshotsPath := "/snapshots" Context(`Using mock server endpoint`, func() { BeforeEach(func() { testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(deleteSnapshotsPath)) - Expect(req.Method).To(Equal("DELETE")) + Expect(req.URL.EscapedPath()).To(Equal(getSharePath)) + 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()["source_volume.id"]).To(Equal([]string{"testString"})) - res.WriteHeader(204) + // Set mock response + res.Header().Set("Content-type", "application/json") + res.WriteHeader(200) + fmt.Fprintf(res, "%s", `{"access_control_mode": "security_group", "created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::share:0fe9e5d8-0a4d-4818-96ec-e99708644a58", "encryption": "provider_managed", "encryption_key": {"crn": "crn:v1:bluemix:public:kms:us-south:a/123456:e4a29d1a-2ef0-42a6-8fd2-350deb1c647e:key:5437653b-c4b1-447f-9646-b2a2a4cd6179"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/shares/0fe9e5d8-0a4d-4818-96ec-e99708644a58", "id": "0fe9e5d8-0a4d-4818-96ec-e99708644a58", "iops": 100, "latest_job": {"status": "cancelled", "status_reasons": [{"code": "cannot_reach_source_share", "message": "The replication failover failed because the source share cannot be reached.", "more_info": "https://cloud.ibm.com/docs/vpc?topic=vpc-file-storage-planning"}], "type": "replication_failover"}, "latest_sync": {"completed_at": "2019-01-01T12:00:00.000Z", "data_transferred": 0, "started_at": "2019-01-01T12:00:00.000Z"}, "lifecycle_state": "stable", "mount_targets": [{"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/shares/0fe9e5d8-0a4d-4818-96ec-e99708644a58/mount_targets/4cf9171a-0043-4434-8727-15b53dbc374c", "id": "4cf9171a-0043-4434-8727-15b53dbc374c", "name": "my-share-mount-target", "resource_type": "share_mount_target"}], "name": "my-share", "profile": {"href": "https://us-south.iaas.cloud.ibm.com/v1/share/profiles/tier-3iops", "name": "tier-3iops", "resource_type": "share_profile"}, "replica_share": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::share:0fe9e5d8-0a4d-4818-96ec-e99708644a58", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/shares/0fe9e5d8-0a4d-4818-96ec-e99708644a58", "id": "0fe9e5d8-0a4d-4818-96ec-e99708644a58", "name": "my-share", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "share"}, "replication_cron_spec": "0 */5 * * *", "replication_role": "none", "replication_status": "active", "replication_status_reasons": [{"code": "cannot_reach_source_share", "message": "The replication failover failed because the source share cannot be reached.", "more_info": "https://cloud.ibm.com/docs/vpc?topic=vpc-file-storage-planning"}], "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "resource_type": "share", "size": 200, "source_share": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::share:0fe9e5d8-0a4d-4818-96ec-e99708644a58", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/shares/0fe9e5d8-0a4d-4818-96ec-e99708644a58", "id": "0fe9e5d8-0a4d-4818-96ec-e99708644a58", "name": "my-share", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "share"}, "user_tags": ["UserTags"], "zone": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south/zones/us-south-1", "name": "us-south-1"}}`) })) }) - It(`Invoke DeleteSnapshots successfully`, func() { + It(`Invoke GetShare successfully`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -57077,21 +57473,24 @@ var _ = Describe(`VpcV1`, func() { Expect(vpcService).ToNot(BeNil()) // Invoke operation with nil options model (negative test) - response, operationErr := vpcService.DeleteSnapshots(nil) + result, response, operationErr := vpcService.GetShare(nil) Expect(operationErr).NotTo(BeNil()) Expect(response).To(BeNil()) + Expect(result).To(BeNil()) - // Construct an instance of the DeleteSnapshotsOptions model - deleteSnapshotsOptionsModel := new(vpcv1.DeleteSnapshotsOptions) - deleteSnapshotsOptionsModel.SourceVolumeID = core.StringPtr("testString") - deleteSnapshotsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the GetShareOptions model + getShareOptionsModel := new(vpcv1.GetShareOptions) + getShareOptionsModel.ID = core.StringPtr("testString") + getShareOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with valid options model (positive test) - response, operationErr = vpcService.DeleteSnapshots(deleteSnapshotsOptionsModel) + result, response, operationErr = vpcService.GetShare(getShareOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) + Expect(result).ToNot(BeNil()) + }) - It(`Invoke DeleteSnapshots with error: Operation validation and request error`, func() { + It(`Invoke GetShare with error: Operation validation and request error`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -57100,70 +57499,87 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the DeleteSnapshotsOptions model - deleteSnapshotsOptionsModel := new(vpcv1.DeleteSnapshotsOptions) - deleteSnapshotsOptionsModel.SourceVolumeID = core.StringPtr("testString") - deleteSnapshotsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the GetShareOptions model + getShareOptionsModel := new(vpcv1.GetShareOptions) + getShareOptionsModel.ID = core.StringPtr("testString") + getShareOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with empty URL (negative test) err := vpcService.SetServiceURL("") Expect(err).To(BeNil()) - response, operationErr := vpcService.DeleteSnapshots(deleteSnapshotsOptionsModel) + result, response, operationErr := vpcService.GetShare(getShareOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING)) Expect(response).To(BeNil()) - // Construct a second instance of the DeleteSnapshotsOptions model with no property values - deleteSnapshotsOptionsModelNew := new(vpcv1.DeleteSnapshotsOptions) + Expect(result).To(BeNil()) + // Construct a second instance of the GetShareOptions model with no property values + getShareOptionsModelNew := new(vpcv1.GetShareOptions) // Invoke operation with invalid model (negative test) - response, operationErr = vpcService.DeleteSnapshots(deleteSnapshotsOptionsModelNew) + result, response, operationErr = vpcService.GetShare(getShareOptionsModelNew) 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 GetShare 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 GetShareOptions model + getShareOptionsModel := new(vpcv1.GetShareOptions) + getShareOptionsModel.ID = core.StringPtr("testString") + getShareOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation + result, response, operationErr := vpcService.GetShare(getShareOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + + // Verify a nil result + Expect(result).To(BeNil()) }) AfterEach(func() { testServer.Close() }) }) }) - Describe(`ListSnapshots(listSnapshotsOptions *ListSnapshotsOptions) - Operation response error`, func() { + Describe(`UpdateShare(updateShareOptions *UpdateShareOptions) - Operation response error`, func() { version := "testString" - listSnapshotsPath := "/snapshots" + updateSharePath := "/shares/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(listSnapshotsPath)) - Expect(req.Method).To(Equal("GET")) + Expect(req.URL.EscapedPath()).To(Equal(updateSharePath)) + 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))})) - Expect(req.URL.Query()["start"]).To(Equal([]string{"testString"})) - Expect(req.URL.Query()["limit"]).To(Equal([]string{fmt.Sprint(int64(10))})) - Expect(req.URL.Query()["tag"]).To(Equal([]string{"testString"})) - Expect(req.URL.Query()["resource_group.id"]).To(Equal([]string{"testString"})) - Expect(req.URL.Query()["name"]).To(Equal([]string{"testString"})) - Expect(req.URL.Query()["source_volume.id"]).To(Equal([]string{"testString"})) - Expect(req.URL.Query()["source_volume.crn"]).To(Equal([]string{"crn:v1:bluemix:public:is:us-south-1:a/123456::volume:1a6b7274-678d-4dfb-8981-c71dd9d4daa5"})) - Expect(req.URL.Query()["source_image.id"]).To(Equal([]string{"testString"})) - Expect(req.URL.Query()["source_image.crn"]).To(Equal([]string{"crn:v1:bluemix:public:is:us-south:a/123456::image:72b27b5c-f4b0-48bb-b954-5becc7c1dcb8"})) - Expect(req.URL.Query()["sort"]).To(Equal([]string{"name"})) - Expect(req.URL.Query()["backup_policy_plan.id"]).To(Equal([]string{"testString"})) - Expect(req.URL.Query()["copies[].id"]).To(Equal([]string{"testString"})) - Expect(req.URL.Query()["copies[].name"]).To(Equal([]string{"my-snapshot-copy"})) - Expect(req.URL.Query()["copies[].crn"]).To(Equal([]string{"testString"})) - Expect(req.URL.Query()["copies[].remote.region.name"]).To(Equal([]string{"us-south"})) - Expect(req.URL.Query()["source_snapshot.id"]).To(Equal([]string{"testString"})) - Expect(req.URL.Query()["source_snapshot.remote.region.name"]).To(Equal([]string{"us-south"})) - Expect(req.URL.Query()["source_volume.remote.region.name"]).To(Equal([]string{"us-south"})) - Expect(req.URL.Query()["source_image.remote.region.name"]).To(Equal([]string{"us-south"})) - Expect(req.URL.Query()["clones[].zone.name"]).To(Equal([]string{"us-south-1"})) - Expect(req.URL.Query()["snapshot_consistency_group.id"]).To(Equal([]string{"testString"})) - Expect(req.URL.Query()["snapshot_consistency_group.crn"]).To(Equal([]string{"crn:v1:bluemix:public:is:us-south:a/123456::snapshot-consistency-group:r134-fa329f6b-0e36-433f-a3bb-0df632e79263"})) res.Header().Set("Content-type", "application/json") res.WriteHeader(200) fmt.Fprint(res, `} this is not valid json {`) })) }) - It(`Invoke ListSnapshots with error: Operation response processing error`, func() { + It(`Invoke UpdateShare with error: Operation response processing error`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -57172,40 +57588,37 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the ListSnapshotsOptions model - listSnapshotsOptionsModel := new(vpcv1.ListSnapshotsOptions) - listSnapshotsOptionsModel.Start = core.StringPtr("testString") - listSnapshotsOptionsModel.Limit = core.Int64Ptr(int64(10)) - listSnapshotsOptionsModel.Tag = core.StringPtr("testString") - listSnapshotsOptionsModel.ResourceGroupID = core.StringPtr("testString") - listSnapshotsOptionsModel.Name = core.StringPtr("testString") - listSnapshotsOptionsModel.SourceVolumeID = core.StringPtr("testString") - listSnapshotsOptionsModel.SourceVolumeCRN = core.StringPtr("crn:v1:bluemix:public:is:us-south-1:a/123456::volume:1a6b7274-678d-4dfb-8981-c71dd9d4daa5") - listSnapshotsOptionsModel.SourceImageID = core.StringPtr("testString") - listSnapshotsOptionsModel.SourceImageCRN = core.StringPtr("crn:v1:bluemix:public:is:us-south:a/123456::image:72b27b5c-f4b0-48bb-b954-5becc7c1dcb8") - listSnapshotsOptionsModel.Sort = core.StringPtr("name") - listSnapshotsOptionsModel.BackupPolicyPlanID = core.StringPtr("testString") - listSnapshotsOptionsModel.CopiesID = core.StringPtr("testString") - listSnapshotsOptionsModel.CopiesName = core.StringPtr("my-snapshot-copy") - listSnapshotsOptionsModel.CopiesCRN = core.StringPtr("testString") - listSnapshotsOptionsModel.CopiesRemoteRegionName = core.StringPtr("us-south") - listSnapshotsOptionsModel.SourceSnapshotID = core.StringPtr("testString") - listSnapshotsOptionsModel.SourceSnapshotRemoteRegionName = core.StringPtr("us-south") - listSnapshotsOptionsModel.SourceVolumeRemoteRegionName = core.StringPtr("us-south") - listSnapshotsOptionsModel.SourceImageRemoteRegionName = core.StringPtr("us-south") - listSnapshotsOptionsModel.ClonesZoneName = core.StringPtr("us-south-1") - listSnapshotsOptionsModel.SnapshotConsistencyGroupID = core.StringPtr("testString") - listSnapshotsOptionsModel.SnapshotConsistencyGroupCRN = core.StringPtr("crn:v1:bluemix:public:is:us-south:a/123456::snapshot-consistency-group:r134-fa329f6b-0e36-433f-a3bb-0df632e79263") - listSnapshotsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the ShareProfileIdentityByName model + shareProfileIdentityModel := new(vpcv1.ShareProfileIdentityByName) + shareProfileIdentityModel.Name = core.StringPtr("tier-3iops") + + // Construct an instance of the SharePatch model + sharePatchModel := new(vpcv1.SharePatch) + sharePatchModel.AccessControlMode = core.StringPtr("security_group") + sharePatchModel.Iops = core.Int64Ptr(int64(100)) + sharePatchModel.Name = core.StringPtr("my-share") + sharePatchModel.Profile = shareProfileIdentityModel + sharePatchModel.ReplicationCronSpec = core.StringPtr("0 */5 * * *") + sharePatchModel.Size = core.Int64Ptr(int64(200)) + sharePatchModel.UserTags = []string{"testString"} + sharePatchModelAsPatch, asPatchErr := sharePatchModel.AsPatch() + Expect(asPatchErr).To(BeNil()) + + // Construct an instance of the UpdateShareOptions model + updateShareOptionsModel := new(vpcv1.UpdateShareOptions) + updateShareOptionsModel.ID = core.StringPtr("testString") + updateShareOptionsModel.SharePatch = sharePatchModelAsPatch + updateShareOptionsModel.IfMatch = core.StringPtr("W/\"96d225c4-56bd-43d9-98fc-d7148e5c5028\"") + updateShareOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Expect response parsing to fail since we are receiving a text/plain response - result, response, operationErr := vpcService.ListSnapshots(listSnapshotsOptionsModel) + result, response, operationErr := vpcService.UpdateShare(updateShareOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).To(BeNil()) // Enable retries and test again vpcService.EnableRetries(0, 0) - result, response, operationErr = vpcService.ListSnapshots(listSnapshotsOptionsModel) + result, response, operationErr = vpcService.UpdateShare(updateShareOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).To(BeNil()) @@ -57215,52 +57628,48 @@ var _ = Describe(`VpcV1`, func() { }) }) }) - Describe(`ListSnapshots(listSnapshotsOptions *ListSnapshotsOptions)`, func() { + Describe(`UpdateShare(updateShareOptions *UpdateShareOptions)`, func() { version := "testString" - listSnapshotsPath := "/snapshots" + updateSharePath := "/shares/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(listSnapshotsPath)) - Expect(req.Method).To(Equal("GET")) + Expect(req.URL.EscapedPath()).To(Equal(updateSharePath)) + 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))})) - Expect(req.URL.Query()["start"]).To(Equal([]string{"testString"})) - Expect(req.URL.Query()["limit"]).To(Equal([]string{fmt.Sprint(int64(10))})) - Expect(req.URL.Query()["tag"]).To(Equal([]string{"testString"})) - Expect(req.URL.Query()["resource_group.id"]).To(Equal([]string{"testString"})) - Expect(req.URL.Query()["name"]).To(Equal([]string{"testString"})) - Expect(req.URL.Query()["source_volume.id"]).To(Equal([]string{"testString"})) - Expect(req.URL.Query()["source_volume.crn"]).To(Equal([]string{"crn:v1:bluemix:public:is:us-south-1:a/123456::volume:1a6b7274-678d-4dfb-8981-c71dd9d4daa5"})) - Expect(req.URL.Query()["source_image.id"]).To(Equal([]string{"testString"})) - Expect(req.URL.Query()["source_image.crn"]).To(Equal([]string{"crn:v1:bluemix:public:is:us-south:a/123456::image:72b27b5c-f4b0-48bb-b954-5becc7c1dcb8"})) - Expect(req.URL.Query()["sort"]).To(Equal([]string{"name"})) - Expect(req.URL.Query()["backup_policy_plan.id"]).To(Equal([]string{"testString"})) - Expect(req.URL.Query()["copies[].id"]).To(Equal([]string{"testString"})) - Expect(req.URL.Query()["copies[].name"]).To(Equal([]string{"my-snapshot-copy"})) - Expect(req.URL.Query()["copies[].crn"]).To(Equal([]string{"testString"})) - Expect(req.URL.Query()["copies[].remote.region.name"]).To(Equal([]string{"us-south"})) - Expect(req.URL.Query()["source_snapshot.id"]).To(Equal([]string{"testString"})) - Expect(req.URL.Query()["source_snapshot.remote.region.name"]).To(Equal([]string{"us-south"})) - Expect(req.URL.Query()["source_volume.remote.region.name"]).To(Equal([]string{"us-south"})) - Expect(req.URL.Query()["source_image.remote.region.name"]).To(Equal([]string{"us-south"})) - Expect(req.URL.Query()["clones[].zone.name"]).To(Equal([]string{"us-south-1"})) - Expect(req.URL.Query()["snapshot_consistency_group.id"]).To(Equal([]string{"testString"})) - Expect(req.URL.Query()["snapshot_consistency_group.crn"]).To(Equal([]string{"crn:v1:bluemix:public:is:us-south:a/123456::snapshot-consistency-group:r134-fa329f6b-0e36-433f-a3bb-0df632e79263"})) // Sleep a short time to support a timeout test time.Sleep(100 * time.Millisecond) // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"first": {"href": "https://us-south.iaas.cloud.ibm.com/v1/snapshots?limit=20"}, "limit": 20, "next": {"href": "https://us-south.iaas.cloud.ibm.com/v1/snapshots?start=9d5a91a3e2cbd233b5a5b33436855ed1&limit=20"}, "snapshots": [{"backup_policy_plan": {"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6/plans/r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "id": "r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "name": "my-policy-plan", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "backup_policy_plan"}, "bootable": true, "captured_at": "2019-01-01T12:00:00.000Z", "clones": [{"available": false, "created_at": "2019-01-01T12:00:00.000Z", "zone": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south/zones/us-south-1", "name": "us-south-1"}}], "copies": [{"crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "id": "r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "name": "my-snapshot", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "snapshot"}], "created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "deletable": false, "encryption": "provider_managed", "encryption_key": {"crn": "crn:v1:bluemix:public:kms:us-south:a/123456:e4a29d1a-2ef0-42a6-8fd2-350deb1c647e:key:5437653b-c4b1-447f-9646-b2a2a4cd6179"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "id": "r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "lifecycle_state": "stable", "minimum_capacity": 1, "name": "my-snapshot", "operating_system": {"architecture": "amd64", "dedicated_host_only": false, "display_name": "Ubuntu Server 16.04 LTS amd64", "family": "Ubuntu Server", "href": "https://us-south.iaas.cloud.ibm.com/v1/operating_systems/ubuntu-16-amd64", "name": "ubuntu-16-amd64", "vendor": "Canonical", "version": "16.04 LTS"}, "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "resource_type": "snapshot", "service_tags": ["ServiceTags"], "size": 1, "snapshot_consistency_group": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot-consistency-group:r134-fa329f6b-0e36-433f-a3bb-0df632e79263", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshot_consistency_groups/r134-fa329f6b-0e36-433f-a3bb-0df632e79263", "id": "r134-fa329f6b-0e36-433f-a3bb-0df632e79263", "name": "my-snapshot-consistency-group", "resource_type": "snapshot_consistency_group"}, "source_image": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::image:72b27b5c-f4b0-48bb-b954-5becc7c1dcb8", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/images/72b27b5c-f4b0-48bb-b954-5becc7c1dcb8", "id": "72b27b5c-f4b0-48bb-b954-5becc7c1dcb8", "name": "my-image", "remote": {"account": {"id": "aa2432b1fa4d4ace891e9b80fc104e34", "resource_type": "account"}, "region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "image"}, "source_snapshot": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "id": "r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "name": "my-snapshot", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "snapshot"}, "source_volume": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::volume:1a6b7274-678d-4dfb-8981-c71dd9d4daa5", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/volumes/1a6b7274-678d-4dfb-8981-c71dd9d4daa5", "id": "1a6b7274-678d-4dfb-8981-c71dd9d4daa5", "name": "my-volume", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "volume"}, "user_tags": ["UserTags"]}], "total_count": 132}`) + fmt.Fprintf(res, "%s", `{"access_control_mode": "security_group", "created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::share:0fe9e5d8-0a4d-4818-96ec-e99708644a58", "encryption": "provider_managed", "encryption_key": {"crn": "crn:v1:bluemix:public:kms:us-south:a/123456:e4a29d1a-2ef0-42a6-8fd2-350deb1c647e:key:5437653b-c4b1-447f-9646-b2a2a4cd6179"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/shares/0fe9e5d8-0a4d-4818-96ec-e99708644a58", "id": "0fe9e5d8-0a4d-4818-96ec-e99708644a58", "iops": 100, "latest_job": {"status": "cancelled", "status_reasons": [{"code": "cannot_reach_source_share", "message": "The replication failover failed because the source share cannot be reached.", "more_info": "https://cloud.ibm.com/docs/vpc?topic=vpc-file-storage-planning"}], "type": "replication_failover"}, "latest_sync": {"completed_at": "2019-01-01T12:00:00.000Z", "data_transferred": 0, "started_at": "2019-01-01T12:00:00.000Z"}, "lifecycle_state": "stable", "mount_targets": [{"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/shares/0fe9e5d8-0a4d-4818-96ec-e99708644a58/mount_targets/4cf9171a-0043-4434-8727-15b53dbc374c", "id": "4cf9171a-0043-4434-8727-15b53dbc374c", "name": "my-share-mount-target", "resource_type": "share_mount_target"}], "name": "my-share", "profile": {"href": "https://us-south.iaas.cloud.ibm.com/v1/share/profiles/tier-3iops", "name": "tier-3iops", "resource_type": "share_profile"}, "replica_share": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::share:0fe9e5d8-0a4d-4818-96ec-e99708644a58", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/shares/0fe9e5d8-0a4d-4818-96ec-e99708644a58", "id": "0fe9e5d8-0a4d-4818-96ec-e99708644a58", "name": "my-share", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "share"}, "replication_cron_spec": "0 */5 * * *", "replication_role": "none", "replication_status": "active", "replication_status_reasons": [{"code": "cannot_reach_source_share", "message": "The replication failover failed because the source share cannot be reached.", "more_info": "https://cloud.ibm.com/docs/vpc?topic=vpc-file-storage-planning"}], "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "resource_type": "share", "size": 200, "source_share": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::share:0fe9e5d8-0a4d-4818-96ec-e99708644a58", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/shares/0fe9e5d8-0a4d-4818-96ec-e99708644a58", "id": "0fe9e5d8-0a4d-4818-96ec-e99708644a58", "name": "my-share", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "share"}, "user_tags": ["UserTags"], "zone": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south/zones/us-south-1", "name": "us-south-1"}}`) })) }) - It(`Invoke ListSnapshots successfully with retries`, func() { + It(`Invoke UpdateShare successfully with retries`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -57270,42 +57679,39 @@ var _ = Describe(`VpcV1`, func() { Expect(vpcService).ToNot(BeNil()) vpcService.EnableRetries(0, 0) - // Construct an instance of the ListSnapshotsOptions model - listSnapshotsOptionsModel := new(vpcv1.ListSnapshotsOptions) - listSnapshotsOptionsModel.Start = core.StringPtr("testString") - listSnapshotsOptionsModel.Limit = core.Int64Ptr(int64(10)) - listSnapshotsOptionsModel.Tag = core.StringPtr("testString") - listSnapshotsOptionsModel.ResourceGroupID = core.StringPtr("testString") - listSnapshotsOptionsModel.Name = core.StringPtr("testString") - listSnapshotsOptionsModel.SourceVolumeID = core.StringPtr("testString") - listSnapshotsOptionsModel.SourceVolumeCRN = core.StringPtr("crn:v1:bluemix:public:is:us-south-1:a/123456::volume:1a6b7274-678d-4dfb-8981-c71dd9d4daa5") - listSnapshotsOptionsModel.SourceImageID = core.StringPtr("testString") - listSnapshotsOptionsModel.SourceImageCRN = core.StringPtr("crn:v1:bluemix:public:is:us-south:a/123456::image:72b27b5c-f4b0-48bb-b954-5becc7c1dcb8") - listSnapshotsOptionsModel.Sort = core.StringPtr("name") - listSnapshotsOptionsModel.BackupPolicyPlanID = core.StringPtr("testString") - listSnapshotsOptionsModel.CopiesID = core.StringPtr("testString") - listSnapshotsOptionsModel.CopiesName = core.StringPtr("my-snapshot-copy") - listSnapshotsOptionsModel.CopiesCRN = core.StringPtr("testString") - listSnapshotsOptionsModel.CopiesRemoteRegionName = core.StringPtr("us-south") - listSnapshotsOptionsModel.SourceSnapshotID = core.StringPtr("testString") - listSnapshotsOptionsModel.SourceSnapshotRemoteRegionName = core.StringPtr("us-south") - listSnapshotsOptionsModel.SourceVolumeRemoteRegionName = core.StringPtr("us-south") - listSnapshotsOptionsModel.SourceImageRemoteRegionName = core.StringPtr("us-south") - listSnapshotsOptionsModel.ClonesZoneName = core.StringPtr("us-south-1") - listSnapshotsOptionsModel.SnapshotConsistencyGroupID = core.StringPtr("testString") - listSnapshotsOptionsModel.SnapshotConsistencyGroupCRN = core.StringPtr("crn:v1:bluemix:public:is:us-south:a/123456::snapshot-consistency-group:r134-fa329f6b-0e36-433f-a3bb-0df632e79263") - listSnapshotsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the ShareProfileIdentityByName model + shareProfileIdentityModel := new(vpcv1.ShareProfileIdentityByName) + shareProfileIdentityModel.Name = core.StringPtr("tier-3iops") + + // Construct an instance of the SharePatch model + sharePatchModel := new(vpcv1.SharePatch) + sharePatchModel.AccessControlMode = core.StringPtr("security_group") + sharePatchModel.Iops = core.Int64Ptr(int64(100)) + sharePatchModel.Name = core.StringPtr("my-share") + sharePatchModel.Profile = shareProfileIdentityModel + sharePatchModel.ReplicationCronSpec = core.StringPtr("0 */5 * * *") + sharePatchModel.Size = core.Int64Ptr(int64(200)) + sharePatchModel.UserTags = []string{"testString"} + sharePatchModelAsPatch, asPatchErr := sharePatchModel.AsPatch() + Expect(asPatchErr).To(BeNil()) + + // Construct an instance of the UpdateShareOptions model + updateShareOptionsModel := new(vpcv1.UpdateShareOptions) + updateShareOptionsModel.ID = core.StringPtr("testString") + updateShareOptionsModel.SharePatch = sharePatchModelAsPatch + updateShareOptionsModel.IfMatch = core.StringPtr("W/\"96d225c4-56bd-43d9-98fc-d7148e5c5028\"") + updateShareOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with a Context to test a timeout error ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond) defer cancelFunc() - _, _, operationErr := vpcService.ListSnapshotsWithContext(ctx, listSnapshotsOptionsModel) + _, _, operationErr := vpcService.UpdateShareWithContext(ctx, updateShareOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) // Disable retries and test again vpcService.DisableRetries() - result, response, operationErr := vpcService.ListSnapshots(listSnapshotsOptionsModel) + result, response, operationErr := vpcService.UpdateShare(updateShareOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) @@ -57313,7 +57719,7 @@ var _ = Describe(`VpcV1`, func() { // Re-test the timeout error with retries disabled ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond) defer cancelFunc2() - _, _, operationErr = vpcService.ListSnapshotsWithContext(ctx, listSnapshotsOptionsModel) + _, _, operationErr = vpcService.UpdateShareWithContext(ctx, updateShareOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) }) @@ -57327,40 +57733,36 @@ var _ = Describe(`VpcV1`, func() { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(listSnapshotsPath)) - Expect(req.Method).To(Equal("GET")) + Expect(req.URL.EscapedPath()).To(Equal(updateSharePath)) + 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))})) - Expect(req.URL.Query()["start"]).To(Equal([]string{"testString"})) - Expect(req.URL.Query()["limit"]).To(Equal([]string{fmt.Sprint(int64(10))})) - Expect(req.URL.Query()["tag"]).To(Equal([]string{"testString"})) - Expect(req.URL.Query()["resource_group.id"]).To(Equal([]string{"testString"})) - Expect(req.URL.Query()["name"]).To(Equal([]string{"testString"})) - Expect(req.URL.Query()["source_volume.id"]).To(Equal([]string{"testString"})) - Expect(req.URL.Query()["source_volume.crn"]).To(Equal([]string{"crn:v1:bluemix:public:is:us-south-1:a/123456::volume:1a6b7274-678d-4dfb-8981-c71dd9d4daa5"})) - Expect(req.URL.Query()["source_image.id"]).To(Equal([]string{"testString"})) - Expect(req.URL.Query()["source_image.crn"]).To(Equal([]string{"crn:v1:bluemix:public:is:us-south:a/123456::image:72b27b5c-f4b0-48bb-b954-5becc7c1dcb8"})) - Expect(req.URL.Query()["sort"]).To(Equal([]string{"name"})) - Expect(req.URL.Query()["backup_policy_plan.id"]).To(Equal([]string{"testString"})) - Expect(req.URL.Query()["copies[].id"]).To(Equal([]string{"testString"})) - Expect(req.URL.Query()["copies[].name"]).To(Equal([]string{"my-snapshot-copy"})) - Expect(req.URL.Query()["copies[].crn"]).To(Equal([]string{"testString"})) - Expect(req.URL.Query()["copies[].remote.region.name"]).To(Equal([]string{"us-south"})) - Expect(req.URL.Query()["source_snapshot.id"]).To(Equal([]string{"testString"})) - Expect(req.URL.Query()["source_snapshot.remote.region.name"]).To(Equal([]string{"us-south"})) - Expect(req.URL.Query()["source_volume.remote.region.name"]).To(Equal([]string{"us-south"})) - Expect(req.URL.Query()["source_image.remote.region.name"]).To(Equal([]string{"us-south"})) - Expect(req.URL.Query()["clones[].zone.name"]).To(Equal([]string{"us-south-1"})) - Expect(req.URL.Query()["snapshot_consistency_group.id"]).To(Equal([]string{"testString"})) - Expect(req.URL.Query()["snapshot_consistency_group.crn"]).To(Equal([]string{"crn:v1:bluemix:public:is:us-south:a/123456::snapshot-consistency-group:r134-fa329f6b-0e36-433f-a3bb-0df632e79263"})) // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"first": {"href": "https://us-south.iaas.cloud.ibm.com/v1/snapshots?limit=20"}, "limit": 20, "next": {"href": "https://us-south.iaas.cloud.ibm.com/v1/snapshots?start=9d5a91a3e2cbd233b5a5b33436855ed1&limit=20"}, "snapshots": [{"backup_policy_plan": {"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6/plans/r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "id": "r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "name": "my-policy-plan", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "backup_policy_plan"}, "bootable": true, "captured_at": "2019-01-01T12:00:00.000Z", "clones": [{"available": false, "created_at": "2019-01-01T12:00:00.000Z", "zone": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south/zones/us-south-1", "name": "us-south-1"}}], "copies": [{"crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "id": "r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "name": "my-snapshot", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "snapshot"}], "created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "deletable": false, "encryption": "provider_managed", "encryption_key": {"crn": "crn:v1:bluemix:public:kms:us-south:a/123456:e4a29d1a-2ef0-42a6-8fd2-350deb1c647e:key:5437653b-c4b1-447f-9646-b2a2a4cd6179"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "id": "r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "lifecycle_state": "stable", "minimum_capacity": 1, "name": "my-snapshot", "operating_system": {"architecture": "amd64", "dedicated_host_only": false, "display_name": "Ubuntu Server 16.04 LTS amd64", "family": "Ubuntu Server", "href": "https://us-south.iaas.cloud.ibm.com/v1/operating_systems/ubuntu-16-amd64", "name": "ubuntu-16-amd64", "vendor": "Canonical", "version": "16.04 LTS"}, "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "resource_type": "snapshot", "service_tags": ["ServiceTags"], "size": 1, "snapshot_consistency_group": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot-consistency-group:r134-fa329f6b-0e36-433f-a3bb-0df632e79263", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshot_consistency_groups/r134-fa329f6b-0e36-433f-a3bb-0df632e79263", "id": "r134-fa329f6b-0e36-433f-a3bb-0df632e79263", "name": "my-snapshot-consistency-group", "resource_type": "snapshot_consistency_group"}, "source_image": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::image:72b27b5c-f4b0-48bb-b954-5becc7c1dcb8", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/images/72b27b5c-f4b0-48bb-b954-5becc7c1dcb8", "id": "72b27b5c-f4b0-48bb-b954-5becc7c1dcb8", "name": "my-image", "remote": {"account": {"id": "aa2432b1fa4d4ace891e9b80fc104e34", "resource_type": "account"}, "region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "image"}, "source_snapshot": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "id": "r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "name": "my-snapshot", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "snapshot"}, "source_volume": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::volume:1a6b7274-678d-4dfb-8981-c71dd9d4daa5", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/volumes/1a6b7274-678d-4dfb-8981-c71dd9d4daa5", "id": "1a6b7274-678d-4dfb-8981-c71dd9d4daa5", "name": "my-volume", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "volume"}, "user_tags": ["UserTags"]}], "total_count": 132}`) + fmt.Fprintf(res, "%s", `{"access_control_mode": "security_group", "created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::share:0fe9e5d8-0a4d-4818-96ec-e99708644a58", "encryption": "provider_managed", "encryption_key": {"crn": "crn:v1:bluemix:public:kms:us-south:a/123456:e4a29d1a-2ef0-42a6-8fd2-350deb1c647e:key:5437653b-c4b1-447f-9646-b2a2a4cd6179"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/shares/0fe9e5d8-0a4d-4818-96ec-e99708644a58", "id": "0fe9e5d8-0a4d-4818-96ec-e99708644a58", "iops": 100, "latest_job": {"status": "cancelled", "status_reasons": [{"code": "cannot_reach_source_share", "message": "The replication failover failed because the source share cannot be reached.", "more_info": "https://cloud.ibm.com/docs/vpc?topic=vpc-file-storage-planning"}], "type": "replication_failover"}, "latest_sync": {"completed_at": "2019-01-01T12:00:00.000Z", "data_transferred": 0, "started_at": "2019-01-01T12:00:00.000Z"}, "lifecycle_state": "stable", "mount_targets": [{"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/shares/0fe9e5d8-0a4d-4818-96ec-e99708644a58/mount_targets/4cf9171a-0043-4434-8727-15b53dbc374c", "id": "4cf9171a-0043-4434-8727-15b53dbc374c", "name": "my-share-mount-target", "resource_type": "share_mount_target"}], "name": "my-share", "profile": {"href": "https://us-south.iaas.cloud.ibm.com/v1/share/profiles/tier-3iops", "name": "tier-3iops", "resource_type": "share_profile"}, "replica_share": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::share:0fe9e5d8-0a4d-4818-96ec-e99708644a58", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/shares/0fe9e5d8-0a4d-4818-96ec-e99708644a58", "id": "0fe9e5d8-0a4d-4818-96ec-e99708644a58", "name": "my-share", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "share"}, "replication_cron_spec": "0 */5 * * *", "replication_role": "none", "replication_status": "active", "replication_status_reasons": [{"code": "cannot_reach_source_share", "message": "The replication failover failed because the source share cannot be reached.", "more_info": "https://cloud.ibm.com/docs/vpc?topic=vpc-file-storage-planning"}], "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "resource_type": "share", "size": 200, "source_share": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::share:0fe9e5d8-0a4d-4818-96ec-e99708644a58", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/shares/0fe9e5d8-0a4d-4818-96ec-e99708644a58", "id": "0fe9e5d8-0a4d-4818-96ec-e99708644a58", "name": "my-share", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "share"}, "user_tags": ["UserTags"], "zone": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south/zones/us-south-1", "name": "us-south-1"}}`) })) }) - It(`Invoke ListSnapshots successfully`, func() { + It(`Invoke UpdateShare successfully`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -57370,45 +57772,42 @@ var _ = Describe(`VpcV1`, func() { Expect(vpcService).ToNot(BeNil()) // Invoke operation with nil options model (negative test) - result, response, operationErr := vpcService.ListSnapshots(nil) + result, response, operationErr := vpcService.UpdateShare(nil) Expect(operationErr).NotTo(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) - // Construct an instance of the ListSnapshotsOptions model - listSnapshotsOptionsModel := new(vpcv1.ListSnapshotsOptions) - listSnapshotsOptionsModel.Start = core.StringPtr("testString") - listSnapshotsOptionsModel.Limit = core.Int64Ptr(int64(10)) - listSnapshotsOptionsModel.Tag = core.StringPtr("testString") - listSnapshotsOptionsModel.ResourceGroupID = core.StringPtr("testString") - listSnapshotsOptionsModel.Name = core.StringPtr("testString") - listSnapshotsOptionsModel.SourceVolumeID = core.StringPtr("testString") - listSnapshotsOptionsModel.SourceVolumeCRN = core.StringPtr("crn:v1:bluemix:public:is:us-south-1:a/123456::volume:1a6b7274-678d-4dfb-8981-c71dd9d4daa5") - listSnapshotsOptionsModel.SourceImageID = core.StringPtr("testString") - listSnapshotsOptionsModel.SourceImageCRN = core.StringPtr("crn:v1:bluemix:public:is:us-south:a/123456::image:72b27b5c-f4b0-48bb-b954-5becc7c1dcb8") - listSnapshotsOptionsModel.Sort = core.StringPtr("name") - listSnapshotsOptionsModel.BackupPolicyPlanID = core.StringPtr("testString") - listSnapshotsOptionsModel.CopiesID = core.StringPtr("testString") - listSnapshotsOptionsModel.CopiesName = core.StringPtr("my-snapshot-copy") - listSnapshotsOptionsModel.CopiesCRN = core.StringPtr("testString") - listSnapshotsOptionsModel.CopiesRemoteRegionName = core.StringPtr("us-south") - listSnapshotsOptionsModel.SourceSnapshotID = core.StringPtr("testString") - listSnapshotsOptionsModel.SourceSnapshotRemoteRegionName = core.StringPtr("us-south") - listSnapshotsOptionsModel.SourceVolumeRemoteRegionName = core.StringPtr("us-south") - listSnapshotsOptionsModel.SourceImageRemoteRegionName = core.StringPtr("us-south") - listSnapshotsOptionsModel.ClonesZoneName = core.StringPtr("us-south-1") - listSnapshotsOptionsModel.SnapshotConsistencyGroupID = core.StringPtr("testString") - listSnapshotsOptionsModel.SnapshotConsistencyGroupCRN = core.StringPtr("crn:v1:bluemix:public:is:us-south:a/123456::snapshot-consistency-group:r134-fa329f6b-0e36-433f-a3bb-0df632e79263") - listSnapshotsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the ShareProfileIdentityByName model + shareProfileIdentityModel := new(vpcv1.ShareProfileIdentityByName) + shareProfileIdentityModel.Name = core.StringPtr("tier-3iops") + + // Construct an instance of the SharePatch model + sharePatchModel := new(vpcv1.SharePatch) + sharePatchModel.AccessControlMode = core.StringPtr("security_group") + sharePatchModel.Iops = core.Int64Ptr(int64(100)) + sharePatchModel.Name = core.StringPtr("my-share") + sharePatchModel.Profile = shareProfileIdentityModel + sharePatchModel.ReplicationCronSpec = core.StringPtr("0 */5 * * *") + sharePatchModel.Size = core.Int64Ptr(int64(200)) + sharePatchModel.UserTags = []string{"testString"} + sharePatchModelAsPatch, asPatchErr := sharePatchModel.AsPatch() + Expect(asPatchErr).To(BeNil()) + + // Construct an instance of the UpdateShareOptions model + updateShareOptionsModel := new(vpcv1.UpdateShareOptions) + updateShareOptionsModel.ID = core.StringPtr("testString") + updateShareOptionsModel.SharePatch = sharePatchModelAsPatch + updateShareOptionsModel.IfMatch = core.StringPtr("W/\"96d225c4-56bd-43d9-98fc-d7148e5c5028\"") + updateShareOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with valid options model (positive test) - result, response, operationErr = vpcService.ListSnapshots(listSnapshotsOptionsModel) + result, response, operationErr = vpcService.UpdateShare(updateShareOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) }) - It(`Invoke ListSnapshots with error: Operation request error`, func() { + It(`Invoke UpdateShare with error: Operation validation and request error`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -57417,39 +57816,43 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the ListSnapshotsOptions model - listSnapshotsOptionsModel := new(vpcv1.ListSnapshotsOptions) - listSnapshotsOptionsModel.Start = core.StringPtr("testString") - listSnapshotsOptionsModel.Limit = core.Int64Ptr(int64(10)) - listSnapshotsOptionsModel.Tag = core.StringPtr("testString") - listSnapshotsOptionsModel.ResourceGroupID = core.StringPtr("testString") - listSnapshotsOptionsModel.Name = core.StringPtr("testString") - listSnapshotsOptionsModel.SourceVolumeID = core.StringPtr("testString") - listSnapshotsOptionsModel.SourceVolumeCRN = core.StringPtr("crn:v1:bluemix:public:is:us-south-1:a/123456::volume:1a6b7274-678d-4dfb-8981-c71dd9d4daa5") - listSnapshotsOptionsModel.SourceImageID = core.StringPtr("testString") - listSnapshotsOptionsModel.SourceImageCRN = core.StringPtr("crn:v1:bluemix:public:is:us-south:a/123456::image:72b27b5c-f4b0-48bb-b954-5becc7c1dcb8") - listSnapshotsOptionsModel.Sort = core.StringPtr("name") - listSnapshotsOptionsModel.BackupPolicyPlanID = core.StringPtr("testString") - listSnapshotsOptionsModel.CopiesID = core.StringPtr("testString") - listSnapshotsOptionsModel.CopiesName = core.StringPtr("my-snapshot-copy") - listSnapshotsOptionsModel.CopiesCRN = core.StringPtr("testString") - listSnapshotsOptionsModel.CopiesRemoteRegionName = core.StringPtr("us-south") - listSnapshotsOptionsModel.SourceSnapshotID = core.StringPtr("testString") - listSnapshotsOptionsModel.SourceSnapshotRemoteRegionName = core.StringPtr("us-south") - listSnapshotsOptionsModel.SourceVolumeRemoteRegionName = core.StringPtr("us-south") - listSnapshotsOptionsModel.SourceImageRemoteRegionName = core.StringPtr("us-south") - listSnapshotsOptionsModel.ClonesZoneName = core.StringPtr("us-south-1") - listSnapshotsOptionsModel.SnapshotConsistencyGroupID = core.StringPtr("testString") - listSnapshotsOptionsModel.SnapshotConsistencyGroupCRN = core.StringPtr("crn:v1:bluemix:public:is:us-south:a/123456::snapshot-consistency-group:r134-fa329f6b-0e36-433f-a3bb-0df632e79263") - listSnapshotsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the ShareProfileIdentityByName model + shareProfileIdentityModel := new(vpcv1.ShareProfileIdentityByName) + shareProfileIdentityModel.Name = core.StringPtr("tier-3iops") + + // Construct an instance of the SharePatch model + sharePatchModel := new(vpcv1.SharePatch) + sharePatchModel.AccessControlMode = core.StringPtr("security_group") + sharePatchModel.Iops = core.Int64Ptr(int64(100)) + sharePatchModel.Name = core.StringPtr("my-share") + sharePatchModel.Profile = shareProfileIdentityModel + sharePatchModel.ReplicationCronSpec = core.StringPtr("0 */5 * * *") + sharePatchModel.Size = core.Int64Ptr(int64(200)) + sharePatchModel.UserTags = []string{"testString"} + sharePatchModelAsPatch, asPatchErr := sharePatchModel.AsPatch() + Expect(asPatchErr).To(BeNil()) + + // Construct an instance of the UpdateShareOptions model + updateShareOptionsModel := new(vpcv1.UpdateShareOptions) + updateShareOptionsModel.ID = core.StringPtr("testString") + updateShareOptionsModel.SharePatch = sharePatchModelAsPatch + updateShareOptionsModel.IfMatch = core.StringPtr("W/\"96d225c4-56bd-43d9-98fc-d7148e5c5028\"") + updateShareOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with empty URL (negative test) err := vpcService.SetServiceURL("") Expect(err).To(BeNil()) - result, response, operationErr := vpcService.ListSnapshots(listSnapshotsOptionsModel) + result, response, operationErr := vpcService.UpdateShare(updateShareOptionsModel) 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 UpdateShareOptions model with no property values + updateShareOptionsModelNew := new(vpcv1.UpdateShareOptions) + // Invoke operation with invalid model (negative test) + result, response, operationErr = vpcService.UpdateShare(updateShareOptionsModelNew) + Expect(operationErr).ToNot(BeNil()) + Expect(response).To(BeNil()) + Expect(result).To(BeNil()) }) AfterEach(func() { testServer.Close() @@ -57464,7 +57867,7 @@ var _ = Describe(`VpcV1`, func() { res.WriteHeader(200) })) }) - It(`Invoke ListSnapshots successfully`, func() { + It(`Invoke UpdateShare successfully`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -57473,34 +57876,31 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the ListSnapshotsOptions model - listSnapshotsOptionsModel := new(vpcv1.ListSnapshotsOptions) - listSnapshotsOptionsModel.Start = core.StringPtr("testString") - listSnapshotsOptionsModel.Limit = core.Int64Ptr(int64(10)) - listSnapshotsOptionsModel.Tag = core.StringPtr("testString") - listSnapshotsOptionsModel.ResourceGroupID = core.StringPtr("testString") - listSnapshotsOptionsModel.Name = core.StringPtr("testString") - listSnapshotsOptionsModel.SourceVolumeID = core.StringPtr("testString") - listSnapshotsOptionsModel.SourceVolumeCRN = core.StringPtr("crn:v1:bluemix:public:is:us-south-1:a/123456::volume:1a6b7274-678d-4dfb-8981-c71dd9d4daa5") - listSnapshotsOptionsModel.SourceImageID = core.StringPtr("testString") - listSnapshotsOptionsModel.SourceImageCRN = core.StringPtr("crn:v1:bluemix:public:is:us-south:a/123456::image:72b27b5c-f4b0-48bb-b954-5becc7c1dcb8") - listSnapshotsOptionsModel.Sort = core.StringPtr("name") - listSnapshotsOptionsModel.BackupPolicyPlanID = core.StringPtr("testString") - listSnapshotsOptionsModel.CopiesID = core.StringPtr("testString") - listSnapshotsOptionsModel.CopiesName = core.StringPtr("my-snapshot-copy") - listSnapshotsOptionsModel.CopiesCRN = core.StringPtr("testString") - listSnapshotsOptionsModel.CopiesRemoteRegionName = core.StringPtr("us-south") - listSnapshotsOptionsModel.SourceSnapshotID = core.StringPtr("testString") - listSnapshotsOptionsModel.SourceSnapshotRemoteRegionName = core.StringPtr("us-south") - listSnapshotsOptionsModel.SourceVolumeRemoteRegionName = core.StringPtr("us-south") - listSnapshotsOptionsModel.SourceImageRemoteRegionName = core.StringPtr("us-south") - listSnapshotsOptionsModel.ClonesZoneName = core.StringPtr("us-south-1") - listSnapshotsOptionsModel.SnapshotConsistencyGroupID = core.StringPtr("testString") - listSnapshotsOptionsModel.SnapshotConsistencyGroupCRN = core.StringPtr("crn:v1:bluemix:public:is:us-south:a/123456::snapshot-consistency-group:r134-fa329f6b-0e36-433f-a3bb-0df632e79263") - listSnapshotsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the ShareProfileIdentityByName model + shareProfileIdentityModel := new(vpcv1.ShareProfileIdentityByName) + shareProfileIdentityModel.Name = core.StringPtr("tier-3iops") + + // Construct an instance of the SharePatch model + sharePatchModel := new(vpcv1.SharePatch) + sharePatchModel.AccessControlMode = core.StringPtr("security_group") + sharePatchModel.Iops = core.Int64Ptr(int64(100)) + sharePatchModel.Name = core.StringPtr("my-share") + sharePatchModel.Profile = shareProfileIdentityModel + sharePatchModel.ReplicationCronSpec = core.StringPtr("0 */5 * * *") + sharePatchModel.Size = core.Int64Ptr(int64(200)) + sharePatchModel.UserTags = []string{"testString"} + sharePatchModelAsPatch, asPatchErr := sharePatchModel.AsPatch() + Expect(asPatchErr).To(BeNil()) + + // Construct an instance of the UpdateShareOptions model + updateShareOptionsModel := new(vpcv1.UpdateShareOptions) + updateShareOptionsModel.ID = core.StringPtr("testString") + updateShareOptionsModel.SharePatch = sharePatchModelAsPatch + updateShareOptionsModel.IfMatch = core.StringPtr("W/\"96d225c4-56bd-43d9-98fc-d7148e5c5028\"") + updateShareOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation - result, response, operationErr := vpcService.ListSnapshots(listSnapshotsOptionsModel) + result, response, operationErr := vpcService.UpdateShare(updateShareOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) @@ -57511,59 +57911,41 @@ var _ = Describe(`VpcV1`, func() { testServer.Close() }) }) - Context(`Test pagination helper method on response`, func() { - It(`Invoke GetNextStart successfully`, func() { - responseObject := new(vpcv1.SnapshotCollection) - nextObject := new(vpcv1.SnapshotCollectionNext) - nextObject.Href = core.StringPtr("ibm.com?start=abc-123") - responseObject.Next = nextObject - - value, err := responseObject.GetNextStart() - Expect(err).To(BeNil()) - Expect(value).To(Equal(core.StringPtr("abc-123"))) - }) - It(`Invoke GetNextStart without a "Next" property in the response`, func() { - responseObject := new(vpcv1.SnapshotCollection) - - value, err := responseObject.GetNextStart() - Expect(err).To(BeNil()) - Expect(value).To(BeNil()) - }) - It(`Invoke GetNextStart without any query params in the "Next" URL`, func() { - responseObject := new(vpcv1.SnapshotCollection) - nextObject := new(vpcv1.SnapshotCollectionNext) - nextObject.Href = core.StringPtr("ibm.com") - responseObject.Next = nextObject - - value, err := responseObject.GetNextStart() - Expect(err).To(BeNil()) - Expect(value).To(BeNil()) - }) - }) - Context(`Using mock server endpoint - paginated response`, func() { + }) + Describe(`FailoverShare(failoverShareOptions *FailoverShareOptions)`, func() { + version := "testString" + failoverSharePath := "/shares/testString/failover" + Context(`Using mock server endpoint`, func() { BeforeEach(func() { - var requestNumber int = 0 testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(listSnapshotsPath)) - Expect(req.Method).To(Equal("GET")) + Expect(req.URL.EscapedPath()).To(Equal(failoverSharePath)) + Expect(req.Method).To(Equal("POST")) - // Set mock response - res.Header().Set("Content-type", "application/json") - res.WriteHeader(200) - requestNumber++ - if requestNumber == 1 { - fmt.Fprintf(res, "%s", `{"snapshots":[{"backup_policy_plan":{"deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6/plans/r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178","id":"r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178","name":"my-policy-plan","remote":{"region":{"href":"https://us-south.iaas.cloud.ibm.com/v1/regions/us-south","name":"us-south"}},"resource_type":"backup_policy_plan"},"bootable":true,"captured_at":"2019-01-01T12:00:00.000Z","clones":[{"available":false,"created_at":"2019-01-01T12:00:00.000Z","zone":{"href":"https://us-south.iaas.cloud.ibm.com/v1/regions/us-south/zones/us-south-1","name":"us-south-1"}}],"copies":[{"crn":"crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263","deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263","id":"r134-f6bfa329-0e36-433f-a3bb-0df632e79263","name":"my-snapshot","remote":{"region":{"href":"https://us-south.iaas.cloud.ibm.com/v1/regions/us-south","name":"us-south"}},"resource_type":"snapshot"}],"created_at":"2019-01-01T12:00:00.000Z","crn":"crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263","deletable":false,"encryption":"provider_managed","encryption_key":{"crn":"crn:v1:bluemix:public:kms:us-south:a/123456:e4a29d1a-2ef0-42a6-8fd2-350deb1c647e:key:5437653b-c4b1-447f-9646-b2a2a4cd6179"},"href":"https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263","id":"r134-f6bfa329-0e36-433f-a3bb-0df632e79263","lifecycle_state":"stable","minimum_capacity":1,"name":"my-snapshot","operating_system":{"architecture":"amd64","dedicated_host_only":false,"display_name":"Ubuntu Server 16.04 LTS amd64","family":"Ubuntu Server","href":"https://us-south.iaas.cloud.ibm.com/v1/operating_systems/ubuntu-16-amd64","name":"ubuntu-16-amd64","vendor":"Canonical","version":"16.04 LTS"},"resource_group":{"href":"https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345","id":"fee82deba12e4c0fb69c3b09d1f12345","name":"my-resource-group"},"resource_type":"snapshot","service_tags":["ServiceTags"],"size":1,"snapshot_consistency_group":{"crn":"crn:v1:bluemix:public:is:us-south:a/123456::snapshot-consistency-group:r134-fa329f6b-0e36-433f-a3bb-0df632e79263","deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/snapshot_consistency_groups/r134-fa329f6b-0e36-433f-a3bb-0df632e79263","id":"r134-fa329f6b-0e36-433f-a3bb-0df632e79263","name":"my-snapshot-consistency-group","resource_type":"snapshot_consistency_group"},"source_image":{"crn":"crn:v1:bluemix:public:is:us-south:a/123456::image:72b27b5c-f4b0-48bb-b954-5becc7c1dcb8","deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/images/72b27b5c-f4b0-48bb-b954-5becc7c1dcb8","id":"72b27b5c-f4b0-48bb-b954-5becc7c1dcb8","name":"my-image","remote":{"account":{"id":"aa2432b1fa4d4ace891e9b80fc104e34","resource_type":"account"},"region":{"href":"https://us-south.iaas.cloud.ibm.com/v1/regions/us-south","name":"us-south"}},"resource_type":"image"},"source_snapshot":{"crn":"crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263","deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263","id":"r134-f6bfa329-0e36-433f-a3bb-0df632e79263","name":"my-snapshot","remote":{"region":{"href":"https://us-south.iaas.cloud.ibm.com/v1/regions/us-south","name":"us-south"}},"resource_type":"snapshot"},"source_volume":{"crn":"crn:v1:bluemix:public:is:us-south-1:a/123456::volume:1a6b7274-678d-4dfb-8981-c71dd9d4daa5","deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/volumes/1a6b7274-678d-4dfb-8981-c71dd9d4daa5","id":"1a6b7274-678d-4dfb-8981-c71dd9d4daa5","name":"my-volume","remote":{"region":{"href":"https://us-south.iaas.cloud.ibm.com/v1/regions/us-south","name":"us-south"}},"resource_type":"volume"},"user_tags":["UserTags"]}],"next":{"href":"https://myhost.com/somePath?start=1"},"total_count":2,"limit":1}`) - } else if requestNumber == 2 { - fmt.Fprintf(res, "%s", `{"snapshots":[{"backup_policy_plan":{"deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6/plans/r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178","id":"r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178","name":"my-policy-plan","remote":{"region":{"href":"https://us-south.iaas.cloud.ibm.com/v1/regions/us-south","name":"us-south"}},"resource_type":"backup_policy_plan"},"bootable":true,"captured_at":"2019-01-01T12:00:00.000Z","clones":[{"available":false,"created_at":"2019-01-01T12:00:00.000Z","zone":{"href":"https://us-south.iaas.cloud.ibm.com/v1/regions/us-south/zones/us-south-1","name":"us-south-1"}}],"copies":[{"crn":"crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263","deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263","id":"r134-f6bfa329-0e36-433f-a3bb-0df632e79263","name":"my-snapshot","remote":{"region":{"href":"https://us-south.iaas.cloud.ibm.com/v1/regions/us-south","name":"us-south"}},"resource_type":"snapshot"}],"created_at":"2019-01-01T12:00:00.000Z","crn":"crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263","deletable":false,"encryption":"provider_managed","encryption_key":{"crn":"crn:v1:bluemix:public:kms:us-south:a/123456:e4a29d1a-2ef0-42a6-8fd2-350deb1c647e:key:5437653b-c4b1-447f-9646-b2a2a4cd6179"},"href":"https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263","id":"r134-f6bfa329-0e36-433f-a3bb-0df632e79263","lifecycle_state":"stable","minimum_capacity":1,"name":"my-snapshot","operating_system":{"architecture":"amd64","dedicated_host_only":false,"display_name":"Ubuntu Server 16.04 LTS amd64","family":"Ubuntu Server","href":"https://us-south.iaas.cloud.ibm.com/v1/operating_systems/ubuntu-16-amd64","name":"ubuntu-16-amd64","vendor":"Canonical","version":"16.04 LTS"},"resource_group":{"href":"https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345","id":"fee82deba12e4c0fb69c3b09d1f12345","name":"my-resource-group"},"resource_type":"snapshot","service_tags":["ServiceTags"],"size":1,"snapshot_consistency_group":{"crn":"crn:v1:bluemix:public:is:us-south:a/123456::snapshot-consistency-group:r134-fa329f6b-0e36-433f-a3bb-0df632e79263","deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/snapshot_consistency_groups/r134-fa329f6b-0e36-433f-a3bb-0df632e79263","id":"r134-fa329f6b-0e36-433f-a3bb-0df632e79263","name":"my-snapshot-consistency-group","resource_type":"snapshot_consistency_group"},"source_image":{"crn":"crn:v1:bluemix:public:is:us-south:a/123456::image:72b27b5c-f4b0-48bb-b954-5becc7c1dcb8","deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/images/72b27b5c-f4b0-48bb-b954-5becc7c1dcb8","id":"72b27b5c-f4b0-48bb-b954-5becc7c1dcb8","name":"my-image","remote":{"account":{"id":"aa2432b1fa4d4ace891e9b80fc104e34","resource_type":"account"},"region":{"href":"https://us-south.iaas.cloud.ibm.com/v1/regions/us-south","name":"us-south"}},"resource_type":"image"},"source_snapshot":{"crn":"crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263","deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263","id":"r134-f6bfa329-0e36-433f-a3bb-0df632e79263","name":"my-snapshot","remote":{"region":{"href":"https://us-south.iaas.cloud.ibm.com/v1/regions/us-south","name":"us-south"}},"resource_type":"snapshot"},"source_volume":{"crn":"crn:v1:bluemix:public:is:us-south-1:a/123456::volume:1a6b7274-678d-4dfb-8981-c71dd9d4daa5","deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/volumes/1a6b7274-678d-4dfb-8981-c71dd9d4daa5","id":"1a6b7274-678d-4dfb-8981-c71dd9d4daa5","name":"my-volume","remote":{"region":{"href":"https://us-south.iaas.cloud.ibm.com/v1/regions/us-south","name":"us-south"}},"resource_type":"volume"},"user_tags":["UserTags"]}],"total_count":2,"limit":1}`) + // 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 { - res.WriteHeader(400) + _, 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))})) + res.WriteHeader(202) })) }) - It(`Use SnapshotsPager.GetNext successfully`, func() { + It(`Invoke FailoverShare successfully`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -57572,44 +57954,24 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - listSnapshotsOptionsModel := &vpcv1.ListSnapshotsOptions{ - Limit: core.Int64Ptr(int64(10)), - Tag: core.StringPtr("testString"), - ResourceGroupID: core.StringPtr("testString"), - Name: core.StringPtr("testString"), - SourceVolumeID: core.StringPtr("testString"), - SourceVolumeCRN: core.StringPtr("crn:v1:bluemix:public:is:us-south-1:a/123456::volume:1a6b7274-678d-4dfb-8981-c71dd9d4daa5"), - SourceImageID: core.StringPtr("testString"), - SourceImageCRN: core.StringPtr("crn:v1:bluemix:public:is:us-south:a/123456::image:72b27b5c-f4b0-48bb-b954-5becc7c1dcb8"), - Sort: core.StringPtr("name"), - BackupPolicyPlanID: core.StringPtr("testString"), - CopiesID: core.StringPtr("testString"), - CopiesName: core.StringPtr("my-snapshot-copy"), - CopiesCRN: core.StringPtr("testString"), - CopiesRemoteRegionName: core.StringPtr("us-south"), - SourceSnapshotID: core.StringPtr("testString"), - SourceSnapshotRemoteRegionName: core.StringPtr("us-south"), - SourceVolumeRemoteRegionName: core.StringPtr("us-south"), - SourceImageRemoteRegionName: core.StringPtr("us-south"), - ClonesZoneName: core.StringPtr("us-south-1"), - SnapshotConsistencyGroupID: core.StringPtr("testString"), - SnapshotConsistencyGroupCRN: core.StringPtr("crn:v1:bluemix:public:is:us-south:a/123456::snapshot-consistency-group:r134-fa329f6b-0e36-433f-a3bb-0df632e79263"), - } + // Invoke operation with nil options model (negative test) + response, operationErr := vpcService.FailoverShare(nil) + Expect(operationErr).NotTo(BeNil()) + Expect(response).To(BeNil()) - pager, err := vpcService.NewSnapshotsPager(listSnapshotsOptionsModel) - Expect(err).To(BeNil()) - Expect(pager).ToNot(BeNil()) + // Construct an instance of the FailoverShareOptions model + failoverShareOptionsModel := new(vpcv1.FailoverShareOptions) + failoverShareOptionsModel.ShareID = core.StringPtr("testString") + failoverShareOptionsModel.FallbackPolicy = core.StringPtr("fail") + failoverShareOptionsModel.Timeout = core.Int64Ptr(int64(600)) + failoverShareOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} - var allResults []vpcv1.Snapshot - for pager.HasNext() { - nextPage, err := pager.GetNext() - Expect(err).To(BeNil()) - Expect(nextPage).ToNot(BeNil()) - allResults = append(allResults, nextPage...) - } - Expect(len(allResults)).To(Equal(2)) + // Invoke operation with valid options model (positive test) + response, operationErr = vpcService.FailoverShare(failoverShareOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) }) - It(`Use SnapshotsPager.GetAll successfully`, func() { + It(`Invoke FailoverShare with error: Operation validation and request error`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -57618,60 +57980,53 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - listSnapshotsOptionsModel := &vpcv1.ListSnapshotsOptions{ - Limit: core.Int64Ptr(int64(10)), - Tag: core.StringPtr("testString"), - ResourceGroupID: core.StringPtr("testString"), - Name: core.StringPtr("testString"), - SourceVolumeID: core.StringPtr("testString"), - SourceVolumeCRN: core.StringPtr("crn:v1:bluemix:public:is:us-south-1:a/123456::volume:1a6b7274-678d-4dfb-8981-c71dd9d4daa5"), - SourceImageID: core.StringPtr("testString"), - SourceImageCRN: core.StringPtr("crn:v1:bluemix:public:is:us-south:a/123456::image:72b27b5c-f4b0-48bb-b954-5becc7c1dcb8"), - Sort: core.StringPtr("name"), - BackupPolicyPlanID: core.StringPtr("testString"), - CopiesID: core.StringPtr("testString"), - CopiesName: core.StringPtr("my-snapshot-copy"), - CopiesCRN: core.StringPtr("testString"), - CopiesRemoteRegionName: core.StringPtr("us-south"), - SourceSnapshotID: core.StringPtr("testString"), - SourceSnapshotRemoteRegionName: core.StringPtr("us-south"), - SourceVolumeRemoteRegionName: core.StringPtr("us-south"), - SourceImageRemoteRegionName: core.StringPtr("us-south"), - ClonesZoneName: core.StringPtr("us-south-1"), - SnapshotConsistencyGroupID: core.StringPtr("testString"), - SnapshotConsistencyGroupCRN: core.StringPtr("crn:v1:bluemix:public:is:us-south:a/123456::snapshot-consistency-group:r134-fa329f6b-0e36-433f-a3bb-0df632e79263"), - } - - pager, err := vpcService.NewSnapshotsPager(listSnapshotsOptionsModel) - Expect(err).To(BeNil()) - Expect(pager).ToNot(BeNil()) - - allResults, err := pager.GetAll() + // Construct an instance of the FailoverShareOptions model + failoverShareOptionsModel := new(vpcv1.FailoverShareOptions) + failoverShareOptionsModel.ShareID = core.StringPtr("testString") + failoverShareOptionsModel.FallbackPolicy = core.StringPtr("fail") + failoverShareOptionsModel.Timeout = core.Int64Ptr(int64(600)) + failoverShareOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Invoke operation with empty URL (negative test) + err := vpcService.SetServiceURL("") Expect(err).To(BeNil()) - Expect(allResults).ToNot(BeNil()) - Expect(len(allResults)).To(Equal(2)) + response, operationErr := vpcService.FailoverShare(failoverShareOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING)) + Expect(response).To(BeNil()) + // Construct a second instance of the FailoverShareOptions model with no property values + failoverShareOptionsModelNew := new(vpcv1.FailoverShareOptions) + // Invoke operation with invalid model (negative test) + response, operationErr = vpcService.FailoverShare(failoverShareOptionsModelNew) + Expect(operationErr).ToNot(BeNil()) + Expect(response).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() }) }) }) - Describe(`CreateSnapshot(createSnapshotOptions *CreateSnapshotOptions) - Operation response error`, func() { + Describe(`ListShareMountTargets(listShareMountTargetsOptions *ListShareMountTargetsOptions) - Operation response error`, func() { version := "testString" - createSnapshotPath := "/snapshots" + listShareMountTargetsPath := "/shares/testString/mount_targets" Context(`Using mock server endpoint with invalid JSON response`, func() { BeforeEach(func() { testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(createSnapshotPath)) - Expect(req.Method).To(Equal("POST")) + Expect(req.URL.EscapedPath()).To(Equal(listShareMountTargetsPath)) + 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"})) + Expect(req.URL.Query()["start"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["limit"]).To(Equal([]string{fmt.Sprint(int64(10))})) res.Header().Set("Content-type", "application/json") - res.WriteHeader(201) + res.WriteHeader(200) fmt.Fprint(res, `} this is not valid json {`) })) }) - It(`Invoke CreateSnapshot with error: Operation response processing error`, func() { + It(`Invoke ListShareMountTargets with error: Operation response processing error`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -57680,43 +58035,22 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the ZoneIdentityByName model - zoneIdentityModel := new(vpcv1.ZoneIdentityByName) - zoneIdentityModel.Name = core.StringPtr("us-south-1") - - // Construct an instance of the SnapshotClonePrototype model - snapshotClonePrototypeModel := new(vpcv1.SnapshotClonePrototype) - snapshotClonePrototypeModel.Zone = zoneIdentityModel - - // Construct an instance of the ResourceGroupIdentityByID model - resourceGroupIdentityModel := new(vpcv1.ResourceGroupIdentityByID) - resourceGroupIdentityModel.ID = core.StringPtr("fee82deba12e4c0fb69c3b09d1f12345") - - // Construct an instance of the VolumeIdentityByID model - volumeIdentityModel := new(vpcv1.VolumeIdentityByID) - volumeIdentityModel.ID = core.StringPtr("1a6b7274-678d-4dfb-8981-c71dd9d4daa5") - - // Construct an instance of the SnapshotPrototypeSnapshotBySourceVolume model - snapshotPrototypeModel := new(vpcv1.SnapshotPrototypeSnapshotBySourceVolume) - snapshotPrototypeModel.Clones = []vpcv1.SnapshotClonePrototype{*snapshotClonePrototypeModel} - snapshotPrototypeModel.Name = core.StringPtr("my-snapshot") - snapshotPrototypeModel.ResourceGroup = resourceGroupIdentityModel - snapshotPrototypeModel.UserTags = []string{} - snapshotPrototypeModel.SourceVolume = volumeIdentityModel - - // Construct an instance of the CreateSnapshotOptions model - createSnapshotOptionsModel := new(vpcv1.CreateSnapshotOptions) - createSnapshotOptionsModel.SnapshotPrototype = snapshotPrototypeModel - createSnapshotOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the ListShareMountTargetsOptions model + listShareMountTargetsOptionsModel := new(vpcv1.ListShareMountTargetsOptions) + listShareMountTargetsOptionsModel.ShareID = core.StringPtr("testString") + listShareMountTargetsOptionsModel.Name = core.StringPtr("testString") + listShareMountTargetsOptionsModel.Start = core.StringPtr("testString") + listShareMountTargetsOptionsModel.Limit = core.Int64Ptr(int64(10)) + listShareMountTargetsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Expect response parsing to fail since we are receiving a text/plain response - result, response, operationErr := vpcService.CreateSnapshot(createSnapshotOptionsModel) + result, response, operationErr := vpcService.ListShareMountTargets(listShareMountTargetsOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).To(BeNil()) // Enable retries and test again vpcService.EnableRetries(0, 0) - result, response, operationErr = vpcService.CreateSnapshot(createSnapshotOptionsModel) + result, response, operationErr = vpcService.ListShareMountTargets(listShareMountTargetsOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).To(BeNil()) @@ -57726,46 +58060,33 @@ var _ = Describe(`VpcV1`, func() { }) }) }) - Describe(`CreateSnapshot(createSnapshotOptions *CreateSnapshotOptions)`, func() { + Describe(`ListShareMountTargets(listShareMountTargetsOptions *ListShareMountTargetsOptions)`, func() { version := "testString" - createSnapshotPath := "/snapshots" + listShareMountTargetsPath := "/shares/testString/mount_targets" Context(`Using mock server endpoint with timeout`, func() { BeforeEach(func() { testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(createSnapshotPath)) - Expect(req.Method).To(Equal("POST")) - - // For gzip-disabled operation, verify Content-Encoding is not set. - Expect(req.Header.Get("Content-Encoding")).To(BeEmpty()) - - // If there is a body, then make sure we can read it - bodyBuf := new(bytes.Buffer) - if req.Header.Get("Content-Encoding") == "gzip" { - body, err := core.NewGzipDecompressionReader(req.Body) - Expect(err).To(BeNil()) - _, err = bodyBuf.ReadFrom(body) - Expect(err).To(BeNil()) - } else { - _, err := bodyBuf.ReadFrom(req.Body) - Expect(err).To(BeNil()) - } - fmt.Fprintf(GinkgoWriter, " Request body: %s", bodyBuf.String()) + Expect(req.URL.EscapedPath()).To(Equal(listShareMountTargetsPath)) + 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"})) + Expect(req.URL.Query()["start"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["limit"]).To(Equal([]string{fmt.Sprint(int64(10))})) // Sleep a short time to support a timeout test time.Sleep(100 * time.Millisecond) // Set mock response res.Header().Set("Content-type", "application/json") - res.WriteHeader(201) - fmt.Fprintf(res, "%s", `{"backup_policy_plan": {"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6/plans/r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "id": "r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "name": "my-policy-plan", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "backup_policy_plan"}, "bootable": true, "captured_at": "2019-01-01T12:00:00.000Z", "clones": [{"available": false, "created_at": "2019-01-01T12:00:00.000Z", "zone": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south/zones/us-south-1", "name": "us-south-1"}}], "copies": [{"crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "id": "r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "name": "my-snapshot", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "snapshot"}], "created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "deletable": false, "encryption": "provider_managed", "encryption_key": {"crn": "crn:v1:bluemix:public:kms:us-south:a/123456:e4a29d1a-2ef0-42a6-8fd2-350deb1c647e:key:5437653b-c4b1-447f-9646-b2a2a4cd6179"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "id": "r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "lifecycle_state": "stable", "minimum_capacity": 1, "name": "my-snapshot", "operating_system": {"architecture": "amd64", "dedicated_host_only": false, "display_name": "Ubuntu Server 16.04 LTS amd64", "family": "Ubuntu Server", "href": "https://us-south.iaas.cloud.ibm.com/v1/operating_systems/ubuntu-16-amd64", "name": "ubuntu-16-amd64", "vendor": "Canonical", "version": "16.04 LTS"}, "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "resource_type": "snapshot", "service_tags": ["ServiceTags"], "size": 1, "snapshot_consistency_group": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot-consistency-group:r134-fa329f6b-0e36-433f-a3bb-0df632e79263", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshot_consistency_groups/r134-fa329f6b-0e36-433f-a3bb-0df632e79263", "id": "r134-fa329f6b-0e36-433f-a3bb-0df632e79263", "name": "my-snapshot-consistency-group", "resource_type": "snapshot_consistency_group"}, "source_image": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::image:72b27b5c-f4b0-48bb-b954-5becc7c1dcb8", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/images/72b27b5c-f4b0-48bb-b954-5becc7c1dcb8", "id": "72b27b5c-f4b0-48bb-b954-5becc7c1dcb8", "name": "my-image", "remote": {"account": {"id": "aa2432b1fa4d4ace891e9b80fc104e34", "resource_type": "account"}, "region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "image"}, "source_snapshot": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "id": "r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "name": "my-snapshot", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "snapshot"}, "source_volume": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::volume:1a6b7274-678d-4dfb-8981-c71dd9d4daa5", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/volumes/1a6b7274-678d-4dfb-8981-c71dd9d4daa5", "id": "1a6b7274-678d-4dfb-8981-c71dd9d4daa5", "name": "my-volume", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "volume"}, "user_tags": ["UserTags"]}`) + res.WriteHeader(200) + fmt.Fprintf(res, "%s", `{"first": {"href": "https://us-south.iaas.cloud.ibm.com/v1/shares/0fe9e5d8-0a4d-4818-96ec-e99708644a58/mount_targets?limit=20"}, "limit": 20, "mount_targets": [{"access_control_mode": "security_group", "created_at": "2019-01-01T12:00:00.000Z", "href": "https://us-south.iaas.cloud.ibm.com/v1/shares/0fe9e5d8-0a4d-4818-96ec-e99708644a58/mount_targets/4cf9171a-0043-4434-8727-15b53dbc374c", "id": "4cf9171a-0043-4434-8727-15b53dbc374c", "lifecycle_state": "stable", "mount_path": "10.240.1.23:/nxg_s_voll_mz7121_58e7e963_8f4b_4a0c_b71a_8ba8d9cd1e2e", "name": "my-share-mount-target", "primary_ip": {"address": "192.168.3.4", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e/reserved_ips/6d353a0f-aeb1-4ae1-832e-1110d10981bb", "id": "6d353a0f-aeb1-4ae1-832e-1110d10981bb", "name": "my-reserved-ip", "resource_type": "subnet_reserved_ip"}, "resource_type": "share_mount_target", "subnet": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "id": "7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "name": "my-subnet", "resource_type": "subnet"}, "transit_encryption": "none", "virtual_network_interface": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::virtual-network-interface:0767-fa41aecb-4f21-423d-8082-630bfba1e1d9", "href": "https://us-south.iaas.cloud.ibm.com/v1/virtual_network_interfaces/0767-fa41aecb-4f21-423d-8082-630bfba1e1d9", "id": "0767-fa41aecb-4f21-423d-8082-630bfba1e1d9", "name": "my-virtual-network-interface", "resource_type": "virtual_network_interface"}, "vpc": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::vpc:4727d842-f94f-4a2d-824a-9bc9b02c523b", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/vpcs/4727d842-f94f-4a2d-824a-9bc9b02c523b", "id": "4727d842-f94f-4a2d-824a-9bc9b02c523b", "name": "my-vpc", "resource_type": "vpc"}}], "next": {"href": "https://us-south.iaas.cloud.ibm.com/v1/shares/0fe9e5d8-0a4d-4818-96ec-e99708644a58/mount_targets?start=9d5a91a3e2cbd233b5a5b33436855ed1&limit=20"}, "total_count": 132}`) })) }) - It(`Invoke CreateSnapshot successfully with retries`, func() { + It(`Invoke ListShareMountTargets successfully with retries`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -57775,45 +58096,24 @@ var _ = Describe(`VpcV1`, func() { Expect(vpcService).ToNot(BeNil()) vpcService.EnableRetries(0, 0) - // Construct an instance of the ZoneIdentityByName model - zoneIdentityModel := new(vpcv1.ZoneIdentityByName) - zoneIdentityModel.Name = core.StringPtr("us-south-1") - - // Construct an instance of the SnapshotClonePrototype model - snapshotClonePrototypeModel := new(vpcv1.SnapshotClonePrototype) - snapshotClonePrototypeModel.Zone = zoneIdentityModel - - // Construct an instance of the ResourceGroupIdentityByID model - resourceGroupIdentityModel := new(vpcv1.ResourceGroupIdentityByID) - resourceGroupIdentityModel.ID = core.StringPtr("fee82deba12e4c0fb69c3b09d1f12345") - - // Construct an instance of the VolumeIdentityByID model - volumeIdentityModel := new(vpcv1.VolumeIdentityByID) - volumeIdentityModel.ID = core.StringPtr("1a6b7274-678d-4dfb-8981-c71dd9d4daa5") - - // Construct an instance of the SnapshotPrototypeSnapshotBySourceVolume model - snapshotPrototypeModel := new(vpcv1.SnapshotPrototypeSnapshotBySourceVolume) - snapshotPrototypeModel.Clones = []vpcv1.SnapshotClonePrototype{*snapshotClonePrototypeModel} - snapshotPrototypeModel.Name = core.StringPtr("my-snapshot") - snapshotPrototypeModel.ResourceGroup = resourceGroupIdentityModel - snapshotPrototypeModel.UserTags = []string{} - snapshotPrototypeModel.SourceVolume = volumeIdentityModel - - // Construct an instance of the CreateSnapshotOptions model - createSnapshotOptionsModel := new(vpcv1.CreateSnapshotOptions) - createSnapshotOptionsModel.SnapshotPrototype = snapshotPrototypeModel - createSnapshotOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the ListShareMountTargetsOptions model + listShareMountTargetsOptionsModel := new(vpcv1.ListShareMountTargetsOptions) + listShareMountTargetsOptionsModel.ShareID = core.StringPtr("testString") + listShareMountTargetsOptionsModel.Name = core.StringPtr("testString") + listShareMountTargetsOptionsModel.Start = core.StringPtr("testString") + listShareMountTargetsOptionsModel.Limit = core.Int64Ptr(int64(10)) + listShareMountTargetsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with a Context to test a timeout error ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond) defer cancelFunc() - _, _, operationErr := vpcService.CreateSnapshotWithContext(ctx, createSnapshotOptionsModel) + _, _, operationErr := vpcService.ListShareMountTargetsWithContext(ctx, listShareMountTargetsOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) // Disable retries and test again vpcService.DisableRetries() - result, response, operationErr := vpcService.CreateSnapshot(createSnapshotOptionsModel) + result, response, operationErr := vpcService.ListShareMountTargets(listShareMountTargetsOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) @@ -57821,7 +58121,7 @@ var _ = Describe(`VpcV1`, func() { // Re-test the timeout error with retries disabled ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond) defer cancelFunc2() - _, _, operationErr = vpcService.CreateSnapshotWithContext(ctx, createSnapshotOptionsModel) + _, _, operationErr = vpcService.ListShareMountTargetsWithContext(ctx, listShareMountTargetsOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) }) @@ -57835,34 +58135,21 @@ var _ = Describe(`VpcV1`, func() { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(createSnapshotPath)) - Expect(req.Method).To(Equal("POST")) - - // For gzip-disabled operation, verify Content-Encoding is not set. - Expect(req.Header.Get("Content-Encoding")).To(BeEmpty()) - - // If there is a body, then make sure we can read it - bodyBuf := new(bytes.Buffer) - if req.Header.Get("Content-Encoding") == "gzip" { - body, err := core.NewGzipDecompressionReader(req.Body) - Expect(err).To(BeNil()) - _, err = bodyBuf.ReadFrom(body) - Expect(err).To(BeNil()) - } else { - _, err := bodyBuf.ReadFrom(req.Body) - Expect(err).To(BeNil()) - } - fmt.Fprintf(GinkgoWriter, " Request body: %s", bodyBuf.String()) + Expect(req.URL.EscapedPath()).To(Equal(listShareMountTargetsPath)) + 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"})) + Expect(req.URL.Query()["start"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["limit"]).To(Equal([]string{fmt.Sprint(int64(10))})) // Set mock response res.Header().Set("Content-type", "application/json") - res.WriteHeader(201) - fmt.Fprintf(res, "%s", `{"backup_policy_plan": {"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6/plans/r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "id": "r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "name": "my-policy-plan", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "backup_policy_plan"}, "bootable": true, "captured_at": "2019-01-01T12:00:00.000Z", "clones": [{"available": false, "created_at": "2019-01-01T12:00:00.000Z", "zone": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south/zones/us-south-1", "name": "us-south-1"}}], "copies": [{"crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "id": "r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "name": "my-snapshot", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "snapshot"}], "created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "deletable": false, "encryption": "provider_managed", "encryption_key": {"crn": "crn:v1:bluemix:public:kms:us-south:a/123456:e4a29d1a-2ef0-42a6-8fd2-350deb1c647e:key:5437653b-c4b1-447f-9646-b2a2a4cd6179"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "id": "r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "lifecycle_state": "stable", "minimum_capacity": 1, "name": "my-snapshot", "operating_system": {"architecture": "amd64", "dedicated_host_only": false, "display_name": "Ubuntu Server 16.04 LTS amd64", "family": "Ubuntu Server", "href": "https://us-south.iaas.cloud.ibm.com/v1/operating_systems/ubuntu-16-amd64", "name": "ubuntu-16-amd64", "vendor": "Canonical", "version": "16.04 LTS"}, "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "resource_type": "snapshot", "service_tags": ["ServiceTags"], "size": 1, "snapshot_consistency_group": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot-consistency-group:r134-fa329f6b-0e36-433f-a3bb-0df632e79263", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshot_consistency_groups/r134-fa329f6b-0e36-433f-a3bb-0df632e79263", "id": "r134-fa329f6b-0e36-433f-a3bb-0df632e79263", "name": "my-snapshot-consistency-group", "resource_type": "snapshot_consistency_group"}, "source_image": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::image:72b27b5c-f4b0-48bb-b954-5becc7c1dcb8", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/images/72b27b5c-f4b0-48bb-b954-5becc7c1dcb8", "id": "72b27b5c-f4b0-48bb-b954-5becc7c1dcb8", "name": "my-image", "remote": {"account": {"id": "aa2432b1fa4d4ace891e9b80fc104e34", "resource_type": "account"}, "region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "image"}, "source_snapshot": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "id": "r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "name": "my-snapshot", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "snapshot"}, "source_volume": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::volume:1a6b7274-678d-4dfb-8981-c71dd9d4daa5", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/volumes/1a6b7274-678d-4dfb-8981-c71dd9d4daa5", "id": "1a6b7274-678d-4dfb-8981-c71dd9d4daa5", "name": "my-volume", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "volume"}, "user_tags": ["UserTags"]}`) + res.WriteHeader(200) + fmt.Fprintf(res, "%s", `{"first": {"href": "https://us-south.iaas.cloud.ibm.com/v1/shares/0fe9e5d8-0a4d-4818-96ec-e99708644a58/mount_targets?limit=20"}, "limit": 20, "mount_targets": [{"access_control_mode": "security_group", "created_at": "2019-01-01T12:00:00.000Z", "href": "https://us-south.iaas.cloud.ibm.com/v1/shares/0fe9e5d8-0a4d-4818-96ec-e99708644a58/mount_targets/4cf9171a-0043-4434-8727-15b53dbc374c", "id": "4cf9171a-0043-4434-8727-15b53dbc374c", "lifecycle_state": "stable", "mount_path": "10.240.1.23:/nxg_s_voll_mz7121_58e7e963_8f4b_4a0c_b71a_8ba8d9cd1e2e", "name": "my-share-mount-target", "primary_ip": {"address": "192.168.3.4", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e/reserved_ips/6d353a0f-aeb1-4ae1-832e-1110d10981bb", "id": "6d353a0f-aeb1-4ae1-832e-1110d10981bb", "name": "my-reserved-ip", "resource_type": "subnet_reserved_ip"}, "resource_type": "share_mount_target", "subnet": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "id": "7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "name": "my-subnet", "resource_type": "subnet"}, "transit_encryption": "none", "virtual_network_interface": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::virtual-network-interface:0767-fa41aecb-4f21-423d-8082-630bfba1e1d9", "href": "https://us-south.iaas.cloud.ibm.com/v1/virtual_network_interfaces/0767-fa41aecb-4f21-423d-8082-630bfba1e1d9", "id": "0767-fa41aecb-4f21-423d-8082-630bfba1e1d9", "name": "my-virtual-network-interface", "resource_type": "virtual_network_interface"}, "vpc": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::vpc:4727d842-f94f-4a2d-824a-9bc9b02c523b", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/vpcs/4727d842-f94f-4a2d-824a-9bc9b02c523b", "id": "4727d842-f94f-4a2d-824a-9bc9b02c523b", "name": "my-vpc", "resource_type": "vpc"}}], "next": {"href": "https://us-south.iaas.cloud.ibm.com/v1/shares/0fe9e5d8-0a4d-4818-96ec-e99708644a58/mount_targets?start=9d5a91a3e2cbd233b5a5b33436855ed1&limit=20"}, "total_count": 132}`) })) }) - It(`Invoke CreateSnapshot successfully`, func() { + It(`Invoke ListShareMountTargets successfully`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -57872,48 +58159,27 @@ var _ = Describe(`VpcV1`, func() { Expect(vpcService).ToNot(BeNil()) // Invoke operation with nil options model (negative test) - result, response, operationErr := vpcService.CreateSnapshot(nil) + result, response, operationErr := vpcService.ListShareMountTargets(nil) Expect(operationErr).NotTo(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) - // Construct an instance of the ZoneIdentityByName model - zoneIdentityModel := new(vpcv1.ZoneIdentityByName) - zoneIdentityModel.Name = core.StringPtr("us-south-1") - - // Construct an instance of the SnapshotClonePrototype model - snapshotClonePrototypeModel := new(vpcv1.SnapshotClonePrototype) - snapshotClonePrototypeModel.Zone = zoneIdentityModel - - // Construct an instance of the ResourceGroupIdentityByID model - resourceGroupIdentityModel := new(vpcv1.ResourceGroupIdentityByID) - resourceGroupIdentityModel.ID = core.StringPtr("fee82deba12e4c0fb69c3b09d1f12345") - - // Construct an instance of the VolumeIdentityByID model - volumeIdentityModel := new(vpcv1.VolumeIdentityByID) - volumeIdentityModel.ID = core.StringPtr("1a6b7274-678d-4dfb-8981-c71dd9d4daa5") - - // Construct an instance of the SnapshotPrototypeSnapshotBySourceVolume model - snapshotPrototypeModel := new(vpcv1.SnapshotPrototypeSnapshotBySourceVolume) - snapshotPrototypeModel.Clones = []vpcv1.SnapshotClonePrototype{*snapshotClonePrototypeModel} - snapshotPrototypeModel.Name = core.StringPtr("my-snapshot") - snapshotPrototypeModel.ResourceGroup = resourceGroupIdentityModel - snapshotPrototypeModel.UserTags = []string{} - snapshotPrototypeModel.SourceVolume = volumeIdentityModel - - // Construct an instance of the CreateSnapshotOptions model - createSnapshotOptionsModel := new(vpcv1.CreateSnapshotOptions) - createSnapshotOptionsModel.SnapshotPrototype = snapshotPrototypeModel - createSnapshotOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the ListShareMountTargetsOptions model + listShareMountTargetsOptionsModel := new(vpcv1.ListShareMountTargetsOptions) + listShareMountTargetsOptionsModel.ShareID = core.StringPtr("testString") + listShareMountTargetsOptionsModel.Name = core.StringPtr("testString") + listShareMountTargetsOptionsModel.Start = core.StringPtr("testString") + listShareMountTargetsOptionsModel.Limit = core.Int64Ptr(int64(10)) + listShareMountTargetsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with valid options model (positive test) - result, response, operationErr = vpcService.CreateSnapshot(createSnapshotOptionsModel) + result, response, operationErr = vpcService.ListShareMountTargets(listShareMountTargetsOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) }) - It(`Invoke CreateSnapshot with error: Operation validation and request error`, func() { + It(`Invoke ListShareMountTargets with error: Operation validation and request error`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -57922,46 +58188,25 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the ZoneIdentityByName model - zoneIdentityModel := new(vpcv1.ZoneIdentityByName) - zoneIdentityModel.Name = core.StringPtr("us-south-1") - - // Construct an instance of the SnapshotClonePrototype model - snapshotClonePrototypeModel := new(vpcv1.SnapshotClonePrototype) - snapshotClonePrototypeModel.Zone = zoneIdentityModel - - // Construct an instance of the ResourceGroupIdentityByID model - resourceGroupIdentityModel := new(vpcv1.ResourceGroupIdentityByID) - resourceGroupIdentityModel.ID = core.StringPtr("fee82deba12e4c0fb69c3b09d1f12345") - - // Construct an instance of the VolumeIdentityByID model - volumeIdentityModel := new(vpcv1.VolumeIdentityByID) - volumeIdentityModel.ID = core.StringPtr("1a6b7274-678d-4dfb-8981-c71dd9d4daa5") - - // Construct an instance of the SnapshotPrototypeSnapshotBySourceVolume model - snapshotPrototypeModel := new(vpcv1.SnapshotPrototypeSnapshotBySourceVolume) - snapshotPrototypeModel.Clones = []vpcv1.SnapshotClonePrototype{*snapshotClonePrototypeModel} - snapshotPrototypeModel.Name = core.StringPtr("my-snapshot") - snapshotPrototypeModel.ResourceGroup = resourceGroupIdentityModel - snapshotPrototypeModel.UserTags = []string{} - snapshotPrototypeModel.SourceVolume = volumeIdentityModel - - // Construct an instance of the CreateSnapshotOptions model - createSnapshotOptionsModel := new(vpcv1.CreateSnapshotOptions) - createSnapshotOptionsModel.SnapshotPrototype = snapshotPrototypeModel - createSnapshotOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the ListShareMountTargetsOptions model + listShareMountTargetsOptionsModel := new(vpcv1.ListShareMountTargetsOptions) + listShareMountTargetsOptionsModel.ShareID = core.StringPtr("testString") + listShareMountTargetsOptionsModel.Name = core.StringPtr("testString") + listShareMountTargetsOptionsModel.Start = core.StringPtr("testString") + listShareMountTargetsOptionsModel.Limit = core.Int64Ptr(int64(10)) + listShareMountTargetsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with empty URL (negative test) err := vpcService.SetServiceURL("") Expect(err).To(BeNil()) - result, response, operationErr := vpcService.CreateSnapshot(createSnapshotOptionsModel) + result, response, operationErr := vpcService.ListShareMountTargets(listShareMountTargetsOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING)) Expect(response).To(BeNil()) Expect(result).To(BeNil()) - // Construct a second instance of the CreateSnapshotOptions model with no property values - createSnapshotOptionsModelNew := new(vpcv1.CreateSnapshotOptions) + // Construct a second instance of the ListShareMountTargetsOptions model with no property values + listShareMountTargetsOptionsModelNew := new(vpcv1.ListShareMountTargetsOptions) // Invoke operation with invalid model (negative test) - result, response, operationErr = vpcService.CreateSnapshot(createSnapshotOptionsModelNew) + result, response, operationErr = vpcService.ListShareMountTargets(listShareMountTargetsOptionsModelNew) Expect(operationErr).ToNot(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) @@ -57976,10 +58221,10 @@ var _ = Describe(`VpcV1`, func() { defer GinkgoRecover() // Set success status code with no respoonse body - res.WriteHeader(201) + res.WriteHeader(200) })) }) - It(`Invoke CreateSnapshot successfully`, func() { + It(`Invoke ListShareMountTargets successfully`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -57988,37 +58233,16 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the ZoneIdentityByName model - zoneIdentityModel := new(vpcv1.ZoneIdentityByName) - zoneIdentityModel.Name = core.StringPtr("us-south-1") - - // Construct an instance of the SnapshotClonePrototype model - snapshotClonePrototypeModel := new(vpcv1.SnapshotClonePrototype) - snapshotClonePrototypeModel.Zone = zoneIdentityModel - - // Construct an instance of the ResourceGroupIdentityByID model - resourceGroupIdentityModel := new(vpcv1.ResourceGroupIdentityByID) - resourceGroupIdentityModel.ID = core.StringPtr("fee82deba12e4c0fb69c3b09d1f12345") - - // Construct an instance of the VolumeIdentityByID model - volumeIdentityModel := new(vpcv1.VolumeIdentityByID) - volumeIdentityModel.ID = core.StringPtr("1a6b7274-678d-4dfb-8981-c71dd9d4daa5") - - // Construct an instance of the SnapshotPrototypeSnapshotBySourceVolume model - snapshotPrototypeModel := new(vpcv1.SnapshotPrototypeSnapshotBySourceVolume) - snapshotPrototypeModel.Clones = []vpcv1.SnapshotClonePrototype{*snapshotClonePrototypeModel} - snapshotPrototypeModel.Name = core.StringPtr("my-snapshot") - snapshotPrototypeModel.ResourceGroup = resourceGroupIdentityModel - snapshotPrototypeModel.UserTags = []string{} - snapshotPrototypeModel.SourceVolume = volumeIdentityModel - - // Construct an instance of the CreateSnapshotOptions model - createSnapshotOptionsModel := new(vpcv1.CreateSnapshotOptions) - createSnapshotOptionsModel.SnapshotPrototype = snapshotPrototypeModel - createSnapshotOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the ListShareMountTargetsOptions model + listShareMountTargetsOptionsModel := new(vpcv1.ListShareMountTargetsOptions) + listShareMountTargetsOptionsModel.ShareID = core.StringPtr("testString") + listShareMountTargetsOptionsModel.Name = core.StringPtr("testString") + listShareMountTargetsOptionsModel.Start = core.StringPtr("testString") + listShareMountTargetsOptionsModel.Limit = core.Int64Ptr(int64(10)) + listShareMountTargetsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation - result, response, operationErr := vpcService.CreateSnapshot(createSnapshotOptionsModel) + result, response, operationErr := vpcService.ListShareMountTargets(listShareMountTargetsOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) @@ -58029,27 +58253,59 @@ var _ = Describe(`VpcV1`, func() { testServer.Close() }) }) - }) - Describe(`DeleteSnapshot(deleteSnapshotOptions *DeleteSnapshotOptions)`, func() { - version := "testString" - deleteSnapshotPath := "/snapshots/testString" - Context(`Using mock server endpoint`, func() { + Context(`Test pagination helper method on response`, func() { + It(`Invoke GetNextStart successfully`, func() { + responseObject := new(vpcv1.ShareMountTargetCollection) + nextObject := new(vpcv1.ShareMountTargetCollectionNext) + 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.ShareMountTargetCollection) + + 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.ShareMountTargetCollection) + nextObject := new(vpcv1.ShareMountTargetCollectionNext) + nextObject.Href = core.StringPtr("ibm.com") + responseObject.Next = nextObject + + value, err := responseObject.GetNextStart() + Expect(err).To(BeNil()) + Expect(value).To(BeNil()) + }) + }) + Context(`Using mock server endpoint - paginated response`, func() { BeforeEach(func() { + var requestNumber int = 0 testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(deleteSnapshotPath)) - Expect(req.Method).To(Equal("DELETE")) + Expect(req.URL.EscapedPath()).To(Equal(listShareMountTargetsPath)) + Expect(req.Method).To(Equal("GET")) - Expect(req.Header["If-Match"]).ToNot(BeNil()) - Expect(req.Header["If-Match"][0]).To(Equal(fmt.Sprintf("%v", `W/"96d225c4-56bd-43d9-98fc-d7148e5c5028"`))) - Expect(req.URL.Query()["version"]).To(Equal([]string{"testString"})) - Expect(req.URL.Query()["generation"]).To(Equal([]string{fmt.Sprint(int64(2))})) - res.WriteHeader(204) + // Set mock response + res.Header().Set("Content-type", "application/json") + res.WriteHeader(200) + requestNumber++ + if requestNumber == 1 { + fmt.Fprintf(res, "%s", `{"next":{"href":"https://myhost.com/somePath?start=1"},"total_count":2,"limit":1,"mount_targets":[{"access_control_mode":"security_group","created_at":"2019-01-01T12:00:00.000Z","href":"https://us-south.iaas.cloud.ibm.com/v1/shares/0fe9e5d8-0a4d-4818-96ec-e99708644a58/mount_targets/4cf9171a-0043-4434-8727-15b53dbc374c","id":"4cf9171a-0043-4434-8727-15b53dbc374c","lifecycle_state":"stable","mount_path":"10.240.1.23:/nxg_s_voll_mz7121_58e7e963_8f4b_4a0c_b71a_8ba8d9cd1e2e","name":"my-share-mount-target","primary_ip":{"address":"192.168.3.4","deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e/reserved_ips/6d353a0f-aeb1-4ae1-832e-1110d10981bb","id":"6d353a0f-aeb1-4ae1-832e-1110d10981bb","name":"my-reserved-ip","resource_type":"subnet_reserved_ip"},"resource_type":"share_mount_target","subnet":{"crn":"crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e","deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e","id":"7ec86020-1c6e-4889-b3f0-a15f2e50f87e","name":"my-subnet","resource_type":"subnet"},"transit_encryption":"none","virtual_network_interface":{"crn":"crn:v1:bluemix:public:is:us-south-1:a/123456::virtual-network-interface:0767-fa41aecb-4f21-423d-8082-630bfba1e1d9","href":"https://us-south.iaas.cloud.ibm.com/v1/virtual_network_interfaces/0767-fa41aecb-4f21-423d-8082-630bfba1e1d9","id":"0767-fa41aecb-4f21-423d-8082-630bfba1e1d9","name":"my-virtual-network-interface","resource_type":"virtual_network_interface"},"vpc":{"crn":"crn:v1:bluemix:public:is:us-south:a/123456::vpc:4727d842-f94f-4a2d-824a-9bc9b02c523b","deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/vpcs/4727d842-f94f-4a2d-824a-9bc9b02c523b","id":"4727d842-f94f-4a2d-824a-9bc9b02c523b","name":"my-vpc","resource_type":"vpc"}}]}`) + } else if requestNumber == 2 { + fmt.Fprintf(res, "%s", `{"total_count":2,"limit":1,"mount_targets":[{"access_control_mode":"security_group","created_at":"2019-01-01T12:00:00.000Z","href":"https://us-south.iaas.cloud.ibm.com/v1/shares/0fe9e5d8-0a4d-4818-96ec-e99708644a58/mount_targets/4cf9171a-0043-4434-8727-15b53dbc374c","id":"4cf9171a-0043-4434-8727-15b53dbc374c","lifecycle_state":"stable","mount_path":"10.240.1.23:/nxg_s_voll_mz7121_58e7e963_8f4b_4a0c_b71a_8ba8d9cd1e2e","name":"my-share-mount-target","primary_ip":{"address":"192.168.3.4","deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e/reserved_ips/6d353a0f-aeb1-4ae1-832e-1110d10981bb","id":"6d353a0f-aeb1-4ae1-832e-1110d10981bb","name":"my-reserved-ip","resource_type":"subnet_reserved_ip"},"resource_type":"share_mount_target","subnet":{"crn":"crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e","deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e","id":"7ec86020-1c6e-4889-b3f0-a15f2e50f87e","name":"my-subnet","resource_type":"subnet"},"transit_encryption":"none","virtual_network_interface":{"crn":"crn:v1:bluemix:public:is:us-south-1:a/123456::virtual-network-interface:0767-fa41aecb-4f21-423d-8082-630bfba1e1d9","href":"https://us-south.iaas.cloud.ibm.com/v1/virtual_network_interfaces/0767-fa41aecb-4f21-423d-8082-630bfba1e1d9","id":"0767-fa41aecb-4f21-423d-8082-630bfba1e1d9","name":"my-virtual-network-interface","resource_type":"virtual_network_interface"},"vpc":{"crn":"crn:v1:bluemix:public:is:us-south:a/123456::vpc:4727d842-f94f-4a2d-824a-9bc9b02c523b","deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/vpcs/4727d842-f94f-4a2d-824a-9bc9b02c523b","id":"4727d842-f94f-4a2d-824a-9bc9b02c523b","name":"my-vpc","resource_type":"vpc"}}]}`) + } else { + res.WriteHeader(400) + } })) }) - It(`Invoke DeleteSnapshot successfully`, func() { + It(`Use ShareMountTargetsPager.GetNext successfully`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -58058,23 +58314,26 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Invoke operation with nil options model (negative test) - response, operationErr := vpcService.DeleteSnapshot(nil) - Expect(operationErr).NotTo(BeNil()) - Expect(response).To(BeNil()) + listShareMountTargetsOptionsModel := &vpcv1.ListShareMountTargetsOptions{ + ShareID: core.StringPtr("testString"), + Name: core.StringPtr("testString"), + Limit: core.Int64Ptr(int64(10)), + } - // Construct an instance of the DeleteSnapshotOptions model - deleteSnapshotOptionsModel := new(vpcv1.DeleteSnapshotOptions) - deleteSnapshotOptionsModel.ID = core.StringPtr("testString") - deleteSnapshotOptionsModel.IfMatch = core.StringPtr(`W/"96d225c4-56bd-43d9-98fc-d7148e5c5028"`) - deleteSnapshotOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + pager, err := vpcService.NewShareMountTargetsPager(listShareMountTargetsOptionsModel) + Expect(err).To(BeNil()) + Expect(pager).ToNot(BeNil()) - // Invoke operation with valid options model (positive test) - response, operationErr = vpcService.DeleteSnapshot(deleteSnapshotOptionsModel) - Expect(operationErr).To(BeNil()) - Expect(response).ToNot(BeNil()) + var allResults []vpcv1.ShareMountTarget + for pager.HasNext() { + nextPage, err := pager.GetNext() + Expect(err).To(BeNil()) + Expect(nextPage).ToNot(BeNil()) + allResults = append(allResults, nextPage...) + } + Expect(len(allResults)).To(Equal(2)) }) - It(`Invoke DeleteSnapshot with error: Operation validation and request error`, func() { + It(`Use ShareMountTargetsPager.GetAll successfully`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -58083,49 +58342,42 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the DeleteSnapshotOptions model - deleteSnapshotOptionsModel := new(vpcv1.DeleteSnapshotOptions) - deleteSnapshotOptionsModel.ID = core.StringPtr("testString") - deleteSnapshotOptionsModel.IfMatch = core.StringPtr(`W/"96d225c4-56bd-43d9-98fc-d7148e5c5028"`) - deleteSnapshotOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} - // Invoke operation with empty URL (negative test) - err := vpcService.SetServiceURL("") + listShareMountTargetsOptionsModel := &vpcv1.ListShareMountTargetsOptions{ + ShareID: core.StringPtr("testString"), + Name: core.StringPtr("testString"), + Limit: core.Int64Ptr(int64(10)), + } + + pager, err := vpcService.NewShareMountTargetsPager(listShareMountTargetsOptionsModel) Expect(err).To(BeNil()) - response, operationErr := vpcService.DeleteSnapshot(deleteSnapshotOptionsModel) - Expect(operationErr).ToNot(BeNil()) - Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING)) - Expect(response).To(BeNil()) - // Construct a second instance of the DeleteSnapshotOptions model with no property values - deleteSnapshotOptionsModelNew := new(vpcv1.DeleteSnapshotOptions) - // Invoke operation with invalid model (negative test) - response, operationErr = vpcService.DeleteSnapshot(deleteSnapshotOptionsModelNew) - Expect(operationErr).ToNot(BeNil()) - Expect(response).To(BeNil()) - }) - AfterEach(func() { - testServer.Close() + Expect(pager).ToNot(BeNil()) + + allResults, err := pager.GetAll() + Expect(err).To(BeNil()) + Expect(allResults).ToNot(BeNil()) + Expect(len(allResults)).To(Equal(2)) }) }) }) - Describe(`GetSnapshot(getSnapshotOptions *GetSnapshotOptions) - Operation response error`, func() { + Describe(`CreateShareMountTarget(createShareMountTargetOptions *CreateShareMountTargetOptions) - Operation response error`, func() { version := "testString" - getSnapshotPath := "/snapshots/testString" + createShareMountTargetPath := "/shares/testString/mount_targets" Context(`Using mock server endpoint with invalid JSON response`, func() { BeforeEach(func() { testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(getSnapshotPath)) - Expect(req.Method).To(Equal("GET")) + Expect(req.URL.EscapedPath()).To(Equal(createShareMountTargetPath)) + 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 GetSnapshot with error: Operation response processing error`, func() { + It(`Invoke CreateShareMountTarget with error: Operation response processing error`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -58134,19 +58386,62 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the GetSnapshotOptions model - getSnapshotOptionsModel := new(vpcv1.GetSnapshotOptions) - getSnapshotOptionsModel.ID = core.StringPtr("testString") - getSnapshotOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the VirtualNetworkInterfaceIPPrototypeReservedIPPrototypeVirtualNetworkInterfaceIPsContext model + virtualNetworkInterfaceIPPrototypeModel := new(vpcv1.VirtualNetworkInterfaceIPPrototypeReservedIPPrototypeVirtualNetworkInterfaceIPsContext) + virtualNetworkInterfaceIPPrototypeModel.Address = core.StringPtr("10.0.0.5") + virtualNetworkInterfaceIPPrototypeModel.AutoDelete = core.BoolPtr(false) + virtualNetworkInterfaceIPPrototypeModel.Name = core.StringPtr("my-reserved-ip") + + // Construct an instance of the VirtualNetworkInterfacePrimaryIPPrototypeReservedIPPrototypeVirtualNetworkInterfacePrimaryIPContext model + virtualNetworkInterfacePrimaryIPPrototypeModel := new(vpcv1.VirtualNetworkInterfacePrimaryIPPrototypeReservedIPPrototypeVirtualNetworkInterfacePrimaryIPContext) + virtualNetworkInterfacePrimaryIPPrototypeModel.Address = core.StringPtr("10.0.0.5") + virtualNetworkInterfacePrimaryIPPrototypeModel.AutoDelete = core.BoolPtr(false) + virtualNetworkInterfacePrimaryIPPrototypeModel.Name = core.StringPtr("my-reserved-ip") + + // Construct an instance of the ResourceGroupIdentityByID model + resourceGroupIdentityModel := new(vpcv1.ResourceGroupIdentityByID) + resourceGroupIdentityModel.ID = core.StringPtr("fee82deba12e4c0fb69c3b09d1f12345") + + // Construct an instance of the SecurityGroupIdentityByID model + securityGroupIdentityModel := new(vpcv1.SecurityGroupIdentityByID) + securityGroupIdentityModel.ID = core.StringPtr("be5df5ca-12a0-494b-907e-aa6ec2bfa271") + + // Construct an instance of the SubnetIdentityByID model + subnetIdentityModel := new(vpcv1.SubnetIdentityByID) + subnetIdentityModel.ID = core.StringPtr("7ec86020-1c6e-4889-b3f0-a15f2e50f87e") + + // Construct an instance of the ShareMountTargetVirtualNetworkInterfacePrototypeVirtualNetworkInterfacePrototypeShareMountTargetContext model + shareMountTargetVirtualNetworkInterfacePrototypeModel := new(vpcv1.ShareMountTargetVirtualNetworkInterfacePrototypeVirtualNetworkInterfacePrototypeShareMountTargetContext) + shareMountTargetVirtualNetworkInterfacePrototypeModel.AllowIPSpoofing = core.BoolPtr(true) + shareMountTargetVirtualNetworkInterfacePrototypeModel.AutoDelete = core.BoolPtr(false) + shareMountTargetVirtualNetworkInterfacePrototypeModel.EnableInfrastructureNat = core.BoolPtr(true) + shareMountTargetVirtualNetworkInterfacePrototypeModel.Ips = []vpcv1.VirtualNetworkInterfaceIPPrototypeIntf{virtualNetworkInterfaceIPPrototypeModel} + shareMountTargetVirtualNetworkInterfacePrototypeModel.Name = core.StringPtr("my-virtual-network-interface") + shareMountTargetVirtualNetworkInterfacePrototypeModel.PrimaryIP = virtualNetworkInterfacePrimaryIPPrototypeModel + shareMountTargetVirtualNetworkInterfacePrototypeModel.ResourceGroup = resourceGroupIdentityModel + shareMountTargetVirtualNetworkInterfacePrototypeModel.SecurityGroups = []vpcv1.SecurityGroupIdentityIntf{securityGroupIdentityModel} + shareMountTargetVirtualNetworkInterfacePrototypeModel.Subnet = subnetIdentityModel + + // Construct an instance of the ShareMountTargetPrototypeShareMountTargetByAccessControlModeSecurityGroup model + shareMountTargetPrototypeModel := new(vpcv1.ShareMountTargetPrototypeShareMountTargetByAccessControlModeSecurityGroup) + shareMountTargetPrototypeModel.Name = core.StringPtr("my-share-mount-target") + shareMountTargetPrototypeModel.TransitEncryption = core.StringPtr("none") + shareMountTargetPrototypeModel.VirtualNetworkInterface = shareMountTargetVirtualNetworkInterfacePrototypeModel + + // Construct an instance of the CreateShareMountTargetOptions model + createShareMountTargetOptionsModel := new(vpcv1.CreateShareMountTargetOptions) + createShareMountTargetOptionsModel.ShareID = core.StringPtr("testString") + createShareMountTargetOptionsModel.ShareMountTargetPrototype = shareMountTargetPrototypeModel + createShareMountTargetOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Expect response parsing to fail since we are receiving a text/plain response - result, response, operationErr := vpcService.GetSnapshot(getSnapshotOptionsModel) + result, response, operationErr := vpcService.CreateShareMountTarget(createShareMountTargetOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).To(BeNil()) // Enable retries and test again vpcService.EnableRetries(0, 0) - result, response, operationErr = vpcService.GetSnapshot(getSnapshotOptionsModel) + result, response, operationErr = vpcService.CreateShareMountTarget(createShareMountTargetOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).To(BeNil()) @@ -58156,17 +58451,33 @@ var _ = Describe(`VpcV1`, func() { }) }) }) - Describe(`GetSnapshot(getSnapshotOptions *GetSnapshotOptions)`, func() { + Describe(`CreateShareMountTarget(createShareMountTargetOptions *CreateShareMountTargetOptions)`, func() { version := "testString" - getSnapshotPath := "/snapshots/testString" + createShareMountTargetPath := "/shares/testString/mount_targets" Context(`Using mock server endpoint with timeout`, func() { BeforeEach(func() { testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(getSnapshotPath)) - Expect(req.Method).To(Equal("GET")) + Expect(req.URL.EscapedPath()).To(Equal(createShareMountTargetPath)) + 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))})) @@ -58175,11 +58486,11 @@ var _ = Describe(`VpcV1`, func() { // Set mock response res.Header().Set("Content-type", "application/json") - res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"backup_policy_plan": {"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6/plans/r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "id": "r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "name": "my-policy-plan", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "backup_policy_plan"}, "bootable": true, "captured_at": "2019-01-01T12:00:00.000Z", "clones": [{"available": false, "created_at": "2019-01-01T12:00:00.000Z", "zone": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south/zones/us-south-1", "name": "us-south-1"}}], "copies": [{"crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "id": "r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "name": "my-snapshot", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "snapshot"}], "created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "deletable": false, "encryption": "provider_managed", "encryption_key": {"crn": "crn:v1:bluemix:public:kms:us-south:a/123456:e4a29d1a-2ef0-42a6-8fd2-350deb1c647e:key:5437653b-c4b1-447f-9646-b2a2a4cd6179"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "id": "r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "lifecycle_state": "stable", "minimum_capacity": 1, "name": "my-snapshot", "operating_system": {"architecture": "amd64", "dedicated_host_only": false, "display_name": "Ubuntu Server 16.04 LTS amd64", "family": "Ubuntu Server", "href": "https://us-south.iaas.cloud.ibm.com/v1/operating_systems/ubuntu-16-amd64", "name": "ubuntu-16-amd64", "vendor": "Canonical", "version": "16.04 LTS"}, "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "resource_type": "snapshot", "service_tags": ["ServiceTags"], "size": 1, "snapshot_consistency_group": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot-consistency-group:r134-fa329f6b-0e36-433f-a3bb-0df632e79263", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshot_consistency_groups/r134-fa329f6b-0e36-433f-a3bb-0df632e79263", "id": "r134-fa329f6b-0e36-433f-a3bb-0df632e79263", "name": "my-snapshot-consistency-group", "resource_type": "snapshot_consistency_group"}, "source_image": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::image:72b27b5c-f4b0-48bb-b954-5becc7c1dcb8", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/images/72b27b5c-f4b0-48bb-b954-5becc7c1dcb8", "id": "72b27b5c-f4b0-48bb-b954-5becc7c1dcb8", "name": "my-image", "remote": {"account": {"id": "aa2432b1fa4d4ace891e9b80fc104e34", "resource_type": "account"}, "region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "image"}, "source_snapshot": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "id": "r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "name": "my-snapshot", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "snapshot"}, "source_volume": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::volume:1a6b7274-678d-4dfb-8981-c71dd9d4daa5", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/volumes/1a6b7274-678d-4dfb-8981-c71dd9d4daa5", "id": "1a6b7274-678d-4dfb-8981-c71dd9d4daa5", "name": "my-volume", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "volume"}, "user_tags": ["UserTags"]}`) + res.WriteHeader(201) + fmt.Fprintf(res, "%s", `{"access_control_mode": "security_group", "created_at": "2019-01-01T12:00:00.000Z", "href": "https://us-south.iaas.cloud.ibm.com/v1/shares/0fe9e5d8-0a4d-4818-96ec-e99708644a58/mount_targets/4cf9171a-0043-4434-8727-15b53dbc374c", "id": "4cf9171a-0043-4434-8727-15b53dbc374c", "lifecycle_state": "stable", "mount_path": "10.240.1.23:/nxg_s_voll_mz7121_58e7e963_8f4b_4a0c_b71a_8ba8d9cd1e2e", "name": "my-share-mount-target", "primary_ip": {"address": "192.168.3.4", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e/reserved_ips/6d353a0f-aeb1-4ae1-832e-1110d10981bb", "id": "6d353a0f-aeb1-4ae1-832e-1110d10981bb", "name": "my-reserved-ip", "resource_type": "subnet_reserved_ip"}, "resource_type": "share_mount_target", "subnet": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "id": "7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "name": "my-subnet", "resource_type": "subnet"}, "transit_encryption": "none", "virtual_network_interface": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::virtual-network-interface:0767-fa41aecb-4f21-423d-8082-630bfba1e1d9", "href": "https://us-south.iaas.cloud.ibm.com/v1/virtual_network_interfaces/0767-fa41aecb-4f21-423d-8082-630bfba1e1d9", "id": "0767-fa41aecb-4f21-423d-8082-630bfba1e1d9", "name": "my-virtual-network-interface", "resource_type": "virtual_network_interface"}, "vpc": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::vpc:4727d842-f94f-4a2d-824a-9bc9b02c523b", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/vpcs/4727d842-f94f-4a2d-824a-9bc9b02c523b", "id": "4727d842-f94f-4a2d-824a-9bc9b02c523b", "name": "my-vpc", "resource_type": "vpc"}}`) })) }) - It(`Invoke GetSnapshot successfully with retries`, func() { + It(`Invoke CreateShareMountTarget successfully with retries`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -58189,21 +58500,64 @@ var _ = Describe(`VpcV1`, func() { Expect(vpcService).ToNot(BeNil()) vpcService.EnableRetries(0, 0) - // Construct an instance of the GetSnapshotOptions model - getSnapshotOptionsModel := new(vpcv1.GetSnapshotOptions) - getSnapshotOptionsModel.ID = core.StringPtr("testString") - getSnapshotOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the VirtualNetworkInterfaceIPPrototypeReservedIPPrototypeVirtualNetworkInterfaceIPsContext model + virtualNetworkInterfaceIPPrototypeModel := new(vpcv1.VirtualNetworkInterfaceIPPrototypeReservedIPPrototypeVirtualNetworkInterfaceIPsContext) + virtualNetworkInterfaceIPPrototypeModel.Address = core.StringPtr("10.0.0.5") + virtualNetworkInterfaceIPPrototypeModel.AutoDelete = core.BoolPtr(false) + virtualNetworkInterfaceIPPrototypeModel.Name = core.StringPtr("my-reserved-ip") + + // Construct an instance of the VirtualNetworkInterfacePrimaryIPPrototypeReservedIPPrototypeVirtualNetworkInterfacePrimaryIPContext model + virtualNetworkInterfacePrimaryIPPrototypeModel := new(vpcv1.VirtualNetworkInterfacePrimaryIPPrototypeReservedIPPrototypeVirtualNetworkInterfacePrimaryIPContext) + virtualNetworkInterfacePrimaryIPPrototypeModel.Address = core.StringPtr("10.0.0.5") + virtualNetworkInterfacePrimaryIPPrototypeModel.AutoDelete = core.BoolPtr(false) + virtualNetworkInterfacePrimaryIPPrototypeModel.Name = core.StringPtr("my-reserved-ip") + + // Construct an instance of the ResourceGroupIdentityByID model + resourceGroupIdentityModel := new(vpcv1.ResourceGroupIdentityByID) + resourceGroupIdentityModel.ID = core.StringPtr("fee82deba12e4c0fb69c3b09d1f12345") + + // Construct an instance of the SecurityGroupIdentityByID model + securityGroupIdentityModel := new(vpcv1.SecurityGroupIdentityByID) + securityGroupIdentityModel.ID = core.StringPtr("be5df5ca-12a0-494b-907e-aa6ec2bfa271") + + // Construct an instance of the SubnetIdentityByID model + subnetIdentityModel := new(vpcv1.SubnetIdentityByID) + subnetIdentityModel.ID = core.StringPtr("7ec86020-1c6e-4889-b3f0-a15f2e50f87e") + + // Construct an instance of the ShareMountTargetVirtualNetworkInterfacePrototypeVirtualNetworkInterfacePrototypeShareMountTargetContext model + shareMountTargetVirtualNetworkInterfacePrototypeModel := new(vpcv1.ShareMountTargetVirtualNetworkInterfacePrototypeVirtualNetworkInterfacePrototypeShareMountTargetContext) + shareMountTargetVirtualNetworkInterfacePrototypeModel.AllowIPSpoofing = core.BoolPtr(true) + shareMountTargetVirtualNetworkInterfacePrototypeModel.AutoDelete = core.BoolPtr(false) + shareMountTargetVirtualNetworkInterfacePrototypeModel.EnableInfrastructureNat = core.BoolPtr(true) + shareMountTargetVirtualNetworkInterfacePrototypeModel.Ips = []vpcv1.VirtualNetworkInterfaceIPPrototypeIntf{virtualNetworkInterfaceIPPrototypeModel} + shareMountTargetVirtualNetworkInterfacePrototypeModel.Name = core.StringPtr("my-virtual-network-interface") + shareMountTargetVirtualNetworkInterfacePrototypeModel.PrimaryIP = virtualNetworkInterfacePrimaryIPPrototypeModel + shareMountTargetVirtualNetworkInterfacePrototypeModel.ResourceGroup = resourceGroupIdentityModel + shareMountTargetVirtualNetworkInterfacePrototypeModel.SecurityGroups = []vpcv1.SecurityGroupIdentityIntf{securityGroupIdentityModel} + shareMountTargetVirtualNetworkInterfacePrototypeModel.Subnet = subnetIdentityModel + + // Construct an instance of the ShareMountTargetPrototypeShareMountTargetByAccessControlModeSecurityGroup model + shareMountTargetPrototypeModel := new(vpcv1.ShareMountTargetPrototypeShareMountTargetByAccessControlModeSecurityGroup) + shareMountTargetPrototypeModel.Name = core.StringPtr("my-share-mount-target") + shareMountTargetPrototypeModel.TransitEncryption = core.StringPtr("none") + shareMountTargetPrototypeModel.VirtualNetworkInterface = shareMountTargetVirtualNetworkInterfacePrototypeModel + + // Construct an instance of the CreateShareMountTargetOptions model + createShareMountTargetOptionsModel := new(vpcv1.CreateShareMountTargetOptions) + createShareMountTargetOptionsModel.ShareID = core.StringPtr("testString") + createShareMountTargetOptionsModel.ShareMountTargetPrototype = shareMountTargetPrototypeModel + createShareMountTargetOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with a Context to test a timeout error ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond) defer cancelFunc() - _, _, operationErr := vpcService.GetSnapshotWithContext(ctx, getSnapshotOptionsModel) + _, _, operationErr := vpcService.CreateShareMountTargetWithContext(ctx, createShareMountTargetOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) // Disable retries and test again vpcService.DisableRetries() - result, response, operationErr := vpcService.GetSnapshot(getSnapshotOptionsModel) + result, response, operationErr := vpcService.CreateShareMountTarget(createShareMountTargetOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) @@ -58211,7 +58565,7 @@ var _ = Describe(`VpcV1`, func() { // Re-test the timeout error with retries disabled ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond) defer cancelFunc2() - _, _, operationErr = vpcService.GetSnapshotWithContext(ctx, getSnapshotOptionsModel) + _, _, operationErr = vpcService.CreateShareMountTargetWithContext(ctx, createShareMountTargetOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) }) @@ -58225,18 +58579,34 @@ var _ = Describe(`VpcV1`, func() { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(getSnapshotPath)) - Expect(req.Method).To(Equal("GET")) + Expect(req.URL.EscapedPath()).To(Equal(createShareMountTargetPath)) + 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(200) - fmt.Fprintf(res, "%s", `{"backup_policy_plan": {"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6/plans/r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "id": "r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "name": "my-policy-plan", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "backup_policy_plan"}, "bootable": true, "captured_at": "2019-01-01T12:00:00.000Z", "clones": [{"available": false, "created_at": "2019-01-01T12:00:00.000Z", "zone": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south/zones/us-south-1", "name": "us-south-1"}}], "copies": [{"crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "id": "r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "name": "my-snapshot", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "snapshot"}], "created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "deletable": false, "encryption": "provider_managed", "encryption_key": {"crn": "crn:v1:bluemix:public:kms:us-south:a/123456:e4a29d1a-2ef0-42a6-8fd2-350deb1c647e:key:5437653b-c4b1-447f-9646-b2a2a4cd6179"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "id": "r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "lifecycle_state": "stable", "minimum_capacity": 1, "name": "my-snapshot", "operating_system": {"architecture": "amd64", "dedicated_host_only": false, "display_name": "Ubuntu Server 16.04 LTS amd64", "family": "Ubuntu Server", "href": "https://us-south.iaas.cloud.ibm.com/v1/operating_systems/ubuntu-16-amd64", "name": "ubuntu-16-amd64", "vendor": "Canonical", "version": "16.04 LTS"}, "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "resource_type": "snapshot", "service_tags": ["ServiceTags"], "size": 1, "snapshot_consistency_group": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot-consistency-group:r134-fa329f6b-0e36-433f-a3bb-0df632e79263", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshot_consistency_groups/r134-fa329f6b-0e36-433f-a3bb-0df632e79263", "id": "r134-fa329f6b-0e36-433f-a3bb-0df632e79263", "name": "my-snapshot-consistency-group", "resource_type": "snapshot_consistency_group"}, "source_image": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::image:72b27b5c-f4b0-48bb-b954-5becc7c1dcb8", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/images/72b27b5c-f4b0-48bb-b954-5becc7c1dcb8", "id": "72b27b5c-f4b0-48bb-b954-5becc7c1dcb8", "name": "my-image", "remote": {"account": {"id": "aa2432b1fa4d4ace891e9b80fc104e34", "resource_type": "account"}, "region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "image"}, "source_snapshot": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "id": "r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "name": "my-snapshot", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "snapshot"}, "source_volume": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::volume:1a6b7274-678d-4dfb-8981-c71dd9d4daa5", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/volumes/1a6b7274-678d-4dfb-8981-c71dd9d4daa5", "id": "1a6b7274-678d-4dfb-8981-c71dd9d4daa5", "name": "my-volume", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "volume"}, "user_tags": ["UserTags"]}`) + res.WriteHeader(201) + fmt.Fprintf(res, "%s", `{"access_control_mode": "security_group", "created_at": "2019-01-01T12:00:00.000Z", "href": "https://us-south.iaas.cloud.ibm.com/v1/shares/0fe9e5d8-0a4d-4818-96ec-e99708644a58/mount_targets/4cf9171a-0043-4434-8727-15b53dbc374c", "id": "4cf9171a-0043-4434-8727-15b53dbc374c", "lifecycle_state": "stable", "mount_path": "10.240.1.23:/nxg_s_voll_mz7121_58e7e963_8f4b_4a0c_b71a_8ba8d9cd1e2e", "name": "my-share-mount-target", "primary_ip": {"address": "192.168.3.4", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e/reserved_ips/6d353a0f-aeb1-4ae1-832e-1110d10981bb", "id": "6d353a0f-aeb1-4ae1-832e-1110d10981bb", "name": "my-reserved-ip", "resource_type": "subnet_reserved_ip"}, "resource_type": "share_mount_target", "subnet": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "id": "7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "name": "my-subnet", "resource_type": "subnet"}, "transit_encryption": "none", "virtual_network_interface": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::virtual-network-interface:0767-fa41aecb-4f21-423d-8082-630bfba1e1d9", "href": "https://us-south.iaas.cloud.ibm.com/v1/virtual_network_interfaces/0767-fa41aecb-4f21-423d-8082-630bfba1e1d9", "id": "0767-fa41aecb-4f21-423d-8082-630bfba1e1d9", "name": "my-virtual-network-interface", "resource_type": "virtual_network_interface"}, "vpc": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::vpc:4727d842-f94f-4a2d-824a-9bc9b02c523b", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/vpcs/4727d842-f94f-4a2d-824a-9bc9b02c523b", "id": "4727d842-f94f-4a2d-824a-9bc9b02c523b", "name": "my-vpc", "resource_type": "vpc"}}`) })) }) - It(`Invoke GetSnapshot successfully`, func() { + It(`Invoke CreateShareMountTarget successfully`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -58246,24 +58616,67 @@ var _ = Describe(`VpcV1`, func() { Expect(vpcService).ToNot(BeNil()) // Invoke operation with nil options model (negative test) - result, response, operationErr := vpcService.GetSnapshot(nil) + result, response, operationErr := vpcService.CreateShareMountTarget(nil) Expect(operationErr).NotTo(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) - // Construct an instance of the GetSnapshotOptions model - getSnapshotOptionsModel := new(vpcv1.GetSnapshotOptions) - getSnapshotOptionsModel.ID = core.StringPtr("testString") - getSnapshotOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the VirtualNetworkInterfaceIPPrototypeReservedIPPrototypeVirtualNetworkInterfaceIPsContext model + virtualNetworkInterfaceIPPrototypeModel := new(vpcv1.VirtualNetworkInterfaceIPPrototypeReservedIPPrototypeVirtualNetworkInterfaceIPsContext) + virtualNetworkInterfaceIPPrototypeModel.Address = core.StringPtr("10.0.0.5") + virtualNetworkInterfaceIPPrototypeModel.AutoDelete = core.BoolPtr(false) + virtualNetworkInterfaceIPPrototypeModel.Name = core.StringPtr("my-reserved-ip") + + // Construct an instance of the VirtualNetworkInterfacePrimaryIPPrototypeReservedIPPrototypeVirtualNetworkInterfacePrimaryIPContext model + virtualNetworkInterfacePrimaryIPPrototypeModel := new(vpcv1.VirtualNetworkInterfacePrimaryIPPrototypeReservedIPPrototypeVirtualNetworkInterfacePrimaryIPContext) + virtualNetworkInterfacePrimaryIPPrototypeModel.Address = core.StringPtr("10.0.0.5") + virtualNetworkInterfacePrimaryIPPrototypeModel.AutoDelete = core.BoolPtr(false) + virtualNetworkInterfacePrimaryIPPrototypeModel.Name = core.StringPtr("my-reserved-ip") + + // Construct an instance of the ResourceGroupIdentityByID model + resourceGroupIdentityModel := new(vpcv1.ResourceGroupIdentityByID) + resourceGroupIdentityModel.ID = core.StringPtr("fee82deba12e4c0fb69c3b09d1f12345") + + // Construct an instance of the SecurityGroupIdentityByID model + securityGroupIdentityModel := new(vpcv1.SecurityGroupIdentityByID) + securityGroupIdentityModel.ID = core.StringPtr("be5df5ca-12a0-494b-907e-aa6ec2bfa271") + + // Construct an instance of the SubnetIdentityByID model + subnetIdentityModel := new(vpcv1.SubnetIdentityByID) + subnetIdentityModel.ID = core.StringPtr("7ec86020-1c6e-4889-b3f0-a15f2e50f87e") + + // Construct an instance of the ShareMountTargetVirtualNetworkInterfacePrototypeVirtualNetworkInterfacePrototypeShareMountTargetContext model + shareMountTargetVirtualNetworkInterfacePrototypeModel := new(vpcv1.ShareMountTargetVirtualNetworkInterfacePrototypeVirtualNetworkInterfacePrototypeShareMountTargetContext) + shareMountTargetVirtualNetworkInterfacePrototypeModel.AllowIPSpoofing = core.BoolPtr(true) + shareMountTargetVirtualNetworkInterfacePrototypeModel.AutoDelete = core.BoolPtr(false) + shareMountTargetVirtualNetworkInterfacePrototypeModel.EnableInfrastructureNat = core.BoolPtr(true) + shareMountTargetVirtualNetworkInterfacePrototypeModel.Ips = []vpcv1.VirtualNetworkInterfaceIPPrototypeIntf{virtualNetworkInterfaceIPPrototypeModel} + shareMountTargetVirtualNetworkInterfacePrototypeModel.Name = core.StringPtr("my-virtual-network-interface") + shareMountTargetVirtualNetworkInterfacePrototypeModel.PrimaryIP = virtualNetworkInterfacePrimaryIPPrototypeModel + shareMountTargetVirtualNetworkInterfacePrototypeModel.ResourceGroup = resourceGroupIdentityModel + shareMountTargetVirtualNetworkInterfacePrototypeModel.SecurityGroups = []vpcv1.SecurityGroupIdentityIntf{securityGroupIdentityModel} + shareMountTargetVirtualNetworkInterfacePrototypeModel.Subnet = subnetIdentityModel + + // Construct an instance of the ShareMountTargetPrototypeShareMountTargetByAccessControlModeSecurityGroup model + shareMountTargetPrototypeModel := new(vpcv1.ShareMountTargetPrototypeShareMountTargetByAccessControlModeSecurityGroup) + shareMountTargetPrototypeModel.Name = core.StringPtr("my-share-mount-target") + shareMountTargetPrototypeModel.TransitEncryption = core.StringPtr("none") + shareMountTargetPrototypeModel.VirtualNetworkInterface = shareMountTargetVirtualNetworkInterfacePrototypeModel + + // Construct an instance of the CreateShareMountTargetOptions model + createShareMountTargetOptionsModel := new(vpcv1.CreateShareMountTargetOptions) + createShareMountTargetOptionsModel.ShareID = core.StringPtr("testString") + createShareMountTargetOptionsModel.ShareMountTargetPrototype = shareMountTargetPrototypeModel + createShareMountTargetOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with valid options model (positive test) - result, response, operationErr = vpcService.GetSnapshot(getSnapshotOptionsModel) + result, response, operationErr = vpcService.CreateShareMountTarget(createShareMountTargetOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) }) - It(`Invoke GetSnapshot with error: Operation validation and request error`, func() { + It(`Invoke CreateShareMountTarget with error: Operation validation and request error`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -58272,22 +58685,65 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the GetSnapshotOptions model - getSnapshotOptionsModel := new(vpcv1.GetSnapshotOptions) - getSnapshotOptionsModel.ID = core.StringPtr("testString") - getSnapshotOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the VirtualNetworkInterfaceIPPrototypeReservedIPPrototypeVirtualNetworkInterfaceIPsContext model + virtualNetworkInterfaceIPPrototypeModel := new(vpcv1.VirtualNetworkInterfaceIPPrototypeReservedIPPrototypeVirtualNetworkInterfaceIPsContext) + virtualNetworkInterfaceIPPrototypeModel.Address = core.StringPtr("10.0.0.5") + virtualNetworkInterfaceIPPrototypeModel.AutoDelete = core.BoolPtr(false) + virtualNetworkInterfaceIPPrototypeModel.Name = core.StringPtr("my-reserved-ip") + + // Construct an instance of the VirtualNetworkInterfacePrimaryIPPrototypeReservedIPPrototypeVirtualNetworkInterfacePrimaryIPContext model + virtualNetworkInterfacePrimaryIPPrototypeModel := new(vpcv1.VirtualNetworkInterfacePrimaryIPPrototypeReservedIPPrototypeVirtualNetworkInterfacePrimaryIPContext) + virtualNetworkInterfacePrimaryIPPrototypeModel.Address = core.StringPtr("10.0.0.5") + virtualNetworkInterfacePrimaryIPPrototypeModel.AutoDelete = core.BoolPtr(false) + virtualNetworkInterfacePrimaryIPPrototypeModel.Name = core.StringPtr("my-reserved-ip") + + // Construct an instance of the ResourceGroupIdentityByID model + resourceGroupIdentityModel := new(vpcv1.ResourceGroupIdentityByID) + resourceGroupIdentityModel.ID = core.StringPtr("fee82deba12e4c0fb69c3b09d1f12345") + + // Construct an instance of the SecurityGroupIdentityByID model + securityGroupIdentityModel := new(vpcv1.SecurityGroupIdentityByID) + securityGroupIdentityModel.ID = core.StringPtr("be5df5ca-12a0-494b-907e-aa6ec2bfa271") + + // Construct an instance of the SubnetIdentityByID model + subnetIdentityModel := new(vpcv1.SubnetIdentityByID) + subnetIdentityModel.ID = core.StringPtr("7ec86020-1c6e-4889-b3f0-a15f2e50f87e") + + // Construct an instance of the ShareMountTargetVirtualNetworkInterfacePrototypeVirtualNetworkInterfacePrototypeShareMountTargetContext model + shareMountTargetVirtualNetworkInterfacePrototypeModel := new(vpcv1.ShareMountTargetVirtualNetworkInterfacePrototypeVirtualNetworkInterfacePrototypeShareMountTargetContext) + shareMountTargetVirtualNetworkInterfacePrototypeModel.AllowIPSpoofing = core.BoolPtr(true) + shareMountTargetVirtualNetworkInterfacePrototypeModel.AutoDelete = core.BoolPtr(false) + shareMountTargetVirtualNetworkInterfacePrototypeModel.EnableInfrastructureNat = core.BoolPtr(true) + shareMountTargetVirtualNetworkInterfacePrototypeModel.Ips = []vpcv1.VirtualNetworkInterfaceIPPrototypeIntf{virtualNetworkInterfaceIPPrototypeModel} + shareMountTargetVirtualNetworkInterfacePrototypeModel.Name = core.StringPtr("my-virtual-network-interface") + shareMountTargetVirtualNetworkInterfacePrototypeModel.PrimaryIP = virtualNetworkInterfacePrimaryIPPrototypeModel + shareMountTargetVirtualNetworkInterfacePrototypeModel.ResourceGroup = resourceGroupIdentityModel + shareMountTargetVirtualNetworkInterfacePrototypeModel.SecurityGroups = []vpcv1.SecurityGroupIdentityIntf{securityGroupIdentityModel} + shareMountTargetVirtualNetworkInterfacePrototypeModel.Subnet = subnetIdentityModel + + // Construct an instance of the ShareMountTargetPrototypeShareMountTargetByAccessControlModeSecurityGroup model + shareMountTargetPrototypeModel := new(vpcv1.ShareMountTargetPrototypeShareMountTargetByAccessControlModeSecurityGroup) + shareMountTargetPrototypeModel.Name = core.StringPtr("my-share-mount-target") + shareMountTargetPrototypeModel.TransitEncryption = core.StringPtr("none") + shareMountTargetPrototypeModel.VirtualNetworkInterface = shareMountTargetVirtualNetworkInterfacePrototypeModel + + // Construct an instance of the CreateShareMountTargetOptions model + createShareMountTargetOptionsModel := new(vpcv1.CreateShareMountTargetOptions) + createShareMountTargetOptionsModel.ShareID = core.StringPtr("testString") + createShareMountTargetOptionsModel.ShareMountTargetPrototype = shareMountTargetPrototypeModel + createShareMountTargetOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with empty URL (negative test) err := vpcService.SetServiceURL("") Expect(err).To(BeNil()) - result, response, operationErr := vpcService.GetSnapshot(getSnapshotOptionsModel) + result, response, operationErr := vpcService.CreateShareMountTarget(createShareMountTargetOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING)) Expect(response).To(BeNil()) Expect(result).To(BeNil()) - // Construct a second instance of the GetSnapshotOptions model with no property values - getSnapshotOptionsModelNew := new(vpcv1.GetSnapshotOptions) + // Construct a second instance of the CreateShareMountTargetOptions model with no property values + createShareMountTargetOptionsModelNew := new(vpcv1.CreateShareMountTargetOptions) // Invoke operation with invalid model (negative test) - result, response, operationErr = vpcService.GetSnapshot(getSnapshotOptionsModelNew) + result, response, operationErr = vpcService.CreateShareMountTarget(createShareMountTargetOptionsModelNew) Expect(operationErr).ToNot(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) @@ -58302,10 +58758,10 @@ var _ = Describe(`VpcV1`, func() { defer GinkgoRecover() // Set success status code with no respoonse body - res.WriteHeader(200) + res.WriteHeader(201) })) }) - It(`Invoke GetSnapshot successfully`, func() { + It(`Invoke CreateShareMountTarget successfully`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -58314,13 +58770,56 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the GetSnapshotOptions model - getSnapshotOptionsModel := new(vpcv1.GetSnapshotOptions) - getSnapshotOptionsModel.ID = core.StringPtr("testString") - getSnapshotOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the VirtualNetworkInterfaceIPPrototypeReservedIPPrototypeVirtualNetworkInterfaceIPsContext model + virtualNetworkInterfaceIPPrototypeModel := new(vpcv1.VirtualNetworkInterfaceIPPrototypeReservedIPPrototypeVirtualNetworkInterfaceIPsContext) + virtualNetworkInterfaceIPPrototypeModel.Address = core.StringPtr("10.0.0.5") + virtualNetworkInterfaceIPPrototypeModel.AutoDelete = core.BoolPtr(false) + virtualNetworkInterfaceIPPrototypeModel.Name = core.StringPtr("my-reserved-ip") + + // Construct an instance of the VirtualNetworkInterfacePrimaryIPPrototypeReservedIPPrototypeVirtualNetworkInterfacePrimaryIPContext model + virtualNetworkInterfacePrimaryIPPrototypeModel := new(vpcv1.VirtualNetworkInterfacePrimaryIPPrototypeReservedIPPrototypeVirtualNetworkInterfacePrimaryIPContext) + virtualNetworkInterfacePrimaryIPPrototypeModel.Address = core.StringPtr("10.0.0.5") + virtualNetworkInterfacePrimaryIPPrototypeModel.AutoDelete = core.BoolPtr(false) + virtualNetworkInterfacePrimaryIPPrototypeModel.Name = core.StringPtr("my-reserved-ip") + + // Construct an instance of the ResourceGroupIdentityByID model + resourceGroupIdentityModel := new(vpcv1.ResourceGroupIdentityByID) + resourceGroupIdentityModel.ID = core.StringPtr("fee82deba12e4c0fb69c3b09d1f12345") + + // Construct an instance of the SecurityGroupIdentityByID model + securityGroupIdentityModel := new(vpcv1.SecurityGroupIdentityByID) + securityGroupIdentityModel.ID = core.StringPtr("be5df5ca-12a0-494b-907e-aa6ec2bfa271") + + // Construct an instance of the SubnetIdentityByID model + subnetIdentityModel := new(vpcv1.SubnetIdentityByID) + subnetIdentityModel.ID = core.StringPtr("7ec86020-1c6e-4889-b3f0-a15f2e50f87e") + + // Construct an instance of the ShareMountTargetVirtualNetworkInterfacePrototypeVirtualNetworkInterfacePrototypeShareMountTargetContext model + shareMountTargetVirtualNetworkInterfacePrototypeModel := new(vpcv1.ShareMountTargetVirtualNetworkInterfacePrototypeVirtualNetworkInterfacePrototypeShareMountTargetContext) + shareMountTargetVirtualNetworkInterfacePrototypeModel.AllowIPSpoofing = core.BoolPtr(true) + shareMountTargetVirtualNetworkInterfacePrototypeModel.AutoDelete = core.BoolPtr(false) + shareMountTargetVirtualNetworkInterfacePrototypeModel.EnableInfrastructureNat = core.BoolPtr(true) + shareMountTargetVirtualNetworkInterfacePrototypeModel.Ips = []vpcv1.VirtualNetworkInterfaceIPPrototypeIntf{virtualNetworkInterfaceIPPrototypeModel} + shareMountTargetVirtualNetworkInterfacePrototypeModel.Name = core.StringPtr("my-virtual-network-interface") + shareMountTargetVirtualNetworkInterfacePrototypeModel.PrimaryIP = virtualNetworkInterfacePrimaryIPPrototypeModel + shareMountTargetVirtualNetworkInterfacePrototypeModel.ResourceGroup = resourceGroupIdentityModel + shareMountTargetVirtualNetworkInterfacePrototypeModel.SecurityGroups = []vpcv1.SecurityGroupIdentityIntf{securityGroupIdentityModel} + shareMountTargetVirtualNetworkInterfacePrototypeModel.Subnet = subnetIdentityModel + + // Construct an instance of the ShareMountTargetPrototypeShareMountTargetByAccessControlModeSecurityGroup model + shareMountTargetPrototypeModel := new(vpcv1.ShareMountTargetPrototypeShareMountTargetByAccessControlModeSecurityGroup) + shareMountTargetPrototypeModel.Name = core.StringPtr("my-share-mount-target") + shareMountTargetPrototypeModel.TransitEncryption = core.StringPtr("none") + shareMountTargetPrototypeModel.VirtualNetworkInterface = shareMountTargetVirtualNetworkInterfacePrototypeModel + + // Construct an instance of the CreateShareMountTargetOptions model + createShareMountTargetOptionsModel := new(vpcv1.CreateShareMountTargetOptions) + createShareMountTargetOptionsModel.ShareID = core.StringPtr("testString") + createShareMountTargetOptionsModel.ShareMountTargetPrototype = shareMountTargetPrototypeModel + createShareMountTargetOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation - result, response, operationErr := vpcService.GetSnapshot(getSnapshotOptionsModel) + result, response, operationErr := vpcService.CreateShareMountTarget(createShareMountTargetOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) @@ -58332,27 +58831,25 @@ var _ = Describe(`VpcV1`, func() { }) }) }) - Describe(`UpdateSnapshot(updateSnapshotOptions *UpdateSnapshotOptions) - Operation response error`, func() { + Describe(`DeleteShareMountTarget(deleteShareMountTargetOptions *DeleteShareMountTargetOptions) - Operation response error`, func() { version := "testString" - updateSnapshotPath := "/snapshots/testString" + deleteShareMountTargetPath := "/shares/testString/mount_targets/testString" Context(`Using mock server endpoint with invalid JSON response`, func() { BeforeEach(func() { testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(updateSnapshotPath)) - Expect(req.Method).To(Equal("PATCH")) - Expect(req.Header["If-Match"]).ToNot(BeNil()) - Expect(req.Header["If-Match"][0]).To(Equal(fmt.Sprintf("%v", `W/"96d225c4-56bd-43d9-98fc-d7148e5c5028"`))) + Expect(req.URL.EscapedPath()).To(Equal(deleteShareMountTargetPath)) + Expect(req.Method).To(Equal("DELETE")) Expect(req.URL.Query()["version"]).To(Equal([]string{"testString"})) Expect(req.URL.Query()["generation"]).To(Equal([]string{fmt.Sprint(int64(2))})) res.Header().Set("Content-type", "application/json") - res.WriteHeader(200) + res.WriteHeader(202) fmt.Fprint(res, `} this is not valid json {`) })) }) - It(`Invoke UpdateSnapshot with error: Operation response processing error`, func() { + It(`Invoke DeleteShareMountTarget with error: Operation response processing error`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -58361,28 +58858,20 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the SnapshotPatch model - snapshotPatchModel := new(vpcv1.SnapshotPatch) - snapshotPatchModel.Name = core.StringPtr("my-snapshot") - snapshotPatchModel.UserTags = []string{"testString"} - snapshotPatchModelAsPatch, asPatchErr := snapshotPatchModel.AsPatch() - Expect(asPatchErr).To(BeNil()) - - // Construct an instance of the UpdateSnapshotOptions model - updateSnapshotOptionsModel := new(vpcv1.UpdateSnapshotOptions) - updateSnapshotOptionsModel.ID = core.StringPtr("testString") - updateSnapshotOptionsModel.SnapshotPatch = snapshotPatchModelAsPatch - updateSnapshotOptionsModel.IfMatch = core.StringPtr(`W/"96d225c4-56bd-43d9-98fc-d7148e5c5028"`) - updateSnapshotOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the DeleteShareMountTargetOptions model + deleteShareMountTargetOptionsModel := new(vpcv1.DeleteShareMountTargetOptions) + deleteShareMountTargetOptionsModel.ShareID = core.StringPtr("testString") + deleteShareMountTargetOptionsModel.ID = core.StringPtr("testString") + deleteShareMountTargetOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Expect response parsing to fail since we are receiving a text/plain response - result, response, operationErr := vpcService.UpdateSnapshot(updateSnapshotOptionsModel) + result, response, operationErr := vpcService.DeleteShareMountTarget(deleteShareMountTargetOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).To(BeNil()) // Enable retries and test again vpcService.EnableRetries(0, 0) - result, response, operationErr = vpcService.UpdateSnapshot(updateSnapshotOptionsModel) + result, response, operationErr = vpcService.DeleteShareMountTarget(deleteShareMountTargetOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).To(BeNil()) @@ -58392,36 +58881,18 @@ var _ = Describe(`VpcV1`, func() { }) }) }) - Describe(`UpdateSnapshot(updateSnapshotOptions *UpdateSnapshotOptions)`, func() { + Describe(`DeleteShareMountTarget(deleteShareMountTargetOptions *DeleteShareMountTargetOptions)`, func() { version := "testString" - updateSnapshotPath := "/snapshots/testString" + deleteShareMountTargetPath := "/shares/testString/mount_targets/testString" Context(`Using mock server endpoint with timeout`, func() { BeforeEach(func() { testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(updateSnapshotPath)) - Expect(req.Method).To(Equal("PATCH")) - - // For gzip-disabled operation, verify Content-Encoding is not set. - Expect(req.Header.Get("Content-Encoding")).To(BeEmpty()) - - // If there is a body, then make sure we can read it - bodyBuf := new(bytes.Buffer) - if req.Header.Get("Content-Encoding") == "gzip" { - body, err := core.NewGzipDecompressionReader(req.Body) - Expect(err).To(BeNil()) - _, err = bodyBuf.ReadFrom(body) - Expect(err).To(BeNil()) - } else { - _, err := bodyBuf.ReadFrom(req.Body) - Expect(err).To(BeNil()) - } - fmt.Fprintf(GinkgoWriter, " Request body: %s", bodyBuf.String()) + Expect(req.URL.EscapedPath()).To(Equal(deleteShareMountTargetPath)) + 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 @@ -58429,11 +58900,11 @@ var _ = Describe(`VpcV1`, func() { // Set mock response res.Header().Set("Content-type", "application/json") - res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"backup_policy_plan": {"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6/plans/r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "id": "r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "name": "my-policy-plan", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "backup_policy_plan"}, "bootable": true, "captured_at": "2019-01-01T12:00:00.000Z", "clones": [{"available": false, "created_at": "2019-01-01T12:00:00.000Z", "zone": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south/zones/us-south-1", "name": "us-south-1"}}], "copies": [{"crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "id": "r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "name": "my-snapshot", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "snapshot"}], "created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "deletable": false, "encryption": "provider_managed", "encryption_key": {"crn": "crn:v1:bluemix:public:kms:us-south:a/123456:e4a29d1a-2ef0-42a6-8fd2-350deb1c647e:key:5437653b-c4b1-447f-9646-b2a2a4cd6179"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "id": "r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "lifecycle_state": "stable", "minimum_capacity": 1, "name": "my-snapshot", "operating_system": {"architecture": "amd64", "dedicated_host_only": false, "display_name": "Ubuntu Server 16.04 LTS amd64", "family": "Ubuntu Server", "href": "https://us-south.iaas.cloud.ibm.com/v1/operating_systems/ubuntu-16-amd64", "name": "ubuntu-16-amd64", "vendor": "Canonical", "version": "16.04 LTS"}, "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "resource_type": "snapshot", "service_tags": ["ServiceTags"], "size": 1, "snapshot_consistency_group": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot-consistency-group:r134-fa329f6b-0e36-433f-a3bb-0df632e79263", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshot_consistency_groups/r134-fa329f6b-0e36-433f-a3bb-0df632e79263", "id": "r134-fa329f6b-0e36-433f-a3bb-0df632e79263", "name": "my-snapshot-consistency-group", "resource_type": "snapshot_consistency_group"}, "source_image": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::image:72b27b5c-f4b0-48bb-b954-5becc7c1dcb8", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/images/72b27b5c-f4b0-48bb-b954-5becc7c1dcb8", "id": "72b27b5c-f4b0-48bb-b954-5becc7c1dcb8", "name": "my-image", "remote": {"account": {"id": "aa2432b1fa4d4ace891e9b80fc104e34", "resource_type": "account"}, "region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "image"}, "source_snapshot": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "id": "r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "name": "my-snapshot", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "snapshot"}, "source_volume": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::volume:1a6b7274-678d-4dfb-8981-c71dd9d4daa5", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/volumes/1a6b7274-678d-4dfb-8981-c71dd9d4daa5", "id": "1a6b7274-678d-4dfb-8981-c71dd9d4daa5", "name": "my-volume", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "volume"}, "user_tags": ["UserTags"]}`) + res.WriteHeader(202) + fmt.Fprintf(res, "%s", `{"access_control_mode": "security_group", "created_at": "2019-01-01T12:00:00.000Z", "href": "https://us-south.iaas.cloud.ibm.com/v1/shares/0fe9e5d8-0a4d-4818-96ec-e99708644a58/mount_targets/4cf9171a-0043-4434-8727-15b53dbc374c", "id": "4cf9171a-0043-4434-8727-15b53dbc374c", "lifecycle_state": "stable", "mount_path": "10.240.1.23:/nxg_s_voll_mz7121_58e7e963_8f4b_4a0c_b71a_8ba8d9cd1e2e", "name": "my-share-mount-target", "primary_ip": {"address": "192.168.3.4", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e/reserved_ips/6d353a0f-aeb1-4ae1-832e-1110d10981bb", "id": "6d353a0f-aeb1-4ae1-832e-1110d10981bb", "name": "my-reserved-ip", "resource_type": "subnet_reserved_ip"}, "resource_type": "share_mount_target", "subnet": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "id": "7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "name": "my-subnet", "resource_type": "subnet"}, "transit_encryption": "none", "virtual_network_interface": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::virtual-network-interface:0767-fa41aecb-4f21-423d-8082-630bfba1e1d9", "href": "https://us-south.iaas.cloud.ibm.com/v1/virtual_network_interfaces/0767-fa41aecb-4f21-423d-8082-630bfba1e1d9", "id": "0767-fa41aecb-4f21-423d-8082-630bfba1e1d9", "name": "my-virtual-network-interface", "resource_type": "virtual_network_interface"}, "vpc": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::vpc:4727d842-f94f-4a2d-824a-9bc9b02c523b", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/vpcs/4727d842-f94f-4a2d-824a-9bc9b02c523b", "id": "4727d842-f94f-4a2d-824a-9bc9b02c523b", "name": "my-vpc", "resource_type": "vpc"}}`) })) }) - It(`Invoke UpdateSnapshot successfully with retries`, func() { + It(`Invoke DeleteShareMountTarget successfully with retries`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -58443,30 +58914,22 @@ var _ = Describe(`VpcV1`, func() { Expect(vpcService).ToNot(BeNil()) vpcService.EnableRetries(0, 0) - // Construct an instance of the SnapshotPatch model - snapshotPatchModel := new(vpcv1.SnapshotPatch) - snapshotPatchModel.Name = core.StringPtr("my-snapshot") - snapshotPatchModel.UserTags = []string{"testString"} - snapshotPatchModelAsPatch, asPatchErr := snapshotPatchModel.AsPatch() - Expect(asPatchErr).To(BeNil()) - - // Construct an instance of the UpdateSnapshotOptions model - updateSnapshotOptionsModel := new(vpcv1.UpdateSnapshotOptions) - updateSnapshotOptionsModel.ID = core.StringPtr("testString") - updateSnapshotOptionsModel.SnapshotPatch = snapshotPatchModelAsPatch - updateSnapshotOptionsModel.IfMatch = core.StringPtr(`W/"96d225c4-56bd-43d9-98fc-d7148e5c5028"`) - updateSnapshotOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the DeleteShareMountTargetOptions model + deleteShareMountTargetOptionsModel := new(vpcv1.DeleteShareMountTargetOptions) + deleteShareMountTargetOptionsModel.ShareID = core.StringPtr("testString") + deleteShareMountTargetOptionsModel.ID = core.StringPtr("testString") + deleteShareMountTargetOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with a Context to test a timeout error ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond) defer cancelFunc() - _, _, operationErr := vpcService.UpdateSnapshotWithContext(ctx, updateSnapshotOptionsModel) + _, _, operationErr := vpcService.DeleteShareMountTargetWithContext(ctx, deleteShareMountTargetOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) // Disable retries and test again vpcService.DisableRetries() - result, response, operationErr := vpcService.UpdateSnapshot(updateSnapshotOptionsModel) + result, response, operationErr := vpcService.DeleteShareMountTarget(deleteShareMountTargetOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) @@ -58474,7 +58937,7 @@ var _ = Describe(`VpcV1`, func() { // Re-test the timeout error with retries disabled ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond) defer cancelFunc2() - _, _, operationErr = vpcService.UpdateSnapshotWithContext(ctx, updateSnapshotOptionsModel) + _, _, operationErr = vpcService.DeleteShareMountTargetWithContext(ctx, deleteShareMountTargetOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) }) @@ -58488,36 +58951,18 @@ var _ = Describe(`VpcV1`, func() { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(updateSnapshotPath)) - Expect(req.Method).To(Equal("PATCH")) - - // For gzip-disabled operation, verify Content-Encoding is not set. - Expect(req.Header.Get("Content-Encoding")).To(BeEmpty()) - - // If there is a body, then make sure we can read it - bodyBuf := new(bytes.Buffer) - if req.Header.Get("Content-Encoding") == "gzip" { - body, err := core.NewGzipDecompressionReader(req.Body) - Expect(err).To(BeNil()) - _, err = bodyBuf.ReadFrom(body) - Expect(err).To(BeNil()) - } else { - _, err := bodyBuf.ReadFrom(req.Body) - Expect(err).To(BeNil()) - } - fmt.Fprintf(GinkgoWriter, " Request body: %s", bodyBuf.String()) + Expect(req.URL.EscapedPath()).To(Equal(deleteShareMountTargetPath)) + 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(200) - fmt.Fprintf(res, "%s", `{"backup_policy_plan": {"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6/plans/r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "id": "r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "name": "my-policy-plan", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "backup_policy_plan"}, "bootable": true, "captured_at": "2019-01-01T12:00:00.000Z", "clones": [{"available": false, "created_at": "2019-01-01T12:00:00.000Z", "zone": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south/zones/us-south-1", "name": "us-south-1"}}], "copies": [{"crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "id": "r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "name": "my-snapshot", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "snapshot"}], "created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "deletable": false, "encryption": "provider_managed", "encryption_key": {"crn": "crn:v1:bluemix:public:kms:us-south:a/123456:e4a29d1a-2ef0-42a6-8fd2-350deb1c647e:key:5437653b-c4b1-447f-9646-b2a2a4cd6179"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "id": "r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "lifecycle_state": "stable", "minimum_capacity": 1, "name": "my-snapshot", "operating_system": {"architecture": "amd64", "dedicated_host_only": false, "display_name": "Ubuntu Server 16.04 LTS amd64", "family": "Ubuntu Server", "href": "https://us-south.iaas.cloud.ibm.com/v1/operating_systems/ubuntu-16-amd64", "name": "ubuntu-16-amd64", "vendor": "Canonical", "version": "16.04 LTS"}, "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "resource_type": "snapshot", "service_tags": ["ServiceTags"], "size": 1, "snapshot_consistency_group": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot-consistency-group:r134-fa329f6b-0e36-433f-a3bb-0df632e79263", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshot_consistency_groups/r134-fa329f6b-0e36-433f-a3bb-0df632e79263", "id": "r134-fa329f6b-0e36-433f-a3bb-0df632e79263", "name": "my-snapshot-consistency-group", "resource_type": "snapshot_consistency_group"}, "source_image": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::image:72b27b5c-f4b0-48bb-b954-5becc7c1dcb8", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/images/72b27b5c-f4b0-48bb-b954-5becc7c1dcb8", "id": "72b27b5c-f4b0-48bb-b954-5becc7c1dcb8", "name": "my-image", "remote": {"account": {"id": "aa2432b1fa4d4ace891e9b80fc104e34", "resource_type": "account"}, "region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "image"}, "source_snapshot": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "id": "r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "name": "my-snapshot", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "snapshot"}, "source_volume": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::volume:1a6b7274-678d-4dfb-8981-c71dd9d4daa5", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/volumes/1a6b7274-678d-4dfb-8981-c71dd9d4daa5", "id": "1a6b7274-678d-4dfb-8981-c71dd9d4daa5", "name": "my-volume", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "volume"}, "user_tags": ["UserTags"]}`) + res.WriteHeader(202) + fmt.Fprintf(res, "%s", `{"access_control_mode": "security_group", "created_at": "2019-01-01T12:00:00.000Z", "href": "https://us-south.iaas.cloud.ibm.com/v1/shares/0fe9e5d8-0a4d-4818-96ec-e99708644a58/mount_targets/4cf9171a-0043-4434-8727-15b53dbc374c", "id": "4cf9171a-0043-4434-8727-15b53dbc374c", "lifecycle_state": "stable", "mount_path": "10.240.1.23:/nxg_s_voll_mz7121_58e7e963_8f4b_4a0c_b71a_8ba8d9cd1e2e", "name": "my-share-mount-target", "primary_ip": {"address": "192.168.3.4", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e/reserved_ips/6d353a0f-aeb1-4ae1-832e-1110d10981bb", "id": "6d353a0f-aeb1-4ae1-832e-1110d10981bb", "name": "my-reserved-ip", "resource_type": "subnet_reserved_ip"}, "resource_type": "share_mount_target", "subnet": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "id": "7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "name": "my-subnet", "resource_type": "subnet"}, "transit_encryption": "none", "virtual_network_interface": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::virtual-network-interface:0767-fa41aecb-4f21-423d-8082-630bfba1e1d9", "href": "https://us-south.iaas.cloud.ibm.com/v1/virtual_network_interfaces/0767-fa41aecb-4f21-423d-8082-630bfba1e1d9", "id": "0767-fa41aecb-4f21-423d-8082-630bfba1e1d9", "name": "my-virtual-network-interface", "resource_type": "virtual_network_interface"}, "vpc": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::vpc:4727d842-f94f-4a2d-824a-9bc9b02c523b", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/vpcs/4727d842-f94f-4a2d-824a-9bc9b02c523b", "id": "4727d842-f94f-4a2d-824a-9bc9b02c523b", "name": "my-vpc", "resource_type": "vpc"}}`) })) }) - It(`Invoke UpdateSnapshot successfully`, func() { + It(`Invoke DeleteShareMountTarget successfully`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -58527,33 +58972,25 @@ var _ = Describe(`VpcV1`, func() { Expect(vpcService).ToNot(BeNil()) // Invoke operation with nil options model (negative test) - result, response, operationErr := vpcService.UpdateSnapshot(nil) + result, response, operationErr := vpcService.DeleteShareMountTarget(nil) Expect(operationErr).NotTo(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) - // Construct an instance of the SnapshotPatch model - snapshotPatchModel := new(vpcv1.SnapshotPatch) - snapshotPatchModel.Name = core.StringPtr("my-snapshot") - snapshotPatchModel.UserTags = []string{"testString"} - snapshotPatchModelAsPatch, asPatchErr := snapshotPatchModel.AsPatch() - Expect(asPatchErr).To(BeNil()) - - // Construct an instance of the UpdateSnapshotOptions model - updateSnapshotOptionsModel := new(vpcv1.UpdateSnapshotOptions) - updateSnapshotOptionsModel.ID = core.StringPtr("testString") - updateSnapshotOptionsModel.SnapshotPatch = snapshotPatchModelAsPatch - updateSnapshotOptionsModel.IfMatch = core.StringPtr(`W/"96d225c4-56bd-43d9-98fc-d7148e5c5028"`) - updateSnapshotOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the DeleteShareMountTargetOptions model + deleteShareMountTargetOptionsModel := new(vpcv1.DeleteShareMountTargetOptions) + deleteShareMountTargetOptionsModel.ShareID = core.StringPtr("testString") + deleteShareMountTargetOptionsModel.ID = core.StringPtr("testString") + deleteShareMountTargetOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with valid options model (positive test) - result, response, operationErr = vpcService.UpdateSnapshot(updateSnapshotOptionsModel) + result, response, operationErr = vpcService.DeleteShareMountTarget(deleteShareMountTargetOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) }) - It(`Invoke UpdateSnapshot with error: Operation validation and request error`, func() { + It(`Invoke DeleteShareMountTarget with error: Operation validation and request error`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -58562,31 +58999,23 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the SnapshotPatch model - snapshotPatchModel := new(vpcv1.SnapshotPatch) - snapshotPatchModel.Name = core.StringPtr("my-snapshot") - snapshotPatchModel.UserTags = []string{"testString"} - snapshotPatchModelAsPatch, asPatchErr := snapshotPatchModel.AsPatch() - Expect(asPatchErr).To(BeNil()) - - // Construct an instance of the UpdateSnapshotOptions model - updateSnapshotOptionsModel := new(vpcv1.UpdateSnapshotOptions) - updateSnapshotOptionsModel.ID = core.StringPtr("testString") - updateSnapshotOptionsModel.SnapshotPatch = snapshotPatchModelAsPatch - updateSnapshotOptionsModel.IfMatch = core.StringPtr(`W/"96d225c4-56bd-43d9-98fc-d7148e5c5028"`) - updateSnapshotOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the DeleteShareMountTargetOptions model + deleteShareMountTargetOptionsModel := new(vpcv1.DeleteShareMountTargetOptions) + deleteShareMountTargetOptionsModel.ShareID = core.StringPtr("testString") + deleteShareMountTargetOptionsModel.ID = core.StringPtr("testString") + deleteShareMountTargetOptionsModel.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.UpdateSnapshot(updateSnapshotOptionsModel) + result, response, operationErr := vpcService.DeleteShareMountTarget(deleteShareMountTargetOptionsModel) 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 UpdateSnapshotOptions model with no property values - updateSnapshotOptionsModelNew := new(vpcv1.UpdateSnapshotOptions) + // Construct a second instance of the DeleteShareMountTargetOptions model with no property values + deleteShareMountTargetOptionsModelNew := new(vpcv1.DeleteShareMountTargetOptions) // Invoke operation with invalid model (negative test) - result, response, operationErr = vpcService.UpdateSnapshot(updateSnapshotOptionsModelNew) + result, response, operationErr = vpcService.DeleteShareMountTarget(deleteShareMountTargetOptionsModelNew) Expect(operationErr).ToNot(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) @@ -58601,10 +59030,10 @@ var _ = Describe(`VpcV1`, func() { defer GinkgoRecover() // Set success status code with no respoonse body - res.WriteHeader(200) + res.WriteHeader(202) })) }) - It(`Invoke UpdateSnapshot successfully`, func() { + It(`Invoke DeleteShareMountTarget successfully`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -58613,22 +59042,14 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the SnapshotPatch model - snapshotPatchModel := new(vpcv1.SnapshotPatch) - snapshotPatchModel.Name = core.StringPtr("my-snapshot") - snapshotPatchModel.UserTags = []string{"testString"} - snapshotPatchModelAsPatch, asPatchErr := snapshotPatchModel.AsPatch() - Expect(asPatchErr).To(BeNil()) - - // Construct an instance of the UpdateSnapshotOptions model - updateSnapshotOptionsModel := new(vpcv1.UpdateSnapshotOptions) - updateSnapshotOptionsModel.ID = core.StringPtr("testString") - updateSnapshotOptionsModel.SnapshotPatch = snapshotPatchModelAsPatch - updateSnapshotOptionsModel.IfMatch = core.StringPtr(`W/"96d225c4-56bd-43d9-98fc-d7148e5c5028"`) - updateSnapshotOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the DeleteShareMountTargetOptions model + deleteShareMountTargetOptionsModel := new(vpcv1.DeleteShareMountTargetOptions) + deleteShareMountTargetOptionsModel.ShareID = core.StringPtr("testString") + deleteShareMountTargetOptionsModel.ID = core.StringPtr("testString") + deleteShareMountTargetOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation - result, response, operationErr := vpcService.UpdateSnapshot(updateSnapshotOptionsModel) + result, response, operationErr := vpcService.DeleteShareMountTarget(deleteShareMountTargetOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) @@ -58640,16 +59061,16 @@ var _ = Describe(`VpcV1`, func() { }) }) }) - Describe(`ListSnapshotClones(listSnapshotClonesOptions *ListSnapshotClonesOptions) - Operation response error`, func() { + Describe(`GetShareMountTarget(getShareMountTargetOptions *GetShareMountTargetOptions) - Operation response error`, func() { version := "testString" - listSnapshotClonesPath := "/snapshots/testString/clones" + getShareMountTargetPath := "/shares/testString/mount_targets/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(listSnapshotClonesPath)) + Expect(req.URL.EscapedPath()).To(Equal(getShareMountTargetPath)) 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))})) @@ -58658,7 +59079,7 @@ var _ = Describe(`VpcV1`, func() { fmt.Fprint(res, `} this is not valid json {`) })) }) - It(`Invoke ListSnapshotClones with error: Operation response processing error`, func() { + It(`Invoke GetShareMountTarget with error: Operation response processing error`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -58667,19 +59088,20 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the ListSnapshotClonesOptions model - listSnapshotClonesOptionsModel := new(vpcv1.ListSnapshotClonesOptions) - listSnapshotClonesOptionsModel.ID = core.StringPtr("testString") - listSnapshotClonesOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the GetShareMountTargetOptions model + getShareMountTargetOptionsModel := new(vpcv1.GetShareMountTargetOptions) + getShareMountTargetOptionsModel.ShareID = core.StringPtr("testString") + getShareMountTargetOptionsModel.ID = core.StringPtr("testString") + getShareMountTargetOptionsModel.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.ListSnapshotClones(listSnapshotClonesOptionsModel) + result, response, operationErr := vpcService.GetShareMountTarget(getShareMountTargetOptionsModel) 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.ListSnapshotClones(listSnapshotClonesOptionsModel) + result, response, operationErr = vpcService.GetShareMountTarget(getShareMountTargetOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).To(BeNil()) @@ -58689,16 +59111,16 @@ var _ = Describe(`VpcV1`, func() { }) }) }) - Describe(`ListSnapshotClones(listSnapshotClonesOptions *ListSnapshotClonesOptions)`, func() { + Describe(`GetShareMountTarget(getShareMountTargetOptions *GetShareMountTargetOptions)`, func() { version := "testString" - listSnapshotClonesPath := "/snapshots/testString/clones" + getShareMountTargetPath := "/shares/testString/mount_targets/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(listSnapshotClonesPath)) + Expect(req.URL.EscapedPath()).To(Equal(getShareMountTargetPath)) Expect(req.Method).To(Equal("GET")) Expect(req.URL.Query()["version"]).To(Equal([]string{"testString"})) @@ -58709,10 +59131,10 @@ var _ = Describe(`VpcV1`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"clones": [{"available": false, "created_at": "2019-01-01T12:00:00.000Z", "zone": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south/zones/us-south-1", "name": "us-south-1"}}]}`) + fmt.Fprintf(res, "%s", `{"access_control_mode": "security_group", "created_at": "2019-01-01T12:00:00.000Z", "href": "https://us-south.iaas.cloud.ibm.com/v1/shares/0fe9e5d8-0a4d-4818-96ec-e99708644a58/mount_targets/4cf9171a-0043-4434-8727-15b53dbc374c", "id": "4cf9171a-0043-4434-8727-15b53dbc374c", "lifecycle_state": "stable", "mount_path": "10.240.1.23:/nxg_s_voll_mz7121_58e7e963_8f4b_4a0c_b71a_8ba8d9cd1e2e", "name": "my-share-mount-target", "primary_ip": {"address": "192.168.3.4", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e/reserved_ips/6d353a0f-aeb1-4ae1-832e-1110d10981bb", "id": "6d353a0f-aeb1-4ae1-832e-1110d10981bb", "name": "my-reserved-ip", "resource_type": "subnet_reserved_ip"}, "resource_type": "share_mount_target", "subnet": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "id": "7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "name": "my-subnet", "resource_type": "subnet"}, "transit_encryption": "none", "virtual_network_interface": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::virtual-network-interface:0767-fa41aecb-4f21-423d-8082-630bfba1e1d9", "href": "https://us-south.iaas.cloud.ibm.com/v1/virtual_network_interfaces/0767-fa41aecb-4f21-423d-8082-630bfba1e1d9", "id": "0767-fa41aecb-4f21-423d-8082-630bfba1e1d9", "name": "my-virtual-network-interface", "resource_type": "virtual_network_interface"}, "vpc": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::vpc:4727d842-f94f-4a2d-824a-9bc9b02c523b", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/vpcs/4727d842-f94f-4a2d-824a-9bc9b02c523b", "id": "4727d842-f94f-4a2d-824a-9bc9b02c523b", "name": "my-vpc", "resource_type": "vpc"}}`) })) }) - It(`Invoke ListSnapshotClones successfully with retries`, func() { + It(`Invoke GetShareMountTarget successfully with retries`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -58722,21 +59144,22 @@ var _ = Describe(`VpcV1`, func() { Expect(vpcService).ToNot(BeNil()) vpcService.EnableRetries(0, 0) - // Construct an instance of the ListSnapshotClonesOptions model - listSnapshotClonesOptionsModel := new(vpcv1.ListSnapshotClonesOptions) - listSnapshotClonesOptionsModel.ID = core.StringPtr("testString") - listSnapshotClonesOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the GetShareMountTargetOptions model + getShareMountTargetOptionsModel := new(vpcv1.GetShareMountTargetOptions) + getShareMountTargetOptionsModel.ShareID = core.StringPtr("testString") + getShareMountTargetOptionsModel.ID = core.StringPtr("testString") + getShareMountTargetOptionsModel.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.ListSnapshotClonesWithContext(ctx, listSnapshotClonesOptionsModel) + _, _, operationErr := vpcService.GetShareMountTargetWithContext(ctx, getShareMountTargetOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) // Disable retries and test again vpcService.DisableRetries() - result, response, operationErr := vpcService.ListSnapshotClones(listSnapshotClonesOptionsModel) + result, response, operationErr := vpcService.GetShareMountTarget(getShareMountTargetOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) @@ -58744,7 +59167,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.ListSnapshotClonesWithContext(ctx, listSnapshotClonesOptionsModel) + _, _, operationErr = vpcService.GetShareMountTargetWithContext(ctx, getShareMountTargetOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) }) @@ -58758,7 +59181,7 @@ var _ = Describe(`VpcV1`, func() { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(listSnapshotClonesPath)) + Expect(req.URL.EscapedPath()).To(Equal(getShareMountTargetPath)) Expect(req.Method).To(Equal("GET")) Expect(req.URL.Query()["version"]).To(Equal([]string{"testString"})) @@ -58766,10 +59189,10 @@ var _ = Describe(`VpcV1`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"clones": [{"available": false, "created_at": "2019-01-01T12:00:00.000Z", "zone": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south/zones/us-south-1", "name": "us-south-1"}}]}`) + fmt.Fprintf(res, "%s", `{"access_control_mode": "security_group", "created_at": "2019-01-01T12:00:00.000Z", "href": "https://us-south.iaas.cloud.ibm.com/v1/shares/0fe9e5d8-0a4d-4818-96ec-e99708644a58/mount_targets/4cf9171a-0043-4434-8727-15b53dbc374c", "id": "4cf9171a-0043-4434-8727-15b53dbc374c", "lifecycle_state": "stable", "mount_path": "10.240.1.23:/nxg_s_voll_mz7121_58e7e963_8f4b_4a0c_b71a_8ba8d9cd1e2e", "name": "my-share-mount-target", "primary_ip": {"address": "192.168.3.4", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e/reserved_ips/6d353a0f-aeb1-4ae1-832e-1110d10981bb", "id": "6d353a0f-aeb1-4ae1-832e-1110d10981bb", "name": "my-reserved-ip", "resource_type": "subnet_reserved_ip"}, "resource_type": "share_mount_target", "subnet": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "id": "7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "name": "my-subnet", "resource_type": "subnet"}, "transit_encryption": "none", "virtual_network_interface": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::virtual-network-interface:0767-fa41aecb-4f21-423d-8082-630bfba1e1d9", "href": "https://us-south.iaas.cloud.ibm.com/v1/virtual_network_interfaces/0767-fa41aecb-4f21-423d-8082-630bfba1e1d9", "id": "0767-fa41aecb-4f21-423d-8082-630bfba1e1d9", "name": "my-virtual-network-interface", "resource_type": "virtual_network_interface"}, "vpc": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::vpc:4727d842-f94f-4a2d-824a-9bc9b02c523b", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/vpcs/4727d842-f94f-4a2d-824a-9bc9b02c523b", "id": "4727d842-f94f-4a2d-824a-9bc9b02c523b", "name": "my-vpc", "resource_type": "vpc"}}`) })) }) - It(`Invoke ListSnapshotClones successfully`, func() { + It(`Invoke GetShareMountTarget successfully`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -58779,24 +59202,25 @@ var _ = Describe(`VpcV1`, func() { Expect(vpcService).ToNot(BeNil()) // Invoke operation with nil options model (negative test) - result, response, operationErr := vpcService.ListSnapshotClones(nil) + result, response, operationErr := vpcService.GetShareMountTarget(nil) Expect(operationErr).NotTo(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) - // Construct an instance of the ListSnapshotClonesOptions model - listSnapshotClonesOptionsModel := new(vpcv1.ListSnapshotClonesOptions) - listSnapshotClonesOptionsModel.ID = core.StringPtr("testString") - listSnapshotClonesOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the GetShareMountTargetOptions model + getShareMountTargetOptionsModel := new(vpcv1.GetShareMountTargetOptions) + getShareMountTargetOptionsModel.ShareID = core.StringPtr("testString") + getShareMountTargetOptionsModel.ID = core.StringPtr("testString") + getShareMountTargetOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with valid options model (positive test) - result, response, operationErr = vpcService.ListSnapshotClones(listSnapshotClonesOptionsModel) + result, response, operationErr = vpcService.GetShareMountTarget(getShareMountTargetOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) }) - It(`Invoke ListSnapshotClones with error: Operation validation and request error`, func() { + It(`Invoke GetShareMountTarget with error: Operation validation and request error`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -58805,22 +59229,23 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the ListSnapshotClonesOptions model - listSnapshotClonesOptionsModel := new(vpcv1.ListSnapshotClonesOptions) - listSnapshotClonesOptionsModel.ID = core.StringPtr("testString") - listSnapshotClonesOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the GetShareMountTargetOptions model + getShareMountTargetOptionsModel := new(vpcv1.GetShareMountTargetOptions) + getShareMountTargetOptionsModel.ShareID = core.StringPtr("testString") + getShareMountTargetOptionsModel.ID = core.StringPtr("testString") + getShareMountTargetOptionsModel.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.ListSnapshotClones(listSnapshotClonesOptionsModel) + result, response, operationErr := vpcService.GetShareMountTarget(getShareMountTargetOptionsModel) 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 ListSnapshotClonesOptions model with no property values - listSnapshotClonesOptionsModelNew := new(vpcv1.ListSnapshotClonesOptions) + // Construct a second instance of the GetShareMountTargetOptions model with no property values + getShareMountTargetOptionsModelNew := new(vpcv1.GetShareMountTargetOptions) // Invoke operation with invalid model (negative test) - result, response, operationErr = vpcService.ListSnapshotClones(listSnapshotClonesOptionsModelNew) + result, response, operationErr = vpcService.GetShareMountTarget(getShareMountTargetOptionsModelNew) Expect(operationErr).ToNot(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) @@ -58838,7 +59263,7 @@ var _ = Describe(`VpcV1`, func() { res.WriteHeader(200) })) }) - It(`Invoke ListSnapshotClones successfully`, func() { + It(`Invoke GetShareMountTarget successfully`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -58847,13 +59272,14 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the ListSnapshotClonesOptions model - listSnapshotClonesOptionsModel := new(vpcv1.ListSnapshotClonesOptions) - listSnapshotClonesOptionsModel.ID = core.StringPtr("testString") - listSnapshotClonesOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the GetShareMountTargetOptions model + getShareMountTargetOptionsModel := new(vpcv1.GetShareMountTargetOptions) + getShareMountTargetOptionsModel.ShareID = core.StringPtr("testString") + getShareMountTargetOptionsModel.ID = core.StringPtr("testString") + getShareMountTargetOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation - result, response, operationErr := vpcService.ListSnapshotClones(listSnapshotClonesOptionsModel) + result, response, operationErr := vpcService.GetShareMountTarget(getShareMountTargetOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) @@ -58865,92 +59291,17 @@ var _ = Describe(`VpcV1`, func() { }) }) }) - Describe(`DeleteSnapshotClone(deleteSnapshotCloneOptions *DeleteSnapshotCloneOptions)`, func() { - version := "testString" - deleteSnapshotClonePath := "/snapshots/testString/clones/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(deleteSnapshotClonePath)) - 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 DeleteSnapshotClone 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.DeleteSnapshotClone(nil) - Expect(operationErr).NotTo(BeNil()) - Expect(response).To(BeNil()) - - // Construct an instance of the DeleteSnapshotCloneOptions model - deleteSnapshotCloneOptionsModel := new(vpcv1.DeleteSnapshotCloneOptions) - deleteSnapshotCloneOptionsModel.ID = core.StringPtr("testString") - deleteSnapshotCloneOptionsModel.ZoneName = core.StringPtr("testString") - deleteSnapshotCloneOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} - - // Invoke operation with valid options model (positive test) - response, operationErr = vpcService.DeleteSnapshotClone(deleteSnapshotCloneOptionsModel) - Expect(operationErr).To(BeNil()) - Expect(response).ToNot(BeNil()) - }) - It(`Invoke DeleteSnapshotClone 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 DeleteSnapshotCloneOptions model - deleteSnapshotCloneOptionsModel := new(vpcv1.DeleteSnapshotCloneOptions) - deleteSnapshotCloneOptionsModel.ID = core.StringPtr("testString") - deleteSnapshotCloneOptionsModel.ZoneName = core.StringPtr("testString") - deleteSnapshotCloneOptionsModel.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.DeleteSnapshotClone(deleteSnapshotCloneOptionsModel) - Expect(operationErr).ToNot(BeNil()) - Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING)) - Expect(response).To(BeNil()) - // Construct a second instance of the DeleteSnapshotCloneOptions model with no property values - deleteSnapshotCloneOptionsModelNew := new(vpcv1.DeleteSnapshotCloneOptions) - // Invoke operation with invalid model (negative test) - response, operationErr = vpcService.DeleteSnapshotClone(deleteSnapshotCloneOptionsModelNew) - Expect(operationErr).ToNot(BeNil()) - Expect(response).To(BeNil()) - }) - AfterEach(func() { - testServer.Close() - }) - }) - }) - Describe(`GetSnapshotClone(getSnapshotCloneOptions *GetSnapshotCloneOptions) - Operation response error`, func() { + Describe(`UpdateShareMountTarget(updateShareMountTargetOptions *UpdateShareMountTargetOptions) - Operation response error`, func() { version := "testString" - getSnapshotClonePath := "/snapshots/testString/clones/testString" + updateShareMountTargetPath := "/shares/testString/mount_targets/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(getSnapshotClonePath)) - Expect(req.Method).To(Equal("GET")) + Expect(req.URL.EscapedPath()).To(Equal(updateShareMountTargetPath)) + 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") @@ -58958,7 +59309,7 @@ var _ = Describe(`VpcV1`, func() { fmt.Fprint(res, `} this is not valid json {`) })) }) - It(`Invoke GetSnapshotClone with error: Operation response processing error`, func() { + It(`Invoke UpdateShareMountTarget with error: Operation response processing error`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -58967,20 +59318,27 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the GetSnapshotCloneOptions model - getSnapshotCloneOptionsModel := new(vpcv1.GetSnapshotCloneOptions) - getSnapshotCloneOptionsModel.ID = core.StringPtr("testString") - getSnapshotCloneOptionsModel.ZoneName = core.StringPtr("testString") - getSnapshotCloneOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the ShareMountTargetPatch model + shareMountTargetPatchModel := new(vpcv1.ShareMountTargetPatch) + shareMountTargetPatchModel.Name = core.StringPtr("my-share-mount-target") + shareMountTargetPatchModelAsPatch, asPatchErr := shareMountTargetPatchModel.AsPatch() + Expect(asPatchErr).To(BeNil()) + + // Construct an instance of the UpdateShareMountTargetOptions model + updateShareMountTargetOptionsModel := new(vpcv1.UpdateShareMountTargetOptions) + updateShareMountTargetOptionsModel.ShareID = core.StringPtr("testString") + updateShareMountTargetOptionsModel.ID = core.StringPtr("testString") + updateShareMountTargetOptionsModel.ShareMountTargetPatch = shareMountTargetPatchModelAsPatch + updateShareMountTargetOptionsModel.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.GetSnapshotClone(getSnapshotCloneOptionsModel) + result, response, operationErr := vpcService.UpdateShareMountTarget(updateShareMountTargetOptionsModel) 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.GetSnapshotClone(getSnapshotCloneOptionsModel) + result, response, operationErr = vpcService.UpdateShareMountTarget(updateShareMountTargetOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).To(BeNil()) @@ -58990,17 +59348,33 @@ var _ = Describe(`VpcV1`, func() { }) }) }) - Describe(`GetSnapshotClone(getSnapshotCloneOptions *GetSnapshotCloneOptions)`, func() { + Describe(`UpdateShareMountTarget(updateShareMountTargetOptions *UpdateShareMountTargetOptions)`, func() { version := "testString" - getSnapshotClonePath := "/snapshots/testString/clones/testString" + updateShareMountTargetPath := "/shares/testString/mount_targets/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(getSnapshotClonePath)) - Expect(req.Method).To(Equal("GET")) + Expect(req.URL.EscapedPath()).To(Equal(updateShareMountTargetPath)) + 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.URL.Query()["version"]).To(Equal([]string{"testString"})) Expect(req.URL.Query()["generation"]).To(Equal([]string{fmt.Sprint(int64(2))})) @@ -59010,10 +59384,10 @@ var _ = Describe(`VpcV1`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"available": false, "created_at": "2019-01-01T12:00:00.000Z", "zone": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south/zones/us-south-1", "name": "us-south-1"}}`) + fmt.Fprintf(res, "%s", `{"access_control_mode": "security_group", "created_at": "2019-01-01T12:00:00.000Z", "href": "https://us-south.iaas.cloud.ibm.com/v1/shares/0fe9e5d8-0a4d-4818-96ec-e99708644a58/mount_targets/4cf9171a-0043-4434-8727-15b53dbc374c", "id": "4cf9171a-0043-4434-8727-15b53dbc374c", "lifecycle_state": "stable", "mount_path": "10.240.1.23:/nxg_s_voll_mz7121_58e7e963_8f4b_4a0c_b71a_8ba8d9cd1e2e", "name": "my-share-mount-target", "primary_ip": {"address": "192.168.3.4", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e/reserved_ips/6d353a0f-aeb1-4ae1-832e-1110d10981bb", "id": "6d353a0f-aeb1-4ae1-832e-1110d10981bb", "name": "my-reserved-ip", "resource_type": "subnet_reserved_ip"}, "resource_type": "share_mount_target", "subnet": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "id": "7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "name": "my-subnet", "resource_type": "subnet"}, "transit_encryption": "none", "virtual_network_interface": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::virtual-network-interface:0767-fa41aecb-4f21-423d-8082-630bfba1e1d9", "href": "https://us-south.iaas.cloud.ibm.com/v1/virtual_network_interfaces/0767-fa41aecb-4f21-423d-8082-630bfba1e1d9", "id": "0767-fa41aecb-4f21-423d-8082-630bfba1e1d9", "name": "my-virtual-network-interface", "resource_type": "virtual_network_interface"}, "vpc": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::vpc:4727d842-f94f-4a2d-824a-9bc9b02c523b", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/vpcs/4727d842-f94f-4a2d-824a-9bc9b02c523b", "id": "4727d842-f94f-4a2d-824a-9bc9b02c523b", "name": "my-vpc", "resource_type": "vpc"}}`) })) }) - It(`Invoke GetSnapshotClone successfully with retries`, func() { + It(`Invoke UpdateShareMountTarget successfully with retries`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -59023,22 +59397,29 @@ var _ = Describe(`VpcV1`, func() { Expect(vpcService).ToNot(BeNil()) vpcService.EnableRetries(0, 0) - // Construct an instance of the GetSnapshotCloneOptions model - getSnapshotCloneOptionsModel := new(vpcv1.GetSnapshotCloneOptions) - getSnapshotCloneOptionsModel.ID = core.StringPtr("testString") - getSnapshotCloneOptionsModel.ZoneName = core.StringPtr("testString") - getSnapshotCloneOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the ShareMountTargetPatch model + shareMountTargetPatchModel := new(vpcv1.ShareMountTargetPatch) + shareMountTargetPatchModel.Name = core.StringPtr("my-share-mount-target") + shareMountTargetPatchModelAsPatch, asPatchErr := shareMountTargetPatchModel.AsPatch() + Expect(asPatchErr).To(BeNil()) + + // Construct an instance of the UpdateShareMountTargetOptions model + updateShareMountTargetOptionsModel := new(vpcv1.UpdateShareMountTargetOptions) + updateShareMountTargetOptionsModel.ShareID = core.StringPtr("testString") + updateShareMountTargetOptionsModel.ID = core.StringPtr("testString") + updateShareMountTargetOptionsModel.ShareMountTargetPatch = shareMountTargetPatchModelAsPatch + updateShareMountTargetOptionsModel.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.GetSnapshotCloneWithContext(ctx, getSnapshotCloneOptionsModel) + _, _, operationErr := vpcService.UpdateShareMountTargetWithContext(ctx, updateShareMountTargetOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) // Disable retries and test again vpcService.DisableRetries() - result, response, operationErr := vpcService.GetSnapshotClone(getSnapshotCloneOptionsModel) + result, response, operationErr := vpcService.UpdateShareMountTarget(updateShareMountTargetOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) @@ -59046,7 +59427,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.GetSnapshotCloneWithContext(ctx, getSnapshotCloneOptionsModel) + _, _, operationErr = vpcService.UpdateShareMountTargetWithContext(ctx, updateShareMountTargetOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) }) @@ -59060,18 +59441,34 @@ var _ = Describe(`VpcV1`, func() { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(getSnapshotClonePath)) - Expect(req.Method).To(Equal("GET")) + Expect(req.URL.EscapedPath()).To(Equal(updateShareMountTargetPath)) + 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.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", `{"available": false, "created_at": "2019-01-01T12:00:00.000Z", "zone": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south/zones/us-south-1", "name": "us-south-1"}}`) + fmt.Fprintf(res, "%s", `{"access_control_mode": "security_group", "created_at": "2019-01-01T12:00:00.000Z", "href": "https://us-south.iaas.cloud.ibm.com/v1/shares/0fe9e5d8-0a4d-4818-96ec-e99708644a58/mount_targets/4cf9171a-0043-4434-8727-15b53dbc374c", "id": "4cf9171a-0043-4434-8727-15b53dbc374c", "lifecycle_state": "stable", "mount_path": "10.240.1.23:/nxg_s_voll_mz7121_58e7e963_8f4b_4a0c_b71a_8ba8d9cd1e2e", "name": "my-share-mount-target", "primary_ip": {"address": "192.168.3.4", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e/reserved_ips/6d353a0f-aeb1-4ae1-832e-1110d10981bb", "id": "6d353a0f-aeb1-4ae1-832e-1110d10981bb", "name": "my-reserved-ip", "resource_type": "subnet_reserved_ip"}, "resource_type": "share_mount_target", "subnet": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "id": "7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "name": "my-subnet", "resource_type": "subnet"}, "transit_encryption": "none", "virtual_network_interface": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::virtual-network-interface:0767-fa41aecb-4f21-423d-8082-630bfba1e1d9", "href": "https://us-south.iaas.cloud.ibm.com/v1/virtual_network_interfaces/0767-fa41aecb-4f21-423d-8082-630bfba1e1d9", "id": "0767-fa41aecb-4f21-423d-8082-630bfba1e1d9", "name": "my-virtual-network-interface", "resource_type": "virtual_network_interface"}, "vpc": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::vpc:4727d842-f94f-4a2d-824a-9bc9b02c523b", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/vpcs/4727d842-f94f-4a2d-824a-9bc9b02c523b", "id": "4727d842-f94f-4a2d-824a-9bc9b02c523b", "name": "my-vpc", "resource_type": "vpc"}}`) })) }) - It(`Invoke GetSnapshotClone successfully`, func() { + It(`Invoke UpdateShareMountTarget successfully`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -59081,25 +59478,32 @@ var _ = Describe(`VpcV1`, func() { Expect(vpcService).ToNot(BeNil()) // Invoke operation with nil options model (negative test) - result, response, operationErr := vpcService.GetSnapshotClone(nil) + result, response, operationErr := vpcService.UpdateShareMountTarget(nil) Expect(operationErr).NotTo(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) - // Construct an instance of the GetSnapshotCloneOptions model - getSnapshotCloneOptionsModel := new(vpcv1.GetSnapshotCloneOptions) - getSnapshotCloneOptionsModel.ID = core.StringPtr("testString") - getSnapshotCloneOptionsModel.ZoneName = core.StringPtr("testString") - getSnapshotCloneOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the ShareMountTargetPatch model + shareMountTargetPatchModel := new(vpcv1.ShareMountTargetPatch) + shareMountTargetPatchModel.Name = core.StringPtr("my-share-mount-target") + shareMountTargetPatchModelAsPatch, asPatchErr := shareMountTargetPatchModel.AsPatch() + Expect(asPatchErr).To(BeNil()) + + // Construct an instance of the UpdateShareMountTargetOptions model + updateShareMountTargetOptionsModel := new(vpcv1.UpdateShareMountTargetOptions) + updateShareMountTargetOptionsModel.ShareID = core.StringPtr("testString") + updateShareMountTargetOptionsModel.ID = core.StringPtr("testString") + updateShareMountTargetOptionsModel.ShareMountTargetPatch = shareMountTargetPatchModelAsPatch + updateShareMountTargetOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with valid options model (positive test) - result, response, operationErr = vpcService.GetSnapshotClone(getSnapshotCloneOptionsModel) + result, response, operationErr = vpcService.UpdateShareMountTarget(updateShareMountTargetOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) }) - It(`Invoke GetSnapshotClone with error: Operation validation and request error`, func() { + It(`Invoke UpdateShareMountTarget with error: Operation validation and request error`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -59108,23 +59512,30 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the GetSnapshotCloneOptions model - getSnapshotCloneOptionsModel := new(vpcv1.GetSnapshotCloneOptions) - getSnapshotCloneOptionsModel.ID = core.StringPtr("testString") - getSnapshotCloneOptionsModel.ZoneName = core.StringPtr("testString") - getSnapshotCloneOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the ShareMountTargetPatch model + shareMountTargetPatchModel := new(vpcv1.ShareMountTargetPatch) + shareMountTargetPatchModel.Name = core.StringPtr("my-share-mount-target") + shareMountTargetPatchModelAsPatch, asPatchErr := shareMountTargetPatchModel.AsPatch() + Expect(asPatchErr).To(BeNil()) + + // Construct an instance of the UpdateShareMountTargetOptions model + updateShareMountTargetOptionsModel := new(vpcv1.UpdateShareMountTargetOptions) + updateShareMountTargetOptionsModel.ShareID = core.StringPtr("testString") + updateShareMountTargetOptionsModel.ID = core.StringPtr("testString") + updateShareMountTargetOptionsModel.ShareMountTargetPatch = shareMountTargetPatchModelAsPatch + updateShareMountTargetOptionsModel.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.GetSnapshotClone(getSnapshotCloneOptionsModel) + result, response, operationErr := vpcService.UpdateShareMountTarget(updateShareMountTargetOptionsModel) 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 GetSnapshotCloneOptions model with no property values - getSnapshotCloneOptionsModelNew := new(vpcv1.GetSnapshotCloneOptions) + // Construct a second instance of the UpdateShareMountTargetOptions model with no property values + updateShareMountTargetOptionsModelNew := new(vpcv1.UpdateShareMountTargetOptions) // Invoke operation with invalid model (negative test) - result, response, operationErr = vpcService.GetSnapshotClone(getSnapshotCloneOptionsModelNew) + result, response, operationErr = vpcService.UpdateShareMountTarget(updateShareMountTargetOptionsModelNew) Expect(operationErr).ToNot(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) @@ -59142,7 +59553,7 @@ var _ = Describe(`VpcV1`, func() { res.WriteHeader(200) })) }) - It(`Invoke GetSnapshotClone successfully`, func() { + It(`Invoke UpdateShareMountTarget successfully`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -59151,36 +59562,116 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the GetSnapshotCloneOptions model - getSnapshotCloneOptionsModel := new(vpcv1.GetSnapshotCloneOptions) - getSnapshotCloneOptionsModel.ID = core.StringPtr("testString") - getSnapshotCloneOptionsModel.ZoneName = core.StringPtr("testString") - getSnapshotCloneOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the ShareMountTargetPatch model + shareMountTargetPatchModel := new(vpcv1.ShareMountTargetPatch) + shareMountTargetPatchModel.Name = core.StringPtr("my-share-mount-target") + shareMountTargetPatchModelAsPatch, asPatchErr := shareMountTargetPatchModel.AsPatch() + Expect(asPatchErr).To(BeNil()) + + // Construct an instance of the UpdateShareMountTargetOptions model + updateShareMountTargetOptionsModel := new(vpcv1.UpdateShareMountTargetOptions) + updateShareMountTargetOptionsModel.ShareID = core.StringPtr("testString") + updateShareMountTargetOptionsModel.ID = core.StringPtr("testString") + updateShareMountTargetOptionsModel.ShareMountTargetPatch = shareMountTargetPatchModelAsPatch + updateShareMountTargetOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation - result, response, operationErr := vpcService.GetSnapshotClone(getSnapshotCloneOptionsModel) + result, response, operationErr := vpcService.UpdateShareMountTarget(updateShareMountTargetOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + + // Verify a nil result + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + }) + Describe(`DeleteShareSource(deleteShareSourceOptions *DeleteShareSourceOptions)`, func() { + version := "testString" + deleteShareSourcePath := "/shares/testString/source" + 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(deleteShareSourcePath)) + 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 DeleteShareSource 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.DeleteShareSource(nil) + Expect(operationErr).NotTo(BeNil()) + Expect(response).To(BeNil()) + + // Construct an instance of the DeleteShareSourceOptions model + deleteShareSourceOptionsModel := new(vpcv1.DeleteShareSourceOptions) + deleteShareSourceOptionsModel.ShareID = core.StringPtr("testString") + deleteShareSourceOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation with valid options model (positive test) + response, operationErr = vpcService.DeleteShareSource(deleteShareSourceOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) + }) + It(`Invoke DeleteShareSource 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()) - // Verify a nil result - Expect(result).To(BeNil()) + // Construct an instance of the DeleteShareSourceOptions model + deleteShareSourceOptionsModel := new(vpcv1.DeleteShareSourceOptions) + deleteShareSourceOptionsModel.ShareID = core.StringPtr("testString") + deleteShareSourceOptionsModel.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.DeleteShareSource(deleteShareSourceOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING)) + Expect(response).To(BeNil()) + // Construct a second instance of the DeleteShareSourceOptions model with no property values + deleteShareSourceOptionsModelNew := new(vpcv1.DeleteShareSourceOptions) + // Invoke operation with invalid model (negative test) + response, operationErr = vpcService.DeleteShareSource(deleteShareSourceOptionsModelNew) + Expect(operationErr).ToNot(BeNil()) + Expect(response).To(BeNil()) }) AfterEach(func() { testServer.Close() }) }) }) - Describe(`CreateSnapshotClone(createSnapshotCloneOptions *CreateSnapshotCloneOptions) - Operation response error`, func() { + Describe(`GetShareSource(getShareSourceOptions *GetShareSourceOptions) - Operation response error`, func() { version := "testString" - createSnapshotClonePath := "/snapshots/testString/clones/testString" + getShareSourcePath := "/shares/testString/source" 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(createSnapshotClonePath)) - Expect(req.Method).To(Equal("PUT")) + Expect(req.URL.EscapedPath()).To(Equal(getShareSourcePath)) + 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") @@ -59188,7 +59679,7 @@ var _ = Describe(`VpcV1`, func() { fmt.Fprint(res, `} this is not valid json {`) })) }) - It(`Invoke CreateSnapshotClone with error: Operation response processing error`, func() { + It(`Invoke GetShareSource with error: Operation response processing error`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -59197,20 +59688,19 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the CreateSnapshotCloneOptions model - createSnapshotCloneOptionsModel := new(vpcv1.CreateSnapshotCloneOptions) - createSnapshotCloneOptionsModel.ID = core.StringPtr("testString") - createSnapshotCloneOptionsModel.ZoneName = core.StringPtr("testString") - createSnapshotCloneOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the GetShareSourceOptions model + getShareSourceOptionsModel := new(vpcv1.GetShareSourceOptions) + getShareSourceOptionsModel.ShareID = core.StringPtr("testString") + getShareSourceOptionsModel.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.CreateSnapshotClone(createSnapshotCloneOptionsModel) + result, response, operationErr := vpcService.GetShareSource(getShareSourceOptionsModel) 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.CreateSnapshotClone(createSnapshotCloneOptionsModel) + result, response, operationErr = vpcService.GetShareSource(getShareSourceOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).To(BeNil()) @@ -59220,17 +59710,17 @@ var _ = Describe(`VpcV1`, func() { }) }) }) - Describe(`CreateSnapshotClone(createSnapshotCloneOptions *CreateSnapshotCloneOptions)`, func() { + Describe(`GetShareSource(getShareSourceOptions *GetShareSourceOptions)`, func() { version := "testString" - createSnapshotClonePath := "/snapshots/testString/clones/testString" + getShareSourcePath := "/shares/testString/source" 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(createSnapshotClonePath)) - Expect(req.Method).To(Equal("PUT")) + Expect(req.URL.EscapedPath()).To(Equal(getShareSourcePath)) + 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))})) @@ -59240,10 +59730,10 @@ var _ = Describe(`VpcV1`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"available": false, "created_at": "2019-01-01T12:00:00.000Z", "zone": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south/zones/us-south-1", "name": "us-south-1"}}`) + fmt.Fprintf(res, "%s", `{"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::share:0fe9e5d8-0a4d-4818-96ec-e99708644a58", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/shares/0fe9e5d8-0a4d-4818-96ec-e99708644a58", "id": "0fe9e5d8-0a4d-4818-96ec-e99708644a58", "name": "my-share", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "share"}`) })) }) - It(`Invoke CreateSnapshotClone successfully with retries`, func() { + It(`Invoke GetShareSource successfully with retries`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -59253,22 +59743,21 @@ var _ = Describe(`VpcV1`, func() { Expect(vpcService).ToNot(BeNil()) vpcService.EnableRetries(0, 0) - // Construct an instance of the CreateSnapshotCloneOptions model - createSnapshotCloneOptionsModel := new(vpcv1.CreateSnapshotCloneOptions) - createSnapshotCloneOptionsModel.ID = core.StringPtr("testString") - createSnapshotCloneOptionsModel.ZoneName = core.StringPtr("testString") - createSnapshotCloneOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the GetShareSourceOptions model + getShareSourceOptionsModel := new(vpcv1.GetShareSourceOptions) + getShareSourceOptionsModel.ShareID = core.StringPtr("testString") + getShareSourceOptionsModel.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.CreateSnapshotCloneWithContext(ctx, createSnapshotCloneOptionsModel) + _, _, operationErr := vpcService.GetShareSourceWithContext(ctx, getShareSourceOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) // Disable retries and test again vpcService.DisableRetries() - result, response, operationErr := vpcService.CreateSnapshotClone(createSnapshotCloneOptionsModel) + result, response, operationErr := vpcService.GetShareSource(getShareSourceOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) @@ -59276,7 +59765,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.CreateSnapshotCloneWithContext(ctx, createSnapshotCloneOptionsModel) + _, _, operationErr = vpcService.GetShareSourceWithContext(ctx, getShareSourceOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) }) @@ -59290,18 +59779,18 @@ var _ = Describe(`VpcV1`, func() { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(createSnapshotClonePath)) - Expect(req.Method).To(Equal("PUT")) + Expect(req.URL.EscapedPath()).To(Equal(getShareSourcePath)) + 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", `{"available": false, "created_at": "2019-01-01T12:00:00.000Z", "zone": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south/zones/us-south-1", "name": "us-south-1"}}`) + fmt.Fprintf(res, "%s", `{"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::share:0fe9e5d8-0a4d-4818-96ec-e99708644a58", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/shares/0fe9e5d8-0a4d-4818-96ec-e99708644a58", "id": "0fe9e5d8-0a4d-4818-96ec-e99708644a58", "name": "my-share", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "share"}`) })) }) - It(`Invoke CreateSnapshotClone successfully`, func() { + It(`Invoke GetShareSource successfully`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -59311,25 +59800,24 @@ var _ = Describe(`VpcV1`, func() { Expect(vpcService).ToNot(BeNil()) // Invoke operation with nil options model (negative test) - result, response, operationErr := vpcService.CreateSnapshotClone(nil) + result, response, operationErr := vpcService.GetShareSource(nil) Expect(operationErr).NotTo(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) - // Construct an instance of the CreateSnapshotCloneOptions model - createSnapshotCloneOptionsModel := new(vpcv1.CreateSnapshotCloneOptions) - createSnapshotCloneOptionsModel.ID = core.StringPtr("testString") - createSnapshotCloneOptionsModel.ZoneName = core.StringPtr("testString") - createSnapshotCloneOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the GetShareSourceOptions model + getShareSourceOptionsModel := new(vpcv1.GetShareSourceOptions) + getShareSourceOptionsModel.ShareID = core.StringPtr("testString") + getShareSourceOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with valid options model (positive test) - result, response, operationErr = vpcService.CreateSnapshotClone(createSnapshotCloneOptionsModel) + result, response, operationErr = vpcService.GetShareSource(getShareSourceOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) }) - It(`Invoke CreateSnapshotClone with error: Operation validation and request error`, func() { + It(`Invoke GetShareSource with error: Operation validation and request error`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -59338,23 +59826,22 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the CreateSnapshotCloneOptions model - createSnapshotCloneOptionsModel := new(vpcv1.CreateSnapshotCloneOptions) - createSnapshotCloneOptionsModel.ID = core.StringPtr("testString") - createSnapshotCloneOptionsModel.ZoneName = core.StringPtr("testString") - createSnapshotCloneOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the GetShareSourceOptions model + getShareSourceOptionsModel := new(vpcv1.GetShareSourceOptions) + getShareSourceOptionsModel.ShareID = core.StringPtr("testString") + getShareSourceOptionsModel.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.CreateSnapshotClone(createSnapshotCloneOptionsModel) + result, response, operationErr := vpcService.GetShareSource(getShareSourceOptionsModel) 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 CreateSnapshotCloneOptions model with no property values - createSnapshotCloneOptionsModelNew := new(vpcv1.CreateSnapshotCloneOptions) + // Construct a second instance of the GetShareSourceOptions model with no property values + getShareSourceOptionsModelNew := new(vpcv1.GetShareSourceOptions) // Invoke operation with invalid model (negative test) - result, response, operationErr = vpcService.CreateSnapshotClone(createSnapshotCloneOptionsModelNew) + result, response, operationErr = vpcService.GetShareSource(getShareSourceOptionsModelNew) Expect(operationErr).ToNot(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) @@ -59372,7 +59859,7 @@ var _ = Describe(`VpcV1`, func() { res.WriteHeader(200) })) }) - It(`Invoke CreateSnapshotClone successfully`, func() { + It(`Invoke GetShareSource successfully`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -59381,14 +59868,13 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the CreateSnapshotCloneOptions model - createSnapshotCloneOptionsModel := new(vpcv1.CreateSnapshotCloneOptions) - createSnapshotCloneOptionsModel.ID = core.StringPtr("testString") - createSnapshotCloneOptionsModel.ZoneName = core.StringPtr("testString") - createSnapshotCloneOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the GetShareSourceOptions model + getShareSourceOptionsModel := new(vpcv1.GetShareSourceOptions) + getShareSourceOptionsModel.ShareID = core.StringPtr("testString") + getShareSourceOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation - result, response, operationErr := vpcService.CreateSnapshotClone(createSnapshotCloneOptionsModel) + result, response, operationErr := vpcService.GetShareSource(getShareSourceOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) @@ -59400,28 +59886,30 @@ var _ = Describe(`VpcV1`, func() { }) }) }) - Describe(`ListShareProfiles(listShareProfilesOptions *ListShareProfilesOptions) - Operation response error`, func() { + Describe(`ListBackupPolicies(listBackupPoliciesOptions *ListBackupPoliciesOptions) - Operation response error`, func() { version := "testString" - listShareProfilesPath := "/share/profiles" + 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(listShareProfilesPath)) + 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(10))})) - Expect(req.URL.Query()["sort"]).To(Equal([]string{"name"})) + 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 ListShareProfiles 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{}, @@ -59430,21 +59918,23 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the ListShareProfilesOptions model - listShareProfilesOptionsModel := new(vpcv1.ListShareProfilesOptions) - listShareProfilesOptionsModel.Start = core.StringPtr("testString") - listShareProfilesOptionsModel.Limit = core.Int64Ptr(int64(10)) - listShareProfilesOptionsModel.Sort = core.StringPtr("name") - listShareProfilesOptionsModel.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(10)) + 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.ListShareProfiles(listShareProfilesOptionsModel) + 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.ListShareProfiles(listShareProfilesOptionsModel) + result, response, operationErr = vpcService.ListBackupPolicies(listBackupPoliciesOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).To(BeNil()) @@ -59454,33 +59944,35 @@ var _ = Describe(`VpcV1`, func() { }) }) }) - Describe(`ListShareProfiles(listShareProfilesOptions *ListShareProfilesOptions)`, func() { + Describe(`ListBackupPolicies(listBackupPoliciesOptions *ListBackupPoliciesOptions)`, func() { version := "testString" - listShareProfilesPath := "/share/profiles" + 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(listShareProfilesPath)) + 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(10))})) - Expect(req.URL.Query()["sort"]).To(Equal([]string{"name"})) + 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/share/profiles?limit=20"}, "limit": 20, "next": {"href": "https://us-south.iaas.cloud.ibm.com/v1/share/profiles?start=9d5a91a3e2cbd233b5a5b33436855ed1&limit=20"}, "profiles": [{"capacity": {"type": "fixed", "value": 4800}, "family": "defined_performance", "href": "https://us-south.iaas.cloud.ibm.com/v1/share/profiles/tier-3iops", "iops": {"type": "fixed", "value": 4000}, "name": "tier-3iops", "resource_type": "share_profile"}], "total_count": 132}`) + fmt.Fprintf(res, "%s", `{"backup_policies": [{"created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south:a/123456::backup-policy:r134-076191ba-49c2-4763-94fd-c70de73ee2e6", "health_reasons": [{"code": "missing_service_authorization_policies", "message": "One or more accounts are missing service authorization policies", "more_info": "https://cloud.ibm.com/docs/vpc?topic=vpc-backup-service-about&interface=ui"}], "health_state": "ok", "href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6", "id": "r134-076191ba-49c2-4763-94fd-c70de73ee2e6", "last_job_completed_at": "2019-01-01T12:00:00.000Z", "lifecycle_state": "stable", "match_user_tags": ["MatchUserTags"], "name": "my-backup-policy", "plans": [{"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6/plans/r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "id": "r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "name": "my-policy-plan", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "backup_policy_plan"}], "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "resource_type": "backup_policy", "scope": {"crn": "crn:v1:bluemix:public:enterprise::a/123456::enterprise:ebc2b430240943458b9e91e1432cfcce", "id": "fee82deba12e4c0fb69c3b09d1f12345", "resource_type": "enterprise"}, "included_content": ["data_volumes"], "match_resource_type": "instance"}], "first": {"href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies?limit=20"}, "limit": 20, "next": {"href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies?start=9d5a91a3e2cbd233b5a5b33436855ed1&limit=20"}, "total_count": 132}`) })) }) - It(`Invoke ListShareProfiles successfully with retries`, func() { + It(`Invoke ListBackupPolicies successfully with retries`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -59490,23 +59982,25 @@ var _ = Describe(`VpcV1`, func() { Expect(vpcService).ToNot(BeNil()) vpcService.EnableRetries(0, 0) - // Construct an instance of the ListShareProfilesOptions model - listShareProfilesOptionsModel := new(vpcv1.ListShareProfilesOptions) - listShareProfilesOptionsModel.Start = core.StringPtr("testString") - listShareProfilesOptionsModel.Limit = core.Int64Ptr(int64(10)) - listShareProfilesOptionsModel.Sort = core.StringPtr("name") - listShareProfilesOptionsModel.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(10)) + 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.ListShareProfilesWithContext(ctx, listShareProfilesOptionsModel) + _, _, 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.ListShareProfiles(listShareProfilesOptionsModel) + result, response, operationErr := vpcService.ListBackupPolicies(listBackupPoliciesOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) @@ -59514,7 +60008,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.ListShareProfilesWithContext(ctx, listShareProfilesOptionsModel) + _, _, operationErr = vpcService.ListBackupPoliciesWithContext(ctx, listBackupPoliciesOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) }) @@ -59528,21 +60022,23 @@ var _ = Describe(`VpcV1`, func() { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(listShareProfilesPath)) + 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(10))})) - Expect(req.URL.Query()["sort"]).To(Equal([]string{"name"})) + 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/share/profiles?limit=20"}, "limit": 20, "next": {"href": "https://us-south.iaas.cloud.ibm.com/v1/share/profiles?start=9d5a91a3e2cbd233b5a5b33436855ed1&limit=20"}, "profiles": [{"capacity": {"type": "fixed", "value": 4800}, "family": "defined_performance", "href": "https://us-south.iaas.cloud.ibm.com/v1/share/profiles/tier-3iops", "iops": {"type": "fixed", "value": 4000}, "name": "tier-3iops", "resource_type": "share_profile"}], "total_count": 132}`) + fmt.Fprintf(res, "%s", `{"backup_policies": [{"created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south:a/123456::backup-policy:r134-076191ba-49c2-4763-94fd-c70de73ee2e6", "health_reasons": [{"code": "missing_service_authorization_policies", "message": "One or more accounts are missing service authorization policies", "more_info": "https://cloud.ibm.com/docs/vpc?topic=vpc-backup-service-about&interface=ui"}], "health_state": "ok", "href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6", "id": "r134-076191ba-49c2-4763-94fd-c70de73ee2e6", "last_job_completed_at": "2019-01-01T12:00:00.000Z", "lifecycle_state": "stable", "match_user_tags": ["MatchUserTags"], "name": "my-backup-policy", "plans": [{"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6/plans/r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "id": "r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "name": "my-policy-plan", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "backup_policy_plan"}], "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "resource_type": "backup_policy", "scope": {"crn": "crn:v1:bluemix:public:enterprise::a/123456::enterprise:ebc2b430240943458b9e91e1432cfcce", "id": "fee82deba12e4c0fb69c3b09d1f12345", "resource_type": "enterprise"}, "included_content": ["data_volumes"], "match_resource_type": "instance"}], "first": {"href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies?limit=20"}, "limit": 20, "next": {"href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies?start=9d5a91a3e2cbd233b5a5b33436855ed1&limit=20"}, "total_count": 132}`) })) }) - It(`Invoke ListShareProfiles successfully`, func() { + It(`Invoke ListBackupPolicies successfully`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -59552,26 +60048,28 @@ var _ = Describe(`VpcV1`, func() { Expect(vpcService).ToNot(BeNil()) // Invoke operation with nil options model (negative test) - result, response, operationErr := vpcService.ListShareProfiles(nil) + result, response, operationErr := vpcService.ListBackupPolicies(nil) Expect(operationErr).NotTo(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) - // Construct an instance of the ListShareProfilesOptions model - listShareProfilesOptionsModel := new(vpcv1.ListShareProfilesOptions) - listShareProfilesOptionsModel.Start = core.StringPtr("testString") - listShareProfilesOptionsModel.Limit = core.Int64Ptr(int64(10)) - listShareProfilesOptionsModel.Sort = core.StringPtr("name") - listShareProfilesOptionsModel.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(10)) + 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.ListShareProfiles(listShareProfilesOptionsModel) + result, response, operationErr = vpcService.ListBackupPolicies(listBackupPoliciesOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) }) - It(`Invoke ListShareProfiles 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{}, @@ -59580,16 +60078,18 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the ListShareProfilesOptions model - listShareProfilesOptionsModel := new(vpcv1.ListShareProfilesOptions) - listShareProfilesOptionsModel.Start = core.StringPtr("testString") - listShareProfilesOptionsModel.Limit = core.Int64Ptr(int64(10)) - listShareProfilesOptionsModel.Sort = core.StringPtr("name") - listShareProfilesOptionsModel.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(10)) + 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.ListShareProfiles(listShareProfilesOptionsModel) + result, response, operationErr := vpcService.ListBackupPolicies(listBackupPoliciesOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING)) Expect(response).To(BeNil()) @@ -59608,7 +60108,7 @@ var _ = Describe(`VpcV1`, func() { res.WriteHeader(200) })) }) - It(`Invoke ListShareProfiles successfully`, func() { + It(`Invoke ListBackupPolicies successfully`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -59617,15 +60117,17 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the ListShareProfilesOptions model - listShareProfilesOptionsModel := new(vpcv1.ListShareProfilesOptions) - listShareProfilesOptionsModel.Start = core.StringPtr("testString") - listShareProfilesOptionsModel.Limit = core.Int64Ptr(int64(10)) - listShareProfilesOptionsModel.Sort = core.StringPtr("name") - listShareProfilesOptionsModel.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(10)) + 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.ListShareProfiles(listShareProfilesOptionsModel) + result, response, operationErr := vpcService.ListBackupPolicies(listBackupPoliciesOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) @@ -59638,8 +60140,8 @@ var _ = Describe(`VpcV1`, func() { }) Context(`Test pagination helper method on response`, func() { It(`Invoke GetNextStart successfully`, func() { - responseObject := new(vpcv1.ShareProfileCollection) - nextObject := new(vpcv1.ShareProfileCollectionNext) + responseObject := new(vpcv1.BackupPolicyCollection) + nextObject := new(vpcv1.BackupPolicyCollectionNext) nextObject.Href = core.StringPtr("ibm.com?start=abc-123") responseObject.Next = nextObject @@ -59648,15 +60150,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.ShareProfileCollection) + 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.ShareProfileCollection) - nextObject := new(vpcv1.ShareProfileCollectionNext) + responseObject := new(vpcv1.BackupPolicyCollection) + nextObject := new(vpcv1.BackupPolicyCollectionNext) nextObject.Href = core.StringPtr("ibm.com") responseObject.Next = nextObject @@ -59672,7 +60174,7 @@ var _ = Describe(`VpcV1`, func() { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(listShareProfilesPath)) + Expect(req.URL.EscapedPath()).To(Equal(listBackupPoliciesPath)) Expect(req.Method).To(Equal("GET")) // Set mock response @@ -59680,42 +60182,15 @@ var _ = Describe(`VpcV1`, func() { res.WriteHeader(200) requestNumber++ if requestNumber == 1 { - fmt.Fprintf(res, "%s", `{"next":{"href":"https://myhost.com/somePath?start=1"},"total_count":2,"limit":1,"profiles":[{"capacity":{"type":"fixed","value":4800},"family":"defined_performance","href":"https://us-south.iaas.cloud.ibm.com/v1/share/profiles/tier-3iops","iops":{"type":"fixed","value":4000},"name":"tier-3iops","resource_type":"share_profile"}]}`) + fmt.Fprintf(res, "%s", `{"next":{"href":"https://myhost.com/somePath?start=1"},"backup_policies":[{"created_at":"2019-01-01T12:00:00.000Z","crn":"crn:v1:bluemix:public:is:us-south:a/123456::backup-policy:r134-076191ba-49c2-4763-94fd-c70de73ee2e6","health_reasons":[{"code":"missing_service_authorization_policies","message":"One or more accounts are missing service authorization policies","more_info":"https://cloud.ibm.com/docs/vpc?topic=vpc-backup-service-about&interface=ui"}],"health_state":"ok","href":"https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6","id":"r134-076191ba-49c2-4763-94fd-c70de73ee2e6","last_job_completed_at":"2019-01-01T12:00:00.000Z","lifecycle_state":"stable","match_user_tags":["MatchUserTags"],"name":"my-backup-policy","plans":[{"deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6/plans/r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178","id":"r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178","name":"my-policy-plan","remote":{"region":{"href":"https://us-south.iaas.cloud.ibm.com/v1/regions/us-south","name":"us-south"}},"resource_type":"backup_policy_plan"}],"resource_group":{"href":"https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345","id":"fee82deba12e4c0fb69c3b09d1f12345","name":"my-resource-group"},"resource_type":"backup_policy","scope":{"crn":"crn:v1:bluemix:public:enterprise::a/123456::enterprise:ebc2b430240943458b9e91e1432cfcce","id":"fee82deba12e4c0fb69c3b09d1f12345","resource_type":"enterprise"},"included_content":["data_volumes"],"match_resource_type":"instance"}],"total_count":2,"limit":1}`) } else if requestNumber == 2 { - fmt.Fprintf(res, "%s", `{"total_count":2,"limit":1,"profiles":[{"capacity":{"type":"fixed","value":4800},"family":"defined_performance","href":"https://us-south.iaas.cloud.ibm.com/v1/share/profiles/tier-3iops","iops":{"type":"fixed","value":4000},"name":"tier-3iops","resource_type":"share_profile"}]}`) + fmt.Fprintf(res, "%s", `{"backup_policies":[{"created_at":"2019-01-01T12:00:00.000Z","crn":"crn:v1:bluemix:public:is:us-south:a/123456::backup-policy:r134-076191ba-49c2-4763-94fd-c70de73ee2e6","health_reasons":[{"code":"missing_service_authorization_policies","message":"One or more accounts are missing service authorization policies","more_info":"https://cloud.ibm.com/docs/vpc?topic=vpc-backup-service-about&interface=ui"}],"health_state":"ok","href":"https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6","id":"r134-076191ba-49c2-4763-94fd-c70de73ee2e6","last_job_completed_at":"2019-01-01T12:00:00.000Z","lifecycle_state":"stable","match_user_tags":["MatchUserTags"],"name":"my-backup-policy","plans":[{"deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6/plans/r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178","id":"r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178","name":"my-policy-plan","remote":{"region":{"href":"https://us-south.iaas.cloud.ibm.com/v1/regions/us-south","name":"us-south"}},"resource_type":"backup_policy_plan"}],"resource_group":{"href":"https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345","id":"fee82deba12e4c0fb69c3b09d1f12345","name":"my-resource-group"},"resource_type":"backup_policy","scope":{"crn":"crn:v1:bluemix:public:enterprise::a/123456::enterprise:ebc2b430240943458b9e91e1432cfcce","id":"fee82deba12e4c0fb69c3b09d1f12345","resource_type":"enterprise"},"included_content":["data_volumes"],"match_resource_type":"instance"}],"total_count":2,"limit":1}`) } else { res.WriteHeader(400) } })) }) - It(`Use ShareProfilesPager.GetNext successfully`, func() { - vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ - URL: testServer.URL, - Authenticator: &core.NoAuthAuthenticator{}, - Version: core.StringPtr(version), - }) - Expect(serviceErr).To(BeNil()) - Expect(vpcService).ToNot(BeNil()) - - listShareProfilesOptionsModel := &vpcv1.ListShareProfilesOptions{ - Limit: core.Int64Ptr(int64(10)), - Sort: core.StringPtr("name"), - } - - pager, err := vpcService.NewShareProfilesPager(listShareProfilesOptionsModel) - Expect(err).To(BeNil()) - Expect(pager).ToNot(BeNil()) - - var allResults []vpcv1.ShareProfile - for pager.HasNext() { - nextPage, err := pager.GetNext() - Expect(err).To(BeNil()) - Expect(nextPage).ToNot(BeNil()) - allResults = append(allResults, nextPage...) - } - Expect(len(allResults)).To(Equal(2)) - }) - It(`Use ShareProfilesPager.GetAll successfully`, func() { + It(`Use BackupPoliciesPager.GetNext successfully`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -59724,221 +60199,27 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - listShareProfilesOptionsModel := &vpcv1.ListShareProfilesOptions{ - Limit: core.Int64Ptr(int64(10)), - Sort: core.StringPtr("name"), + listBackupPoliciesOptionsModel := &vpcv1.ListBackupPoliciesOptions{ + Limit: core.Int64Ptr(int64(10)), + ResourceGroupID: core.StringPtr("testString"), + Name: core.StringPtr("testString"), + Tag: core.StringPtr("testString"), } - pager, err := vpcService.NewShareProfilesPager(listShareProfilesOptionsModel) - Expect(err).To(BeNil()) - Expect(pager).ToNot(BeNil()) - - allResults, err := pager.GetAll() - Expect(err).To(BeNil()) - Expect(allResults).ToNot(BeNil()) - Expect(len(allResults)).To(Equal(2)) - }) - }) - }) - Describe(`GetShareProfile(getShareProfileOptions *GetShareProfileOptions) - Operation response error`, func() { - version := "testString" - getShareProfilePath := "/share/profiles/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(getShareProfilePath)) - 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 GetShareProfile 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 GetShareProfileOptions model - getShareProfileOptionsModel := new(vpcv1.GetShareProfileOptions) - getShareProfileOptionsModel.Name = core.StringPtr("testString") - getShareProfileOptionsModel.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.GetShareProfile(getShareProfileOptionsModel) - 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.GetShareProfile(getShareProfileOptionsModel) - Expect(operationErr).ToNot(BeNil()) - Expect(response).ToNot(BeNil()) - Expect(result).To(BeNil()) - }) - AfterEach(func() { - testServer.Close() - }) - }) - }) - Describe(`GetShareProfile(getShareProfileOptions *GetShareProfileOptions)`, func() { - version := "testString" - getShareProfilePath := "/share/profiles/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(getShareProfilePath)) - 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", `{"capacity": {"type": "fixed", "value": 4800}, "family": "defined_performance", "href": "https://us-south.iaas.cloud.ibm.com/v1/share/profiles/tier-3iops", "iops": {"type": "fixed", "value": 4000}, "name": "tier-3iops", "resource_type": "share_profile"}`) - })) - }) - It(`Invoke GetShareProfile 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 GetShareProfileOptions model - getShareProfileOptionsModel := new(vpcv1.GetShareProfileOptions) - getShareProfileOptionsModel.Name = core.StringPtr("testString") - getShareProfileOptionsModel.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.GetShareProfileWithContext(ctx, getShareProfileOptionsModel) - Expect(operationErr).ToNot(BeNil()) - Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) - - // Disable retries and test again - vpcService.DisableRetries() - result, response, operationErr := vpcService.GetShareProfile(getShareProfileOptionsModel) - 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.GetShareProfileWithContext(ctx, getShareProfileOptionsModel) - 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(getShareProfilePath)) - 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", `{"capacity": {"type": "fixed", "value": 4800}, "family": "defined_performance", "href": "https://us-south.iaas.cloud.ibm.com/v1/share/profiles/tier-3iops", "iops": {"type": "fixed", "value": 4000}, "name": "tier-3iops", "resource_type": "share_profile"}`) - })) - }) - It(`Invoke GetShareProfile 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.GetShareProfile(nil) - Expect(operationErr).NotTo(BeNil()) - Expect(response).To(BeNil()) - Expect(result).To(BeNil()) - - // Construct an instance of the GetShareProfileOptions model - getShareProfileOptionsModel := new(vpcv1.GetShareProfileOptions) - getShareProfileOptionsModel.Name = core.StringPtr("testString") - getShareProfileOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} - - // Invoke operation with valid options model (positive test) - result, response, operationErr = vpcService.GetShareProfile(getShareProfileOptionsModel) - Expect(operationErr).To(BeNil()) - Expect(response).ToNot(BeNil()) - Expect(result).ToNot(BeNil()) - - }) - It(`Invoke GetShareProfile 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 GetShareProfileOptions model - getShareProfileOptionsModel := new(vpcv1.GetShareProfileOptions) - getShareProfileOptionsModel.Name = core.StringPtr("testString") - getShareProfileOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} - // Invoke operation with empty URL (negative test) - err := vpcService.SetServiceURL("") + pager, err := vpcService.NewBackupPoliciesPager(listBackupPoliciesOptionsModel) Expect(err).To(BeNil()) - result, response, operationErr := vpcService.GetShareProfile(getShareProfileOptionsModel) - 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 GetShareProfileOptions model with no property values - getShareProfileOptionsModelNew := new(vpcv1.GetShareProfileOptions) - // Invoke operation with invalid model (negative test) - result, response, operationErr = vpcService.GetShareProfile(getShareProfileOptionsModelNew) - 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) - })) + Expect(pager).ToNot(BeNil()) + + var allResults []vpcv1.BackupPolicyIntf + for pager.HasNext() { + nextPage, err := pager.GetNext() + Expect(err).To(BeNil()) + Expect(nextPage).ToNot(BeNil()) + allResults = append(allResults, nextPage...) + } + Expect(len(allResults)).To(Equal(2)) }) - It(`Invoke GetShareProfile successfully`, func() { + It(`Use BackupPoliciesPager.GetAll successfully`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -59947,49 +60228,43 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the GetShareProfileOptions model - getShareProfileOptionsModel := new(vpcv1.GetShareProfileOptions) - getShareProfileOptionsModel.Name = core.StringPtr("testString") - getShareProfileOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + listBackupPoliciesOptionsModel := &vpcv1.ListBackupPoliciesOptions{ + Limit: core.Int64Ptr(int64(10)), + ResourceGroupID: core.StringPtr("testString"), + Name: core.StringPtr("testString"), + Tag: core.StringPtr("testString"), + } - // Invoke operation - result, response, operationErr := vpcService.GetShareProfile(getShareProfileOptionsModel) - Expect(operationErr).To(BeNil()) - Expect(response).ToNot(BeNil()) + pager, err := vpcService.NewBackupPoliciesPager(listBackupPoliciesOptionsModel) + Expect(err).To(BeNil()) + Expect(pager).ToNot(BeNil()) - // Verify a nil result - Expect(result).To(BeNil()) - }) - AfterEach(func() { - testServer.Close() + allResults, err := pager.GetAll() + Expect(err).To(BeNil()) + Expect(allResults).ToNot(BeNil()) + Expect(len(allResults)).To(Equal(2)) }) }) }) - Describe(`ListShares(listSharesOptions *ListSharesOptions) - Operation response error`, func() { + Describe(`CreateBackupPolicy(createBackupPolicyOptions *CreateBackupPolicyOptions) - Operation response error`, func() { version := "testString" - listSharesPath := "/shares" + 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(listSharesPath)) - Expect(req.Method).To(Equal("GET")) + 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))})) - Expect(req.URL.Query()["start"]).To(Equal([]string{"testString"})) - Expect(req.URL.Query()["limit"]).To(Equal([]string{fmt.Sprint(int64(10))})) - Expect(req.URL.Query()["resource_group.id"]).To(Equal([]string{"testString"})) - Expect(req.URL.Query()["name"]).To(Equal([]string{"testString"})) - Expect(req.URL.Query()["sort"]).To(Equal([]string{"name"})) - Expect(req.URL.Query()["replication_role"]).To(Equal([]string{"none"})) res.Header().Set("Content-type", "application/json") - res.WriteHeader(200) + res.WriteHeader(201) fmt.Fprint(res, `} this is not valid json {`) })) }) - It(`Invoke ListShares 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{}, @@ -59998,24 +60273,75 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the ListSharesOptions model - listSharesOptionsModel := new(vpcv1.ListSharesOptions) - listSharesOptionsModel.Start = core.StringPtr("testString") - listSharesOptionsModel.Limit = core.Int64Ptr(int64(10)) - listSharesOptionsModel.ResourceGroupID = core.StringPtr("testString") - listSharesOptionsModel.Name = core.StringPtr("testString") - listSharesOptionsModel.Sort = core.StringPtr("name") - listSharesOptionsModel.ReplicationRole = core.StringPtr("none") - listSharesOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the ZoneIdentityByName model + zoneIdentityModel := new(vpcv1.ZoneIdentityByName) + zoneIdentityModel.Name = core.StringPtr("us-south-1") + + // Construct an instance of the BackupPolicyPlanClonePolicyPrototype model + backupPolicyPlanClonePolicyPrototypeModel := new(vpcv1.BackupPolicyPlanClonePolicyPrototype) + backupPolicyPlanClonePolicyPrototypeModel.MaxSnapshots = core.Int64Ptr(int64(5)) + backupPolicyPlanClonePolicyPrototypeModel.Zones = []vpcv1.ZoneIdentityIntf{zoneIdentityModel} + + // 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 EncryptionKeyIdentityByCRN model + encryptionKeyIdentityModel := new(vpcv1.EncryptionKeyIdentityByCRN) + encryptionKeyIdentityModel.CRN = core.StringPtr("crn:v1:bluemix:public:kms:us-south:a/123456:e4a29d1a-2ef0-42a6-8fd2-350deb1c647e:key:5437653b-c4b1-447f-9646-b2a2a4cd6179") + + // Construct an instance of the RegionIdentityByName model + regionIdentityModel := new(vpcv1.RegionIdentityByName) + regionIdentityModel.Name = core.StringPtr("us-south") + + // Construct an instance of the BackupPolicyPlanRemoteRegionPolicyPrototype model + backupPolicyPlanRemoteRegionPolicyPrototypeModel := new(vpcv1.BackupPolicyPlanRemoteRegionPolicyPrototype) + backupPolicyPlanRemoteRegionPolicyPrototypeModel.DeleteOverCount = core.Int64Ptr(int64(5)) + backupPolicyPlanRemoteRegionPolicyPrototypeModel.EncryptionKey = encryptionKeyIdentityModel + backupPolicyPlanRemoteRegionPolicyPrototypeModel.Region = regionIdentityModel + + // Construct an instance of the BackupPolicyPlanPrototype model + backupPolicyPlanPrototypeModel := new(vpcv1.BackupPolicyPlanPrototype) + backupPolicyPlanPrototypeModel.Active = core.BoolPtr(true) + backupPolicyPlanPrototypeModel.AttachUserTags = []string{"my-daily-backup-plan"} + backupPolicyPlanPrototypeModel.ClonePolicy = backupPolicyPlanClonePolicyPrototypeModel + backupPolicyPlanPrototypeModel.CopyUserTags = core.BoolPtr(true) + backupPolicyPlanPrototypeModel.CronSpec = core.StringPtr("30 */2 * * 1-5") + backupPolicyPlanPrototypeModel.DeletionTrigger = backupPolicyPlanDeletionTriggerPrototypeModel + backupPolicyPlanPrototypeModel.Name = core.StringPtr("my-policy-plan") + backupPolicyPlanPrototypeModel.RemoteRegionPolicies = []vpcv1.BackupPolicyPlanRemoteRegionPolicyPrototype{*backupPolicyPlanRemoteRegionPolicyPrototypeModel} + + // Construct an instance of the ResourceGroupIdentityByID model + resourceGroupIdentityModel := new(vpcv1.ResourceGroupIdentityByID) + resourceGroupIdentityModel.ID = core.StringPtr("fee82deba12e4c0fb69c3b09d1f12345") + + // Construct an instance of the BackupPolicyScopePrototypeEnterpriseIdentityEnterpriseIdentityByCRN model + backupPolicyScopePrototypeModel := new(vpcv1.BackupPolicyScopePrototypeEnterpriseIdentityEnterpriseIdentityByCRN) + backupPolicyScopePrototypeModel.CRN = core.StringPtr("crn:v1:bluemix:public:enterprise::a/123456::enterprise:ebc2b430240943458b9e91e1432cfcce") + + // Construct an instance of the BackupPolicyPrototypeBackupPolicyMatchResourceTypeVolumePrototype model + backupPolicyPrototypeModel := new(vpcv1.BackupPolicyPrototypeBackupPolicyMatchResourceTypeVolumePrototype) + backupPolicyPrototypeModel.MatchUserTags = []string{"my-daily-backup-policy"} + backupPolicyPrototypeModel.Name = core.StringPtr("my-backup-policy") + backupPolicyPrototypeModel.Plans = []vpcv1.BackupPolicyPlanPrototype{*backupPolicyPlanPrototypeModel} + backupPolicyPrototypeModel.ResourceGroup = resourceGroupIdentityModel + backupPolicyPrototypeModel.Scope = backupPolicyScopePrototypeModel + backupPolicyPrototypeModel.MatchResourceType = core.StringPtr("volume") + + // Construct an instance of the CreateBackupPolicyOptions model + createBackupPolicyOptionsModel := new(vpcv1.CreateBackupPolicyOptions) + createBackupPolicyOptionsModel.BackupPolicyPrototype = backupPolicyPrototypeModel + createBackupPolicyOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Expect response parsing to fail since we are receiving a text/plain response - result, response, operationErr := vpcService.ListShares(listSharesOptionsModel) + 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.ListShares(listSharesOptionsModel) + result, response, operationErr = vpcService.CreateBackupPolicy(createBackupPolicyOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).To(BeNil()) @@ -60025,36 +60351,46 @@ var _ = Describe(`VpcV1`, func() { }) }) }) - Describe(`ListShares(listSharesOptions *ListSharesOptions)`, func() { + Describe(`CreateBackupPolicy(createBackupPolicyOptions *CreateBackupPolicyOptions)`, func() { version := "testString" - listSharesPath := "/shares" + 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(listSharesPath)) - Expect(req.Method).To(Equal("GET")) + Expect(req.URL.EscapedPath()).To(Equal(createBackupPolicyPath)) + 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))})) - Expect(req.URL.Query()["start"]).To(Equal([]string{"testString"})) - Expect(req.URL.Query()["limit"]).To(Equal([]string{fmt.Sprint(int64(10))})) - Expect(req.URL.Query()["resource_group.id"]).To(Equal([]string{"testString"})) - Expect(req.URL.Query()["name"]).To(Equal([]string{"testString"})) - Expect(req.URL.Query()["sort"]).To(Equal([]string{"name"})) - Expect(req.URL.Query()["replication_role"]).To(Equal([]string{"none"})) // 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/shares?limit=20"}, "limit": 20, "next": {"href": "https://us-south.iaas.cloud.ibm.com/v1/shares?start=9d5a91a3e2cbd233b5a5b33436855ed1&limit=20"}, "shares": [{"access_control_mode": "security_group", "created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::share:0fe9e5d8-0a4d-4818-96ec-e99708644a58", "encryption": "provider_managed", "encryption_key": {"crn": "crn:v1:bluemix:public:kms:us-south:a/123456:e4a29d1a-2ef0-42a6-8fd2-350deb1c647e:key:5437653b-c4b1-447f-9646-b2a2a4cd6179"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/shares/0fe9e5d8-0a4d-4818-96ec-e99708644a58", "id": "0fe9e5d8-0a4d-4818-96ec-e99708644a58", "iops": 100, "latest_job": {"status": "cancelled", "status_reasons": [{"code": "cannot_reach_source_share", "message": "The replication failover failed because the source share cannot be reached.", "more_info": "https://cloud.ibm.com/docs/vpc?topic=vpc-file-storage-planning"}], "type": "replication_failover"}, "latest_sync": {"completed_at": "2019-01-01T12:00:00.000Z", "data_transferred": 0, "started_at": "2019-01-01T12:00:00.000Z"}, "lifecycle_state": "stable", "mount_targets": [{"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/shares/0fe9e5d8-0a4d-4818-96ec-e99708644a58/mount_targets/4cf9171a-0043-4434-8727-15b53dbc374c", "id": "4cf9171a-0043-4434-8727-15b53dbc374c", "name": "my-share-mount-target", "resource_type": "share_mount_target"}], "name": "my-share", "profile": {"href": "https://us-south.iaas.cloud.ibm.com/v1/share/profiles/tier-3iops", "name": "tier-3iops", "resource_type": "share_profile"}, "replica_share": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::share:0fe9e5d8-0a4d-4818-96ec-e99708644a58", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/shares/0fe9e5d8-0a4d-4818-96ec-e99708644a58", "id": "0fe9e5d8-0a4d-4818-96ec-e99708644a58", "name": "my-share", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "share"}, "replication_cron_spec": "0 */5 * * *", "replication_role": "none", "replication_status": "active", "replication_status_reasons": [{"code": "cannot_reach_source_share", "message": "The replication failover failed because the source share cannot be reached.", "more_info": "https://cloud.ibm.com/docs/vpc?topic=vpc-file-storage-planning"}], "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "resource_type": "share", "size": 200, "source_share": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::share:0fe9e5d8-0a4d-4818-96ec-e99708644a58", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/shares/0fe9e5d8-0a4d-4818-96ec-e99708644a58", "id": "0fe9e5d8-0a4d-4818-96ec-e99708644a58", "name": "my-share", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "share"}, "user_tags": ["UserTags"], "zone": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south/zones/us-south-1", "name": "us-south-1"}}], "total_count": 132}`) + res.WriteHeader(201) + fmt.Fprintf(res, "%s", `{"created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south:a/123456::backup-policy:r134-076191ba-49c2-4763-94fd-c70de73ee2e6", "health_reasons": [{"code": "missing_service_authorization_policies", "message": "One or more accounts are missing service authorization policies", "more_info": "https://cloud.ibm.com/docs/vpc?topic=vpc-backup-service-about&interface=ui"}], "health_state": "ok", "href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6", "id": "r134-076191ba-49c2-4763-94fd-c70de73ee2e6", "last_job_completed_at": "2019-01-01T12:00:00.000Z", "lifecycle_state": "stable", "match_user_tags": ["MatchUserTags"], "name": "my-backup-policy", "plans": [{"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6/plans/r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "id": "r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "name": "my-policy-plan", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "backup_policy_plan"}], "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "resource_type": "backup_policy", "scope": {"crn": "crn:v1:bluemix:public:enterprise::a/123456::enterprise:ebc2b430240943458b9e91e1432cfcce", "id": "fee82deba12e4c0fb69c3b09d1f12345", "resource_type": "enterprise"}, "included_content": ["data_volumes"], "match_resource_type": "instance"}`) })) }) - It(`Invoke ListShares successfully with retries`, func() { + It(`Invoke CreateBackupPolicy successfully with retries`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -60064,26 +60400,77 @@ var _ = Describe(`VpcV1`, func() { Expect(vpcService).ToNot(BeNil()) vpcService.EnableRetries(0, 0) - // Construct an instance of the ListSharesOptions model - listSharesOptionsModel := new(vpcv1.ListSharesOptions) - listSharesOptionsModel.Start = core.StringPtr("testString") - listSharesOptionsModel.Limit = core.Int64Ptr(int64(10)) - listSharesOptionsModel.ResourceGroupID = core.StringPtr("testString") - listSharesOptionsModel.Name = core.StringPtr("testString") - listSharesOptionsModel.Sort = core.StringPtr("name") - listSharesOptionsModel.ReplicationRole = core.StringPtr("none") - listSharesOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the ZoneIdentityByName model + zoneIdentityModel := new(vpcv1.ZoneIdentityByName) + zoneIdentityModel.Name = core.StringPtr("us-south-1") + + // Construct an instance of the BackupPolicyPlanClonePolicyPrototype model + backupPolicyPlanClonePolicyPrototypeModel := new(vpcv1.BackupPolicyPlanClonePolicyPrototype) + backupPolicyPlanClonePolicyPrototypeModel.MaxSnapshots = core.Int64Ptr(int64(5)) + backupPolicyPlanClonePolicyPrototypeModel.Zones = []vpcv1.ZoneIdentityIntf{zoneIdentityModel} + + // 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 EncryptionKeyIdentityByCRN model + encryptionKeyIdentityModel := new(vpcv1.EncryptionKeyIdentityByCRN) + encryptionKeyIdentityModel.CRN = core.StringPtr("crn:v1:bluemix:public:kms:us-south:a/123456:e4a29d1a-2ef0-42a6-8fd2-350deb1c647e:key:5437653b-c4b1-447f-9646-b2a2a4cd6179") + + // Construct an instance of the RegionIdentityByName model + regionIdentityModel := new(vpcv1.RegionIdentityByName) + regionIdentityModel.Name = core.StringPtr("us-south") + + // Construct an instance of the BackupPolicyPlanRemoteRegionPolicyPrototype model + backupPolicyPlanRemoteRegionPolicyPrototypeModel := new(vpcv1.BackupPolicyPlanRemoteRegionPolicyPrototype) + backupPolicyPlanRemoteRegionPolicyPrototypeModel.DeleteOverCount = core.Int64Ptr(int64(5)) + backupPolicyPlanRemoteRegionPolicyPrototypeModel.EncryptionKey = encryptionKeyIdentityModel + backupPolicyPlanRemoteRegionPolicyPrototypeModel.Region = regionIdentityModel + + // Construct an instance of the BackupPolicyPlanPrototype model + backupPolicyPlanPrototypeModel := new(vpcv1.BackupPolicyPlanPrototype) + backupPolicyPlanPrototypeModel.Active = core.BoolPtr(true) + backupPolicyPlanPrototypeModel.AttachUserTags = []string{"my-daily-backup-plan"} + backupPolicyPlanPrototypeModel.ClonePolicy = backupPolicyPlanClonePolicyPrototypeModel + backupPolicyPlanPrototypeModel.CopyUserTags = core.BoolPtr(true) + backupPolicyPlanPrototypeModel.CronSpec = core.StringPtr("30 */2 * * 1-5") + backupPolicyPlanPrototypeModel.DeletionTrigger = backupPolicyPlanDeletionTriggerPrototypeModel + backupPolicyPlanPrototypeModel.Name = core.StringPtr("my-policy-plan") + backupPolicyPlanPrototypeModel.RemoteRegionPolicies = []vpcv1.BackupPolicyPlanRemoteRegionPolicyPrototype{*backupPolicyPlanRemoteRegionPolicyPrototypeModel} + + // Construct an instance of the ResourceGroupIdentityByID model + resourceGroupIdentityModel := new(vpcv1.ResourceGroupIdentityByID) + resourceGroupIdentityModel.ID = core.StringPtr("fee82deba12e4c0fb69c3b09d1f12345") + + // Construct an instance of the BackupPolicyScopePrototypeEnterpriseIdentityEnterpriseIdentityByCRN model + backupPolicyScopePrototypeModel := new(vpcv1.BackupPolicyScopePrototypeEnterpriseIdentityEnterpriseIdentityByCRN) + backupPolicyScopePrototypeModel.CRN = core.StringPtr("crn:v1:bluemix:public:enterprise::a/123456::enterprise:ebc2b430240943458b9e91e1432cfcce") + + // Construct an instance of the BackupPolicyPrototypeBackupPolicyMatchResourceTypeVolumePrototype model + backupPolicyPrototypeModel := new(vpcv1.BackupPolicyPrototypeBackupPolicyMatchResourceTypeVolumePrototype) + backupPolicyPrototypeModel.MatchUserTags = []string{"my-daily-backup-policy"} + backupPolicyPrototypeModel.Name = core.StringPtr("my-backup-policy") + backupPolicyPrototypeModel.Plans = []vpcv1.BackupPolicyPlanPrototype{*backupPolicyPlanPrototypeModel} + backupPolicyPrototypeModel.ResourceGroup = resourceGroupIdentityModel + backupPolicyPrototypeModel.Scope = backupPolicyScopePrototypeModel + backupPolicyPrototypeModel.MatchResourceType = core.StringPtr("volume") + + // Construct an instance of the CreateBackupPolicyOptions model + createBackupPolicyOptionsModel := new(vpcv1.CreateBackupPolicyOptions) + createBackupPolicyOptionsModel.BackupPolicyPrototype = backupPolicyPrototypeModel + 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.ListSharesWithContext(ctx, listSharesOptionsModel) + _, _, 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.ListShares(listSharesOptionsModel) + result, response, operationErr := vpcService.CreateBackupPolicy(createBackupPolicyOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) @@ -60091,7 +60478,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.ListSharesWithContext(ctx, listSharesOptionsModel) + _, _, operationErr = vpcService.CreateBackupPolicyWithContext(ctx, createBackupPolicyOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) }) @@ -60105,24 +60492,34 @@ var _ = Describe(`VpcV1`, func() { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(listSharesPath)) - Expect(req.Method).To(Equal("GET")) + Expect(req.URL.EscapedPath()).To(Equal(createBackupPolicyPath)) + 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))})) - Expect(req.URL.Query()["start"]).To(Equal([]string{"testString"})) - Expect(req.URL.Query()["limit"]).To(Equal([]string{fmt.Sprint(int64(10))})) - Expect(req.URL.Query()["resource_group.id"]).To(Equal([]string{"testString"})) - Expect(req.URL.Query()["name"]).To(Equal([]string{"testString"})) - Expect(req.URL.Query()["sort"]).To(Equal([]string{"name"})) - Expect(req.URL.Query()["replication_role"]).To(Equal([]string{"none"})) // 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/shares?limit=20"}, "limit": 20, "next": {"href": "https://us-south.iaas.cloud.ibm.com/v1/shares?start=9d5a91a3e2cbd233b5a5b33436855ed1&limit=20"}, "shares": [{"access_control_mode": "security_group", "created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::share:0fe9e5d8-0a4d-4818-96ec-e99708644a58", "encryption": "provider_managed", "encryption_key": {"crn": "crn:v1:bluemix:public:kms:us-south:a/123456:e4a29d1a-2ef0-42a6-8fd2-350deb1c647e:key:5437653b-c4b1-447f-9646-b2a2a4cd6179"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/shares/0fe9e5d8-0a4d-4818-96ec-e99708644a58", "id": "0fe9e5d8-0a4d-4818-96ec-e99708644a58", "iops": 100, "latest_job": {"status": "cancelled", "status_reasons": [{"code": "cannot_reach_source_share", "message": "The replication failover failed because the source share cannot be reached.", "more_info": "https://cloud.ibm.com/docs/vpc?topic=vpc-file-storage-planning"}], "type": "replication_failover"}, "latest_sync": {"completed_at": "2019-01-01T12:00:00.000Z", "data_transferred": 0, "started_at": "2019-01-01T12:00:00.000Z"}, "lifecycle_state": "stable", "mount_targets": [{"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/shares/0fe9e5d8-0a4d-4818-96ec-e99708644a58/mount_targets/4cf9171a-0043-4434-8727-15b53dbc374c", "id": "4cf9171a-0043-4434-8727-15b53dbc374c", "name": "my-share-mount-target", "resource_type": "share_mount_target"}], "name": "my-share", "profile": {"href": "https://us-south.iaas.cloud.ibm.com/v1/share/profiles/tier-3iops", "name": "tier-3iops", "resource_type": "share_profile"}, "replica_share": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::share:0fe9e5d8-0a4d-4818-96ec-e99708644a58", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/shares/0fe9e5d8-0a4d-4818-96ec-e99708644a58", "id": "0fe9e5d8-0a4d-4818-96ec-e99708644a58", "name": "my-share", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "share"}, "replication_cron_spec": "0 */5 * * *", "replication_role": "none", "replication_status": "active", "replication_status_reasons": [{"code": "cannot_reach_source_share", "message": "The replication failover failed because the source share cannot be reached.", "more_info": "https://cloud.ibm.com/docs/vpc?topic=vpc-file-storage-planning"}], "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "resource_type": "share", "size": 200, "source_share": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::share:0fe9e5d8-0a4d-4818-96ec-e99708644a58", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/shares/0fe9e5d8-0a4d-4818-96ec-e99708644a58", "id": "0fe9e5d8-0a4d-4818-96ec-e99708644a58", "name": "my-share", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "share"}, "user_tags": ["UserTags"], "zone": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south/zones/us-south-1", "name": "us-south-1"}}], "total_count": 132}`) + res.WriteHeader(201) + fmt.Fprintf(res, "%s", `{"created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south:a/123456::backup-policy:r134-076191ba-49c2-4763-94fd-c70de73ee2e6", "health_reasons": [{"code": "missing_service_authorization_policies", "message": "One or more accounts are missing service authorization policies", "more_info": "https://cloud.ibm.com/docs/vpc?topic=vpc-backup-service-about&interface=ui"}], "health_state": "ok", "href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6", "id": "r134-076191ba-49c2-4763-94fd-c70de73ee2e6", "last_job_completed_at": "2019-01-01T12:00:00.000Z", "lifecycle_state": "stable", "match_user_tags": ["MatchUserTags"], "name": "my-backup-policy", "plans": [{"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6/plans/r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "id": "r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "name": "my-policy-plan", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "backup_policy_plan"}], "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "resource_type": "backup_policy", "scope": {"crn": "crn:v1:bluemix:public:enterprise::a/123456::enterprise:ebc2b430240943458b9e91e1432cfcce", "id": "fee82deba12e4c0fb69c3b09d1f12345", "resource_type": "enterprise"}, "included_content": ["data_volumes"], "match_resource_type": "instance"}`) })) }) - It(`Invoke ListShares successfully`, func() { + It(`Invoke CreateBackupPolicy successfully`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -60132,29 +60529,80 @@ var _ = Describe(`VpcV1`, func() { Expect(vpcService).ToNot(BeNil()) // Invoke operation with nil options model (negative test) - result, response, operationErr := vpcService.ListShares(nil) + result, response, operationErr := vpcService.CreateBackupPolicy(nil) Expect(operationErr).NotTo(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) - // Construct an instance of the ListSharesOptions model - listSharesOptionsModel := new(vpcv1.ListSharesOptions) - listSharesOptionsModel.Start = core.StringPtr("testString") - listSharesOptionsModel.Limit = core.Int64Ptr(int64(10)) - listSharesOptionsModel.ResourceGroupID = core.StringPtr("testString") - listSharesOptionsModel.Name = core.StringPtr("testString") - listSharesOptionsModel.Sort = core.StringPtr("name") - listSharesOptionsModel.ReplicationRole = core.StringPtr("none") - listSharesOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the ZoneIdentityByName model + zoneIdentityModel := new(vpcv1.ZoneIdentityByName) + zoneIdentityModel.Name = core.StringPtr("us-south-1") + + // Construct an instance of the BackupPolicyPlanClonePolicyPrototype model + backupPolicyPlanClonePolicyPrototypeModel := new(vpcv1.BackupPolicyPlanClonePolicyPrototype) + backupPolicyPlanClonePolicyPrototypeModel.MaxSnapshots = core.Int64Ptr(int64(5)) + backupPolicyPlanClonePolicyPrototypeModel.Zones = []vpcv1.ZoneIdentityIntf{zoneIdentityModel} + + // 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 EncryptionKeyIdentityByCRN model + encryptionKeyIdentityModel := new(vpcv1.EncryptionKeyIdentityByCRN) + encryptionKeyIdentityModel.CRN = core.StringPtr("crn:v1:bluemix:public:kms:us-south:a/123456:e4a29d1a-2ef0-42a6-8fd2-350deb1c647e:key:5437653b-c4b1-447f-9646-b2a2a4cd6179") + + // Construct an instance of the RegionIdentityByName model + regionIdentityModel := new(vpcv1.RegionIdentityByName) + regionIdentityModel.Name = core.StringPtr("us-south") + + // Construct an instance of the BackupPolicyPlanRemoteRegionPolicyPrototype model + backupPolicyPlanRemoteRegionPolicyPrototypeModel := new(vpcv1.BackupPolicyPlanRemoteRegionPolicyPrototype) + backupPolicyPlanRemoteRegionPolicyPrototypeModel.DeleteOverCount = core.Int64Ptr(int64(5)) + backupPolicyPlanRemoteRegionPolicyPrototypeModel.EncryptionKey = encryptionKeyIdentityModel + backupPolicyPlanRemoteRegionPolicyPrototypeModel.Region = regionIdentityModel + + // Construct an instance of the BackupPolicyPlanPrototype model + backupPolicyPlanPrototypeModel := new(vpcv1.BackupPolicyPlanPrototype) + backupPolicyPlanPrototypeModel.Active = core.BoolPtr(true) + backupPolicyPlanPrototypeModel.AttachUserTags = []string{"my-daily-backup-plan"} + backupPolicyPlanPrototypeModel.ClonePolicy = backupPolicyPlanClonePolicyPrototypeModel + backupPolicyPlanPrototypeModel.CopyUserTags = core.BoolPtr(true) + backupPolicyPlanPrototypeModel.CronSpec = core.StringPtr("30 */2 * * 1-5") + backupPolicyPlanPrototypeModel.DeletionTrigger = backupPolicyPlanDeletionTriggerPrototypeModel + backupPolicyPlanPrototypeModel.Name = core.StringPtr("my-policy-plan") + backupPolicyPlanPrototypeModel.RemoteRegionPolicies = []vpcv1.BackupPolicyPlanRemoteRegionPolicyPrototype{*backupPolicyPlanRemoteRegionPolicyPrototypeModel} + + // Construct an instance of the ResourceGroupIdentityByID model + resourceGroupIdentityModel := new(vpcv1.ResourceGroupIdentityByID) + resourceGroupIdentityModel.ID = core.StringPtr("fee82deba12e4c0fb69c3b09d1f12345") + + // Construct an instance of the BackupPolicyScopePrototypeEnterpriseIdentityEnterpriseIdentityByCRN model + backupPolicyScopePrototypeModel := new(vpcv1.BackupPolicyScopePrototypeEnterpriseIdentityEnterpriseIdentityByCRN) + backupPolicyScopePrototypeModel.CRN = core.StringPtr("crn:v1:bluemix:public:enterprise::a/123456::enterprise:ebc2b430240943458b9e91e1432cfcce") + + // Construct an instance of the BackupPolicyPrototypeBackupPolicyMatchResourceTypeVolumePrototype model + backupPolicyPrototypeModel := new(vpcv1.BackupPolicyPrototypeBackupPolicyMatchResourceTypeVolumePrototype) + backupPolicyPrototypeModel.MatchUserTags = []string{"my-daily-backup-policy"} + backupPolicyPrototypeModel.Name = core.StringPtr("my-backup-policy") + backupPolicyPrototypeModel.Plans = []vpcv1.BackupPolicyPlanPrototype{*backupPolicyPlanPrototypeModel} + backupPolicyPrototypeModel.ResourceGroup = resourceGroupIdentityModel + backupPolicyPrototypeModel.Scope = backupPolicyScopePrototypeModel + backupPolicyPrototypeModel.MatchResourceType = core.StringPtr("volume") + + // Construct an instance of the CreateBackupPolicyOptions model + createBackupPolicyOptionsModel := new(vpcv1.CreateBackupPolicyOptions) + createBackupPolicyOptionsModel.BackupPolicyPrototype = backupPolicyPrototypeModel + createBackupPolicyOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with valid options model (positive test) - result, response, operationErr = vpcService.ListShares(listSharesOptionsModel) + result, response, operationErr = vpcService.CreateBackupPolicy(createBackupPolicyOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) }) - It(`Invoke ListShares with error: Operation request error`, func() { + It(`Invoke CreateBackupPolicy with error: Operation validation and request error`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -60163,121 +60611,96 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the ListSharesOptions model - listSharesOptionsModel := new(vpcv1.ListSharesOptions) - listSharesOptionsModel.Start = core.StringPtr("testString") - listSharesOptionsModel.Limit = core.Int64Ptr(int64(10)) - listSharesOptionsModel.ResourceGroupID = core.StringPtr("testString") - listSharesOptionsModel.Name = core.StringPtr("testString") - listSharesOptionsModel.Sort = core.StringPtr("name") - listSharesOptionsModel.ReplicationRole = core.StringPtr("none") - listSharesOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the ZoneIdentityByName model + zoneIdentityModel := new(vpcv1.ZoneIdentityByName) + zoneIdentityModel.Name = core.StringPtr("us-south-1") + + // Construct an instance of the BackupPolicyPlanClonePolicyPrototype model + backupPolicyPlanClonePolicyPrototypeModel := new(vpcv1.BackupPolicyPlanClonePolicyPrototype) + backupPolicyPlanClonePolicyPrototypeModel.MaxSnapshots = core.Int64Ptr(int64(5)) + backupPolicyPlanClonePolicyPrototypeModel.Zones = []vpcv1.ZoneIdentityIntf{zoneIdentityModel} + + // 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 EncryptionKeyIdentityByCRN model + encryptionKeyIdentityModel := new(vpcv1.EncryptionKeyIdentityByCRN) + encryptionKeyIdentityModel.CRN = core.StringPtr("crn:v1:bluemix:public:kms:us-south:a/123456:e4a29d1a-2ef0-42a6-8fd2-350deb1c647e:key:5437653b-c4b1-447f-9646-b2a2a4cd6179") + + // Construct an instance of the RegionIdentityByName model + regionIdentityModel := new(vpcv1.RegionIdentityByName) + regionIdentityModel.Name = core.StringPtr("us-south") + + // Construct an instance of the BackupPolicyPlanRemoteRegionPolicyPrototype model + backupPolicyPlanRemoteRegionPolicyPrototypeModel := new(vpcv1.BackupPolicyPlanRemoteRegionPolicyPrototype) + backupPolicyPlanRemoteRegionPolicyPrototypeModel.DeleteOverCount = core.Int64Ptr(int64(5)) + backupPolicyPlanRemoteRegionPolicyPrototypeModel.EncryptionKey = encryptionKeyIdentityModel + backupPolicyPlanRemoteRegionPolicyPrototypeModel.Region = regionIdentityModel + + // Construct an instance of the BackupPolicyPlanPrototype model + backupPolicyPlanPrototypeModel := new(vpcv1.BackupPolicyPlanPrototype) + backupPolicyPlanPrototypeModel.Active = core.BoolPtr(true) + backupPolicyPlanPrototypeModel.AttachUserTags = []string{"my-daily-backup-plan"} + backupPolicyPlanPrototypeModel.ClonePolicy = backupPolicyPlanClonePolicyPrototypeModel + backupPolicyPlanPrototypeModel.CopyUserTags = core.BoolPtr(true) + backupPolicyPlanPrototypeModel.CronSpec = core.StringPtr("30 */2 * * 1-5") + backupPolicyPlanPrototypeModel.DeletionTrigger = backupPolicyPlanDeletionTriggerPrototypeModel + backupPolicyPlanPrototypeModel.Name = core.StringPtr("my-policy-plan") + backupPolicyPlanPrototypeModel.RemoteRegionPolicies = []vpcv1.BackupPolicyPlanRemoteRegionPolicyPrototype{*backupPolicyPlanRemoteRegionPolicyPrototypeModel} + + // Construct an instance of the ResourceGroupIdentityByID model + resourceGroupIdentityModel := new(vpcv1.ResourceGroupIdentityByID) + resourceGroupIdentityModel.ID = core.StringPtr("fee82deba12e4c0fb69c3b09d1f12345") + + // Construct an instance of the BackupPolicyScopePrototypeEnterpriseIdentityEnterpriseIdentityByCRN model + backupPolicyScopePrototypeModel := new(vpcv1.BackupPolicyScopePrototypeEnterpriseIdentityEnterpriseIdentityByCRN) + backupPolicyScopePrototypeModel.CRN = core.StringPtr("crn:v1:bluemix:public:enterprise::a/123456::enterprise:ebc2b430240943458b9e91e1432cfcce") + + // Construct an instance of the BackupPolicyPrototypeBackupPolicyMatchResourceTypeVolumePrototype model + backupPolicyPrototypeModel := new(vpcv1.BackupPolicyPrototypeBackupPolicyMatchResourceTypeVolumePrototype) + backupPolicyPrototypeModel.MatchUserTags = []string{"my-daily-backup-policy"} + backupPolicyPrototypeModel.Name = core.StringPtr("my-backup-policy") + backupPolicyPrototypeModel.Plans = []vpcv1.BackupPolicyPlanPrototype{*backupPolicyPlanPrototypeModel} + backupPolicyPrototypeModel.ResourceGroup = resourceGroupIdentityModel + backupPolicyPrototypeModel.Scope = backupPolicyScopePrototypeModel + backupPolicyPrototypeModel.MatchResourceType = core.StringPtr("volume") + + // Construct an instance of the CreateBackupPolicyOptions model + createBackupPolicyOptionsModel := new(vpcv1.CreateBackupPolicyOptions) + createBackupPolicyOptionsModel.BackupPolicyPrototype = backupPolicyPrototypeModel + 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.ListShares(listSharesOptionsModel) + 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()) - }) - 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 ListShares 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 ListSharesOptions model - listSharesOptionsModel := new(vpcv1.ListSharesOptions) - listSharesOptionsModel.Start = core.StringPtr("testString") - listSharesOptionsModel.Limit = core.Int64Ptr(int64(10)) - listSharesOptionsModel.ResourceGroupID = core.StringPtr("testString") - listSharesOptionsModel.Name = core.StringPtr("testString") - listSharesOptionsModel.Sort = core.StringPtr("name") - listSharesOptionsModel.ReplicationRole = core.StringPtr("none") - listSharesOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} - - // Invoke operation - result, response, operationErr := vpcService.ListShares(listSharesOptionsModel) - Expect(operationErr).To(BeNil()) - Expect(response).ToNot(BeNil()) - - // Verify a nil result + // Construct a second instance of the CreateBackupPolicyOptions model with no property values + createBackupPolicyOptionsModelNew := new(vpcv1.CreateBackupPolicyOptions) + // Invoke operation with invalid model (negative test) + result, response, operationErr = vpcService.CreateBackupPolicy(createBackupPolicyOptionsModelNew) + Expect(operationErr).ToNot(BeNil()) + Expect(response).To(BeNil()) Expect(result).To(BeNil()) }) AfterEach(func() { testServer.Close() }) }) - Context(`Test pagination helper method on response`, func() { - It(`Invoke GetNextStart successfully`, func() { - responseObject := new(vpcv1.ShareCollection) - nextObject := new(vpcv1.ShareCollectionNext) - 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.ShareCollection) - - 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.ShareCollection) - nextObject := new(vpcv1.ShareCollectionNext) - nextObject.Href = core.StringPtr("ibm.com") - responseObject.Next = nextObject - - value, err := responseObject.GetNextStart() - Expect(err).To(BeNil()) - Expect(value).To(BeNil()) - }) - }) - Context(`Using mock server endpoint - paginated response`, func() { + Context(`Using mock server endpoint with missing response body`, func() { BeforeEach(func() { - var requestNumber int = 0 testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { - defer GinkgoRecover() - - // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(listSharesPath)) - Expect(req.Method).To(Equal("GET")) - - // Set mock response - res.Header().Set("Content-type", "application/json") - res.WriteHeader(200) - requestNumber++ - if requestNumber == 1 { - fmt.Fprintf(res, "%s", `{"shares":[{"access_control_mode":"security_group","created_at":"2019-01-01T12:00:00.000Z","crn":"crn:v1:bluemix:public:is:us-south-1:a/123456::share:0fe9e5d8-0a4d-4818-96ec-e99708644a58","encryption":"provider_managed","encryption_key":{"crn":"crn:v1:bluemix:public:kms:us-south:a/123456:e4a29d1a-2ef0-42a6-8fd2-350deb1c647e:key:5437653b-c4b1-447f-9646-b2a2a4cd6179"},"href":"https://us-south.iaas.cloud.ibm.com/v1/shares/0fe9e5d8-0a4d-4818-96ec-e99708644a58","id":"0fe9e5d8-0a4d-4818-96ec-e99708644a58","iops":100,"latest_job":{"status":"cancelled","status_reasons":[{"code":"cannot_reach_source_share","message":"The replication failover failed because the source share cannot be reached.","more_info":"https://cloud.ibm.com/docs/vpc?topic=vpc-file-storage-planning"}],"type":"replication_failover"},"latest_sync":{"completed_at":"2019-01-01T12:00:00.000Z","data_transferred":0,"started_at":"2019-01-01T12:00:00.000Z"},"lifecycle_state":"stable","mount_targets":[{"deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/shares/0fe9e5d8-0a4d-4818-96ec-e99708644a58/mount_targets/4cf9171a-0043-4434-8727-15b53dbc374c","id":"4cf9171a-0043-4434-8727-15b53dbc374c","name":"my-share-mount-target","resource_type":"share_mount_target"}],"name":"my-share","profile":{"href":"https://us-south.iaas.cloud.ibm.com/v1/share/profiles/tier-3iops","name":"tier-3iops","resource_type":"share_profile"},"replica_share":{"crn":"crn:v1:bluemix:public:is:us-south-1:a/123456::share:0fe9e5d8-0a4d-4818-96ec-e99708644a58","deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/shares/0fe9e5d8-0a4d-4818-96ec-e99708644a58","id":"0fe9e5d8-0a4d-4818-96ec-e99708644a58","name":"my-share","remote":{"region":{"href":"https://us-south.iaas.cloud.ibm.com/v1/regions/us-south","name":"us-south"}},"resource_type":"share"},"replication_cron_spec":"0 */5 * * *","replication_role":"none","replication_status":"active","replication_status_reasons":[{"code":"cannot_reach_source_share","message":"The replication failover failed because the source share cannot be reached.","more_info":"https://cloud.ibm.com/docs/vpc?topic=vpc-file-storage-planning"}],"resource_group":{"href":"https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345","id":"fee82deba12e4c0fb69c3b09d1f12345","name":"my-resource-group"},"resource_type":"share","size":200,"source_share":{"crn":"crn:v1:bluemix:public:is:us-south-1:a/123456::share:0fe9e5d8-0a4d-4818-96ec-e99708644a58","deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/shares/0fe9e5d8-0a4d-4818-96ec-e99708644a58","id":"0fe9e5d8-0a4d-4818-96ec-e99708644a58","name":"my-share","remote":{"region":{"href":"https://us-south.iaas.cloud.ibm.com/v1/regions/us-south","name":"us-south"}},"resource_type":"share"},"user_tags":["UserTags"],"zone":{"href":"https://us-south.iaas.cloud.ibm.com/v1/regions/us-south/zones/us-south-1","name":"us-south-1"}}],"next":{"href":"https://myhost.com/somePath?start=1"},"total_count":2,"limit":1}`) - } else if requestNumber == 2 { - fmt.Fprintf(res, "%s", `{"shares":[{"access_control_mode":"security_group","created_at":"2019-01-01T12:00:00.000Z","crn":"crn:v1:bluemix:public:is:us-south-1:a/123456::share:0fe9e5d8-0a4d-4818-96ec-e99708644a58","encryption":"provider_managed","encryption_key":{"crn":"crn:v1:bluemix:public:kms:us-south:a/123456:e4a29d1a-2ef0-42a6-8fd2-350deb1c647e:key:5437653b-c4b1-447f-9646-b2a2a4cd6179"},"href":"https://us-south.iaas.cloud.ibm.com/v1/shares/0fe9e5d8-0a4d-4818-96ec-e99708644a58","id":"0fe9e5d8-0a4d-4818-96ec-e99708644a58","iops":100,"latest_job":{"status":"cancelled","status_reasons":[{"code":"cannot_reach_source_share","message":"The replication failover failed because the source share cannot be reached.","more_info":"https://cloud.ibm.com/docs/vpc?topic=vpc-file-storage-planning"}],"type":"replication_failover"},"latest_sync":{"completed_at":"2019-01-01T12:00:00.000Z","data_transferred":0,"started_at":"2019-01-01T12:00:00.000Z"},"lifecycle_state":"stable","mount_targets":[{"deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/shares/0fe9e5d8-0a4d-4818-96ec-e99708644a58/mount_targets/4cf9171a-0043-4434-8727-15b53dbc374c","id":"4cf9171a-0043-4434-8727-15b53dbc374c","name":"my-share-mount-target","resource_type":"share_mount_target"}],"name":"my-share","profile":{"href":"https://us-south.iaas.cloud.ibm.com/v1/share/profiles/tier-3iops","name":"tier-3iops","resource_type":"share_profile"},"replica_share":{"crn":"crn:v1:bluemix:public:is:us-south-1:a/123456::share:0fe9e5d8-0a4d-4818-96ec-e99708644a58","deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/shares/0fe9e5d8-0a4d-4818-96ec-e99708644a58","id":"0fe9e5d8-0a4d-4818-96ec-e99708644a58","name":"my-share","remote":{"region":{"href":"https://us-south.iaas.cloud.ibm.com/v1/regions/us-south","name":"us-south"}},"resource_type":"share"},"replication_cron_spec":"0 */5 * * *","replication_role":"none","replication_status":"active","replication_status_reasons":[{"code":"cannot_reach_source_share","message":"The replication failover failed because the source share cannot be reached.","more_info":"https://cloud.ibm.com/docs/vpc?topic=vpc-file-storage-planning"}],"resource_group":{"href":"https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345","id":"fee82deba12e4c0fb69c3b09d1f12345","name":"my-resource-group"},"resource_type":"share","size":200,"source_share":{"crn":"crn:v1:bluemix:public:is:us-south-1:a/123456::share:0fe9e5d8-0a4d-4818-96ec-e99708644a58","deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/shares/0fe9e5d8-0a4d-4818-96ec-e99708644a58","id":"0fe9e5d8-0a4d-4818-96ec-e99708644a58","name":"my-share","remote":{"region":{"href":"https://us-south.iaas.cloud.ibm.com/v1/regions/us-south","name":"us-south"}},"resource_type":"share"},"user_tags":["UserTags"],"zone":{"href":"https://us-south.iaas.cloud.ibm.com/v1/regions/us-south/zones/us-south-1","name":"us-south-1"}}],"total_count":2,"limit":1}`) - } else { - res.WriteHeader(400) - } + defer GinkgoRecover() + + // Set success status code with no respoonse body + res.WriteHeader(201) })) }) - It(`Use SharesPager.GetNext successfully`, func() { + It(`Invoke CreateBackupPolicy successfully`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -60286,74 +60709,107 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - listSharesOptionsModel := &vpcv1.ListSharesOptions{ - Limit: core.Int64Ptr(int64(10)), - ResourceGroupID: core.StringPtr("testString"), - Name: core.StringPtr("testString"), - Sort: core.StringPtr("name"), - ReplicationRole: core.StringPtr("none"), - } + // Construct an instance of the ZoneIdentityByName model + zoneIdentityModel := new(vpcv1.ZoneIdentityByName) + zoneIdentityModel.Name = core.StringPtr("us-south-1") - pager, err := vpcService.NewSharesPager(listSharesOptionsModel) - Expect(err).To(BeNil()) - Expect(pager).ToNot(BeNil()) + // Construct an instance of the BackupPolicyPlanClonePolicyPrototype model + backupPolicyPlanClonePolicyPrototypeModel := new(vpcv1.BackupPolicyPlanClonePolicyPrototype) + backupPolicyPlanClonePolicyPrototypeModel.MaxSnapshots = core.Int64Ptr(int64(5)) + backupPolicyPlanClonePolicyPrototypeModel.Zones = []vpcv1.ZoneIdentityIntf{zoneIdentityModel} - var allResults []vpcv1.Share - for pager.HasNext() { - nextPage, err := pager.GetNext() - Expect(err).To(BeNil()) - Expect(nextPage).ToNot(BeNil()) - allResults = append(allResults, nextPage...) - } - Expect(len(allResults)).To(Equal(2)) - }) - It(`Use SharesPager.GetAll successfully`, func() { - vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ - URL: testServer.URL, - Authenticator: &core.NoAuthAuthenticator{}, - Version: core.StringPtr(version), - }) - Expect(serviceErr).To(BeNil()) - Expect(vpcService).ToNot(BeNil()) + // Construct an instance of the BackupPolicyPlanDeletionTriggerPrototype model + backupPolicyPlanDeletionTriggerPrototypeModel := new(vpcv1.BackupPolicyPlanDeletionTriggerPrototype) + backupPolicyPlanDeletionTriggerPrototypeModel.DeleteAfter = core.Int64Ptr(int64(20)) + backupPolicyPlanDeletionTriggerPrototypeModel.DeleteOverCount = core.Int64Ptr(int64(20)) - listSharesOptionsModel := &vpcv1.ListSharesOptions{ - Limit: core.Int64Ptr(int64(10)), - ResourceGroupID: core.StringPtr("testString"), - Name: core.StringPtr("testString"), - Sort: core.StringPtr("name"), - ReplicationRole: core.StringPtr("none"), - } + // Construct an instance of the EncryptionKeyIdentityByCRN model + encryptionKeyIdentityModel := new(vpcv1.EncryptionKeyIdentityByCRN) + encryptionKeyIdentityModel.CRN = core.StringPtr("crn:v1:bluemix:public:kms:us-south:a/123456:e4a29d1a-2ef0-42a6-8fd2-350deb1c647e:key:5437653b-c4b1-447f-9646-b2a2a4cd6179") - pager, err := vpcService.NewSharesPager(listSharesOptionsModel) - Expect(err).To(BeNil()) - Expect(pager).ToNot(BeNil()) + // Construct an instance of the RegionIdentityByName model + regionIdentityModel := new(vpcv1.RegionIdentityByName) + regionIdentityModel.Name = core.StringPtr("us-south") - allResults, err := pager.GetAll() - Expect(err).To(BeNil()) - Expect(allResults).ToNot(BeNil()) - Expect(len(allResults)).To(Equal(2)) + // Construct an instance of the BackupPolicyPlanRemoteRegionPolicyPrototype model + backupPolicyPlanRemoteRegionPolicyPrototypeModel := new(vpcv1.BackupPolicyPlanRemoteRegionPolicyPrototype) + backupPolicyPlanRemoteRegionPolicyPrototypeModel.DeleteOverCount = core.Int64Ptr(int64(5)) + backupPolicyPlanRemoteRegionPolicyPrototypeModel.EncryptionKey = encryptionKeyIdentityModel + backupPolicyPlanRemoteRegionPolicyPrototypeModel.Region = regionIdentityModel + + // Construct an instance of the BackupPolicyPlanPrototype model + backupPolicyPlanPrototypeModel := new(vpcv1.BackupPolicyPlanPrototype) + backupPolicyPlanPrototypeModel.Active = core.BoolPtr(true) + backupPolicyPlanPrototypeModel.AttachUserTags = []string{"my-daily-backup-plan"} + backupPolicyPlanPrototypeModel.ClonePolicy = backupPolicyPlanClonePolicyPrototypeModel + backupPolicyPlanPrototypeModel.CopyUserTags = core.BoolPtr(true) + backupPolicyPlanPrototypeModel.CronSpec = core.StringPtr("30 */2 * * 1-5") + backupPolicyPlanPrototypeModel.DeletionTrigger = backupPolicyPlanDeletionTriggerPrototypeModel + backupPolicyPlanPrototypeModel.Name = core.StringPtr("my-policy-plan") + backupPolicyPlanPrototypeModel.RemoteRegionPolicies = []vpcv1.BackupPolicyPlanRemoteRegionPolicyPrototype{*backupPolicyPlanRemoteRegionPolicyPrototypeModel} + + // Construct an instance of the ResourceGroupIdentityByID model + resourceGroupIdentityModel := new(vpcv1.ResourceGroupIdentityByID) + resourceGroupIdentityModel.ID = core.StringPtr("fee82deba12e4c0fb69c3b09d1f12345") + + // Construct an instance of the BackupPolicyScopePrototypeEnterpriseIdentityEnterpriseIdentityByCRN model + backupPolicyScopePrototypeModel := new(vpcv1.BackupPolicyScopePrototypeEnterpriseIdentityEnterpriseIdentityByCRN) + backupPolicyScopePrototypeModel.CRN = core.StringPtr("crn:v1:bluemix:public:enterprise::a/123456::enterprise:ebc2b430240943458b9e91e1432cfcce") + + // Construct an instance of the BackupPolicyPrototypeBackupPolicyMatchResourceTypeVolumePrototype model + backupPolicyPrototypeModel := new(vpcv1.BackupPolicyPrototypeBackupPolicyMatchResourceTypeVolumePrototype) + backupPolicyPrototypeModel.MatchUserTags = []string{"my-daily-backup-policy"} + backupPolicyPrototypeModel.Name = core.StringPtr("my-backup-policy") + backupPolicyPrototypeModel.Plans = []vpcv1.BackupPolicyPlanPrototype{*backupPolicyPlanPrototypeModel} + backupPolicyPrototypeModel.ResourceGroup = resourceGroupIdentityModel + backupPolicyPrototypeModel.Scope = backupPolicyScopePrototypeModel + backupPolicyPrototypeModel.MatchResourceType = core.StringPtr("volume") + + // Construct an instance of the CreateBackupPolicyOptions model + createBackupPolicyOptionsModel := new(vpcv1.CreateBackupPolicyOptions) + createBackupPolicyOptionsModel.BackupPolicyPrototype = backupPolicyPrototypeModel + createBackupPolicyOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation + result, response, operationErr := vpcService.CreateBackupPolicy(createBackupPolicyOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + + // Verify a nil result + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() }) }) }) - Describe(`CreateShare(createShareOptions *CreateShareOptions) - Operation response error`, func() { + Describe(`ListBackupPolicyJobs(listBackupPolicyJobsOptions *ListBackupPolicyJobsOptions) - Operation response error`, func() { version := "testString" - createSharePath := "/shares" + listBackupPolicyJobsPath := "/backup_policies/testString/jobs" 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(createSharePath)) - Expect(req.Method).To(Equal("POST")) + Expect(req.URL.EscapedPath()).To(Equal(listBackupPolicyJobsPath)) + 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()["status"]).To(Equal([]string{"failed"})) + Expect(req.URL.Query()["backup_policy_plan.id"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["start"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["limit"]).To(Equal([]string{fmt.Sprint(int64(10))})) + Expect(req.URL.Query()["sort"]).To(Equal([]string{"name"})) + Expect(req.URL.Query()["source.id"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["target_snapshots[].id"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["target_snapshots[].crn"]).To(Equal([]string{"crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263"})) res.Header().Set("Content-type", "application/json") - res.WriteHeader(201) + res.WriteHeader(200) fmt.Fprint(res, `} this is not valid json {`) })) }) - It(`Invoke CreateShare with error: Operation response processing error`, func() { + It(`Invoke ListBackupPolicyJobs with error: Operation response processing error`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -60362,104 +60818,27 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the VirtualNetworkInterfaceIPPrototypeReservedIPPrototypeVirtualNetworkInterfaceIPsContext model - virtualNetworkInterfaceIPPrototypeModel := new(vpcv1.VirtualNetworkInterfaceIPPrototypeReservedIPPrototypeVirtualNetworkInterfaceIPsContext) - virtualNetworkInterfaceIPPrototypeModel.Address = core.StringPtr("10.0.0.5") - virtualNetworkInterfaceIPPrototypeModel.AutoDelete = core.BoolPtr(false) - virtualNetworkInterfaceIPPrototypeModel.Name = core.StringPtr("my-reserved-ip") - - // Construct an instance of the VirtualNetworkInterfacePrimaryIPPrototypeReservedIPPrototypeVirtualNetworkInterfacePrimaryIPContext model - virtualNetworkInterfacePrimaryIPPrototypeModel := new(vpcv1.VirtualNetworkInterfacePrimaryIPPrototypeReservedIPPrototypeVirtualNetworkInterfacePrimaryIPContext) - virtualNetworkInterfacePrimaryIPPrototypeModel.Address = core.StringPtr("10.0.0.5") - virtualNetworkInterfacePrimaryIPPrototypeModel.AutoDelete = core.BoolPtr(false) - virtualNetworkInterfacePrimaryIPPrototypeModel.Name = core.StringPtr("my-reserved-ip") - - // Construct an instance of the ResourceGroupIdentityByID model - resourceGroupIdentityModel := new(vpcv1.ResourceGroupIdentityByID) - resourceGroupIdentityModel.ID = core.StringPtr("fee82deba12e4c0fb69c3b09d1f12345") - - // Construct an instance of the SecurityGroupIdentityByID model - securityGroupIdentityModel := new(vpcv1.SecurityGroupIdentityByID) - securityGroupIdentityModel.ID = core.StringPtr("be5df5ca-12a0-494b-907e-aa6ec2bfa271") - - // Construct an instance of the SubnetIdentityByID model - subnetIdentityModel := new(vpcv1.SubnetIdentityByID) - subnetIdentityModel.ID = core.StringPtr("7ec86020-1c6e-4889-b3f0-a15f2e50f87e") - - // Construct an instance of the ShareMountTargetVirtualNetworkInterfacePrototypeVirtualNetworkInterfacePrototypeShareMountTargetContext model - shareMountTargetVirtualNetworkInterfacePrototypeModel := new(vpcv1.ShareMountTargetVirtualNetworkInterfacePrototypeVirtualNetworkInterfacePrototypeShareMountTargetContext) - shareMountTargetVirtualNetworkInterfacePrototypeModel.AllowIPSpoofing = core.BoolPtr(true) - shareMountTargetVirtualNetworkInterfacePrototypeModel.AutoDelete = core.BoolPtr(false) - shareMountTargetVirtualNetworkInterfacePrototypeModel.EnableInfrastructureNat = core.BoolPtr(true) - shareMountTargetVirtualNetworkInterfacePrototypeModel.Ips = []vpcv1.VirtualNetworkInterfaceIPPrototypeIntf{virtualNetworkInterfaceIPPrototypeModel} - shareMountTargetVirtualNetworkInterfacePrototypeModel.Name = core.StringPtr("my-virtual-network-interface") - shareMountTargetVirtualNetworkInterfacePrototypeModel.PrimaryIP = virtualNetworkInterfacePrimaryIPPrototypeModel - shareMountTargetVirtualNetworkInterfacePrototypeModel.ResourceGroup = resourceGroupIdentityModel - shareMountTargetVirtualNetworkInterfacePrototypeModel.SecurityGroups = []vpcv1.SecurityGroupIdentityIntf{securityGroupIdentityModel} - shareMountTargetVirtualNetworkInterfacePrototypeModel.Subnet = subnetIdentityModel - - // Construct an instance of the ShareMountTargetPrototypeShareMountTargetByAccessControlModeSecurityGroup model - shareMountTargetPrototypeModel := new(vpcv1.ShareMountTargetPrototypeShareMountTargetByAccessControlModeSecurityGroup) - shareMountTargetPrototypeModel.Name = core.StringPtr("my-share-mount-target") - shareMountTargetPrototypeModel.TransitEncryption = core.StringPtr("none") - shareMountTargetPrototypeModel.VirtualNetworkInterface = shareMountTargetVirtualNetworkInterfacePrototypeModel - - // Construct an instance of the ShareProfileIdentityByName model - shareProfileIdentityModel := new(vpcv1.ShareProfileIdentityByName) - shareProfileIdentityModel.Name = core.StringPtr("tier-3iops") - - // Construct an instance of the ZoneIdentityByName model - zoneIdentityModel := new(vpcv1.ZoneIdentityByName) - zoneIdentityModel.Name = core.StringPtr("us-south-1") - - // Construct an instance of the SharePrototypeShareContext model - sharePrototypeShareContextModel := new(vpcv1.SharePrototypeShareContext) - sharePrototypeShareContextModel.Iops = core.Int64Ptr(int64(100)) - sharePrototypeShareContextModel.MountTargets = []vpcv1.ShareMountTargetPrototypeIntf{shareMountTargetPrototypeModel} - sharePrototypeShareContextModel.Name = core.StringPtr("my-share") - sharePrototypeShareContextModel.Profile = shareProfileIdentityModel - sharePrototypeShareContextModel.ReplicationCronSpec = core.StringPtr("0 */5 * * *") - sharePrototypeShareContextModel.ResourceGroup = resourceGroupIdentityModel - sharePrototypeShareContextModel.UserTags = []string{} - sharePrototypeShareContextModel.Zone = zoneIdentityModel - - // Construct an instance of the EncryptionKeyIdentityByCRN model - encryptionKeyIdentityModel := new(vpcv1.EncryptionKeyIdentityByCRN) - encryptionKeyIdentityModel.CRN = core.StringPtr("crn:v1:bluemix:public:kms:us-south:a/123456:e4a29d1a-2ef0-42a6-8fd2-350deb1c647e:key:5437653b-c4b1-447f-9646-b2a2a4cd6179") - - // Construct an instance of the ShareInitialOwner model - shareInitialOwnerModel := new(vpcv1.ShareInitialOwner) - shareInitialOwnerModel.Gid = core.Int64Ptr(int64(50)) - shareInitialOwnerModel.Uid = core.Int64Ptr(int64(50)) - - // Construct an instance of the SharePrototypeShareBySize model - sharePrototypeModel := new(vpcv1.SharePrototypeShareBySize) - sharePrototypeModel.Iops = core.Int64Ptr(int64(100)) - sharePrototypeModel.MountTargets = []vpcv1.ShareMountTargetPrototypeIntf{shareMountTargetPrototypeModel} - sharePrototypeModel.Name = core.StringPtr("my-share") - sharePrototypeModel.Profile = shareProfileIdentityModel - sharePrototypeModel.ReplicaShare = sharePrototypeShareContextModel - sharePrototypeModel.UserTags = []string{} - sharePrototypeModel.Zone = zoneIdentityModel - sharePrototypeModel.AccessControlMode = core.StringPtr("security_group") - sharePrototypeModel.EncryptionKey = encryptionKeyIdentityModel - sharePrototypeModel.InitialOwner = shareInitialOwnerModel - sharePrototypeModel.ResourceGroup = resourceGroupIdentityModel - sharePrototypeModel.Size = core.Int64Ptr(int64(200)) - - // Construct an instance of the CreateShareOptions model - createShareOptionsModel := new(vpcv1.CreateShareOptions) - createShareOptionsModel.SharePrototype = sharePrototypeModel - createShareOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the ListBackupPolicyJobsOptions model + listBackupPolicyJobsOptionsModel := new(vpcv1.ListBackupPolicyJobsOptions) + listBackupPolicyJobsOptionsModel.BackupPolicyID = core.StringPtr("testString") + listBackupPolicyJobsOptionsModel.Status = core.StringPtr("failed") + listBackupPolicyJobsOptionsModel.BackupPolicyPlanID = core.StringPtr("testString") + listBackupPolicyJobsOptionsModel.Start = core.StringPtr("testString") + listBackupPolicyJobsOptionsModel.Limit = core.Int64Ptr(int64(10)) + listBackupPolicyJobsOptionsModel.Sort = core.StringPtr("name") + listBackupPolicyJobsOptionsModel.SourceID = core.StringPtr("testString") + listBackupPolicyJobsOptionsModel.TargetSnapshotsID = core.StringPtr("testString") + listBackupPolicyJobsOptionsModel.TargetSnapshotsCRN = core.StringPtr("crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263") + listBackupPolicyJobsOptionsModel.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.CreateShare(createShareOptionsModel) + result, response, operationErr := vpcService.ListBackupPolicyJobs(listBackupPolicyJobsOptionsModel) 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.CreateShare(createShareOptionsModel) + result, response, operationErr = vpcService.ListBackupPolicyJobs(listBackupPolicyJobsOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).To(BeNil()) @@ -60469,46 +60848,38 @@ var _ = Describe(`VpcV1`, func() { }) }) }) - Describe(`CreateShare(createShareOptions *CreateShareOptions)`, func() { + Describe(`ListBackupPolicyJobs(listBackupPolicyJobsOptions *ListBackupPolicyJobsOptions)`, func() { version := "testString" - createSharePath := "/shares" + listBackupPolicyJobsPath := "/backup_policies/testString/jobs" 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(createSharePath)) - 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.EscapedPath()).To(Equal(listBackupPolicyJobsPath)) + 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()["status"]).To(Equal([]string{"failed"})) + Expect(req.URL.Query()["backup_policy_plan.id"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["start"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["limit"]).To(Equal([]string{fmt.Sprint(int64(10))})) + Expect(req.URL.Query()["sort"]).To(Equal([]string{"name"})) + Expect(req.URL.Query()["source.id"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["target_snapshots[].id"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["target_snapshots[].crn"]).To(Equal([]string{"crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263"})) // Sleep a short time to support a timeout test time.Sleep(100 * time.Millisecond) // Set mock response res.Header().Set("Content-type", "application/json") - res.WriteHeader(201) - fmt.Fprintf(res, "%s", `{"access_control_mode": "security_group", "created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::share:0fe9e5d8-0a4d-4818-96ec-e99708644a58", "encryption": "provider_managed", "encryption_key": {"crn": "crn:v1:bluemix:public:kms:us-south:a/123456:e4a29d1a-2ef0-42a6-8fd2-350deb1c647e:key:5437653b-c4b1-447f-9646-b2a2a4cd6179"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/shares/0fe9e5d8-0a4d-4818-96ec-e99708644a58", "id": "0fe9e5d8-0a4d-4818-96ec-e99708644a58", "iops": 100, "latest_job": {"status": "cancelled", "status_reasons": [{"code": "cannot_reach_source_share", "message": "The replication failover failed because the source share cannot be reached.", "more_info": "https://cloud.ibm.com/docs/vpc?topic=vpc-file-storage-planning"}], "type": "replication_failover"}, "latest_sync": {"completed_at": "2019-01-01T12:00:00.000Z", "data_transferred": 0, "started_at": "2019-01-01T12:00:00.000Z"}, "lifecycle_state": "stable", "mount_targets": [{"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/shares/0fe9e5d8-0a4d-4818-96ec-e99708644a58/mount_targets/4cf9171a-0043-4434-8727-15b53dbc374c", "id": "4cf9171a-0043-4434-8727-15b53dbc374c", "name": "my-share-mount-target", "resource_type": "share_mount_target"}], "name": "my-share", "profile": {"href": "https://us-south.iaas.cloud.ibm.com/v1/share/profiles/tier-3iops", "name": "tier-3iops", "resource_type": "share_profile"}, "replica_share": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::share:0fe9e5d8-0a4d-4818-96ec-e99708644a58", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/shares/0fe9e5d8-0a4d-4818-96ec-e99708644a58", "id": "0fe9e5d8-0a4d-4818-96ec-e99708644a58", "name": "my-share", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "share"}, "replication_cron_spec": "0 */5 * * *", "replication_role": "none", "replication_status": "active", "replication_status_reasons": [{"code": "cannot_reach_source_share", "message": "The replication failover failed because the source share cannot be reached.", "more_info": "https://cloud.ibm.com/docs/vpc?topic=vpc-file-storage-planning"}], "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "resource_type": "share", "size": 200, "source_share": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::share:0fe9e5d8-0a4d-4818-96ec-e99708644a58", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/shares/0fe9e5d8-0a4d-4818-96ec-e99708644a58", "id": "0fe9e5d8-0a4d-4818-96ec-e99708644a58", "name": "my-share", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "share"}, "user_tags": ["UserTags"], "zone": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south/zones/us-south-1", "name": "us-south-1"}}`) + res.WriteHeader(200) + fmt.Fprintf(res, "%s", `{"first": {"href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies/7241e2a8-601f-11ea-8503-000c29475bed/jobs?limit=20"}, "jobs": [{"auto_delete": true, "auto_delete_after": 90, "backup_policy_plan": {"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6/plans/r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "id": "r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "name": "my-policy-plan", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "backup_policy_plan"}, "completed_at": "2019-01-01T12:00:00.000Z", "created_at": "2019-01-01T12:00:00.000Z", "href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies/0fe9e5d8-0a4d-4818-96ec-e99708644a58/jobs/4cf9171a-0043-4434-8727-15b53dbc374c", "id": "4cf9171a-0043-4434-8727-15b53dbc374c", "job_type": "creation", "resource_type": "backup_policy_job", "source": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::volume:1a6b7274-678d-4dfb-8981-c71dd9d4daa5", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/volumes/1a6b7274-678d-4dfb-8981-c71dd9d4daa5", "id": "1a6b7274-678d-4dfb-8981-c71dd9d4daa5", "name": "my-volume", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "volume"}, "status": "failed", "status_reasons": [{"code": "source_volume_busy", "message": "Message", "more_info": "https://cloud.ibm.com/docs/vpc?topic=vpc-troubleshooting-backup-for-vpc"}], "target_snapshots": [{"crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "id": "r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "name": "my-snapshot", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "snapshot"}]}], "limit": 20, "next": {"href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies/7241e2a8-601f-11ea-8503-000c29475bed/jobss?start=9d5a91a3e2cbd233b5a5b33436855ed1&limit=20"}, "total_count": 132}`) })) }) - It(`Invoke CreateShare successfully with retries`, func() { + It(`Invoke ListBackupPolicyJobs successfully with retries`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -60518,106 +60889,29 @@ var _ = Describe(`VpcV1`, func() { Expect(vpcService).ToNot(BeNil()) vpcService.EnableRetries(0, 0) - // Construct an instance of the VirtualNetworkInterfaceIPPrototypeReservedIPPrototypeVirtualNetworkInterfaceIPsContext model - virtualNetworkInterfaceIPPrototypeModel := new(vpcv1.VirtualNetworkInterfaceIPPrototypeReservedIPPrototypeVirtualNetworkInterfaceIPsContext) - virtualNetworkInterfaceIPPrototypeModel.Address = core.StringPtr("10.0.0.5") - virtualNetworkInterfaceIPPrototypeModel.AutoDelete = core.BoolPtr(false) - virtualNetworkInterfaceIPPrototypeModel.Name = core.StringPtr("my-reserved-ip") - - // Construct an instance of the VirtualNetworkInterfacePrimaryIPPrototypeReservedIPPrototypeVirtualNetworkInterfacePrimaryIPContext model - virtualNetworkInterfacePrimaryIPPrototypeModel := new(vpcv1.VirtualNetworkInterfacePrimaryIPPrototypeReservedIPPrototypeVirtualNetworkInterfacePrimaryIPContext) - virtualNetworkInterfacePrimaryIPPrototypeModel.Address = core.StringPtr("10.0.0.5") - virtualNetworkInterfacePrimaryIPPrototypeModel.AutoDelete = core.BoolPtr(false) - virtualNetworkInterfacePrimaryIPPrototypeModel.Name = core.StringPtr("my-reserved-ip") - - // Construct an instance of the ResourceGroupIdentityByID model - resourceGroupIdentityModel := new(vpcv1.ResourceGroupIdentityByID) - resourceGroupIdentityModel.ID = core.StringPtr("fee82deba12e4c0fb69c3b09d1f12345") - - // Construct an instance of the SecurityGroupIdentityByID model - securityGroupIdentityModel := new(vpcv1.SecurityGroupIdentityByID) - securityGroupIdentityModel.ID = core.StringPtr("be5df5ca-12a0-494b-907e-aa6ec2bfa271") - - // Construct an instance of the SubnetIdentityByID model - subnetIdentityModel := new(vpcv1.SubnetIdentityByID) - subnetIdentityModel.ID = core.StringPtr("7ec86020-1c6e-4889-b3f0-a15f2e50f87e") - - // Construct an instance of the ShareMountTargetVirtualNetworkInterfacePrototypeVirtualNetworkInterfacePrototypeShareMountTargetContext model - shareMountTargetVirtualNetworkInterfacePrototypeModel := new(vpcv1.ShareMountTargetVirtualNetworkInterfacePrototypeVirtualNetworkInterfacePrototypeShareMountTargetContext) - shareMountTargetVirtualNetworkInterfacePrototypeModel.AllowIPSpoofing = core.BoolPtr(true) - shareMountTargetVirtualNetworkInterfacePrototypeModel.AutoDelete = core.BoolPtr(false) - shareMountTargetVirtualNetworkInterfacePrototypeModel.EnableInfrastructureNat = core.BoolPtr(true) - shareMountTargetVirtualNetworkInterfacePrototypeModel.Ips = []vpcv1.VirtualNetworkInterfaceIPPrototypeIntf{virtualNetworkInterfaceIPPrototypeModel} - shareMountTargetVirtualNetworkInterfacePrototypeModel.Name = core.StringPtr("my-virtual-network-interface") - shareMountTargetVirtualNetworkInterfacePrototypeModel.PrimaryIP = virtualNetworkInterfacePrimaryIPPrototypeModel - shareMountTargetVirtualNetworkInterfacePrototypeModel.ResourceGroup = resourceGroupIdentityModel - shareMountTargetVirtualNetworkInterfacePrototypeModel.SecurityGroups = []vpcv1.SecurityGroupIdentityIntf{securityGroupIdentityModel} - shareMountTargetVirtualNetworkInterfacePrototypeModel.Subnet = subnetIdentityModel - - // Construct an instance of the ShareMountTargetPrototypeShareMountTargetByAccessControlModeSecurityGroup model - shareMountTargetPrototypeModel := new(vpcv1.ShareMountTargetPrototypeShareMountTargetByAccessControlModeSecurityGroup) - shareMountTargetPrototypeModel.Name = core.StringPtr("my-share-mount-target") - shareMountTargetPrototypeModel.TransitEncryption = core.StringPtr("none") - shareMountTargetPrototypeModel.VirtualNetworkInterface = shareMountTargetVirtualNetworkInterfacePrototypeModel - - // Construct an instance of the ShareProfileIdentityByName model - shareProfileIdentityModel := new(vpcv1.ShareProfileIdentityByName) - shareProfileIdentityModel.Name = core.StringPtr("tier-3iops") - - // Construct an instance of the ZoneIdentityByName model - zoneIdentityModel := new(vpcv1.ZoneIdentityByName) - zoneIdentityModel.Name = core.StringPtr("us-south-1") - - // Construct an instance of the SharePrototypeShareContext model - sharePrototypeShareContextModel := new(vpcv1.SharePrototypeShareContext) - sharePrototypeShareContextModel.Iops = core.Int64Ptr(int64(100)) - sharePrototypeShareContextModel.MountTargets = []vpcv1.ShareMountTargetPrototypeIntf{shareMountTargetPrototypeModel} - sharePrototypeShareContextModel.Name = core.StringPtr("my-share") - sharePrototypeShareContextModel.Profile = shareProfileIdentityModel - sharePrototypeShareContextModel.ReplicationCronSpec = core.StringPtr("0 */5 * * *") - sharePrototypeShareContextModel.ResourceGroup = resourceGroupIdentityModel - sharePrototypeShareContextModel.UserTags = []string{} - sharePrototypeShareContextModel.Zone = zoneIdentityModel - - // Construct an instance of the EncryptionKeyIdentityByCRN model - encryptionKeyIdentityModel := new(vpcv1.EncryptionKeyIdentityByCRN) - encryptionKeyIdentityModel.CRN = core.StringPtr("crn:v1:bluemix:public:kms:us-south:a/123456:e4a29d1a-2ef0-42a6-8fd2-350deb1c647e:key:5437653b-c4b1-447f-9646-b2a2a4cd6179") - - // Construct an instance of the ShareInitialOwner model - shareInitialOwnerModel := new(vpcv1.ShareInitialOwner) - shareInitialOwnerModel.Gid = core.Int64Ptr(int64(50)) - shareInitialOwnerModel.Uid = core.Int64Ptr(int64(50)) - - // Construct an instance of the SharePrototypeShareBySize model - sharePrototypeModel := new(vpcv1.SharePrototypeShareBySize) - sharePrototypeModel.Iops = core.Int64Ptr(int64(100)) - sharePrototypeModel.MountTargets = []vpcv1.ShareMountTargetPrototypeIntf{shareMountTargetPrototypeModel} - sharePrototypeModel.Name = core.StringPtr("my-share") - sharePrototypeModel.Profile = shareProfileIdentityModel - sharePrototypeModel.ReplicaShare = sharePrototypeShareContextModel - sharePrototypeModel.UserTags = []string{} - sharePrototypeModel.Zone = zoneIdentityModel - sharePrototypeModel.AccessControlMode = core.StringPtr("security_group") - sharePrototypeModel.EncryptionKey = encryptionKeyIdentityModel - sharePrototypeModel.InitialOwner = shareInitialOwnerModel - sharePrototypeModel.ResourceGroup = resourceGroupIdentityModel - sharePrototypeModel.Size = core.Int64Ptr(int64(200)) - - // Construct an instance of the CreateShareOptions model - createShareOptionsModel := new(vpcv1.CreateShareOptions) - createShareOptionsModel.SharePrototype = sharePrototypeModel - createShareOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the ListBackupPolicyJobsOptions model + listBackupPolicyJobsOptionsModel := new(vpcv1.ListBackupPolicyJobsOptions) + listBackupPolicyJobsOptionsModel.BackupPolicyID = core.StringPtr("testString") + listBackupPolicyJobsOptionsModel.Status = core.StringPtr("failed") + listBackupPolicyJobsOptionsModel.BackupPolicyPlanID = core.StringPtr("testString") + listBackupPolicyJobsOptionsModel.Start = core.StringPtr("testString") + listBackupPolicyJobsOptionsModel.Limit = core.Int64Ptr(int64(10)) + listBackupPolicyJobsOptionsModel.Sort = core.StringPtr("name") + listBackupPolicyJobsOptionsModel.SourceID = core.StringPtr("testString") + listBackupPolicyJobsOptionsModel.TargetSnapshotsID = core.StringPtr("testString") + listBackupPolicyJobsOptionsModel.TargetSnapshotsCRN = core.StringPtr("crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263") + listBackupPolicyJobsOptionsModel.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.CreateShareWithContext(ctx, createShareOptionsModel) + _, _, operationErr := vpcService.ListBackupPolicyJobsWithContext(ctx, listBackupPolicyJobsOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) // Disable retries and test again vpcService.DisableRetries() - result, response, operationErr := vpcService.CreateShare(createShareOptionsModel) + result, response, operationErr := vpcService.ListBackupPolicyJobs(listBackupPolicyJobsOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) @@ -60625,7 +60919,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.CreateShareWithContext(ctx, createShareOptionsModel) + _, _, operationErr = vpcService.ListBackupPolicyJobsWithContext(ctx, listBackupPolicyJobsOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) }) @@ -60639,34 +60933,26 @@ var _ = Describe(`VpcV1`, func() { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(createSharePath)) - 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.EscapedPath()).To(Equal(listBackupPolicyJobsPath)) + 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()["status"]).To(Equal([]string{"failed"})) + Expect(req.URL.Query()["backup_policy_plan.id"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["start"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["limit"]).To(Equal([]string{fmt.Sprint(int64(10))})) + Expect(req.URL.Query()["sort"]).To(Equal([]string{"name"})) + Expect(req.URL.Query()["source.id"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["target_snapshots[].id"]).To(Equal([]string{"testString"})) + Expect(req.URL.Query()["target_snapshots[].crn"]).To(Equal([]string{"crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263"})) // Set mock response res.Header().Set("Content-type", "application/json") - res.WriteHeader(201) - fmt.Fprintf(res, "%s", `{"access_control_mode": "security_group", "created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::share:0fe9e5d8-0a4d-4818-96ec-e99708644a58", "encryption": "provider_managed", "encryption_key": {"crn": "crn:v1:bluemix:public:kms:us-south:a/123456:e4a29d1a-2ef0-42a6-8fd2-350deb1c647e:key:5437653b-c4b1-447f-9646-b2a2a4cd6179"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/shares/0fe9e5d8-0a4d-4818-96ec-e99708644a58", "id": "0fe9e5d8-0a4d-4818-96ec-e99708644a58", "iops": 100, "latest_job": {"status": "cancelled", "status_reasons": [{"code": "cannot_reach_source_share", "message": "The replication failover failed because the source share cannot be reached.", "more_info": "https://cloud.ibm.com/docs/vpc?topic=vpc-file-storage-planning"}], "type": "replication_failover"}, "latest_sync": {"completed_at": "2019-01-01T12:00:00.000Z", "data_transferred": 0, "started_at": "2019-01-01T12:00:00.000Z"}, "lifecycle_state": "stable", "mount_targets": [{"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/shares/0fe9e5d8-0a4d-4818-96ec-e99708644a58/mount_targets/4cf9171a-0043-4434-8727-15b53dbc374c", "id": "4cf9171a-0043-4434-8727-15b53dbc374c", "name": "my-share-mount-target", "resource_type": "share_mount_target"}], "name": "my-share", "profile": {"href": "https://us-south.iaas.cloud.ibm.com/v1/share/profiles/tier-3iops", "name": "tier-3iops", "resource_type": "share_profile"}, "replica_share": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::share:0fe9e5d8-0a4d-4818-96ec-e99708644a58", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/shares/0fe9e5d8-0a4d-4818-96ec-e99708644a58", "id": "0fe9e5d8-0a4d-4818-96ec-e99708644a58", "name": "my-share", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "share"}, "replication_cron_spec": "0 */5 * * *", "replication_role": "none", "replication_status": "active", "replication_status_reasons": [{"code": "cannot_reach_source_share", "message": "The replication failover failed because the source share cannot be reached.", "more_info": "https://cloud.ibm.com/docs/vpc?topic=vpc-file-storage-planning"}], "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "resource_type": "share", "size": 200, "source_share": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::share:0fe9e5d8-0a4d-4818-96ec-e99708644a58", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/shares/0fe9e5d8-0a4d-4818-96ec-e99708644a58", "id": "0fe9e5d8-0a4d-4818-96ec-e99708644a58", "name": "my-share", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "share"}, "user_tags": ["UserTags"], "zone": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south/zones/us-south-1", "name": "us-south-1"}}`) + res.WriteHeader(200) + fmt.Fprintf(res, "%s", `{"first": {"href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies/7241e2a8-601f-11ea-8503-000c29475bed/jobs?limit=20"}, "jobs": [{"auto_delete": true, "auto_delete_after": 90, "backup_policy_plan": {"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6/plans/r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "id": "r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "name": "my-policy-plan", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "backup_policy_plan"}, "completed_at": "2019-01-01T12:00:00.000Z", "created_at": "2019-01-01T12:00:00.000Z", "href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies/0fe9e5d8-0a4d-4818-96ec-e99708644a58/jobs/4cf9171a-0043-4434-8727-15b53dbc374c", "id": "4cf9171a-0043-4434-8727-15b53dbc374c", "job_type": "creation", "resource_type": "backup_policy_job", "source": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::volume:1a6b7274-678d-4dfb-8981-c71dd9d4daa5", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/volumes/1a6b7274-678d-4dfb-8981-c71dd9d4daa5", "id": "1a6b7274-678d-4dfb-8981-c71dd9d4daa5", "name": "my-volume", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "volume"}, "status": "failed", "status_reasons": [{"code": "source_volume_busy", "message": "Message", "more_info": "https://cloud.ibm.com/docs/vpc?topic=vpc-troubleshooting-backup-for-vpc"}], "target_snapshots": [{"crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "id": "r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "name": "my-snapshot", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "snapshot"}]}], "limit": 20, "next": {"href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies/7241e2a8-601f-11ea-8503-000c29475bed/jobss?start=9d5a91a3e2cbd233b5a5b33436855ed1&limit=20"}, "total_count": 132}`) })) }) - It(`Invoke CreateShare successfully`, func() { + It(`Invoke ListBackupPolicyJobs successfully`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -60676,109 +60962,32 @@ var _ = Describe(`VpcV1`, func() { Expect(vpcService).ToNot(BeNil()) // Invoke operation with nil options model (negative test) - result, response, operationErr := vpcService.CreateShare(nil) + result, response, operationErr := vpcService.ListBackupPolicyJobs(nil) Expect(operationErr).NotTo(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) - // Construct an instance of the VirtualNetworkInterfaceIPPrototypeReservedIPPrototypeVirtualNetworkInterfaceIPsContext model - virtualNetworkInterfaceIPPrototypeModel := new(vpcv1.VirtualNetworkInterfaceIPPrototypeReservedIPPrototypeVirtualNetworkInterfaceIPsContext) - virtualNetworkInterfaceIPPrototypeModel.Address = core.StringPtr("10.0.0.5") - virtualNetworkInterfaceIPPrototypeModel.AutoDelete = core.BoolPtr(false) - virtualNetworkInterfaceIPPrototypeModel.Name = core.StringPtr("my-reserved-ip") - - // Construct an instance of the VirtualNetworkInterfacePrimaryIPPrototypeReservedIPPrototypeVirtualNetworkInterfacePrimaryIPContext model - virtualNetworkInterfacePrimaryIPPrototypeModel := new(vpcv1.VirtualNetworkInterfacePrimaryIPPrototypeReservedIPPrototypeVirtualNetworkInterfacePrimaryIPContext) - virtualNetworkInterfacePrimaryIPPrototypeModel.Address = core.StringPtr("10.0.0.5") - virtualNetworkInterfacePrimaryIPPrototypeModel.AutoDelete = core.BoolPtr(false) - virtualNetworkInterfacePrimaryIPPrototypeModel.Name = core.StringPtr("my-reserved-ip") - - // Construct an instance of the ResourceGroupIdentityByID model - resourceGroupIdentityModel := new(vpcv1.ResourceGroupIdentityByID) - resourceGroupIdentityModel.ID = core.StringPtr("fee82deba12e4c0fb69c3b09d1f12345") - - // Construct an instance of the SecurityGroupIdentityByID model - securityGroupIdentityModel := new(vpcv1.SecurityGroupIdentityByID) - securityGroupIdentityModel.ID = core.StringPtr("be5df5ca-12a0-494b-907e-aa6ec2bfa271") - - // Construct an instance of the SubnetIdentityByID model - subnetIdentityModel := new(vpcv1.SubnetIdentityByID) - subnetIdentityModel.ID = core.StringPtr("7ec86020-1c6e-4889-b3f0-a15f2e50f87e") - - // Construct an instance of the ShareMountTargetVirtualNetworkInterfacePrototypeVirtualNetworkInterfacePrototypeShareMountTargetContext model - shareMountTargetVirtualNetworkInterfacePrototypeModel := new(vpcv1.ShareMountTargetVirtualNetworkInterfacePrototypeVirtualNetworkInterfacePrototypeShareMountTargetContext) - shareMountTargetVirtualNetworkInterfacePrototypeModel.AllowIPSpoofing = core.BoolPtr(true) - shareMountTargetVirtualNetworkInterfacePrototypeModel.AutoDelete = core.BoolPtr(false) - shareMountTargetVirtualNetworkInterfacePrototypeModel.EnableInfrastructureNat = core.BoolPtr(true) - shareMountTargetVirtualNetworkInterfacePrototypeModel.Ips = []vpcv1.VirtualNetworkInterfaceIPPrototypeIntf{virtualNetworkInterfaceIPPrototypeModel} - shareMountTargetVirtualNetworkInterfacePrototypeModel.Name = core.StringPtr("my-virtual-network-interface") - shareMountTargetVirtualNetworkInterfacePrototypeModel.PrimaryIP = virtualNetworkInterfacePrimaryIPPrototypeModel - shareMountTargetVirtualNetworkInterfacePrototypeModel.ResourceGroup = resourceGroupIdentityModel - shareMountTargetVirtualNetworkInterfacePrototypeModel.SecurityGroups = []vpcv1.SecurityGroupIdentityIntf{securityGroupIdentityModel} - shareMountTargetVirtualNetworkInterfacePrototypeModel.Subnet = subnetIdentityModel - - // Construct an instance of the ShareMountTargetPrototypeShareMountTargetByAccessControlModeSecurityGroup model - shareMountTargetPrototypeModel := new(vpcv1.ShareMountTargetPrototypeShareMountTargetByAccessControlModeSecurityGroup) - shareMountTargetPrototypeModel.Name = core.StringPtr("my-share-mount-target") - shareMountTargetPrototypeModel.TransitEncryption = core.StringPtr("none") - shareMountTargetPrototypeModel.VirtualNetworkInterface = shareMountTargetVirtualNetworkInterfacePrototypeModel - - // Construct an instance of the ShareProfileIdentityByName model - shareProfileIdentityModel := new(vpcv1.ShareProfileIdentityByName) - shareProfileIdentityModel.Name = core.StringPtr("tier-3iops") - - // Construct an instance of the ZoneIdentityByName model - zoneIdentityModel := new(vpcv1.ZoneIdentityByName) - zoneIdentityModel.Name = core.StringPtr("us-south-1") - - // Construct an instance of the SharePrototypeShareContext model - sharePrototypeShareContextModel := new(vpcv1.SharePrototypeShareContext) - sharePrototypeShareContextModel.Iops = core.Int64Ptr(int64(100)) - sharePrototypeShareContextModel.MountTargets = []vpcv1.ShareMountTargetPrototypeIntf{shareMountTargetPrototypeModel} - sharePrototypeShareContextModel.Name = core.StringPtr("my-share") - sharePrototypeShareContextModel.Profile = shareProfileIdentityModel - sharePrototypeShareContextModel.ReplicationCronSpec = core.StringPtr("0 */5 * * *") - sharePrototypeShareContextModel.ResourceGroup = resourceGroupIdentityModel - sharePrototypeShareContextModel.UserTags = []string{} - sharePrototypeShareContextModel.Zone = zoneIdentityModel - - // Construct an instance of the EncryptionKeyIdentityByCRN model - encryptionKeyIdentityModel := new(vpcv1.EncryptionKeyIdentityByCRN) - encryptionKeyIdentityModel.CRN = core.StringPtr("crn:v1:bluemix:public:kms:us-south:a/123456:e4a29d1a-2ef0-42a6-8fd2-350deb1c647e:key:5437653b-c4b1-447f-9646-b2a2a4cd6179") - - // Construct an instance of the ShareInitialOwner model - shareInitialOwnerModel := new(vpcv1.ShareInitialOwner) - shareInitialOwnerModel.Gid = core.Int64Ptr(int64(50)) - shareInitialOwnerModel.Uid = core.Int64Ptr(int64(50)) - - // Construct an instance of the SharePrototypeShareBySize model - sharePrototypeModel := new(vpcv1.SharePrototypeShareBySize) - sharePrototypeModel.Iops = core.Int64Ptr(int64(100)) - sharePrototypeModel.MountTargets = []vpcv1.ShareMountTargetPrototypeIntf{shareMountTargetPrototypeModel} - sharePrototypeModel.Name = core.StringPtr("my-share") - sharePrototypeModel.Profile = shareProfileIdentityModel - sharePrototypeModel.ReplicaShare = sharePrototypeShareContextModel - sharePrototypeModel.UserTags = []string{} - sharePrototypeModel.Zone = zoneIdentityModel - sharePrototypeModel.AccessControlMode = core.StringPtr("security_group") - sharePrototypeModel.EncryptionKey = encryptionKeyIdentityModel - sharePrototypeModel.InitialOwner = shareInitialOwnerModel - sharePrototypeModel.ResourceGroup = resourceGroupIdentityModel - sharePrototypeModel.Size = core.Int64Ptr(int64(200)) - - // Construct an instance of the CreateShareOptions model - createShareOptionsModel := new(vpcv1.CreateShareOptions) - createShareOptionsModel.SharePrototype = sharePrototypeModel - createShareOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the ListBackupPolicyJobsOptions model + listBackupPolicyJobsOptionsModel := new(vpcv1.ListBackupPolicyJobsOptions) + listBackupPolicyJobsOptionsModel.BackupPolicyID = core.StringPtr("testString") + listBackupPolicyJobsOptionsModel.Status = core.StringPtr("failed") + listBackupPolicyJobsOptionsModel.BackupPolicyPlanID = core.StringPtr("testString") + listBackupPolicyJobsOptionsModel.Start = core.StringPtr("testString") + listBackupPolicyJobsOptionsModel.Limit = core.Int64Ptr(int64(10)) + listBackupPolicyJobsOptionsModel.Sort = core.StringPtr("name") + listBackupPolicyJobsOptionsModel.SourceID = core.StringPtr("testString") + listBackupPolicyJobsOptionsModel.TargetSnapshotsID = core.StringPtr("testString") + listBackupPolicyJobsOptionsModel.TargetSnapshotsCRN = core.StringPtr("crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263") + listBackupPolicyJobsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with valid options model (positive test) - result, response, operationErr = vpcService.CreateShare(createShareOptionsModel) + result, response, operationErr = vpcService.ListBackupPolicyJobs(listBackupPolicyJobsOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) }) - It(`Invoke CreateShare with error: Operation validation and request error`, func() { + It(`Invoke ListBackupPolicyJobs with error: Operation validation and request error`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -60787,107 +60996,30 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the VirtualNetworkInterfaceIPPrototypeReservedIPPrototypeVirtualNetworkInterfaceIPsContext model - virtualNetworkInterfaceIPPrototypeModel := new(vpcv1.VirtualNetworkInterfaceIPPrototypeReservedIPPrototypeVirtualNetworkInterfaceIPsContext) - virtualNetworkInterfaceIPPrototypeModel.Address = core.StringPtr("10.0.0.5") - virtualNetworkInterfaceIPPrototypeModel.AutoDelete = core.BoolPtr(false) - virtualNetworkInterfaceIPPrototypeModel.Name = core.StringPtr("my-reserved-ip") - - // Construct an instance of the VirtualNetworkInterfacePrimaryIPPrototypeReservedIPPrototypeVirtualNetworkInterfacePrimaryIPContext model - virtualNetworkInterfacePrimaryIPPrototypeModel := new(vpcv1.VirtualNetworkInterfacePrimaryIPPrototypeReservedIPPrototypeVirtualNetworkInterfacePrimaryIPContext) - virtualNetworkInterfacePrimaryIPPrototypeModel.Address = core.StringPtr("10.0.0.5") - virtualNetworkInterfacePrimaryIPPrototypeModel.AutoDelete = core.BoolPtr(false) - virtualNetworkInterfacePrimaryIPPrototypeModel.Name = core.StringPtr("my-reserved-ip") - - // Construct an instance of the ResourceGroupIdentityByID model - resourceGroupIdentityModel := new(vpcv1.ResourceGroupIdentityByID) - resourceGroupIdentityModel.ID = core.StringPtr("fee82deba12e4c0fb69c3b09d1f12345") - - // Construct an instance of the SecurityGroupIdentityByID model - securityGroupIdentityModel := new(vpcv1.SecurityGroupIdentityByID) - securityGroupIdentityModel.ID = core.StringPtr("be5df5ca-12a0-494b-907e-aa6ec2bfa271") - - // Construct an instance of the SubnetIdentityByID model - subnetIdentityModel := new(vpcv1.SubnetIdentityByID) - subnetIdentityModel.ID = core.StringPtr("7ec86020-1c6e-4889-b3f0-a15f2e50f87e") - - // Construct an instance of the ShareMountTargetVirtualNetworkInterfacePrototypeVirtualNetworkInterfacePrototypeShareMountTargetContext model - shareMountTargetVirtualNetworkInterfacePrototypeModel := new(vpcv1.ShareMountTargetVirtualNetworkInterfacePrototypeVirtualNetworkInterfacePrototypeShareMountTargetContext) - shareMountTargetVirtualNetworkInterfacePrototypeModel.AllowIPSpoofing = core.BoolPtr(true) - shareMountTargetVirtualNetworkInterfacePrototypeModel.AutoDelete = core.BoolPtr(false) - shareMountTargetVirtualNetworkInterfacePrototypeModel.EnableInfrastructureNat = core.BoolPtr(true) - shareMountTargetVirtualNetworkInterfacePrototypeModel.Ips = []vpcv1.VirtualNetworkInterfaceIPPrototypeIntf{virtualNetworkInterfaceIPPrototypeModel} - shareMountTargetVirtualNetworkInterfacePrototypeModel.Name = core.StringPtr("my-virtual-network-interface") - shareMountTargetVirtualNetworkInterfacePrototypeModel.PrimaryIP = virtualNetworkInterfacePrimaryIPPrototypeModel - shareMountTargetVirtualNetworkInterfacePrototypeModel.ResourceGroup = resourceGroupIdentityModel - shareMountTargetVirtualNetworkInterfacePrototypeModel.SecurityGroups = []vpcv1.SecurityGroupIdentityIntf{securityGroupIdentityModel} - shareMountTargetVirtualNetworkInterfacePrototypeModel.Subnet = subnetIdentityModel - - // Construct an instance of the ShareMountTargetPrototypeShareMountTargetByAccessControlModeSecurityGroup model - shareMountTargetPrototypeModel := new(vpcv1.ShareMountTargetPrototypeShareMountTargetByAccessControlModeSecurityGroup) - shareMountTargetPrototypeModel.Name = core.StringPtr("my-share-mount-target") - shareMountTargetPrototypeModel.TransitEncryption = core.StringPtr("none") - shareMountTargetPrototypeModel.VirtualNetworkInterface = shareMountTargetVirtualNetworkInterfacePrototypeModel - - // Construct an instance of the ShareProfileIdentityByName model - shareProfileIdentityModel := new(vpcv1.ShareProfileIdentityByName) - shareProfileIdentityModel.Name = core.StringPtr("tier-3iops") - - // Construct an instance of the ZoneIdentityByName model - zoneIdentityModel := new(vpcv1.ZoneIdentityByName) - zoneIdentityModel.Name = core.StringPtr("us-south-1") - - // Construct an instance of the SharePrototypeShareContext model - sharePrototypeShareContextModel := new(vpcv1.SharePrototypeShareContext) - sharePrototypeShareContextModel.Iops = core.Int64Ptr(int64(100)) - sharePrototypeShareContextModel.MountTargets = []vpcv1.ShareMountTargetPrototypeIntf{shareMountTargetPrototypeModel} - sharePrototypeShareContextModel.Name = core.StringPtr("my-share") - sharePrototypeShareContextModel.Profile = shareProfileIdentityModel - sharePrototypeShareContextModel.ReplicationCronSpec = core.StringPtr("0 */5 * * *") - sharePrototypeShareContextModel.ResourceGroup = resourceGroupIdentityModel - sharePrototypeShareContextModel.UserTags = []string{} - sharePrototypeShareContextModel.Zone = zoneIdentityModel - - // Construct an instance of the EncryptionKeyIdentityByCRN model - encryptionKeyIdentityModel := new(vpcv1.EncryptionKeyIdentityByCRN) - encryptionKeyIdentityModel.CRN = core.StringPtr("crn:v1:bluemix:public:kms:us-south:a/123456:e4a29d1a-2ef0-42a6-8fd2-350deb1c647e:key:5437653b-c4b1-447f-9646-b2a2a4cd6179") - - // Construct an instance of the ShareInitialOwner model - shareInitialOwnerModel := new(vpcv1.ShareInitialOwner) - shareInitialOwnerModel.Gid = core.Int64Ptr(int64(50)) - shareInitialOwnerModel.Uid = core.Int64Ptr(int64(50)) - - // Construct an instance of the SharePrototypeShareBySize model - sharePrototypeModel := new(vpcv1.SharePrototypeShareBySize) - sharePrototypeModel.Iops = core.Int64Ptr(int64(100)) - sharePrototypeModel.MountTargets = []vpcv1.ShareMountTargetPrototypeIntf{shareMountTargetPrototypeModel} - sharePrototypeModel.Name = core.StringPtr("my-share") - sharePrototypeModel.Profile = shareProfileIdentityModel - sharePrototypeModel.ReplicaShare = sharePrototypeShareContextModel - sharePrototypeModel.UserTags = []string{} - sharePrototypeModel.Zone = zoneIdentityModel - sharePrototypeModel.AccessControlMode = core.StringPtr("security_group") - sharePrototypeModel.EncryptionKey = encryptionKeyIdentityModel - sharePrototypeModel.InitialOwner = shareInitialOwnerModel - sharePrototypeModel.ResourceGroup = resourceGroupIdentityModel - sharePrototypeModel.Size = core.Int64Ptr(int64(200)) - - // Construct an instance of the CreateShareOptions model - createShareOptionsModel := new(vpcv1.CreateShareOptions) - createShareOptionsModel.SharePrototype = sharePrototypeModel - createShareOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the ListBackupPolicyJobsOptions model + listBackupPolicyJobsOptionsModel := new(vpcv1.ListBackupPolicyJobsOptions) + listBackupPolicyJobsOptionsModel.BackupPolicyID = core.StringPtr("testString") + listBackupPolicyJobsOptionsModel.Status = core.StringPtr("failed") + listBackupPolicyJobsOptionsModel.BackupPolicyPlanID = core.StringPtr("testString") + listBackupPolicyJobsOptionsModel.Start = core.StringPtr("testString") + listBackupPolicyJobsOptionsModel.Limit = core.Int64Ptr(int64(10)) + listBackupPolicyJobsOptionsModel.Sort = core.StringPtr("name") + listBackupPolicyJobsOptionsModel.SourceID = core.StringPtr("testString") + listBackupPolicyJobsOptionsModel.TargetSnapshotsID = core.StringPtr("testString") + listBackupPolicyJobsOptionsModel.TargetSnapshotsCRN = core.StringPtr("crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263") + listBackupPolicyJobsOptionsModel.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.CreateShare(createShareOptionsModel) + result, response, operationErr := vpcService.ListBackupPolicyJobs(listBackupPolicyJobsOptionsModel) 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 CreateShareOptions model with no property values - createShareOptionsModelNew := new(vpcv1.CreateShareOptions) + // Construct a second instance of the ListBackupPolicyJobsOptions model with no property values + listBackupPolicyJobsOptionsModelNew := new(vpcv1.ListBackupPolicyJobsOptions) // Invoke operation with invalid model (negative test) - result, response, operationErr = vpcService.CreateShare(createShareOptionsModelNew) + result, response, operationErr = vpcService.ListBackupPolicyJobs(listBackupPolicyJobsOptionsModelNew) Expect(operationErr).ToNot(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) @@ -60902,10 +61034,10 @@ var _ = Describe(`VpcV1`, func() { defer GinkgoRecover() // Set success status code with no respoonse body - res.WriteHeader(201) + res.WriteHeader(200) })) }) - It(`Invoke CreateShare successfully`, func() { + It(`Invoke ListBackupPolicyJobs successfully`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -60914,130 +61046,166 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the VirtualNetworkInterfaceIPPrototypeReservedIPPrototypeVirtualNetworkInterfaceIPsContext model - virtualNetworkInterfaceIPPrototypeModel := new(vpcv1.VirtualNetworkInterfaceIPPrototypeReservedIPPrototypeVirtualNetworkInterfaceIPsContext) - virtualNetworkInterfaceIPPrototypeModel.Address = core.StringPtr("10.0.0.5") - virtualNetworkInterfaceIPPrototypeModel.AutoDelete = core.BoolPtr(false) - virtualNetworkInterfaceIPPrototypeModel.Name = core.StringPtr("my-reserved-ip") - - // Construct an instance of the VirtualNetworkInterfacePrimaryIPPrototypeReservedIPPrototypeVirtualNetworkInterfacePrimaryIPContext model - virtualNetworkInterfacePrimaryIPPrototypeModel := new(vpcv1.VirtualNetworkInterfacePrimaryIPPrototypeReservedIPPrototypeVirtualNetworkInterfacePrimaryIPContext) - virtualNetworkInterfacePrimaryIPPrototypeModel.Address = core.StringPtr("10.0.0.5") - virtualNetworkInterfacePrimaryIPPrototypeModel.AutoDelete = core.BoolPtr(false) - virtualNetworkInterfacePrimaryIPPrototypeModel.Name = core.StringPtr("my-reserved-ip") - - // Construct an instance of the ResourceGroupIdentityByID model - resourceGroupIdentityModel := new(vpcv1.ResourceGroupIdentityByID) - resourceGroupIdentityModel.ID = core.StringPtr("fee82deba12e4c0fb69c3b09d1f12345") + // Construct an instance of the ListBackupPolicyJobsOptions model + listBackupPolicyJobsOptionsModel := new(vpcv1.ListBackupPolicyJobsOptions) + listBackupPolicyJobsOptionsModel.BackupPolicyID = core.StringPtr("testString") + listBackupPolicyJobsOptionsModel.Status = core.StringPtr("failed") + listBackupPolicyJobsOptionsModel.BackupPolicyPlanID = core.StringPtr("testString") + listBackupPolicyJobsOptionsModel.Start = core.StringPtr("testString") + listBackupPolicyJobsOptionsModel.Limit = core.Int64Ptr(int64(10)) + listBackupPolicyJobsOptionsModel.Sort = core.StringPtr("name") + listBackupPolicyJobsOptionsModel.SourceID = core.StringPtr("testString") + listBackupPolicyJobsOptionsModel.TargetSnapshotsID = core.StringPtr("testString") + listBackupPolicyJobsOptionsModel.TargetSnapshotsCRN = core.StringPtr("crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263") + listBackupPolicyJobsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} - // Construct an instance of the SecurityGroupIdentityByID model - securityGroupIdentityModel := new(vpcv1.SecurityGroupIdentityByID) - securityGroupIdentityModel.ID = core.StringPtr("be5df5ca-12a0-494b-907e-aa6ec2bfa271") + // Invoke operation + result, response, operationErr := vpcService.ListBackupPolicyJobs(listBackupPolicyJobsOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) - // Construct an instance of the SubnetIdentityByID model - subnetIdentityModel := new(vpcv1.SubnetIdentityByID) - subnetIdentityModel.ID = core.StringPtr("7ec86020-1c6e-4889-b3f0-a15f2e50f87e") + // 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.BackupPolicyJobCollection) + nextObject := new(vpcv1.BackupPolicyJobCollectionNext) + nextObject.Href = core.StringPtr("ibm.com?start=abc-123") + responseObject.Next = nextObject - // Construct an instance of the ShareMountTargetVirtualNetworkInterfacePrototypeVirtualNetworkInterfacePrototypeShareMountTargetContext model - shareMountTargetVirtualNetworkInterfacePrototypeModel := new(vpcv1.ShareMountTargetVirtualNetworkInterfacePrototypeVirtualNetworkInterfacePrototypeShareMountTargetContext) - shareMountTargetVirtualNetworkInterfacePrototypeModel.AllowIPSpoofing = core.BoolPtr(true) - shareMountTargetVirtualNetworkInterfacePrototypeModel.AutoDelete = core.BoolPtr(false) - shareMountTargetVirtualNetworkInterfacePrototypeModel.EnableInfrastructureNat = core.BoolPtr(true) - shareMountTargetVirtualNetworkInterfacePrototypeModel.Ips = []vpcv1.VirtualNetworkInterfaceIPPrototypeIntf{virtualNetworkInterfaceIPPrototypeModel} - shareMountTargetVirtualNetworkInterfacePrototypeModel.Name = core.StringPtr("my-virtual-network-interface") - shareMountTargetVirtualNetworkInterfacePrototypeModel.PrimaryIP = virtualNetworkInterfacePrimaryIPPrototypeModel - shareMountTargetVirtualNetworkInterfacePrototypeModel.ResourceGroup = resourceGroupIdentityModel - shareMountTargetVirtualNetworkInterfacePrototypeModel.SecurityGroups = []vpcv1.SecurityGroupIdentityIntf{securityGroupIdentityModel} - shareMountTargetVirtualNetworkInterfacePrototypeModel.Subnet = subnetIdentityModel + 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.BackupPolicyJobCollection) - // Construct an instance of the ShareMountTargetPrototypeShareMountTargetByAccessControlModeSecurityGroup model - shareMountTargetPrototypeModel := new(vpcv1.ShareMountTargetPrototypeShareMountTargetByAccessControlModeSecurityGroup) - shareMountTargetPrototypeModel.Name = core.StringPtr("my-share-mount-target") - shareMountTargetPrototypeModel.TransitEncryption = core.StringPtr("none") - shareMountTargetPrototypeModel.VirtualNetworkInterface = shareMountTargetVirtualNetworkInterfacePrototypeModel + 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.BackupPolicyJobCollection) + nextObject := new(vpcv1.BackupPolicyJobCollectionNext) + nextObject.Href = core.StringPtr("ibm.com") + responseObject.Next = nextObject - // Construct an instance of the ShareProfileIdentityByName model - shareProfileIdentityModel := new(vpcv1.ShareProfileIdentityByName) - shareProfileIdentityModel.Name = core.StringPtr("tier-3iops") + value, err := responseObject.GetNextStart() + Expect(err).To(BeNil()) + Expect(value).To(BeNil()) + }) + }) + Context(`Using mock server endpoint - paginated response`, func() { + BeforeEach(func() { + var requestNumber int = 0 + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() - // Construct an instance of the ZoneIdentityByName model - zoneIdentityModel := new(vpcv1.ZoneIdentityByName) - zoneIdentityModel.Name = core.StringPtr("us-south-1") + // Verify the contents of the request + Expect(req.URL.EscapedPath()).To(Equal(listBackupPolicyJobsPath)) + Expect(req.Method).To(Equal("GET")) - // Construct an instance of the SharePrototypeShareContext model - sharePrototypeShareContextModel := new(vpcv1.SharePrototypeShareContext) - sharePrototypeShareContextModel.Iops = core.Int64Ptr(int64(100)) - sharePrototypeShareContextModel.MountTargets = []vpcv1.ShareMountTargetPrototypeIntf{shareMountTargetPrototypeModel} - sharePrototypeShareContextModel.Name = core.StringPtr("my-share") - sharePrototypeShareContextModel.Profile = shareProfileIdentityModel - sharePrototypeShareContextModel.ReplicationCronSpec = core.StringPtr("0 */5 * * *") - sharePrototypeShareContextModel.ResourceGroup = resourceGroupIdentityModel - sharePrototypeShareContextModel.UserTags = []string{} - sharePrototypeShareContextModel.Zone = zoneIdentityModel + // Set mock response + res.Header().Set("Content-type", "application/json") + res.WriteHeader(200) + requestNumber++ + if requestNumber == 1 { + fmt.Fprintf(res, "%s", `{"next":{"href":"https://myhost.com/somePath?start=1"},"total_count":2,"jobs":[{"auto_delete":true,"auto_delete_after":90,"backup_policy_plan":{"deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6/plans/r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178","id":"r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178","name":"my-policy-plan","remote":{"region":{"href":"https://us-south.iaas.cloud.ibm.com/v1/regions/us-south","name":"us-south"}},"resource_type":"backup_policy_plan"},"completed_at":"2019-01-01T12:00:00.000Z","created_at":"2019-01-01T12:00:00.000Z","href":"https://us-south.iaas.cloud.ibm.com/v1/backup_policies/0fe9e5d8-0a4d-4818-96ec-e99708644a58/jobs/4cf9171a-0043-4434-8727-15b53dbc374c","id":"4cf9171a-0043-4434-8727-15b53dbc374c","job_type":"creation","resource_type":"backup_policy_job","source":{"crn":"crn:v1:bluemix:public:is:us-south-1:a/123456::volume:1a6b7274-678d-4dfb-8981-c71dd9d4daa5","deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/volumes/1a6b7274-678d-4dfb-8981-c71dd9d4daa5","id":"1a6b7274-678d-4dfb-8981-c71dd9d4daa5","name":"my-volume","remote":{"region":{"href":"https://us-south.iaas.cloud.ibm.com/v1/regions/us-south","name":"us-south"}},"resource_type":"volume"},"status":"failed","status_reasons":[{"code":"source_volume_busy","message":"Message","more_info":"https://cloud.ibm.com/docs/vpc?topic=vpc-troubleshooting-backup-for-vpc"}],"target_snapshots":[{"crn":"crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263","deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263","id":"r134-f6bfa329-0e36-433f-a3bb-0df632e79263","name":"my-snapshot","remote":{"region":{"href":"https://us-south.iaas.cloud.ibm.com/v1/regions/us-south","name":"us-south"}},"resource_type":"snapshot"}]}],"limit":1}`) + } else if requestNumber == 2 { + fmt.Fprintf(res, "%s", `{"total_count":2,"jobs":[{"auto_delete":true,"auto_delete_after":90,"backup_policy_plan":{"deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6/plans/r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178","id":"r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178","name":"my-policy-plan","remote":{"region":{"href":"https://us-south.iaas.cloud.ibm.com/v1/regions/us-south","name":"us-south"}},"resource_type":"backup_policy_plan"},"completed_at":"2019-01-01T12:00:00.000Z","created_at":"2019-01-01T12:00:00.000Z","href":"https://us-south.iaas.cloud.ibm.com/v1/backup_policies/0fe9e5d8-0a4d-4818-96ec-e99708644a58/jobs/4cf9171a-0043-4434-8727-15b53dbc374c","id":"4cf9171a-0043-4434-8727-15b53dbc374c","job_type":"creation","resource_type":"backup_policy_job","source":{"crn":"crn:v1:bluemix:public:is:us-south-1:a/123456::volume:1a6b7274-678d-4dfb-8981-c71dd9d4daa5","deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/volumes/1a6b7274-678d-4dfb-8981-c71dd9d4daa5","id":"1a6b7274-678d-4dfb-8981-c71dd9d4daa5","name":"my-volume","remote":{"region":{"href":"https://us-south.iaas.cloud.ibm.com/v1/regions/us-south","name":"us-south"}},"resource_type":"volume"},"status":"failed","status_reasons":[{"code":"source_volume_busy","message":"Message","more_info":"https://cloud.ibm.com/docs/vpc?topic=vpc-troubleshooting-backup-for-vpc"}],"target_snapshots":[{"crn":"crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263","deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263","id":"r134-f6bfa329-0e36-433f-a3bb-0df632e79263","name":"my-snapshot","remote":{"region":{"href":"https://us-south.iaas.cloud.ibm.com/v1/regions/us-south","name":"us-south"}},"resource_type":"snapshot"}]}],"limit":1}`) + } else { + res.WriteHeader(400) + } + })) + }) + It(`Use BackupPolicyJobsPager.GetNext successfully`, func() { + vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + Version: core.StringPtr(version), + }) + Expect(serviceErr).To(BeNil()) + Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the EncryptionKeyIdentityByCRN model - encryptionKeyIdentityModel := new(vpcv1.EncryptionKeyIdentityByCRN) - encryptionKeyIdentityModel.CRN = core.StringPtr("crn:v1:bluemix:public:kms:us-south:a/123456:e4a29d1a-2ef0-42a6-8fd2-350deb1c647e:key:5437653b-c4b1-447f-9646-b2a2a4cd6179") + listBackupPolicyJobsOptionsModel := &vpcv1.ListBackupPolicyJobsOptions{ + BackupPolicyID: core.StringPtr("testString"), + Status: core.StringPtr("failed"), + BackupPolicyPlanID: core.StringPtr("testString"), + Limit: core.Int64Ptr(int64(10)), + Sort: core.StringPtr("name"), + SourceID: core.StringPtr("testString"), + TargetSnapshotsID: core.StringPtr("testString"), + TargetSnapshotsCRN: core.StringPtr("crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263"), + } - // Construct an instance of the ShareInitialOwner model - shareInitialOwnerModel := new(vpcv1.ShareInitialOwner) - shareInitialOwnerModel.Gid = core.Int64Ptr(int64(50)) - shareInitialOwnerModel.Uid = core.Int64Ptr(int64(50)) + pager, err := vpcService.NewBackupPolicyJobsPager(listBackupPolicyJobsOptionsModel) + Expect(err).To(BeNil()) + Expect(pager).ToNot(BeNil()) - // Construct an instance of the SharePrototypeShareBySize model - sharePrototypeModel := new(vpcv1.SharePrototypeShareBySize) - sharePrototypeModel.Iops = core.Int64Ptr(int64(100)) - sharePrototypeModel.MountTargets = []vpcv1.ShareMountTargetPrototypeIntf{shareMountTargetPrototypeModel} - sharePrototypeModel.Name = core.StringPtr("my-share") - sharePrototypeModel.Profile = shareProfileIdentityModel - sharePrototypeModel.ReplicaShare = sharePrototypeShareContextModel - sharePrototypeModel.UserTags = []string{} - sharePrototypeModel.Zone = zoneIdentityModel - sharePrototypeModel.AccessControlMode = core.StringPtr("security_group") - sharePrototypeModel.EncryptionKey = encryptionKeyIdentityModel - sharePrototypeModel.InitialOwner = shareInitialOwnerModel - sharePrototypeModel.ResourceGroup = resourceGroupIdentityModel - sharePrototypeModel.Size = core.Int64Ptr(int64(200)) + var allResults []vpcv1.BackupPolicyJob + for pager.HasNext() { + nextPage, err := pager.GetNext() + Expect(err).To(BeNil()) + Expect(nextPage).ToNot(BeNil()) + allResults = append(allResults, nextPage...) + } + Expect(len(allResults)).To(Equal(2)) + }) + It(`Use BackupPolicyJobsPager.GetAll successfully`, func() { + vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + Version: core.StringPtr(version), + }) + Expect(serviceErr).To(BeNil()) + Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the CreateShareOptions model - createShareOptionsModel := new(vpcv1.CreateShareOptions) - createShareOptionsModel.SharePrototype = sharePrototypeModel - createShareOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + listBackupPolicyJobsOptionsModel := &vpcv1.ListBackupPolicyJobsOptions{ + BackupPolicyID: core.StringPtr("testString"), + Status: core.StringPtr("failed"), + BackupPolicyPlanID: core.StringPtr("testString"), + Limit: core.Int64Ptr(int64(10)), + Sort: core.StringPtr("name"), + SourceID: core.StringPtr("testString"), + TargetSnapshotsID: core.StringPtr("testString"), + TargetSnapshotsCRN: core.StringPtr("crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263"), + } - // Invoke operation - result, response, operationErr := vpcService.CreateShare(createShareOptionsModel) - Expect(operationErr).To(BeNil()) - Expect(response).ToNot(BeNil()) + pager, err := vpcService.NewBackupPolicyJobsPager(listBackupPolicyJobsOptionsModel) + Expect(err).To(BeNil()) + Expect(pager).ToNot(BeNil()) - // Verify a nil result - Expect(result).To(BeNil()) - }) - AfterEach(func() { - testServer.Close() + allResults, err := pager.GetAll() + Expect(err).To(BeNil()) + Expect(allResults).ToNot(BeNil()) + Expect(len(allResults)).To(Equal(2)) }) }) }) - Describe(`DeleteShare(deleteShareOptions *DeleteShareOptions) - Operation response error`, func() { + Describe(`GetBackupPolicyJob(getBackupPolicyJobOptions *GetBackupPolicyJobOptions) - Operation response error`, func() { version := "testString" - deleteSharePath := "/shares/testString" + getBackupPolicyJobPath := "/backup_policies/testString/jobs/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(deleteSharePath)) - 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.EscapedPath()).To(Equal(getBackupPolicyJobPath)) + 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(202) + res.WriteHeader(200) fmt.Fprint(res, `} this is not valid json {`) })) }) - It(`Invoke DeleteShare with error: Operation response processing error`, func() { + It(`Invoke GetBackupPolicyJob with error: Operation response processing error`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -61046,20 +61214,20 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the DeleteShareOptions model - deleteShareOptionsModel := new(vpcv1.DeleteShareOptions) - deleteShareOptionsModel.ID = core.StringPtr("testString") - deleteShareOptionsModel.IfMatch = core.StringPtr(`W/"96d225c4-56bd-43d9-98fc-d7148e5c5028"`) - deleteShareOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the GetBackupPolicyJobOptions model + getBackupPolicyJobOptionsModel := new(vpcv1.GetBackupPolicyJobOptions) + getBackupPolicyJobOptionsModel.BackupPolicyID = core.StringPtr("testString") + getBackupPolicyJobOptionsModel.ID = core.StringPtr("testString") + getBackupPolicyJobOptionsModel.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.DeleteShare(deleteShareOptionsModel) + result, response, operationErr := vpcService.GetBackupPolicyJob(getBackupPolicyJobOptionsModel) 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.DeleteShare(deleteShareOptionsModel) + result, response, operationErr = vpcService.GetBackupPolicyJob(getBackupPolicyJobOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).To(BeNil()) @@ -61069,20 +61237,18 @@ var _ = Describe(`VpcV1`, func() { }) }) }) - Describe(`DeleteShare(deleteShareOptions *DeleteShareOptions)`, func() { + Describe(`GetBackupPolicyJob(getBackupPolicyJobOptions *GetBackupPolicyJobOptions)`, func() { version := "testString" - deleteSharePath := "/shares/testString" + getBackupPolicyJobPath := "/backup_policies/testString/jobs/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(deleteSharePath)) - Expect(req.Method).To(Equal("DELETE")) + Expect(req.URL.EscapedPath()).To(Equal(getBackupPolicyJobPath)) + Expect(req.Method).To(Equal("GET")) - 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 @@ -61090,11 +61256,11 @@ var _ = Describe(`VpcV1`, func() { // Set mock response res.Header().Set("Content-type", "application/json") - res.WriteHeader(202) - fmt.Fprintf(res, "%s", `{"access_control_mode": "security_group", "created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::share:0fe9e5d8-0a4d-4818-96ec-e99708644a58", "encryption": "provider_managed", "encryption_key": {"crn": "crn:v1:bluemix:public:kms:us-south:a/123456:e4a29d1a-2ef0-42a6-8fd2-350deb1c647e:key:5437653b-c4b1-447f-9646-b2a2a4cd6179"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/shares/0fe9e5d8-0a4d-4818-96ec-e99708644a58", "id": "0fe9e5d8-0a4d-4818-96ec-e99708644a58", "iops": 100, "latest_job": {"status": "cancelled", "status_reasons": [{"code": "cannot_reach_source_share", "message": "The replication failover failed because the source share cannot be reached.", "more_info": "https://cloud.ibm.com/docs/vpc?topic=vpc-file-storage-planning"}], "type": "replication_failover"}, "latest_sync": {"completed_at": "2019-01-01T12:00:00.000Z", "data_transferred": 0, "started_at": "2019-01-01T12:00:00.000Z"}, "lifecycle_state": "stable", "mount_targets": [{"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/shares/0fe9e5d8-0a4d-4818-96ec-e99708644a58/mount_targets/4cf9171a-0043-4434-8727-15b53dbc374c", "id": "4cf9171a-0043-4434-8727-15b53dbc374c", "name": "my-share-mount-target", "resource_type": "share_mount_target"}], "name": "my-share", "profile": {"href": "https://us-south.iaas.cloud.ibm.com/v1/share/profiles/tier-3iops", "name": "tier-3iops", "resource_type": "share_profile"}, "replica_share": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::share:0fe9e5d8-0a4d-4818-96ec-e99708644a58", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/shares/0fe9e5d8-0a4d-4818-96ec-e99708644a58", "id": "0fe9e5d8-0a4d-4818-96ec-e99708644a58", "name": "my-share", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "share"}, "replication_cron_spec": "0 */5 * * *", "replication_role": "none", "replication_status": "active", "replication_status_reasons": [{"code": "cannot_reach_source_share", "message": "The replication failover failed because the source share cannot be reached.", "more_info": "https://cloud.ibm.com/docs/vpc?topic=vpc-file-storage-planning"}], "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "resource_type": "share", "size": 200, "source_share": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::share:0fe9e5d8-0a4d-4818-96ec-e99708644a58", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/shares/0fe9e5d8-0a4d-4818-96ec-e99708644a58", "id": "0fe9e5d8-0a4d-4818-96ec-e99708644a58", "name": "my-share", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "share"}, "user_tags": ["UserTags"], "zone": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south/zones/us-south-1", "name": "us-south-1"}}`) + res.WriteHeader(200) + fmt.Fprintf(res, "%s", `{"auto_delete": true, "auto_delete_after": 90, "backup_policy_plan": {"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6/plans/r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "id": "r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "name": "my-policy-plan", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "backup_policy_plan"}, "completed_at": "2019-01-01T12:00:00.000Z", "created_at": "2019-01-01T12:00:00.000Z", "href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies/0fe9e5d8-0a4d-4818-96ec-e99708644a58/jobs/4cf9171a-0043-4434-8727-15b53dbc374c", "id": "4cf9171a-0043-4434-8727-15b53dbc374c", "job_type": "creation", "resource_type": "backup_policy_job", "source": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::volume:1a6b7274-678d-4dfb-8981-c71dd9d4daa5", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/volumes/1a6b7274-678d-4dfb-8981-c71dd9d4daa5", "id": "1a6b7274-678d-4dfb-8981-c71dd9d4daa5", "name": "my-volume", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "volume"}, "status": "failed", "status_reasons": [{"code": "source_volume_busy", "message": "Message", "more_info": "https://cloud.ibm.com/docs/vpc?topic=vpc-troubleshooting-backup-for-vpc"}], "target_snapshots": [{"crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "id": "r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "name": "my-snapshot", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "snapshot"}]}`) })) }) - It(`Invoke DeleteShare successfully with retries`, func() { + It(`Invoke GetBackupPolicyJob successfully with retries`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -61104,22 +61270,22 @@ var _ = Describe(`VpcV1`, func() { Expect(vpcService).ToNot(BeNil()) vpcService.EnableRetries(0, 0) - // Construct an instance of the DeleteShareOptions model - deleteShareOptionsModel := new(vpcv1.DeleteShareOptions) - deleteShareOptionsModel.ID = core.StringPtr("testString") - deleteShareOptionsModel.IfMatch = core.StringPtr(`W/"96d225c4-56bd-43d9-98fc-d7148e5c5028"`) - deleteShareOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the GetBackupPolicyJobOptions model + getBackupPolicyJobOptionsModel := new(vpcv1.GetBackupPolicyJobOptions) + getBackupPolicyJobOptionsModel.BackupPolicyID = core.StringPtr("testString") + getBackupPolicyJobOptionsModel.ID = core.StringPtr("testString") + getBackupPolicyJobOptionsModel.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.DeleteShareWithContext(ctx, deleteShareOptionsModel) + _, _, operationErr := vpcService.GetBackupPolicyJobWithContext(ctx, getBackupPolicyJobOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) // Disable retries and test again vpcService.DisableRetries() - result, response, operationErr := vpcService.DeleteShare(deleteShareOptionsModel) + result, response, operationErr := vpcService.GetBackupPolicyJob(getBackupPolicyJobOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) @@ -61127,7 +61293,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.DeleteShareWithContext(ctx, deleteShareOptionsModel) + _, _, operationErr = vpcService.GetBackupPolicyJobWithContext(ctx, getBackupPolicyJobOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) }) @@ -61141,20 +61307,18 @@ var _ = Describe(`VpcV1`, func() { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(deleteSharePath)) - Expect(req.Method).To(Equal("DELETE")) + Expect(req.URL.EscapedPath()).To(Equal(getBackupPolicyJobPath)) + Expect(req.Method).To(Equal("GET")) - 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", `{"access_control_mode": "security_group", "created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::share:0fe9e5d8-0a4d-4818-96ec-e99708644a58", "encryption": "provider_managed", "encryption_key": {"crn": "crn:v1:bluemix:public:kms:us-south:a/123456:e4a29d1a-2ef0-42a6-8fd2-350deb1c647e:key:5437653b-c4b1-447f-9646-b2a2a4cd6179"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/shares/0fe9e5d8-0a4d-4818-96ec-e99708644a58", "id": "0fe9e5d8-0a4d-4818-96ec-e99708644a58", "iops": 100, "latest_job": {"status": "cancelled", "status_reasons": [{"code": "cannot_reach_source_share", "message": "The replication failover failed because the source share cannot be reached.", "more_info": "https://cloud.ibm.com/docs/vpc?topic=vpc-file-storage-planning"}], "type": "replication_failover"}, "latest_sync": {"completed_at": "2019-01-01T12:00:00.000Z", "data_transferred": 0, "started_at": "2019-01-01T12:00:00.000Z"}, "lifecycle_state": "stable", "mount_targets": [{"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/shares/0fe9e5d8-0a4d-4818-96ec-e99708644a58/mount_targets/4cf9171a-0043-4434-8727-15b53dbc374c", "id": "4cf9171a-0043-4434-8727-15b53dbc374c", "name": "my-share-mount-target", "resource_type": "share_mount_target"}], "name": "my-share", "profile": {"href": "https://us-south.iaas.cloud.ibm.com/v1/share/profiles/tier-3iops", "name": "tier-3iops", "resource_type": "share_profile"}, "replica_share": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::share:0fe9e5d8-0a4d-4818-96ec-e99708644a58", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/shares/0fe9e5d8-0a4d-4818-96ec-e99708644a58", "id": "0fe9e5d8-0a4d-4818-96ec-e99708644a58", "name": "my-share", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "share"}, "replication_cron_spec": "0 */5 * * *", "replication_role": "none", "replication_status": "active", "replication_status_reasons": [{"code": "cannot_reach_source_share", "message": "The replication failover failed because the source share cannot be reached.", "more_info": "https://cloud.ibm.com/docs/vpc?topic=vpc-file-storage-planning"}], "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "resource_type": "share", "size": 200, "source_share": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::share:0fe9e5d8-0a4d-4818-96ec-e99708644a58", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/shares/0fe9e5d8-0a4d-4818-96ec-e99708644a58", "id": "0fe9e5d8-0a4d-4818-96ec-e99708644a58", "name": "my-share", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "share"}, "user_tags": ["UserTags"], "zone": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south/zones/us-south-1", "name": "us-south-1"}}`) + res.WriteHeader(200) + fmt.Fprintf(res, "%s", `{"auto_delete": true, "auto_delete_after": 90, "backup_policy_plan": {"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6/plans/r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "id": "r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "name": "my-policy-plan", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "backup_policy_plan"}, "completed_at": "2019-01-01T12:00:00.000Z", "created_at": "2019-01-01T12:00:00.000Z", "href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies/0fe9e5d8-0a4d-4818-96ec-e99708644a58/jobs/4cf9171a-0043-4434-8727-15b53dbc374c", "id": "4cf9171a-0043-4434-8727-15b53dbc374c", "job_type": "creation", "resource_type": "backup_policy_job", "source": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::volume:1a6b7274-678d-4dfb-8981-c71dd9d4daa5", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/volumes/1a6b7274-678d-4dfb-8981-c71dd9d4daa5", "id": "1a6b7274-678d-4dfb-8981-c71dd9d4daa5", "name": "my-volume", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "volume"}, "status": "failed", "status_reasons": [{"code": "source_volume_busy", "message": "Message", "more_info": "https://cloud.ibm.com/docs/vpc?topic=vpc-troubleshooting-backup-for-vpc"}], "target_snapshots": [{"crn": "crn:v1:bluemix:public:is:us-south:a/123456::snapshot:r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/snapshots/r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "id": "r134-f6bfa329-0e36-433f-a3bb-0df632e79263", "name": "my-snapshot", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "snapshot"}]}`) })) }) - It(`Invoke DeleteShare successfully`, func() { + It(`Invoke GetBackupPolicyJob successfully`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -61164,25 +61328,25 @@ var _ = Describe(`VpcV1`, func() { Expect(vpcService).ToNot(BeNil()) // Invoke operation with nil options model (negative test) - result, response, operationErr := vpcService.DeleteShare(nil) + result, response, operationErr := vpcService.GetBackupPolicyJob(nil) Expect(operationErr).NotTo(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) - // Construct an instance of the DeleteShareOptions model - deleteShareOptionsModel := new(vpcv1.DeleteShareOptions) - deleteShareOptionsModel.ID = core.StringPtr("testString") - deleteShareOptionsModel.IfMatch = core.StringPtr(`W/"96d225c4-56bd-43d9-98fc-d7148e5c5028"`) - deleteShareOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the GetBackupPolicyJobOptions model + getBackupPolicyJobOptionsModel := new(vpcv1.GetBackupPolicyJobOptions) + getBackupPolicyJobOptionsModel.BackupPolicyID = core.StringPtr("testString") + getBackupPolicyJobOptionsModel.ID = core.StringPtr("testString") + getBackupPolicyJobOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with valid options model (positive test) - result, response, operationErr = vpcService.DeleteShare(deleteShareOptionsModel) + result, response, operationErr = vpcService.GetBackupPolicyJob(getBackupPolicyJobOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) }) - It(`Invoke DeleteShare with error: Operation validation and request error`, func() { + It(`Invoke GetBackupPolicyJob with error: Operation validation and request error`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -61191,23 +61355,23 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the DeleteShareOptions model - deleteShareOptionsModel := new(vpcv1.DeleteShareOptions) - deleteShareOptionsModel.ID = core.StringPtr("testString") - deleteShareOptionsModel.IfMatch = core.StringPtr(`W/"96d225c4-56bd-43d9-98fc-d7148e5c5028"`) - deleteShareOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the GetBackupPolicyJobOptions model + getBackupPolicyJobOptionsModel := new(vpcv1.GetBackupPolicyJobOptions) + getBackupPolicyJobOptionsModel.BackupPolicyID = core.StringPtr("testString") + getBackupPolicyJobOptionsModel.ID = core.StringPtr("testString") + getBackupPolicyJobOptionsModel.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.DeleteShare(deleteShareOptionsModel) + result, response, operationErr := vpcService.GetBackupPolicyJob(getBackupPolicyJobOptionsModel) 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 DeleteShareOptions model with no property values - deleteShareOptionsModelNew := new(vpcv1.DeleteShareOptions) + // Construct a second instance of the GetBackupPolicyJobOptions model with no property values + getBackupPolicyJobOptionsModelNew := new(vpcv1.GetBackupPolicyJobOptions) // Invoke operation with invalid model (negative test) - result, response, operationErr = vpcService.DeleteShare(deleteShareOptionsModelNew) + result, response, operationErr = vpcService.GetBackupPolicyJob(getBackupPolicyJobOptionsModelNew) Expect(operationErr).ToNot(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) @@ -61222,10 +61386,10 @@ var _ = Describe(`VpcV1`, func() { defer GinkgoRecover() // Set success status code with no respoonse body - res.WriteHeader(202) + res.WriteHeader(200) })) }) - It(`Invoke DeleteShare successfully`, func() { + It(`Invoke GetBackupPolicyJob successfully`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -61234,14 +61398,14 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the DeleteShareOptions model - deleteShareOptionsModel := new(vpcv1.DeleteShareOptions) - deleteShareOptionsModel.ID = core.StringPtr("testString") - deleteShareOptionsModel.IfMatch = core.StringPtr(`W/"96d225c4-56bd-43d9-98fc-d7148e5c5028"`) - deleteShareOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the GetBackupPolicyJobOptions model + getBackupPolicyJobOptionsModel := new(vpcv1.GetBackupPolicyJobOptions) + getBackupPolicyJobOptionsModel.BackupPolicyID = core.StringPtr("testString") + getBackupPolicyJobOptionsModel.ID = core.StringPtr("testString") + getBackupPolicyJobOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation - result, response, operationErr := vpcService.DeleteShare(deleteShareOptionsModel) + result, response, operationErr := vpcService.GetBackupPolicyJob(getBackupPolicyJobOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) @@ -61253,25 +61417,26 @@ var _ = Describe(`VpcV1`, func() { }) }) }) - Describe(`GetShare(getShareOptions *GetShareOptions) - Operation response error`, func() { + Describe(`ListBackupPolicyPlans(listBackupPolicyPlansOptions *ListBackupPolicyPlansOptions) - Operation response error`, func() { version := "testString" - getSharePath := "/shares/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(getSharePath)) + 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 GetShare 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{}, @@ -61280,19 +61445,20 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the GetShareOptions model - getShareOptionsModel := new(vpcv1.GetShareOptions) - getShareOptionsModel.ID = core.StringPtr("testString") - getShareOptionsModel.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.GetShare(getShareOptionsModel) + 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.GetShare(getShareOptionsModel) + result, response, operationErr = vpcService.ListBackupPolicyPlans(listBackupPolicyPlansOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).To(BeNil()) @@ -61302,30 +61468,31 @@ var _ = Describe(`VpcV1`, func() { }) }) }) - Describe(`GetShare(getShareOptions *GetShareOptions)`, func() { + Describe(`ListBackupPolicyPlans(listBackupPolicyPlansOptions *ListBackupPolicyPlansOptions)`, func() { version := "testString" - getSharePath := "/shares/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(getSharePath)) + 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", `{"access_control_mode": "security_group", "created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::share:0fe9e5d8-0a4d-4818-96ec-e99708644a58", "encryption": "provider_managed", "encryption_key": {"crn": "crn:v1:bluemix:public:kms:us-south:a/123456:e4a29d1a-2ef0-42a6-8fd2-350deb1c647e:key:5437653b-c4b1-447f-9646-b2a2a4cd6179"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/shares/0fe9e5d8-0a4d-4818-96ec-e99708644a58", "id": "0fe9e5d8-0a4d-4818-96ec-e99708644a58", "iops": 100, "latest_job": {"status": "cancelled", "status_reasons": [{"code": "cannot_reach_source_share", "message": "The replication failover failed because the source share cannot be reached.", "more_info": "https://cloud.ibm.com/docs/vpc?topic=vpc-file-storage-planning"}], "type": "replication_failover"}, "latest_sync": {"completed_at": "2019-01-01T12:00:00.000Z", "data_transferred": 0, "started_at": "2019-01-01T12:00:00.000Z"}, "lifecycle_state": "stable", "mount_targets": [{"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/shares/0fe9e5d8-0a4d-4818-96ec-e99708644a58/mount_targets/4cf9171a-0043-4434-8727-15b53dbc374c", "id": "4cf9171a-0043-4434-8727-15b53dbc374c", "name": "my-share-mount-target", "resource_type": "share_mount_target"}], "name": "my-share", "profile": {"href": "https://us-south.iaas.cloud.ibm.com/v1/share/profiles/tier-3iops", "name": "tier-3iops", "resource_type": "share_profile"}, "replica_share": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::share:0fe9e5d8-0a4d-4818-96ec-e99708644a58", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/shares/0fe9e5d8-0a4d-4818-96ec-e99708644a58", "id": "0fe9e5d8-0a4d-4818-96ec-e99708644a58", "name": "my-share", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "share"}, "replication_cron_spec": "0 */5 * * *", "replication_role": "none", "replication_status": "active", "replication_status_reasons": [{"code": "cannot_reach_source_share", "message": "The replication failover failed because the source share cannot be reached.", "more_info": "https://cloud.ibm.com/docs/vpc?topic=vpc-file-storage-planning"}], "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "resource_type": "share", "size": 200, "source_share": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::share:0fe9e5d8-0a4d-4818-96ec-e99708644a58", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/shares/0fe9e5d8-0a4d-4818-96ec-e99708644a58", "id": "0fe9e5d8-0a4d-4818-96ec-e99708644a58", "name": "my-share", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "share"}, "user_tags": ["UserTags"], "zone": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south/zones/us-south-1", "name": "us-south-1"}}`) + fmt.Fprintf(res, "%s", `{"first": {"href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6/plans?limit=20"}, "limit": 20, "next": {"href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6/plans?start=9d5a91a3e2cbd233b5a5b33436855ed1&limit=20"}, "plans": [{"active": true, "attach_user_tags": ["AttachUserTags"], "clone_policy": {"max_snapshots": 1, "zones": [{"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south/zones/us-south-1", "name": "us-south-1"}]}, "copy_user_tags": true, "created_at": "2019-01-01T12:00:00.000Z", "cron_spec": "30 */2 * * 1-5", "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", "remote_region_policies": [{"delete_over_count": 1, "encryption_key": {"crn": "crn:v1:bluemix:public:kms:us-south:a/123456:e4a29d1a-2ef0-42a6-8fd2-350deb1c647e:key:5437653b-c4b1-447f-9646-b2a2a4cd6179"}, "region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}], "resource_type": "backup_policy_plan"}], "total_count": 132}`) })) }) - It(`Invoke GetShare successfully with retries`, func() { + It(`Invoke ListBackupPolicyPlans successfully with retries`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -61335,21 +61502,22 @@ var _ = Describe(`VpcV1`, func() { Expect(vpcService).ToNot(BeNil()) vpcService.EnableRetries(0, 0) - // Construct an instance of the GetShareOptions model - getShareOptionsModel := new(vpcv1.GetShareOptions) - getShareOptionsModel.ID = core.StringPtr("testString") - getShareOptionsModel.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.GetShareWithContext(ctx, getShareOptionsModel) + _, _, 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.GetShare(getShareOptionsModel) + result, response, operationErr := vpcService.ListBackupPolicyPlans(listBackupPolicyPlansOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) @@ -61357,7 +61525,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.GetShareWithContext(ctx, getShareOptionsModel) + _, _, operationErr = vpcService.ListBackupPolicyPlansWithContext(ctx, listBackupPolicyPlansOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) }) @@ -61371,18 +61539,19 @@ var _ = Describe(`VpcV1`, func() { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(getSharePath)) + 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", `{"access_control_mode": "security_group", "created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::share:0fe9e5d8-0a4d-4818-96ec-e99708644a58", "encryption": "provider_managed", "encryption_key": {"crn": "crn:v1:bluemix:public:kms:us-south:a/123456:e4a29d1a-2ef0-42a6-8fd2-350deb1c647e:key:5437653b-c4b1-447f-9646-b2a2a4cd6179"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/shares/0fe9e5d8-0a4d-4818-96ec-e99708644a58", "id": "0fe9e5d8-0a4d-4818-96ec-e99708644a58", "iops": 100, "latest_job": {"status": "cancelled", "status_reasons": [{"code": "cannot_reach_source_share", "message": "The replication failover failed because the source share cannot be reached.", "more_info": "https://cloud.ibm.com/docs/vpc?topic=vpc-file-storage-planning"}], "type": "replication_failover"}, "latest_sync": {"completed_at": "2019-01-01T12:00:00.000Z", "data_transferred": 0, "started_at": "2019-01-01T12:00:00.000Z"}, "lifecycle_state": "stable", "mount_targets": [{"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/shares/0fe9e5d8-0a4d-4818-96ec-e99708644a58/mount_targets/4cf9171a-0043-4434-8727-15b53dbc374c", "id": "4cf9171a-0043-4434-8727-15b53dbc374c", "name": "my-share-mount-target", "resource_type": "share_mount_target"}], "name": "my-share", "profile": {"href": "https://us-south.iaas.cloud.ibm.com/v1/share/profiles/tier-3iops", "name": "tier-3iops", "resource_type": "share_profile"}, "replica_share": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::share:0fe9e5d8-0a4d-4818-96ec-e99708644a58", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/shares/0fe9e5d8-0a4d-4818-96ec-e99708644a58", "id": "0fe9e5d8-0a4d-4818-96ec-e99708644a58", "name": "my-share", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "share"}, "replication_cron_spec": "0 */5 * * *", "replication_role": "none", "replication_status": "active", "replication_status_reasons": [{"code": "cannot_reach_source_share", "message": "The replication failover failed because the source share cannot be reached.", "more_info": "https://cloud.ibm.com/docs/vpc?topic=vpc-file-storage-planning"}], "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "resource_type": "share", "size": 200, "source_share": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::share:0fe9e5d8-0a4d-4818-96ec-e99708644a58", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/shares/0fe9e5d8-0a4d-4818-96ec-e99708644a58", "id": "0fe9e5d8-0a4d-4818-96ec-e99708644a58", "name": "my-share", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "share"}, "user_tags": ["UserTags"], "zone": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south/zones/us-south-1", "name": "us-south-1"}}`) + fmt.Fprintf(res, "%s", `{"first": {"href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6/plans?limit=20"}, "limit": 20, "next": {"href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6/plans?start=9d5a91a3e2cbd233b5a5b33436855ed1&limit=20"}, "plans": [{"active": true, "attach_user_tags": ["AttachUserTags"], "clone_policy": {"max_snapshots": 1, "zones": [{"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south/zones/us-south-1", "name": "us-south-1"}]}, "copy_user_tags": true, "created_at": "2019-01-01T12:00:00.000Z", "cron_spec": "30 */2 * * 1-5", "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", "remote_region_policies": [{"delete_over_count": 1, "encryption_key": {"crn": "crn:v1:bluemix:public:kms:us-south:a/123456:e4a29d1a-2ef0-42a6-8fd2-350deb1c647e:key:5437653b-c4b1-447f-9646-b2a2a4cd6179"}, "region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}], "resource_type": "backup_policy_plan"}], "total_count": 132}`) })) }) - It(`Invoke GetShare successfully`, func() { + It(`Invoke ListBackupPolicyPlans successfully`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -61392,24 +61561,25 @@ var _ = Describe(`VpcV1`, func() { Expect(vpcService).ToNot(BeNil()) // Invoke operation with nil options model (negative test) - result, response, operationErr := vpcService.GetShare(nil) + result, response, operationErr := vpcService.ListBackupPolicyPlans(nil) Expect(operationErr).NotTo(BeNil()) Expect(response).To(BeNil()) - Expect(result).To(BeNil()) - - // Construct an instance of the GetShareOptions model - getShareOptionsModel := new(vpcv1.GetShareOptions) - getShareOptionsModel.ID = core.StringPtr("testString") - getShareOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + Expect(result).To(BeNil()) + + // 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.GetShare(getShareOptionsModel) + result, response, operationErr = vpcService.ListBackupPolicyPlans(listBackupPolicyPlansOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) }) - It(`Invoke GetShare 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{}, @@ -61418,22 +61588,23 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the GetShareOptions model - getShareOptionsModel := new(vpcv1.GetShareOptions) - getShareOptionsModel.ID = core.StringPtr("testString") - getShareOptionsModel.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.GetShare(getShareOptionsModel) + 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 GetShareOptions model with no property values - getShareOptionsModelNew := new(vpcv1.GetShareOptions) + // 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.GetShare(getShareOptionsModelNew) + result, response, operationErr = vpcService.ListBackupPolicyPlans(listBackupPolicyPlansOptionsModelNew) Expect(operationErr).ToNot(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) @@ -61451,7 +61622,7 @@ var _ = Describe(`VpcV1`, func() { res.WriteHeader(200) })) }) - It(`Invoke GetShare successfully`, func() { + It(`Invoke ListBackupPolicyPlans successfully`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -61460,13 +61631,14 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the GetShareOptions model - getShareOptionsModel := new(vpcv1.GetShareOptions) - getShareOptionsModel.ID = core.StringPtr("testString") - getShareOptionsModel.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.GetShare(getShareOptionsModel) + result, response, operationErr := vpcService.ListBackupPolicyPlans(listBackupPolicyPlansOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) @@ -61478,27 +61650,25 @@ var _ = Describe(`VpcV1`, func() { }) }) }) - Describe(`UpdateShare(updateShareOptions *UpdateShareOptions) - Operation response error`, func() { + Describe(`CreateBackupPolicyPlan(createBackupPolicyPlanOptions *CreateBackupPolicyPlanOptions) - Operation response error`, func() { version := "testString" - updateSharePath := "/shares/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(updateSharePath)) - 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.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 UpdateShare 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{}, @@ -61507,37 +61677,55 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the ShareProfileIdentityByName model - shareProfileIdentityModel := new(vpcv1.ShareProfileIdentityByName) - shareProfileIdentityModel.Name = core.StringPtr("tier-3iops") + // Construct an instance of the ZoneIdentityByName model + zoneIdentityModel := new(vpcv1.ZoneIdentityByName) + zoneIdentityModel.Name = core.StringPtr("us-south-1") - // Construct an instance of the SharePatch model - sharePatchModel := new(vpcv1.SharePatch) - sharePatchModel.AccessControlMode = core.StringPtr("security_group") - sharePatchModel.Iops = core.Int64Ptr(int64(100)) - sharePatchModel.Name = core.StringPtr("my-share") - sharePatchModel.Profile = shareProfileIdentityModel - sharePatchModel.ReplicationCronSpec = core.StringPtr("0 */5 * * *") - sharePatchModel.Size = core.Int64Ptr(int64(200)) - sharePatchModel.UserTags = []string{"testString"} - sharePatchModelAsPatch, asPatchErr := sharePatchModel.AsPatch() - Expect(asPatchErr).To(BeNil()) + // Construct an instance of the BackupPolicyPlanClonePolicyPrototype model + backupPolicyPlanClonePolicyPrototypeModel := new(vpcv1.BackupPolicyPlanClonePolicyPrototype) + backupPolicyPlanClonePolicyPrototypeModel.MaxSnapshots = core.Int64Ptr(int64(5)) + backupPolicyPlanClonePolicyPrototypeModel.Zones = []vpcv1.ZoneIdentityIntf{zoneIdentityModel} - // Construct an instance of the UpdateShareOptions model - updateShareOptionsModel := new(vpcv1.UpdateShareOptions) - updateShareOptionsModel.ID = core.StringPtr("testString") - updateShareOptionsModel.SharePatch = sharePatchModelAsPatch - updateShareOptionsModel.IfMatch = core.StringPtr(`W/"96d225c4-56bd-43d9-98fc-d7148e5c5028"`) - updateShareOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // 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 EncryptionKeyIdentityByCRN model + encryptionKeyIdentityModel := new(vpcv1.EncryptionKeyIdentityByCRN) + encryptionKeyIdentityModel.CRN = core.StringPtr("crn:v1:bluemix:public:kms:us-south:a/123456:e4a29d1a-2ef0-42a6-8fd2-350deb1c647e:key:5437653b-c4b1-447f-9646-b2a2a4cd6179") + + // Construct an instance of the RegionIdentityByName model + regionIdentityModel := new(vpcv1.RegionIdentityByName) + regionIdentityModel.Name = core.StringPtr("us-south") + + // Construct an instance of the BackupPolicyPlanRemoteRegionPolicyPrototype model + backupPolicyPlanRemoteRegionPolicyPrototypeModel := new(vpcv1.BackupPolicyPlanRemoteRegionPolicyPrototype) + backupPolicyPlanRemoteRegionPolicyPrototypeModel.DeleteOverCount = core.Int64Ptr(int64(5)) + backupPolicyPlanRemoteRegionPolicyPrototypeModel.EncryptionKey = encryptionKeyIdentityModel + backupPolicyPlanRemoteRegionPolicyPrototypeModel.Region = regionIdentityModel + + // Construct an instance of the CreateBackupPolicyPlanOptions model + createBackupPolicyPlanOptionsModel := new(vpcv1.CreateBackupPolicyPlanOptions) + createBackupPolicyPlanOptionsModel.BackupPolicyID = core.StringPtr("testString") + createBackupPolicyPlanOptionsModel.CronSpec = core.StringPtr("30 */2 * * 1-5") + createBackupPolicyPlanOptionsModel.Active = core.BoolPtr(true) + createBackupPolicyPlanOptionsModel.AttachUserTags = []string{"my-daily-backup-plan"} + createBackupPolicyPlanOptionsModel.ClonePolicy = backupPolicyPlanClonePolicyPrototypeModel + createBackupPolicyPlanOptionsModel.CopyUserTags = core.BoolPtr(true) + createBackupPolicyPlanOptionsModel.DeletionTrigger = backupPolicyPlanDeletionTriggerPrototypeModel + createBackupPolicyPlanOptionsModel.Name = core.StringPtr("my-policy-plan") + createBackupPolicyPlanOptionsModel.RemoteRegionPolicies = []vpcv1.BackupPolicyPlanRemoteRegionPolicyPrototype{*backupPolicyPlanRemoteRegionPolicyPrototypeModel} + 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.UpdateShare(updateShareOptionsModel) + 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.UpdateShare(updateShareOptionsModel) + result, response, operationErr = vpcService.CreateBackupPolicyPlan(createBackupPolicyPlanOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).To(BeNil()) @@ -61547,17 +61735,17 @@ var _ = Describe(`VpcV1`, func() { }) }) }) - Describe(`UpdateShare(updateShareOptions *UpdateShareOptions)`, func() { + Describe(`CreateBackupPolicyPlan(createBackupPolicyPlanOptions *CreateBackupPolicyPlanOptions)`, func() { version := "testString" - updateSharePath := "/shares/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(updateSharePath)) - 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()) @@ -61575,8 +61763,6 @@ var _ = Describe(`VpcV1`, func() { } 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 @@ -61584,11 +61770,11 @@ var _ = Describe(`VpcV1`, func() { // Set mock response res.Header().Set("Content-type", "application/json") - res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"access_control_mode": "security_group", "created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::share:0fe9e5d8-0a4d-4818-96ec-e99708644a58", "encryption": "provider_managed", "encryption_key": {"crn": "crn:v1:bluemix:public:kms:us-south:a/123456:e4a29d1a-2ef0-42a6-8fd2-350deb1c647e:key:5437653b-c4b1-447f-9646-b2a2a4cd6179"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/shares/0fe9e5d8-0a4d-4818-96ec-e99708644a58", "id": "0fe9e5d8-0a4d-4818-96ec-e99708644a58", "iops": 100, "latest_job": {"status": "cancelled", "status_reasons": [{"code": "cannot_reach_source_share", "message": "The replication failover failed because the source share cannot be reached.", "more_info": "https://cloud.ibm.com/docs/vpc?topic=vpc-file-storage-planning"}], "type": "replication_failover"}, "latest_sync": {"completed_at": "2019-01-01T12:00:00.000Z", "data_transferred": 0, "started_at": "2019-01-01T12:00:00.000Z"}, "lifecycle_state": "stable", "mount_targets": [{"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/shares/0fe9e5d8-0a4d-4818-96ec-e99708644a58/mount_targets/4cf9171a-0043-4434-8727-15b53dbc374c", "id": "4cf9171a-0043-4434-8727-15b53dbc374c", "name": "my-share-mount-target", "resource_type": "share_mount_target"}], "name": "my-share", "profile": {"href": "https://us-south.iaas.cloud.ibm.com/v1/share/profiles/tier-3iops", "name": "tier-3iops", "resource_type": "share_profile"}, "replica_share": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::share:0fe9e5d8-0a4d-4818-96ec-e99708644a58", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/shares/0fe9e5d8-0a4d-4818-96ec-e99708644a58", "id": "0fe9e5d8-0a4d-4818-96ec-e99708644a58", "name": "my-share", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "share"}, "replication_cron_spec": "0 */5 * * *", "replication_role": "none", "replication_status": "active", "replication_status_reasons": [{"code": "cannot_reach_source_share", "message": "The replication failover failed because the source share cannot be reached.", "more_info": "https://cloud.ibm.com/docs/vpc?topic=vpc-file-storage-planning"}], "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "resource_type": "share", "size": 200, "source_share": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::share:0fe9e5d8-0a4d-4818-96ec-e99708644a58", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/shares/0fe9e5d8-0a4d-4818-96ec-e99708644a58", "id": "0fe9e5d8-0a4d-4818-96ec-e99708644a58", "name": "my-share", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "share"}, "user_tags": ["UserTags"], "zone": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south/zones/us-south-1", "name": "us-south-1"}}`) + res.WriteHeader(201) + fmt.Fprintf(res, "%s", `{"active": true, "attach_user_tags": ["AttachUserTags"], "clone_policy": {"max_snapshots": 1, "zones": [{"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south/zones/us-south-1", "name": "us-south-1"}]}, "copy_user_tags": true, "created_at": "2019-01-01T12:00:00.000Z", "cron_spec": "30 */2 * * 1-5", "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", "remote_region_policies": [{"delete_over_count": 1, "encryption_key": {"crn": "crn:v1:bluemix:public:kms:us-south:a/123456:e4a29d1a-2ef0-42a6-8fd2-350deb1c647e:key:5437653b-c4b1-447f-9646-b2a2a4cd6179"}, "region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}], "resource_type": "backup_policy_plan"}`) })) }) - It(`Invoke UpdateShare successfully with retries`, func() { + It(`Invoke CreateBackupPolicyPlan successfully with retries`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -61598,39 +61784,57 @@ var _ = Describe(`VpcV1`, func() { Expect(vpcService).ToNot(BeNil()) vpcService.EnableRetries(0, 0) - // Construct an instance of the ShareProfileIdentityByName model - shareProfileIdentityModel := new(vpcv1.ShareProfileIdentityByName) - shareProfileIdentityModel.Name = core.StringPtr("tier-3iops") + // Construct an instance of the ZoneIdentityByName model + zoneIdentityModel := new(vpcv1.ZoneIdentityByName) + zoneIdentityModel.Name = core.StringPtr("us-south-1") - // Construct an instance of the SharePatch model - sharePatchModel := new(vpcv1.SharePatch) - sharePatchModel.AccessControlMode = core.StringPtr("security_group") - sharePatchModel.Iops = core.Int64Ptr(int64(100)) - sharePatchModel.Name = core.StringPtr("my-share") - sharePatchModel.Profile = shareProfileIdentityModel - sharePatchModel.ReplicationCronSpec = core.StringPtr("0 */5 * * *") - sharePatchModel.Size = core.Int64Ptr(int64(200)) - sharePatchModel.UserTags = []string{"testString"} - sharePatchModelAsPatch, asPatchErr := sharePatchModel.AsPatch() - Expect(asPatchErr).To(BeNil()) + // Construct an instance of the BackupPolicyPlanClonePolicyPrototype model + backupPolicyPlanClonePolicyPrototypeModel := new(vpcv1.BackupPolicyPlanClonePolicyPrototype) + backupPolicyPlanClonePolicyPrototypeModel.MaxSnapshots = core.Int64Ptr(int64(5)) + backupPolicyPlanClonePolicyPrototypeModel.Zones = []vpcv1.ZoneIdentityIntf{zoneIdentityModel} - // Construct an instance of the UpdateShareOptions model - updateShareOptionsModel := new(vpcv1.UpdateShareOptions) - updateShareOptionsModel.ID = core.StringPtr("testString") - updateShareOptionsModel.SharePatch = sharePatchModelAsPatch - updateShareOptionsModel.IfMatch = core.StringPtr(`W/"96d225c4-56bd-43d9-98fc-d7148e5c5028"`) - updateShareOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // 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 EncryptionKeyIdentityByCRN model + encryptionKeyIdentityModel := new(vpcv1.EncryptionKeyIdentityByCRN) + encryptionKeyIdentityModel.CRN = core.StringPtr("crn:v1:bluemix:public:kms:us-south:a/123456:e4a29d1a-2ef0-42a6-8fd2-350deb1c647e:key:5437653b-c4b1-447f-9646-b2a2a4cd6179") + + // Construct an instance of the RegionIdentityByName model + regionIdentityModel := new(vpcv1.RegionIdentityByName) + regionIdentityModel.Name = core.StringPtr("us-south") + + // Construct an instance of the BackupPolicyPlanRemoteRegionPolicyPrototype model + backupPolicyPlanRemoteRegionPolicyPrototypeModel := new(vpcv1.BackupPolicyPlanRemoteRegionPolicyPrototype) + backupPolicyPlanRemoteRegionPolicyPrototypeModel.DeleteOverCount = core.Int64Ptr(int64(5)) + backupPolicyPlanRemoteRegionPolicyPrototypeModel.EncryptionKey = encryptionKeyIdentityModel + backupPolicyPlanRemoteRegionPolicyPrototypeModel.Region = regionIdentityModel + + // Construct an instance of the CreateBackupPolicyPlanOptions model + createBackupPolicyPlanOptionsModel := new(vpcv1.CreateBackupPolicyPlanOptions) + createBackupPolicyPlanOptionsModel.BackupPolicyID = core.StringPtr("testString") + createBackupPolicyPlanOptionsModel.CronSpec = core.StringPtr("30 */2 * * 1-5") + createBackupPolicyPlanOptionsModel.Active = core.BoolPtr(true) + createBackupPolicyPlanOptionsModel.AttachUserTags = []string{"my-daily-backup-plan"} + createBackupPolicyPlanOptionsModel.ClonePolicy = backupPolicyPlanClonePolicyPrototypeModel + createBackupPolicyPlanOptionsModel.CopyUserTags = core.BoolPtr(true) + createBackupPolicyPlanOptionsModel.DeletionTrigger = backupPolicyPlanDeletionTriggerPrototypeModel + createBackupPolicyPlanOptionsModel.Name = core.StringPtr("my-policy-plan") + createBackupPolicyPlanOptionsModel.RemoteRegionPolicies = []vpcv1.BackupPolicyPlanRemoteRegionPolicyPrototype{*backupPolicyPlanRemoteRegionPolicyPrototypeModel} + 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.UpdateShareWithContext(ctx, updateShareOptionsModel) + _, _, 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.UpdateShare(updateShareOptionsModel) + result, response, operationErr := vpcService.CreateBackupPolicyPlan(createBackupPolicyPlanOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) @@ -61638,7 +61842,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.UpdateShareWithContext(ctx, updateShareOptionsModel) + _, _, operationErr = vpcService.CreateBackupPolicyPlanWithContext(ctx, createBackupPolicyPlanOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) }) @@ -61652,8 +61856,8 @@ var _ = Describe(`VpcV1`, func() { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(updateSharePath)) - 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()) @@ -61671,17 +61875,15 @@ var _ = Describe(`VpcV1`, func() { } 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", `{"access_control_mode": "security_group", "created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::share:0fe9e5d8-0a4d-4818-96ec-e99708644a58", "encryption": "provider_managed", "encryption_key": {"crn": "crn:v1:bluemix:public:kms:us-south:a/123456:e4a29d1a-2ef0-42a6-8fd2-350deb1c647e:key:5437653b-c4b1-447f-9646-b2a2a4cd6179"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/shares/0fe9e5d8-0a4d-4818-96ec-e99708644a58", "id": "0fe9e5d8-0a4d-4818-96ec-e99708644a58", "iops": 100, "latest_job": {"status": "cancelled", "status_reasons": [{"code": "cannot_reach_source_share", "message": "The replication failover failed because the source share cannot be reached.", "more_info": "https://cloud.ibm.com/docs/vpc?topic=vpc-file-storage-planning"}], "type": "replication_failover"}, "latest_sync": {"completed_at": "2019-01-01T12:00:00.000Z", "data_transferred": 0, "started_at": "2019-01-01T12:00:00.000Z"}, "lifecycle_state": "stable", "mount_targets": [{"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/shares/0fe9e5d8-0a4d-4818-96ec-e99708644a58/mount_targets/4cf9171a-0043-4434-8727-15b53dbc374c", "id": "4cf9171a-0043-4434-8727-15b53dbc374c", "name": "my-share-mount-target", "resource_type": "share_mount_target"}], "name": "my-share", "profile": {"href": "https://us-south.iaas.cloud.ibm.com/v1/share/profiles/tier-3iops", "name": "tier-3iops", "resource_type": "share_profile"}, "replica_share": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::share:0fe9e5d8-0a4d-4818-96ec-e99708644a58", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/shares/0fe9e5d8-0a4d-4818-96ec-e99708644a58", "id": "0fe9e5d8-0a4d-4818-96ec-e99708644a58", "name": "my-share", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "share"}, "replication_cron_spec": "0 */5 * * *", "replication_role": "none", "replication_status": "active", "replication_status_reasons": [{"code": "cannot_reach_source_share", "message": "The replication failover failed because the source share cannot be reached.", "more_info": "https://cloud.ibm.com/docs/vpc?topic=vpc-file-storage-planning"}], "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "resource_type": "share", "size": 200, "source_share": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::share:0fe9e5d8-0a4d-4818-96ec-e99708644a58", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/shares/0fe9e5d8-0a4d-4818-96ec-e99708644a58", "id": "0fe9e5d8-0a4d-4818-96ec-e99708644a58", "name": "my-share", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "share"}, "user_tags": ["UserTags"], "zone": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south/zones/us-south-1", "name": "us-south-1"}}`) + res.WriteHeader(201) + fmt.Fprintf(res, "%s", `{"active": true, "attach_user_tags": ["AttachUserTags"], "clone_policy": {"max_snapshots": 1, "zones": [{"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south/zones/us-south-1", "name": "us-south-1"}]}, "copy_user_tags": true, "created_at": "2019-01-01T12:00:00.000Z", "cron_spec": "30 */2 * * 1-5", "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", "remote_region_policies": [{"delete_over_count": 1, "encryption_key": {"crn": "crn:v1:bluemix:public:kms:us-south:a/123456:e4a29d1a-2ef0-42a6-8fd2-350deb1c647e:key:5437653b-c4b1-447f-9646-b2a2a4cd6179"}, "region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}], "resource_type": "backup_policy_plan"}`) })) }) - It(`Invoke UpdateShare successfully`, func() { + It(`Invoke CreateBackupPolicyPlan successfully`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -61691,42 +61893,60 @@ var _ = Describe(`VpcV1`, func() { Expect(vpcService).ToNot(BeNil()) // Invoke operation with nil options model (negative test) - result, response, operationErr := vpcService.UpdateShare(nil) + result, response, operationErr := vpcService.CreateBackupPolicyPlan(nil) Expect(operationErr).NotTo(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) - // Construct an instance of the ShareProfileIdentityByName model - shareProfileIdentityModel := new(vpcv1.ShareProfileIdentityByName) - shareProfileIdentityModel.Name = core.StringPtr("tier-3iops") + // Construct an instance of the ZoneIdentityByName model + zoneIdentityModel := new(vpcv1.ZoneIdentityByName) + zoneIdentityModel.Name = core.StringPtr("us-south-1") - // Construct an instance of the SharePatch model - sharePatchModel := new(vpcv1.SharePatch) - sharePatchModel.AccessControlMode = core.StringPtr("security_group") - sharePatchModel.Iops = core.Int64Ptr(int64(100)) - sharePatchModel.Name = core.StringPtr("my-share") - sharePatchModel.Profile = shareProfileIdentityModel - sharePatchModel.ReplicationCronSpec = core.StringPtr("0 */5 * * *") - sharePatchModel.Size = core.Int64Ptr(int64(200)) - sharePatchModel.UserTags = []string{"testString"} - sharePatchModelAsPatch, asPatchErr := sharePatchModel.AsPatch() - Expect(asPatchErr).To(BeNil()) + // Construct an instance of the BackupPolicyPlanClonePolicyPrototype model + backupPolicyPlanClonePolicyPrototypeModel := new(vpcv1.BackupPolicyPlanClonePolicyPrototype) + backupPolicyPlanClonePolicyPrototypeModel.MaxSnapshots = core.Int64Ptr(int64(5)) + backupPolicyPlanClonePolicyPrototypeModel.Zones = []vpcv1.ZoneIdentityIntf{zoneIdentityModel} - // Construct an instance of the UpdateShareOptions model - updateShareOptionsModel := new(vpcv1.UpdateShareOptions) - updateShareOptionsModel.ID = core.StringPtr("testString") - updateShareOptionsModel.SharePatch = sharePatchModelAsPatch - updateShareOptionsModel.IfMatch = core.StringPtr(`W/"96d225c4-56bd-43d9-98fc-d7148e5c5028"`) - updateShareOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // 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 EncryptionKeyIdentityByCRN model + encryptionKeyIdentityModel := new(vpcv1.EncryptionKeyIdentityByCRN) + encryptionKeyIdentityModel.CRN = core.StringPtr("crn:v1:bluemix:public:kms:us-south:a/123456:e4a29d1a-2ef0-42a6-8fd2-350deb1c647e:key:5437653b-c4b1-447f-9646-b2a2a4cd6179") + + // Construct an instance of the RegionIdentityByName model + regionIdentityModel := new(vpcv1.RegionIdentityByName) + regionIdentityModel.Name = core.StringPtr("us-south") + + // Construct an instance of the BackupPolicyPlanRemoteRegionPolicyPrototype model + backupPolicyPlanRemoteRegionPolicyPrototypeModel := new(vpcv1.BackupPolicyPlanRemoteRegionPolicyPrototype) + backupPolicyPlanRemoteRegionPolicyPrototypeModel.DeleteOverCount = core.Int64Ptr(int64(5)) + backupPolicyPlanRemoteRegionPolicyPrototypeModel.EncryptionKey = encryptionKeyIdentityModel + backupPolicyPlanRemoteRegionPolicyPrototypeModel.Region = regionIdentityModel + + // Construct an instance of the CreateBackupPolicyPlanOptions model + createBackupPolicyPlanOptionsModel := new(vpcv1.CreateBackupPolicyPlanOptions) + createBackupPolicyPlanOptionsModel.BackupPolicyID = core.StringPtr("testString") + createBackupPolicyPlanOptionsModel.CronSpec = core.StringPtr("30 */2 * * 1-5") + createBackupPolicyPlanOptionsModel.Active = core.BoolPtr(true) + createBackupPolicyPlanOptionsModel.AttachUserTags = []string{"my-daily-backup-plan"} + createBackupPolicyPlanOptionsModel.ClonePolicy = backupPolicyPlanClonePolicyPrototypeModel + createBackupPolicyPlanOptionsModel.CopyUserTags = core.BoolPtr(true) + createBackupPolicyPlanOptionsModel.DeletionTrigger = backupPolicyPlanDeletionTriggerPrototypeModel + createBackupPolicyPlanOptionsModel.Name = core.StringPtr("my-policy-plan") + createBackupPolicyPlanOptionsModel.RemoteRegionPolicies = []vpcv1.BackupPolicyPlanRemoteRegionPolicyPrototype{*backupPolicyPlanRemoteRegionPolicyPrototypeModel} + createBackupPolicyPlanOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with valid options model (positive test) - result, response, operationErr = vpcService.UpdateShare(updateShareOptionsModel) + result, response, operationErr = vpcService.CreateBackupPolicyPlan(createBackupPolicyPlanOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) }) - It(`Invoke UpdateShare with error: Operation validation and request error`, func() { + It(`Invoke CreateBackupPolicyPlan with error: Operation validation and request error`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -61735,40 +61955,58 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the ShareProfileIdentityByName model - shareProfileIdentityModel := new(vpcv1.ShareProfileIdentityByName) - shareProfileIdentityModel.Name = core.StringPtr("tier-3iops") + // Construct an instance of the ZoneIdentityByName model + zoneIdentityModel := new(vpcv1.ZoneIdentityByName) + zoneIdentityModel.Name = core.StringPtr("us-south-1") - // Construct an instance of the SharePatch model - sharePatchModel := new(vpcv1.SharePatch) - sharePatchModel.AccessControlMode = core.StringPtr("security_group") - sharePatchModel.Iops = core.Int64Ptr(int64(100)) - sharePatchModel.Name = core.StringPtr("my-share") - sharePatchModel.Profile = shareProfileIdentityModel - sharePatchModel.ReplicationCronSpec = core.StringPtr("0 */5 * * *") - sharePatchModel.Size = core.Int64Ptr(int64(200)) - sharePatchModel.UserTags = []string{"testString"} - sharePatchModelAsPatch, asPatchErr := sharePatchModel.AsPatch() - Expect(asPatchErr).To(BeNil()) + // Construct an instance of the BackupPolicyPlanClonePolicyPrototype model + backupPolicyPlanClonePolicyPrototypeModel := new(vpcv1.BackupPolicyPlanClonePolicyPrototype) + backupPolicyPlanClonePolicyPrototypeModel.MaxSnapshots = core.Int64Ptr(int64(5)) + backupPolicyPlanClonePolicyPrototypeModel.Zones = []vpcv1.ZoneIdentityIntf{zoneIdentityModel} - // Construct an instance of the UpdateShareOptions model - updateShareOptionsModel := new(vpcv1.UpdateShareOptions) - updateShareOptionsModel.ID = core.StringPtr("testString") - updateShareOptionsModel.SharePatch = sharePatchModelAsPatch - updateShareOptionsModel.IfMatch = core.StringPtr(`W/"96d225c4-56bd-43d9-98fc-d7148e5c5028"`) - updateShareOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // 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 EncryptionKeyIdentityByCRN model + encryptionKeyIdentityModel := new(vpcv1.EncryptionKeyIdentityByCRN) + encryptionKeyIdentityModel.CRN = core.StringPtr("crn:v1:bluemix:public:kms:us-south:a/123456:e4a29d1a-2ef0-42a6-8fd2-350deb1c647e:key:5437653b-c4b1-447f-9646-b2a2a4cd6179") + + // Construct an instance of the RegionIdentityByName model + regionIdentityModel := new(vpcv1.RegionIdentityByName) + regionIdentityModel.Name = core.StringPtr("us-south") + + // Construct an instance of the BackupPolicyPlanRemoteRegionPolicyPrototype model + backupPolicyPlanRemoteRegionPolicyPrototypeModel := new(vpcv1.BackupPolicyPlanRemoteRegionPolicyPrototype) + backupPolicyPlanRemoteRegionPolicyPrototypeModel.DeleteOverCount = core.Int64Ptr(int64(5)) + backupPolicyPlanRemoteRegionPolicyPrototypeModel.EncryptionKey = encryptionKeyIdentityModel + backupPolicyPlanRemoteRegionPolicyPrototypeModel.Region = regionIdentityModel + + // Construct an instance of the CreateBackupPolicyPlanOptions model + createBackupPolicyPlanOptionsModel := new(vpcv1.CreateBackupPolicyPlanOptions) + createBackupPolicyPlanOptionsModel.BackupPolicyID = core.StringPtr("testString") + createBackupPolicyPlanOptionsModel.CronSpec = core.StringPtr("30 */2 * * 1-5") + createBackupPolicyPlanOptionsModel.Active = core.BoolPtr(true) + createBackupPolicyPlanOptionsModel.AttachUserTags = []string{"my-daily-backup-plan"} + createBackupPolicyPlanOptionsModel.ClonePolicy = backupPolicyPlanClonePolicyPrototypeModel + createBackupPolicyPlanOptionsModel.CopyUserTags = core.BoolPtr(true) + createBackupPolicyPlanOptionsModel.DeletionTrigger = backupPolicyPlanDeletionTriggerPrototypeModel + createBackupPolicyPlanOptionsModel.Name = core.StringPtr("my-policy-plan") + createBackupPolicyPlanOptionsModel.RemoteRegionPolicies = []vpcv1.BackupPolicyPlanRemoteRegionPolicyPrototype{*backupPolicyPlanRemoteRegionPolicyPrototypeModel} + 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.UpdateShare(updateShareOptionsModel) + 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 UpdateShareOptions model with no property values - updateShareOptionsModelNew := new(vpcv1.UpdateShareOptions) + // 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.UpdateShare(updateShareOptionsModelNew) + result, response, operationErr = vpcService.CreateBackupPolicyPlan(createBackupPolicyPlanOptionsModelNew) Expect(operationErr).ToNot(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) @@ -61783,10 +62021,10 @@ var _ = Describe(`VpcV1`, func() { defer GinkgoRecover() // Set success status code with no respoonse body - res.WriteHeader(200) + res.WriteHeader(201) })) }) - It(`Invoke UpdateShare successfully`, func() { + It(`Invoke CreateBackupPolicyPlan successfully`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -61795,181 +62033,104 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the ShareProfileIdentityByName model - shareProfileIdentityModel := new(vpcv1.ShareProfileIdentityByName) - shareProfileIdentityModel.Name = core.StringPtr("tier-3iops") - - // Construct an instance of the SharePatch model - sharePatchModel := new(vpcv1.SharePatch) - sharePatchModel.AccessControlMode = core.StringPtr("security_group") - sharePatchModel.Iops = core.Int64Ptr(int64(100)) - sharePatchModel.Name = core.StringPtr("my-share") - sharePatchModel.Profile = shareProfileIdentityModel - sharePatchModel.ReplicationCronSpec = core.StringPtr("0 */5 * * *") - sharePatchModel.Size = core.Int64Ptr(int64(200)) - sharePatchModel.UserTags = []string{"testString"} - sharePatchModelAsPatch, asPatchErr := sharePatchModel.AsPatch() - Expect(asPatchErr).To(BeNil()) - - // Construct an instance of the UpdateShareOptions model - updateShareOptionsModel := new(vpcv1.UpdateShareOptions) - updateShareOptionsModel.ID = core.StringPtr("testString") - updateShareOptionsModel.SharePatch = sharePatchModelAsPatch - updateShareOptionsModel.IfMatch = core.StringPtr(`W/"96d225c4-56bd-43d9-98fc-d7148e5c5028"`) - updateShareOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} - - // Invoke operation - result, response, operationErr := vpcService.UpdateShare(updateShareOptionsModel) - Expect(operationErr).To(BeNil()) - Expect(response).ToNot(BeNil()) - - // Verify a nil result - Expect(result).To(BeNil()) - }) - AfterEach(func() { - testServer.Close() - }) - }) - }) - Describe(`FailoverShare(failoverShareOptions *FailoverShareOptions)`, func() { - version := "testString" - failoverSharePath := "/shares/testString/failover" - Context(`Using mock server endpoint`, func() { - BeforeEach(func() { - testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { - defer GinkgoRecover() + // Construct an instance of the ZoneIdentityByName model + zoneIdentityModel := new(vpcv1.ZoneIdentityByName) + zoneIdentityModel.Name = core.StringPtr("us-south-1") - // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(failoverSharePath)) - Expect(req.Method).To(Equal("POST")) + // Construct an instance of the BackupPolicyPlanClonePolicyPrototype model + backupPolicyPlanClonePolicyPrototypeModel := new(vpcv1.BackupPolicyPlanClonePolicyPrototype) + backupPolicyPlanClonePolicyPrototypeModel.MaxSnapshots = core.Int64Ptr(int64(5)) + backupPolicyPlanClonePolicyPrototypeModel.Zones = []vpcv1.ZoneIdentityIntf{zoneIdentityModel} - // For gzip-disabled operation, verify Content-Encoding is not set. - Expect(req.Header.Get("Content-Encoding")).To(BeEmpty()) + // Construct an instance of the BackupPolicyPlanDeletionTriggerPrototype model + backupPolicyPlanDeletionTriggerPrototypeModel := new(vpcv1.BackupPolicyPlanDeletionTriggerPrototype) + backupPolicyPlanDeletionTriggerPrototypeModel.DeleteAfter = core.Int64Ptr(int64(20)) + backupPolicyPlanDeletionTriggerPrototypeModel.DeleteOverCount = core.Int64Ptr(int64(20)) - // 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()) + // Construct an instance of the EncryptionKeyIdentityByCRN model + encryptionKeyIdentityModel := new(vpcv1.EncryptionKeyIdentityByCRN) + encryptionKeyIdentityModel.CRN = core.StringPtr("crn:v1:bluemix:public:kms:us-south:a/123456:e4a29d1a-2ef0-42a6-8fd2-350deb1c647e:key:5437653b-c4b1-447f-9646-b2a2a4cd6179") - 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 FailoverShare 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 RegionIdentityByName model + regionIdentityModel := new(vpcv1.RegionIdentityByName) + regionIdentityModel.Name = core.StringPtr("us-south") - // Invoke operation with nil options model (negative test) - response, operationErr := vpcService.FailoverShare(nil) - Expect(operationErr).NotTo(BeNil()) - Expect(response).To(BeNil()) + // Construct an instance of the BackupPolicyPlanRemoteRegionPolicyPrototype model + backupPolicyPlanRemoteRegionPolicyPrototypeModel := new(vpcv1.BackupPolicyPlanRemoteRegionPolicyPrototype) + backupPolicyPlanRemoteRegionPolicyPrototypeModel.DeleteOverCount = core.Int64Ptr(int64(5)) + backupPolicyPlanRemoteRegionPolicyPrototypeModel.EncryptionKey = encryptionKeyIdentityModel + backupPolicyPlanRemoteRegionPolicyPrototypeModel.Region = regionIdentityModel - // Construct an instance of the FailoverShareOptions model - failoverShareOptionsModel := new(vpcv1.FailoverShareOptions) - failoverShareOptionsModel.ShareID = core.StringPtr("testString") - failoverShareOptionsModel.FallbackPolicy = core.StringPtr("fail") - failoverShareOptionsModel.Timeout = core.Int64Ptr(int64(600)) - failoverShareOptionsModel.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("30 */2 * * 1-5") + createBackupPolicyPlanOptionsModel.Active = core.BoolPtr(true) + createBackupPolicyPlanOptionsModel.AttachUserTags = []string{"my-daily-backup-plan"} + createBackupPolicyPlanOptionsModel.ClonePolicy = backupPolicyPlanClonePolicyPrototypeModel + createBackupPolicyPlanOptionsModel.CopyUserTags = core.BoolPtr(true) + createBackupPolicyPlanOptionsModel.DeletionTrigger = backupPolicyPlanDeletionTriggerPrototypeModel + createBackupPolicyPlanOptionsModel.Name = core.StringPtr("my-policy-plan") + createBackupPolicyPlanOptionsModel.RemoteRegionPolicies = []vpcv1.BackupPolicyPlanRemoteRegionPolicyPrototype{*backupPolicyPlanRemoteRegionPolicyPrototypeModel} + createBackupPolicyPlanOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} - // Invoke operation with valid options model (positive test) - response, operationErr = vpcService.FailoverShare(failoverShareOptionsModel) + // Invoke operation + result, response, operationErr := vpcService.CreateBackupPolicyPlan(createBackupPolicyPlanOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) - }) - It(`Invoke FailoverShare 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 FailoverShareOptions model - failoverShareOptionsModel := new(vpcv1.FailoverShareOptions) - failoverShareOptionsModel.ShareID = core.StringPtr("testString") - failoverShareOptionsModel.FallbackPolicy = core.StringPtr("fail") - failoverShareOptionsModel.Timeout = core.Int64Ptr(int64(600)) - failoverShareOptionsModel.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.FailoverShare(failoverShareOptionsModel) - Expect(operationErr).ToNot(BeNil()) - Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING)) - Expect(response).To(BeNil()) - // Construct a second instance of the FailoverShareOptions model with no property values - failoverShareOptionsModelNew := new(vpcv1.FailoverShareOptions) - // Invoke operation with invalid model (negative test) - response, operationErr = vpcService.FailoverShare(failoverShareOptionsModelNew) - Expect(operationErr).ToNot(BeNil()) - Expect(response).To(BeNil()) + // Verify a nil result + Expect(result).To(BeNil()) }) AfterEach(func() { testServer.Close() }) }) }) - Describe(`ListShareMountTargets(listShareMountTargetsOptions *ListShareMountTargetsOptions) - Operation response error`, func() { + Describe(`DeleteBackupPolicyPlan(deleteBackupPolicyPlanOptions *DeleteBackupPolicyPlanOptions) - Operation response error`, func() { version := "testString" - listShareMountTargetsPath := "/shares/testString/mount_targets" + 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(listShareMountTargetsPath)) - Expect(req.Method).To(Equal("GET")) + 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))})) - Expect(req.URL.Query()["name"]).To(Equal([]string{"testString"})) - Expect(req.URL.Query()["start"]).To(Equal([]string{"testString"})) - Expect(req.URL.Query()["limit"]).To(Equal([]string{fmt.Sprint(int64(10))})) res.Header().Set("Content-type", "application/json") - res.WriteHeader(200) + res.WriteHeader(202) fmt.Fprint(res, `} this is not valid json {`) })) }) - It(`Invoke ListShareMountTargets with error: Operation response processing error`, func() { + 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 ListShareMountTargetsOptions model - listShareMountTargetsOptionsModel := new(vpcv1.ListShareMountTargetsOptions) - listShareMountTargetsOptionsModel.ShareID = core.StringPtr("testString") - listShareMountTargetsOptionsModel.Name = core.StringPtr("testString") - listShareMountTargetsOptionsModel.Start = core.StringPtr("testString") - listShareMountTargetsOptionsModel.Limit = core.Int64Ptr(int64(10)) - listShareMountTargetsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + 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.ListShareMountTargets(listShareMountTargetsOptionsModel) + 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.ListShareMountTargets(listShareMountTargetsOptionsModel) + result, response, operationErr = vpcService.DeleteBackupPolicyPlan(deleteBackupPolicyPlanOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).To(BeNil()) @@ -61979,33 +62140,32 @@ var _ = Describe(`VpcV1`, func() { }) }) }) - Describe(`ListShareMountTargets(listShareMountTargetsOptions *ListShareMountTargetsOptions)`, func() { + Describe(`DeleteBackupPolicyPlan(deleteBackupPolicyPlanOptions *DeleteBackupPolicyPlanOptions)`, func() { version := "testString" - listShareMountTargetsPath := "/shares/testString/mount_targets" + 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(listShareMountTargetsPath)) - Expect(req.Method).To(Equal("GET")) + 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))})) - Expect(req.URL.Query()["name"]).To(Equal([]string{"testString"})) - Expect(req.URL.Query()["start"]).To(Equal([]string{"testString"})) - Expect(req.URL.Query()["limit"]).To(Equal([]string{fmt.Sprint(int64(10))})) // 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/shares/0fe9e5d8-0a4d-4818-96ec-e99708644a58/mount_targets?limit=20"}, "limit": 20, "mount_targets": [{"access_control_mode": "security_group", "created_at": "2019-01-01T12:00:00.000Z", "href": "https://us-south.iaas.cloud.ibm.com/v1/shares/0fe9e5d8-0a4d-4818-96ec-e99708644a58/mount_targets/4cf9171a-0043-4434-8727-15b53dbc374c", "id": "4cf9171a-0043-4434-8727-15b53dbc374c", "lifecycle_state": "stable", "mount_path": "10.240.1.23:/nxg_s_voll_mz7121_58e7e963_8f4b_4a0c_b71a_8ba8d9cd1e2e", "name": "my-share-mount-target", "primary_ip": {"address": "192.168.3.4", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e/reserved_ips/6d353a0f-aeb1-4ae1-832e-1110d10981bb", "id": "6d353a0f-aeb1-4ae1-832e-1110d10981bb", "name": "my-reserved-ip", "resource_type": "subnet_reserved_ip"}, "resource_type": "share_mount_target", "subnet": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "id": "7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "name": "my-subnet", "resource_type": "subnet"}, "transit_encryption": "none", "virtual_network_interface": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::virtual-network-interface:0767-fa41aecb-4f21-423d-8082-630bfba1e1d9", "href": "https://us-south.iaas.cloud.ibm.com/v1/virtual_network_interfaces/0767-fa41aecb-4f21-423d-8082-630bfba1e1d9", "id": "0767-fa41aecb-4f21-423d-8082-630bfba1e1d9", "name": "my-virtual-network-interface", "resource_type": "virtual_network_interface"}, "vpc": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::vpc:4727d842-f94f-4a2d-824a-9bc9b02c523b", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/vpcs/4727d842-f94f-4a2d-824a-9bc9b02c523b", "id": "4727d842-f94f-4a2d-824a-9bc9b02c523b", "name": "my-vpc", "resource_type": "vpc"}}], "next": {"href": "https://us-south.iaas.cloud.ibm.com/v1/shares/0fe9e5d8-0a4d-4818-96ec-e99708644a58/mount_targets?start=9d5a91a3e2cbd233b5a5b33436855ed1&limit=20"}, "total_count": 132}`) + res.WriteHeader(202) + fmt.Fprintf(res, "%s", `{"active": true, "attach_user_tags": ["AttachUserTags"], "clone_policy": {"max_snapshots": 1, "zones": [{"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south/zones/us-south-1", "name": "us-south-1"}]}, "copy_user_tags": true, "created_at": "2019-01-01T12:00:00.000Z", "cron_spec": "30 */2 * * 1-5", "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", "remote_region_policies": [{"delete_over_count": 1, "encryption_key": {"crn": "crn:v1:bluemix:public:kms:us-south:a/123456:e4a29d1a-2ef0-42a6-8fd2-350deb1c647e:key:5437653b-c4b1-447f-9646-b2a2a4cd6179"}, "region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}], "resource_type": "backup_policy_plan"}`) })) }) - It(`Invoke ListShareMountTargets successfully with retries`, func() { + It(`Invoke DeleteBackupPolicyPlan successfully with retries`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -62015,24 +62175,23 @@ var _ = Describe(`VpcV1`, func() { Expect(vpcService).ToNot(BeNil()) vpcService.EnableRetries(0, 0) - // Construct an instance of the ListShareMountTargetsOptions model - listShareMountTargetsOptionsModel := new(vpcv1.ListShareMountTargetsOptions) - listShareMountTargetsOptionsModel.ShareID = core.StringPtr("testString") - listShareMountTargetsOptionsModel.Name = core.StringPtr("testString") - listShareMountTargetsOptionsModel.Start = core.StringPtr("testString") - listShareMountTargetsOptionsModel.Limit = core.Int64Ptr(int64(10)) - listShareMountTargetsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // 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.ListShareMountTargetsWithContext(ctx, listShareMountTargetsOptionsModel) + _, _, 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.ListShareMountTargets(listShareMountTargetsOptionsModel) + result, response, operationErr := vpcService.DeleteBackupPolicyPlan(deleteBackupPolicyPlanOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) @@ -62040,7 +62199,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.ListShareMountTargetsWithContext(ctx, listShareMountTargetsOptionsModel) + _, _, operationErr = vpcService.DeleteBackupPolicyPlanWithContext(ctx, deleteBackupPolicyPlanOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) }) @@ -62054,21 +62213,20 @@ var _ = Describe(`VpcV1`, func() { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(listShareMountTargetsPath)) - Expect(req.Method).To(Equal("GET")) + 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))})) - Expect(req.URL.Query()["name"]).To(Equal([]string{"testString"})) - Expect(req.URL.Query()["start"]).To(Equal([]string{"testString"})) - Expect(req.URL.Query()["limit"]).To(Equal([]string{fmt.Sprint(int64(10))})) // 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/shares/0fe9e5d8-0a4d-4818-96ec-e99708644a58/mount_targets?limit=20"}, "limit": 20, "mount_targets": [{"access_control_mode": "security_group", "created_at": "2019-01-01T12:00:00.000Z", "href": "https://us-south.iaas.cloud.ibm.com/v1/shares/0fe9e5d8-0a4d-4818-96ec-e99708644a58/mount_targets/4cf9171a-0043-4434-8727-15b53dbc374c", "id": "4cf9171a-0043-4434-8727-15b53dbc374c", "lifecycle_state": "stable", "mount_path": "10.240.1.23:/nxg_s_voll_mz7121_58e7e963_8f4b_4a0c_b71a_8ba8d9cd1e2e", "name": "my-share-mount-target", "primary_ip": {"address": "192.168.3.4", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e/reserved_ips/6d353a0f-aeb1-4ae1-832e-1110d10981bb", "id": "6d353a0f-aeb1-4ae1-832e-1110d10981bb", "name": "my-reserved-ip", "resource_type": "subnet_reserved_ip"}, "resource_type": "share_mount_target", "subnet": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "id": "7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "name": "my-subnet", "resource_type": "subnet"}, "transit_encryption": "none", "virtual_network_interface": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::virtual-network-interface:0767-fa41aecb-4f21-423d-8082-630bfba1e1d9", "href": "https://us-south.iaas.cloud.ibm.com/v1/virtual_network_interfaces/0767-fa41aecb-4f21-423d-8082-630bfba1e1d9", "id": "0767-fa41aecb-4f21-423d-8082-630bfba1e1d9", "name": "my-virtual-network-interface", "resource_type": "virtual_network_interface"}, "vpc": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::vpc:4727d842-f94f-4a2d-824a-9bc9b02c523b", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/vpcs/4727d842-f94f-4a2d-824a-9bc9b02c523b", "id": "4727d842-f94f-4a2d-824a-9bc9b02c523b", "name": "my-vpc", "resource_type": "vpc"}}], "next": {"href": "https://us-south.iaas.cloud.ibm.com/v1/shares/0fe9e5d8-0a4d-4818-96ec-e99708644a58/mount_targets?start=9d5a91a3e2cbd233b5a5b33436855ed1&limit=20"}, "total_count": 132}`) + res.WriteHeader(202) + fmt.Fprintf(res, "%s", `{"active": true, "attach_user_tags": ["AttachUserTags"], "clone_policy": {"max_snapshots": 1, "zones": [{"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south/zones/us-south-1", "name": "us-south-1"}]}, "copy_user_tags": true, "created_at": "2019-01-01T12:00:00.000Z", "cron_spec": "30 */2 * * 1-5", "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", "remote_region_policies": [{"delete_over_count": 1, "encryption_key": {"crn": "crn:v1:bluemix:public:kms:us-south:a/123456:e4a29d1a-2ef0-42a6-8fd2-350deb1c647e:key:5437653b-c4b1-447f-9646-b2a2a4cd6179"}, "region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}], "resource_type": "backup_policy_plan"}`) })) }) - It(`Invoke ListShareMountTargets successfully`, func() { + It(`Invoke DeleteBackupPolicyPlan successfully`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -62078,27 +62236,26 @@ var _ = Describe(`VpcV1`, func() { Expect(vpcService).ToNot(BeNil()) // Invoke operation with nil options model (negative test) - result, response, operationErr := vpcService.ListShareMountTargets(nil) + result, response, operationErr := vpcService.DeleteBackupPolicyPlan(nil) Expect(operationErr).NotTo(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) - // Construct an instance of the ListShareMountTargetsOptions model - listShareMountTargetsOptionsModel := new(vpcv1.ListShareMountTargetsOptions) - listShareMountTargetsOptionsModel.ShareID = core.StringPtr("testString") - listShareMountTargetsOptionsModel.Name = core.StringPtr("testString") - listShareMountTargetsOptionsModel.Start = core.StringPtr("testString") - listShareMountTargetsOptionsModel.Limit = core.Int64Ptr(int64(10)) - listShareMountTargetsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // 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.ListShareMountTargets(listShareMountTargetsOptionsModel) + result, response, operationErr = vpcService.DeleteBackupPolicyPlan(deleteBackupPolicyPlanOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) }) - It(`Invoke ListShareMountTargets with error: Operation validation and request error`, func() { + It(`Invoke DeleteBackupPolicyPlan with error: Operation validation and request error`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -62107,25 +62264,24 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the ListShareMountTargetsOptions model - listShareMountTargetsOptionsModel := new(vpcv1.ListShareMountTargetsOptions) - listShareMountTargetsOptionsModel.ShareID = core.StringPtr("testString") - listShareMountTargetsOptionsModel.Name = core.StringPtr("testString") - listShareMountTargetsOptionsModel.Start = core.StringPtr("testString") - listShareMountTargetsOptionsModel.Limit = core.Int64Ptr(int64(10)) - listShareMountTargetsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // 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.ListShareMountTargets(listShareMountTargetsOptionsModel) + 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 ListShareMountTargetsOptions model with no property values - listShareMountTargetsOptionsModelNew := new(vpcv1.ListShareMountTargetsOptions) + // 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.ListShareMountTargets(listShareMountTargetsOptionsModelNew) + result, response, operationErr = vpcService.DeleteBackupPolicyPlan(deleteBackupPolicyPlanOptionsModelNew) Expect(operationErr).ToNot(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) @@ -62140,10 +62296,10 @@ var _ = Describe(`VpcV1`, func() { defer GinkgoRecover() // Set success status code with no respoonse body - res.WriteHeader(200) + res.WriteHeader(202) })) }) - It(`Invoke ListShareMountTargets successfully`, func() { + It(`Invoke DeleteBackupPolicyPlan successfully`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -62152,16 +62308,15 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the ListShareMountTargetsOptions model - listShareMountTargetsOptionsModel := new(vpcv1.ListShareMountTargetsOptions) - listShareMountTargetsOptionsModel.ShareID = core.StringPtr("testString") - listShareMountTargetsOptionsModel.Name = core.StringPtr("testString") - listShareMountTargetsOptionsModel.Start = core.StringPtr("testString") - listShareMountTargetsOptionsModel.Limit = core.Int64Ptr(int64(10)) - listShareMountTargetsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // 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.ListShareMountTargets(listShareMountTargetsOptionsModel) + result, response, operationErr := vpcService.DeleteBackupPolicyPlan(deleteBackupPolicyPlanOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) @@ -62172,131 +62327,26 @@ var _ = Describe(`VpcV1`, func() { testServer.Close() }) }) - Context(`Test pagination helper method on response`, func() { - It(`Invoke GetNextStart successfully`, func() { - responseObject := new(vpcv1.ShareMountTargetCollection) - nextObject := new(vpcv1.ShareMountTargetCollectionNext) - 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.ShareMountTargetCollection) - - 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.ShareMountTargetCollection) - nextObject := new(vpcv1.ShareMountTargetCollectionNext) - nextObject.Href = core.StringPtr("ibm.com") - responseObject.Next = nextObject - - value, err := responseObject.GetNextStart() - Expect(err).To(BeNil()) - Expect(value).To(BeNil()) - }) - }) - Context(`Using mock server endpoint - paginated response`, func() { - BeforeEach(func() { - var requestNumber int = 0 - testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { - defer GinkgoRecover() - - // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(listShareMountTargetsPath)) - Expect(req.Method).To(Equal("GET")) - - // Set mock response - res.Header().Set("Content-type", "application/json") - res.WriteHeader(200) - requestNumber++ - if requestNumber == 1 { - fmt.Fprintf(res, "%s", `{"next":{"href":"https://myhost.com/somePath?start=1"},"total_count":2,"limit":1,"mount_targets":[{"access_control_mode":"security_group","created_at":"2019-01-01T12:00:00.000Z","href":"https://us-south.iaas.cloud.ibm.com/v1/shares/0fe9e5d8-0a4d-4818-96ec-e99708644a58/mount_targets/4cf9171a-0043-4434-8727-15b53dbc374c","id":"4cf9171a-0043-4434-8727-15b53dbc374c","lifecycle_state":"stable","mount_path":"10.240.1.23:/nxg_s_voll_mz7121_58e7e963_8f4b_4a0c_b71a_8ba8d9cd1e2e","name":"my-share-mount-target","primary_ip":{"address":"192.168.3.4","deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e/reserved_ips/6d353a0f-aeb1-4ae1-832e-1110d10981bb","id":"6d353a0f-aeb1-4ae1-832e-1110d10981bb","name":"my-reserved-ip","resource_type":"subnet_reserved_ip"},"resource_type":"share_mount_target","subnet":{"crn":"crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e","deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e","id":"7ec86020-1c6e-4889-b3f0-a15f2e50f87e","name":"my-subnet","resource_type":"subnet"},"transit_encryption":"none","virtual_network_interface":{"crn":"crn:v1:bluemix:public:is:us-south-1:a/123456::virtual-network-interface:0767-fa41aecb-4f21-423d-8082-630bfba1e1d9","href":"https://us-south.iaas.cloud.ibm.com/v1/virtual_network_interfaces/0767-fa41aecb-4f21-423d-8082-630bfba1e1d9","id":"0767-fa41aecb-4f21-423d-8082-630bfba1e1d9","name":"my-virtual-network-interface","resource_type":"virtual_network_interface"},"vpc":{"crn":"crn:v1:bluemix:public:is:us-south:a/123456::vpc:4727d842-f94f-4a2d-824a-9bc9b02c523b","deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/vpcs/4727d842-f94f-4a2d-824a-9bc9b02c523b","id":"4727d842-f94f-4a2d-824a-9bc9b02c523b","name":"my-vpc","resource_type":"vpc"}}]}`) - } else if requestNumber == 2 { - fmt.Fprintf(res, "%s", `{"total_count":2,"limit":1,"mount_targets":[{"access_control_mode":"security_group","created_at":"2019-01-01T12:00:00.000Z","href":"https://us-south.iaas.cloud.ibm.com/v1/shares/0fe9e5d8-0a4d-4818-96ec-e99708644a58/mount_targets/4cf9171a-0043-4434-8727-15b53dbc374c","id":"4cf9171a-0043-4434-8727-15b53dbc374c","lifecycle_state":"stable","mount_path":"10.240.1.23:/nxg_s_voll_mz7121_58e7e963_8f4b_4a0c_b71a_8ba8d9cd1e2e","name":"my-share-mount-target","primary_ip":{"address":"192.168.3.4","deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e/reserved_ips/6d353a0f-aeb1-4ae1-832e-1110d10981bb","id":"6d353a0f-aeb1-4ae1-832e-1110d10981bb","name":"my-reserved-ip","resource_type":"subnet_reserved_ip"},"resource_type":"share_mount_target","subnet":{"crn":"crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e","deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e","id":"7ec86020-1c6e-4889-b3f0-a15f2e50f87e","name":"my-subnet","resource_type":"subnet"},"transit_encryption":"none","virtual_network_interface":{"crn":"crn:v1:bluemix:public:is:us-south-1:a/123456::virtual-network-interface:0767-fa41aecb-4f21-423d-8082-630bfba1e1d9","href":"https://us-south.iaas.cloud.ibm.com/v1/virtual_network_interfaces/0767-fa41aecb-4f21-423d-8082-630bfba1e1d9","id":"0767-fa41aecb-4f21-423d-8082-630bfba1e1d9","name":"my-virtual-network-interface","resource_type":"virtual_network_interface"},"vpc":{"crn":"crn:v1:bluemix:public:is:us-south:a/123456::vpc:4727d842-f94f-4a2d-824a-9bc9b02c523b","deleted":{"more_info":"https://cloud.ibm.com/apidocs/vpc#deleted-resources"},"href":"https://us-south.iaas.cloud.ibm.com/v1/vpcs/4727d842-f94f-4a2d-824a-9bc9b02c523b","id":"4727d842-f94f-4a2d-824a-9bc9b02c523b","name":"my-vpc","resource_type":"vpc"}}]}`) - } else { - res.WriteHeader(400) - } - })) - }) - It(`Use ShareMountTargetsPager.GetNext successfully`, func() { - vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ - URL: testServer.URL, - Authenticator: &core.NoAuthAuthenticator{}, - Version: core.StringPtr(version), - }) - Expect(serviceErr).To(BeNil()) - Expect(vpcService).ToNot(BeNil()) - - listShareMountTargetsOptionsModel := &vpcv1.ListShareMountTargetsOptions{ - ShareID: core.StringPtr("testString"), - Name: core.StringPtr("testString"), - Limit: core.Int64Ptr(int64(10)), - } - - pager, err := vpcService.NewShareMountTargetsPager(listShareMountTargetsOptionsModel) - Expect(err).To(BeNil()) - Expect(pager).ToNot(BeNil()) - - var allResults []vpcv1.ShareMountTarget - for pager.HasNext() { - nextPage, err := pager.GetNext() - Expect(err).To(BeNil()) - Expect(nextPage).ToNot(BeNil()) - allResults = append(allResults, nextPage...) - } - Expect(len(allResults)).To(Equal(2)) - }) - It(`Use ShareMountTargetsPager.GetAll successfully`, func() { - vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ - URL: testServer.URL, - Authenticator: &core.NoAuthAuthenticator{}, - Version: core.StringPtr(version), - }) - Expect(serviceErr).To(BeNil()) - Expect(vpcService).ToNot(BeNil()) - - listShareMountTargetsOptionsModel := &vpcv1.ListShareMountTargetsOptions{ - ShareID: core.StringPtr("testString"), - Name: core.StringPtr("testString"), - Limit: core.Int64Ptr(int64(10)), - } - - pager, err := vpcService.NewShareMountTargetsPager(listShareMountTargetsOptionsModel) - Expect(err).To(BeNil()) - Expect(pager).ToNot(BeNil()) - - allResults, err := pager.GetAll() - Expect(err).To(BeNil()) - Expect(allResults).ToNot(BeNil()) - Expect(len(allResults)).To(Equal(2)) - }) - }) }) - Describe(`CreateShareMountTarget(createShareMountTargetOptions *CreateShareMountTargetOptions) - Operation response error`, func() { + Describe(`GetBackupPolicyPlan(getBackupPolicyPlanOptions *GetBackupPolicyPlanOptions) - Operation response error`, func() { version := "testString" - createShareMountTargetPath := "/shares/testString/mount_targets" + 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(createShareMountTargetPath)) - Expect(req.Method).To(Equal("POST")) + 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(201) + res.WriteHeader(200) fmt.Fprint(res, `} this is not valid json {`) })) }) - It(`Invoke CreateShareMountTarget with error: Operation response processing error`, func() { + It(`Invoke GetBackupPolicyPlan with error: Operation response processing error`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -62305,62 +62355,20 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the VirtualNetworkInterfaceIPPrototypeReservedIPPrototypeVirtualNetworkInterfaceIPsContext model - virtualNetworkInterfaceIPPrototypeModel := new(vpcv1.VirtualNetworkInterfaceIPPrototypeReservedIPPrototypeVirtualNetworkInterfaceIPsContext) - virtualNetworkInterfaceIPPrototypeModel.Address = core.StringPtr("10.0.0.5") - virtualNetworkInterfaceIPPrototypeModel.AutoDelete = core.BoolPtr(false) - virtualNetworkInterfaceIPPrototypeModel.Name = core.StringPtr("my-reserved-ip") - - // Construct an instance of the VirtualNetworkInterfacePrimaryIPPrototypeReservedIPPrototypeVirtualNetworkInterfacePrimaryIPContext model - virtualNetworkInterfacePrimaryIPPrototypeModel := new(vpcv1.VirtualNetworkInterfacePrimaryIPPrototypeReservedIPPrototypeVirtualNetworkInterfacePrimaryIPContext) - virtualNetworkInterfacePrimaryIPPrototypeModel.Address = core.StringPtr("10.0.0.5") - virtualNetworkInterfacePrimaryIPPrototypeModel.AutoDelete = core.BoolPtr(false) - virtualNetworkInterfacePrimaryIPPrototypeModel.Name = core.StringPtr("my-reserved-ip") - - // Construct an instance of the ResourceGroupIdentityByID model - resourceGroupIdentityModel := new(vpcv1.ResourceGroupIdentityByID) - resourceGroupIdentityModel.ID = core.StringPtr("fee82deba12e4c0fb69c3b09d1f12345") - - // Construct an instance of the SecurityGroupIdentityByID model - securityGroupIdentityModel := new(vpcv1.SecurityGroupIdentityByID) - securityGroupIdentityModel.ID = core.StringPtr("be5df5ca-12a0-494b-907e-aa6ec2bfa271") - - // Construct an instance of the SubnetIdentityByID model - subnetIdentityModel := new(vpcv1.SubnetIdentityByID) - subnetIdentityModel.ID = core.StringPtr("7ec86020-1c6e-4889-b3f0-a15f2e50f87e") - - // Construct an instance of the ShareMountTargetVirtualNetworkInterfacePrototypeVirtualNetworkInterfacePrototypeShareMountTargetContext model - shareMountTargetVirtualNetworkInterfacePrototypeModel := new(vpcv1.ShareMountTargetVirtualNetworkInterfacePrototypeVirtualNetworkInterfacePrototypeShareMountTargetContext) - shareMountTargetVirtualNetworkInterfacePrototypeModel.AllowIPSpoofing = core.BoolPtr(true) - shareMountTargetVirtualNetworkInterfacePrototypeModel.AutoDelete = core.BoolPtr(false) - shareMountTargetVirtualNetworkInterfacePrototypeModel.EnableInfrastructureNat = core.BoolPtr(true) - shareMountTargetVirtualNetworkInterfacePrototypeModel.Ips = []vpcv1.VirtualNetworkInterfaceIPPrototypeIntf{virtualNetworkInterfaceIPPrototypeModel} - shareMountTargetVirtualNetworkInterfacePrototypeModel.Name = core.StringPtr("my-virtual-network-interface") - shareMountTargetVirtualNetworkInterfacePrototypeModel.PrimaryIP = virtualNetworkInterfacePrimaryIPPrototypeModel - shareMountTargetVirtualNetworkInterfacePrototypeModel.ResourceGroup = resourceGroupIdentityModel - shareMountTargetVirtualNetworkInterfacePrototypeModel.SecurityGroups = []vpcv1.SecurityGroupIdentityIntf{securityGroupIdentityModel} - shareMountTargetVirtualNetworkInterfacePrototypeModel.Subnet = subnetIdentityModel - - // Construct an instance of the ShareMountTargetPrototypeShareMountTargetByAccessControlModeSecurityGroup model - shareMountTargetPrototypeModel := new(vpcv1.ShareMountTargetPrototypeShareMountTargetByAccessControlModeSecurityGroup) - shareMountTargetPrototypeModel.Name = core.StringPtr("my-share-mount-target") - shareMountTargetPrototypeModel.TransitEncryption = core.StringPtr("none") - shareMountTargetPrototypeModel.VirtualNetworkInterface = shareMountTargetVirtualNetworkInterfacePrototypeModel - - // Construct an instance of the CreateShareMountTargetOptions model - createShareMountTargetOptionsModel := new(vpcv1.CreateShareMountTargetOptions) - createShareMountTargetOptionsModel.ShareID = core.StringPtr("testString") - createShareMountTargetOptionsModel.ShareMountTargetPrototype = shareMountTargetPrototypeModel - createShareMountTargetOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // 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.CreateShareMountTarget(createShareMountTargetOptionsModel) + 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.CreateShareMountTarget(createShareMountTargetOptionsModel) + result, response, operationErr = vpcService.GetBackupPolicyPlan(getBackupPolicyPlanOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).To(BeNil()) @@ -62370,33 +62378,17 @@ var _ = Describe(`VpcV1`, func() { }) }) }) - Describe(`CreateShareMountTarget(createShareMountTargetOptions *CreateShareMountTargetOptions)`, func() { + Describe(`GetBackupPolicyPlan(getBackupPolicyPlanOptions *GetBackupPolicyPlanOptions)`, func() { version := "testString" - createShareMountTargetPath := "/shares/testString/mount_targets" + 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(createShareMountTargetPath)) - 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.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))})) @@ -62405,11 +62397,11 @@ var _ = Describe(`VpcV1`, func() { // Set mock response res.Header().Set("Content-type", "application/json") - res.WriteHeader(201) - fmt.Fprintf(res, "%s", `{"access_control_mode": "security_group", "created_at": "2019-01-01T12:00:00.000Z", "href": "https://us-south.iaas.cloud.ibm.com/v1/shares/0fe9e5d8-0a4d-4818-96ec-e99708644a58/mount_targets/4cf9171a-0043-4434-8727-15b53dbc374c", "id": "4cf9171a-0043-4434-8727-15b53dbc374c", "lifecycle_state": "stable", "mount_path": "10.240.1.23:/nxg_s_voll_mz7121_58e7e963_8f4b_4a0c_b71a_8ba8d9cd1e2e", "name": "my-share-mount-target", "primary_ip": {"address": "192.168.3.4", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e/reserved_ips/6d353a0f-aeb1-4ae1-832e-1110d10981bb", "id": "6d353a0f-aeb1-4ae1-832e-1110d10981bb", "name": "my-reserved-ip", "resource_type": "subnet_reserved_ip"}, "resource_type": "share_mount_target", "subnet": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "id": "7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "name": "my-subnet", "resource_type": "subnet"}, "transit_encryption": "none", "virtual_network_interface": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::virtual-network-interface:0767-fa41aecb-4f21-423d-8082-630bfba1e1d9", "href": "https://us-south.iaas.cloud.ibm.com/v1/virtual_network_interfaces/0767-fa41aecb-4f21-423d-8082-630bfba1e1d9", "id": "0767-fa41aecb-4f21-423d-8082-630bfba1e1d9", "name": "my-virtual-network-interface", "resource_type": "virtual_network_interface"}, "vpc": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::vpc:4727d842-f94f-4a2d-824a-9bc9b02c523b", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/vpcs/4727d842-f94f-4a2d-824a-9bc9b02c523b", "id": "4727d842-f94f-4a2d-824a-9bc9b02c523b", "name": "my-vpc", "resource_type": "vpc"}}`) + res.WriteHeader(200) + fmt.Fprintf(res, "%s", `{"active": true, "attach_user_tags": ["AttachUserTags"], "clone_policy": {"max_snapshots": 1, "zones": [{"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south/zones/us-south-1", "name": "us-south-1"}]}, "copy_user_tags": true, "created_at": "2019-01-01T12:00:00.000Z", "cron_spec": "30 */2 * * 1-5", "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", "remote_region_policies": [{"delete_over_count": 1, "encryption_key": {"crn": "crn:v1:bluemix:public:kms:us-south:a/123456:e4a29d1a-2ef0-42a6-8fd2-350deb1c647e:key:5437653b-c4b1-447f-9646-b2a2a4cd6179"}, "region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}], "resource_type": "backup_policy_plan"}`) })) }) - It(`Invoke CreateShareMountTarget successfully with retries`, func() { + It(`Invoke GetBackupPolicyPlan successfully with retries`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -62419,64 +62411,22 @@ var _ = Describe(`VpcV1`, func() { Expect(vpcService).ToNot(BeNil()) vpcService.EnableRetries(0, 0) - // Construct an instance of the VirtualNetworkInterfaceIPPrototypeReservedIPPrototypeVirtualNetworkInterfaceIPsContext model - virtualNetworkInterfaceIPPrototypeModel := new(vpcv1.VirtualNetworkInterfaceIPPrototypeReservedIPPrototypeVirtualNetworkInterfaceIPsContext) - virtualNetworkInterfaceIPPrototypeModel.Address = core.StringPtr("10.0.0.5") - virtualNetworkInterfaceIPPrototypeModel.AutoDelete = core.BoolPtr(false) - virtualNetworkInterfaceIPPrototypeModel.Name = core.StringPtr("my-reserved-ip") - - // Construct an instance of the VirtualNetworkInterfacePrimaryIPPrototypeReservedIPPrototypeVirtualNetworkInterfacePrimaryIPContext model - virtualNetworkInterfacePrimaryIPPrototypeModel := new(vpcv1.VirtualNetworkInterfacePrimaryIPPrototypeReservedIPPrototypeVirtualNetworkInterfacePrimaryIPContext) - virtualNetworkInterfacePrimaryIPPrototypeModel.Address = core.StringPtr("10.0.0.5") - virtualNetworkInterfacePrimaryIPPrototypeModel.AutoDelete = core.BoolPtr(false) - virtualNetworkInterfacePrimaryIPPrototypeModel.Name = core.StringPtr("my-reserved-ip") - - // Construct an instance of the ResourceGroupIdentityByID model - resourceGroupIdentityModel := new(vpcv1.ResourceGroupIdentityByID) - resourceGroupIdentityModel.ID = core.StringPtr("fee82deba12e4c0fb69c3b09d1f12345") - - // Construct an instance of the SecurityGroupIdentityByID model - securityGroupIdentityModel := new(vpcv1.SecurityGroupIdentityByID) - securityGroupIdentityModel.ID = core.StringPtr("be5df5ca-12a0-494b-907e-aa6ec2bfa271") - - // Construct an instance of the SubnetIdentityByID model - subnetIdentityModel := new(vpcv1.SubnetIdentityByID) - subnetIdentityModel.ID = core.StringPtr("7ec86020-1c6e-4889-b3f0-a15f2e50f87e") - - // Construct an instance of the ShareMountTargetVirtualNetworkInterfacePrototypeVirtualNetworkInterfacePrototypeShareMountTargetContext model - shareMountTargetVirtualNetworkInterfacePrototypeModel := new(vpcv1.ShareMountTargetVirtualNetworkInterfacePrototypeVirtualNetworkInterfacePrototypeShareMountTargetContext) - shareMountTargetVirtualNetworkInterfacePrototypeModel.AllowIPSpoofing = core.BoolPtr(true) - shareMountTargetVirtualNetworkInterfacePrototypeModel.AutoDelete = core.BoolPtr(false) - shareMountTargetVirtualNetworkInterfacePrototypeModel.EnableInfrastructureNat = core.BoolPtr(true) - shareMountTargetVirtualNetworkInterfacePrototypeModel.Ips = []vpcv1.VirtualNetworkInterfaceIPPrototypeIntf{virtualNetworkInterfaceIPPrototypeModel} - shareMountTargetVirtualNetworkInterfacePrototypeModel.Name = core.StringPtr("my-virtual-network-interface") - shareMountTargetVirtualNetworkInterfacePrototypeModel.PrimaryIP = virtualNetworkInterfacePrimaryIPPrototypeModel - shareMountTargetVirtualNetworkInterfacePrototypeModel.ResourceGroup = resourceGroupIdentityModel - shareMountTargetVirtualNetworkInterfacePrototypeModel.SecurityGroups = []vpcv1.SecurityGroupIdentityIntf{securityGroupIdentityModel} - shareMountTargetVirtualNetworkInterfacePrototypeModel.Subnet = subnetIdentityModel - - // Construct an instance of the ShareMountTargetPrototypeShareMountTargetByAccessControlModeSecurityGroup model - shareMountTargetPrototypeModel := new(vpcv1.ShareMountTargetPrototypeShareMountTargetByAccessControlModeSecurityGroup) - shareMountTargetPrototypeModel.Name = core.StringPtr("my-share-mount-target") - shareMountTargetPrototypeModel.TransitEncryption = core.StringPtr("none") - shareMountTargetPrototypeModel.VirtualNetworkInterface = shareMountTargetVirtualNetworkInterfacePrototypeModel - - // Construct an instance of the CreateShareMountTargetOptions model - createShareMountTargetOptionsModel := new(vpcv1.CreateShareMountTargetOptions) - createShareMountTargetOptionsModel.ShareID = core.StringPtr("testString") - createShareMountTargetOptionsModel.ShareMountTargetPrototype = shareMountTargetPrototypeModel - createShareMountTargetOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // 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.CreateShareMountTargetWithContext(ctx, createShareMountTargetOptionsModel) + _, _, 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.CreateShareMountTarget(createShareMountTargetOptionsModel) + result, response, operationErr := vpcService.GetBackupPolicyPlan(getBackupPolicyPlanOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) @@ -62484,7 +62434,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.CreateShareMountTargetWithContext(ctx, createShareMountTargetOptionsModel) + _, _, operationErr = vpcService.GetBackupPolicyPlanWithContext(ctx, getBackupPolicyPlanOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) }) @@ -62498,34 +62448,18 @@ var _ = Describe(`VpcV1`, func() { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(createShareMountTargetPath)) - 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.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(201) - fmt.Fprintf(res, "%s", `{"access_control_mode": "security_group", "created_at": "2019-01-01T12:00:00.000Z", "href": "https://us-south.iaas.cloud.ibm.com/v1/shares/0fe9e5d8-0a4d-4818-96ec-e99708644a58/mount_targets/4cf9171a-0043-4434-8727-15b53dbc374c", "id": "4cf9171a-0043-4434-8727-15b53dbc374c", "lifecycle_state": "stable", "mount_path": "10.240.1.23:/nxg_s_voll_mz7121_58e7e963_8f4b_4a0c_b71a_8ba8d9cd1e2e", "name": "my-share-mount-target", "primary_ip": {"address": "192.168.3.4", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e/reserved_ips/6d353a0f-aeb1-4ae1-832e-1110d10981bb", "id": "6d353a0f-aeb1-4ae1-832e-1110d10981bb", "name": "my-reserved-ip", "resource_type": "subnet_reserved_ip"}, "resource_type": "share_mount_target", "subnet": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "id": "7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "name": "my-subnet", "resource_type": "subnet"}, "transit_encryption": "none", "virtual_network_interface": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::virtual-network-interface:0767-fa41aecb-4f21-423d-8082-630bfba1e1d9", "href": "https://us-south.iaas.cloud.ibm.com/v1/virtual_network_interfaces/0767-fa41aecb-4f21-423d-8082-630bfba1e1d9", "id": "0767-fa41aecb-4f21-423d-8082-630bfba1e1d9", "name": "my-virtual-network-interface", "resource_type": "virtual_network_interface"}, "vpc": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::vpc:4727d842-f94f-4a2d-824a-9bc9b02c523b", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/vpcs/4727d842-f94f-4a2d-824a-9bc9b02c523b", "id": "4727d842-f94f-4a2d-824a-9bc9b02c523b", "name": "my-vpc", "resource_type": "vpc"}}`) + res.WriteHeader(200) + fmt.Fprintf(res, "%s", `{"active": true, "attach_user_tags": ["AttachUserTags"], "clone_policy": {"max_snapshots": 1, "zones": [{"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south/zones/us-south-1", "name": "us-south-1"}]}, "copy_user_tags": true, "created_at": "2019-01-01T12:00:00.000Z", "cron_spec": "30 */2 * * 1-5", "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", "remote_region_policies": [{"delete_over_count": 1, "encryption_key": {"crn": "crn:v1:bluemix:public:kms:us-south:a/123456:e4a29d1a-2ef0-42a6-8fd2-350deb1c647e:key:5437653b-c4b1-447f-9646-b2a2a4cd6179"}, "region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}], "resource_type": "backup_policy_plan"}`) })) }) - It(`Invoke CreateShareMountTarget successfully`, func() { + It(`Invoke GetBackupPolicyPlan successfully`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -62535,134 +62469,50 @@ var _ = Describe(`VpcV1`, func() { Expect(vpcService).ToNot(BeNil()) // Invoke operation with nil options model (negative test) - result, response, operationErr := vpcService.CreateShareMountTarget(nil) + result, response, operationErr := vpcService.GetBackupPolicyPlan(nil) Expect(operationErr).NotTo(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) - // Construct an instance of the VirtualNetworkInterfaceIPPrototypeReservedIPPrototypeVirtualNetworkInterfaceIPsContext model - virtualNetworkInterfaceIPPrototypeModel := new(vpcv1.VirtualNetworkInterfaceIPPrototypeReservedIPPrototypeVirtualNetworkInterfaceIPsContext) - virtualNetworkInterfaceIPPrototypeModel.Address = core.StringPtr("10.0.0.5") - virtualNetworkInterfaceIPPrototypeModel.AutoDelete = core.BoolPtr(false) - virtualNetworkInterfaceIPPrototypeModel.Name = core.StringPtr("my-reserved-ip") - - // Construct an instance of the VirtualNetworkInterfacePrimaryIPPrototypeReservedIPPrototypeVirtualNetworkInterfacePrimaryIPContext model - virtualNetworkInterfacePrimaryIPPrototypeModel := new(vpcv1.VirtualNetworkInterfacePrimaryIPPrototypeReservedIPPrototypeVirtualNetworkInterfacePrimaryIPContext) - virtualNetworkInterfacePrimaryIPPrototypeModel.Address = core.StringPtr("10.0.0.5") - virtualNetworkInterfacePrimaryIPPrototypeModel.AutoDelete = core.BoolPtr(false) - virtualNetworkInterfacePrimaryIPPrototypeModel.Name = core.StringPtr("my-reserved-ip") - - // Construct an instance of the ResourceGroupIdentityByID model - resourceGroupIdentityModel := new(vpcv1.ResourceGroupIdentityByID) - resourceGroupIdentityModel.ID = core.StringPtr("fee82deba12e4c0fb69c3b09d1f12345") - - // Construct an instance of the SecurityGroupIdentityByID model - securityGroupIdentityModel := new(vpcv1.SecurityGroupIdentityByID) - securityGroupIdentityModel.ID = core.StringPtr("be5df5ca-12a0-494b-907e-aa6ec2bfa271") - - // Construct an instance of the SubnetIdentityByID model - subnetIdentityModel := new(vpcv1.SubnetIdentityByID) - subnetIdentityModel.ID = core.StringPtr("7ec86020-1c6e-4889-b3f0-a15f2e50f87e") - - // Construct an instance of the ShareMountTargetVirtualNetworkInterfacePrototypeVirtualNetworkInterfacePrototypeShareMountTargetContext model - shareMountTargetVirtualNetworkInterfacePrototypeModel := new(vpcv1.ShareMountTargetVirtualNetworkInterfacePrototypeVirtualNetworkInterfacePrototypeShareMountTargetContext) - shareMountTargetVirtualNetworkInterfacePrototypeModel.AllowIPSpoofing = core.BoolPtr(true) - shareMountTargetVirtualNetworkInterfacePrototypeModel.AutoDelete = core.BoolPtr(false) - shareMountTargetVirtualNetworkInterfacePrototypeModel.EnableInfrastructureNat = core.BoolPtr(true) - shareMountTargetVirtualNetworkInterfacePrototypeModel.Ips = []vpcv1.VirtualNetworkInterfaceIPPrototypeIntf{virtualNetworkInterfaceIPPrototypeModel} - shareMountTargetVirtualNetworkInterfacePrototypeModel.Name = core.StringPtr("my-virtual-network-interface") - shareMountTargetVirtualNetworkInterfacePrototypeModel.PrimaryIP = virtualNetworkInterfacePrimaryIPPrototypeModel - shareMountTargetVirtualNetworkInterfacePrototypeModel.ResourceGroup = resourceGroupIdentityModel - shareMountTargetVirtualNetworkInterfacePrototypeModel.SecurityGroups = []vpcv1.SecurityGroupIdentityIntf{securityGroupIdentityModel} - shareMountTargetVirtualNetworkInterfacePrototypeModel.Subnet = subnetIdentityModel - - // Construct an instance of the ShareMountTargetPrototypeShareMountTargetByAccessControlModeSecurityGroup model - shareMountTargetPrototypeModel := new(vpcv1.ShareMountTargetPrototypeShareMountTargetByAccessControlModeSecurityGroup) - shareMountTargetPrototypeModel.Name = core.StringPtr("my-share-mount-target") - shareMountTargetPrototypeModel.TransitEncryption = core.StringPtr("none") - shareMountTargetPrototypeModel.VirtualNetworkInterface = shareMountTargetVirtualNetworkInterfacePrototypeModel - - // Construct an instance of the CreateShareMountTargetOptions model - createShareMountTargetOptionsModel := new(vpcv1.CreateShareMountTargetOptions) - createShareMountTargetOptionsModel.ShareID = core.StringPtr("testString") - createShareMountTargetOptionsModel.ShareMountTargetPrototype = shareMountTargetPrototypeModel - createShareMountTargetOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // 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.CreateShareMountTarget(createShareMountTargetOptionsModel) + result, response, operationErr = vpcService.GetBackupPolicyPlan(getBackupPolicyPlanOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) }) - It(`Invoke CreateShareMountTarget with error: Operation validation and request error`, func() { + 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 VirtualNetworkInterfaceIPPrototypeReservedIPPrototypeVirtualNetworkInterfaceIPsContext model - virtualNetworkInterfaceIPPrototypeModel := new(vpcv1.VirtualNetworkInterfaceIPPrototypeReservedIPPrototypeVirtualNetworkInterfaceIPsContext) - virtualNetworkInterfaceIPPrototypeModel.Address = core.StringPtr("10.0.0.5") - virtualNetworkInterfaceIPPrototypeModel.AutoDelete = core.BoolPtr(false) - virtualNetworkInterfaceIPPrototypeModel.Name = core.StringPtr("my-reserved-ip") - - // Construct an instance of the VirtualNetworkInterfacePrimaryIPPrototypeReservedIPPrototypeVirtualNetworkInterfacePrimaryIPContext model - virtualNetworkInterfacePrimaryIPPrototypeModel := new(vpcv1.VirtualNetworkInterfacePrimaryIPPrototypeReservedIPPrototypeVirtualNetworkInterfacePrimaryIPContext) - virtualNetworkInterfacePrimaryIPPrototypeModel.Address = core.StringPtr("10.0.0.5") - virtualNetworkInterfacePrimaryIPPrototypeModel.AutoDelete = core.BoolPtr(false) - virtualNetworkInterfacePrimaryIPPrototypeModel.Name = core.StringPtr("my-reserved-ip") - - // Construct an instance of the ResourceGroupIdentityByID model - resourceGroupIdentityModel := new(vpcv1.ResourceGroupIdentityByID) - resourceGroupIdentityModel.ID = core.StringPtr("fee82deba12e4c0fb69c3b09d1f12345") - - // Construct an instance of the SecurityGroupIdentityByID model - securityGroupIdentityModel := new(vpcv1.SecurityGroupIdentityByID) - securityGroupIdentityModel.ID = core.StringPtr("be5df5ca-12a0-494b-907e-aa6ec2bfa271") - - // Construct an instance of the SubnetIdentityByID model - subnetIdentityModel := new(vpcv1.SubnetIdentityByID) - subnetIdentityModel.ID = core.StringPtr("7ec86020-1c6e-4889-b3f0-a15f2e50f87e") - - // Construct an instance of the ShareMountTargetVirtualNetworkInterfacePrototypeVirtualNetworkInterfacePrototypeShareMountTargetContext model - shareMountTargetVirtualNetworkInterfacePrototypeModel := new(vpcv1.ShareMountTargetVirtualNetworkInterfacePrototypeVirtualNetworkInterfacePrototypeShareMountTargetContext) - shareMountTargetVirtualNetworkInterfacePrototypeModel.AllowIPSpoofing = core.BoolPtr(true) - shareMountTargetVirtualNetworkInterfacePrototypeModel.AutoDelete = core.BoolPtr(false) - shareMountTargetVirtualNetworkInterfacePrototypeModel.EnableInfrastructureNat = core.BoolPtr(true) - shareMountTargetVirtualNetworkInterfacePrototypeModel.Ips = []vpcv1.VirtualNetworkInterfaceIPPrototypeIntf{virtualNetworkInterfaceIPPrototypeModel} - shareMountTargetVirtualNetworkInterfacePrototypeModel.Name = core.StringPtr("my-virtual-network-interface") - shareMountTargetVirtualNetworkInterfacePrototypeModel.PrimaryIP = virtualNetworkInterfacePrimaryIPPrototypeModel - shareMountTargetVirtualNetworkInterfacePrototypeModel.ResourceGroup = resourceGroupIdentityModel - shareMountTargetVirtualNetworkInterfacePrototypeModel.SecurityGroups = []vpcv1.SecurityGroupIdentityIntf{securityGroupIdentityModel} - shareMountTargetVirtualNetworkInterfacePrototypeModel.Subnet = subnetIdentityModel - - // Construct an instance of the ShareMountTargetPrototypeShareMountTargetByAccessControlModeSecurityGroup model - shareMountTargetPrototypeModel := new(vpcv1.ShareMountTargetPrototypeShareMountTargetByAccessControlModeSecurityGroup) - shareMountTargetPrototypeModel.Name = core.StringPtr("my-share-mount-target") - shareMountTargetPrototypeModel.TransitEncryption = core.StringPtr("none") - shareMountTargetPrototypeModel.VirtualNetworkInterface = shareMountTargetVirtualNetworkInterfacePrototypeModel - - // Construct an instance of the CreateShareMountTargetOptions model - createShareMountTargetOptionsModel := new(vpcv1.CreateShareMountTargetOptions) - createShareMountTargetOptionsModel.ShareID = core.StringPtr("testString") - createShareMountTargetOptionsModel.ShareMountTargetPrototype = shareMountTargetPrototypeModel - createShareMountTargetOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + 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.CreateShareMountTarget(createShareMountTargetOptionsModel) + 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 CreateShareMountTargetOptions model with no property values - createShareMountTargetOptionsModelNew := new(vpcv1.CreateShareMountTargetOptions) + // 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.CreateShareMountTarget(createShareMountTargetOptionsModelNew) + result, response, operationErr = vpcService.GetBackupPolicyPlan(getBackupPolicyPlanOptionsModelNew) Expect(operationErr).ToNot(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) @@ -62677,10 +62527,10 @@ var _ = Describe(`VpcV1`, func() { defer GinkgoRecover() // Set success status code with no respoonse body - res.WriteHeader(201) + res.WriteHeader(200) })) }) - It(`Invoke CreateShareMountTarget successfully`, func() { + It(`Invoke GetBackupPolicyPlan successfully`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -62689,56 +62539,14 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the VirtualNetworkInterfaceIPPrototypeReservedIPPrototypeVirtualNetworkInterfaceIPsContext model - virtualNetworkInterfaceIPPrototypeModel := new(vpcv1.VirtualNetworkInterfaceIPPrototypeReservedIPPrototypeVirtualNetworkInterfaceIPsContext) - virtualNetworkInterfaceIPPrototypeModel.Address = core.StringPtr("10.0.0.5") - virtualNetworkInterfaceIPPrototypeModel.AutoDelete = core.BoolPtr(false) - virtualNetworkInterfaceIPPrototypeModel.Name = core.StringPtr("my-reserved-ip") - - // Construct an instance of the VirtualNetworkInterfacePrimaryIPPrototypeReservedIPPrototypeVirtualNetworkInterfacePrimaryIPContext model - virtualNetworkInterfacePrimaryIPPrototypeModel := new(vpcv1.VirtualNetworkInterfacePrimaryIPPrototypeReservedIPPrototypeVirtualNetworkInterfacePrimaryIPContext) - virtualNetworkInterfacePrimaryIPPrototypeModel.Address = core.StringPtr("10.0.0.5") - virtualNetworkInterfacePrimaryIPPrototypeModel.AutoDelete = core.BoolPtr(false) - virtualNetworkInterfacePrimaryIPPrototypeModel.Name = core.StringPtr("my-reserved-ip") - - // Construct an instance of the ResourceGroupIdentityByID model - resourceGroupIdentityModel := new(vpcv1.ResourceGroupIdentityByID) - resourceGroupIdentityModel.ID = core.StringPtr("fee82deba12e4c0fb69c3b09d1f12345") - - // Construct an instance of the SecurityGroupIdentityByID model - securityGroupIdentityModel := new(vpcv1.SecurityGroupIdentityByID) - securityGroupIdentityModel.ID = core.StringPtr("be5df5ca-12a0-494b-907e-aa6ec2bfa271") - - // Construct an instance of the SubnetIdentityByID model - subnetIdentityModel := new(vpcv1.SubnetIdentityByID) - subnetIdentityModel.ID = core.StringPtr("7ec86020-1c6e-4889-b3f0-a15f2e50f87e") - - // Construct an instance of the ShareMountTargetVirtualNetworkInterfacePrototypeVirtualNetworkInterfacePrototypeShareMountTargetContext model - shareMountTargetVirtualNetworkInterfacePrototypeModel := new(vpcv1.ShareMountTargetVirtualNetworkInterfacePrototypeVirtualNetworkInterfacePrototypeShareMountTargetContext) - shareMountTargetVirtualNetworkInterfacePrototypeModel.AllowIPSpoofing = core.BoolPtr(true) - shareMountTargetVirtualNetworkInterfacePrototypeModel.AutoDelete = core.BoolPtr(false) - shareMountTargetVirtualNetworkInterfacePrototypeModel.EnableInfrastructureNat = core.BoolPtr(true) - shareMountTargetVirtualNetworkInterfacePrototypeModel.Ips = []vpcv1.VirtualNetworkInterfaceIPPrototypeIntf{virtualNetworkInterfaceIPPrototypeModel} - shareMountTargetVirtualNetworkInterfacePrototypeModel.Name = core.StringPtr("my-virtual-network-interface") - shareMountTargetVirtualNetworkInterfacePrototypeModel.PrimaryIP = virtualNetworkInterfacePrimaryIPPrototypeModel - shareMountTargetVirtualNetworkInterfacePrototypeModel.ResourceGroup = resourceGroupIdentityModel - shareMountTargetVirtualNetworkInterfacePrototypeModel.SecurityGroups = []vpcv1.SecurityGroupIdentityIntf{securityGroupIdentityModel} - shareMountTargetVirtualNetworkInterfacePrototypeModel.Subnet = subnetIdentityModel - - // Construct an instance of the ShareMountTargetPrototypeShareMountTargetByAccessControlModeSecurityGroup model - shareMountTargetPrototypeModel := new(vpcv1.ShareMountTargetPrototypeShareMountTargetByAccessControlModeSecurityGroup) - shareMountTargetPrototypeModel.Name = core.StringPtr("my-share-mount-target") - shareMountTargetPrototypeModel.TransitEncryption = core.StringPtr("none") - shareMountTargetPrototypeModel.VirtualNetworkInterface = shareMountTargetVirtualNetworkInterfacePrototypeModel - - // Construct an instance of the CreateShareMountTargetOptions model - createShareMountTargetOptionsModel := new(vpcv1.CreateShareMountTargetOptions) - createShareMountTargetOptionsModel.ShareID = core.StringPtr("testString") - createShareMountTargetOptionsModel.ShareMountTargetPrototype = shareMountTargetPrototypeModel - createShareMountTargetOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // 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.CreateShareMountTarget(createShareMountTargetOptionsModel) + result, response, operationErr := vpcService.GetBackupPolicyPlan(getBackupPolicyPlanOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) @@ -62750,25 +62558,27 @@ var _ = Describe(`VpcV1`, func() { }) }) }) - Describe(`DeleteShareMountTarget(deleteShareMountTargetOptions *DeleteShareMountTargetOptions) - Operation response error`, func() { + Describe(`UpdateBackupPolicyPlan(updateBackupPolicyPlanOptions *UpdateBackupPolicyPlanOptions) - Operation response error`, func() { version := "testString" - deleteShareMountTargetPath := "/shares/testString/mount_targets/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(deleteShareMountTargetPath)) - Expect(req.Method).To(Equal("DELETE")) + 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(202) + res.WriteHeader(200) fmt.Fprint(res, `} this is not valid json {`) })) }) - It(`Invoke DeleteShareMountTarget with error: Operation response processing error`, func() { + It(`Invoke UpdateBackupPolicyPlan with error: Operation response processing error`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -62777,20 +62587,63 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the DeleteShareMountTargetOptions model - deleteShareMountTargetOptionsModel := new(vpcv1.DeleteShareMountTargetOptions) - deleteShareMountTargetOptionsModel.ShareID = core.StringPtr("testString") - deleteShareMountTargetOptionsModel.ID = core.StringPtr("testString") - deleteShareMountTargetOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the ZoneIdentityByName model + zoneIdentityModel := new(vpcv1.ZoneIdentityByName) + zoneIdentityModel.Name = core.StringPtr("us-south-1") + + // Construct an instance of the BackupPolicyPlanClonePolicyPatch model + backupPolicyPlanClonePolicyPatchModel := new(vpcv1.BackupPolicyPlanClonePolicyPatch) + backupPolicyPlanClonePolicyPatchModel.MaxSnapshots = core.Int64Ptr(int64(1)) + backupPolicyPlanClonePolicyPatchModel.Zones = []vpcv1.ZoneIdentityIntf{zoneIdentityModel} + + // Construct an instance of the BackupPolicyPlanDeletionTriggerPatch model + backupPolicyPlanDeletionTriggerPatchModel := new(vpcv1.BackupPolicyPlanDeletionTriggerPatch) + backupPolicyPlanDeletionTriggerPatchModel.DeleteAfter = core.Int64Ptr(int64(20)) + backupPolicyPlanDeletionTriggerPatchModel.DeleteOverCount = core.Int64Ptr(int64(1)) + + // Construct an instance of the EncryptionKeyIdentityByCRN model + encryptionKeyIdentityModel := new(vpcv1.EncryptionKeyIdentityByCRN) + encryptionKeyIdentityModel.CRN = core.StringPtr("crn:v1:bluemix:public:kms:us-south:a/123456:e4a29d1a-2ef0-42a6-8fd2-350deb1c647e:key:5437653b-c4b1-447f-9646-b2a2a4cd6179") + + // Construct an instance of the RegionIdentityByName model + regionIdentityModel := new(vpcv1.RegionIdentityByName) + regionIdentityModel.Name = core.StringPtr("us-south") + + // Construct an instance of the BackupPolicyPlanRemoteRegionPolicyPrototype model + backupPolicyPlanRemoteRegionPolicyPrototypeModel := new(vpcv1.BackupPolicyPlanRemoteRegionPolicyPrototype) + backupPolicyPlanRemoteRegionPolicyPrototypeModel.DeleteOverCount = core.Int64Ptr(int64(5)) + backupPolicyPlanRemoteRegionPolicyPrototypeModel.EncryptionKey = encryptionKeyIdentityModel + backupPolicyPlanRemoteRegionPolicyPrototypeModel.Region = regionIdentityModel + + // Construct an instance of the BackupPolicyPlanPatch model + backupPolicyPlanPatchModel := new(vpcv1.BackupPolicyPlanPatch) + backupPolicyPlanPatchModel.Active = core.BoolPtr(true) + backupPolicyPlanPatchModel.AttachUserTags = []string{"my-daily-backup-plan"} + backupPolicyPlanPatchModel.ClonePolicy = backupPolicyPlanClonePolicyPatchModel + backupPolicyPlanPatchModel.CopyUserTags = core.BoolPtr(true) + backupPolicyPlanPatchModel.CronSpec = core.StringPtr("30 */2 * * 1-5") + backupPolicyPlanPatchModel.DeletionTrigger = backupPolicyPlanDeletionTriggerPatchModel + backupPolicyPlanPatchModel.Name = core.StringPtr("my-policy-plan") + backupPolicyPlanPatchModel.RemoteRegionPolicies = []vpcv1.BackupPolicyPlanRemoteRegionPolicyPrototype{*backupPolicyPlanRemoteRegionPolicyPrototypeModel} + 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.DeleteShareMountTarget(deleteShareMountTargetOptionsModel) + 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.DeleteShareMountTarget(deleteShareMountTargetOptionsModel) + result, response, operationErr = vpcService.UpdateBackupPolicyPlan(updateBackupPolicyPlanOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).To(BeNil()) @@ -62800,18 +62653,36 @@ var _ = Describe(`VpcV1`, func() { }) }) }) - Describe(`DeleteShareMountTarget(deleteShareMountTargetOptions *DeleteShareMountTargetOptions)`, func() { + Describe(`UpdateBackupPolicyPlan(updateBackupPolicyPlanOptions *UpdateBackupPolicyPlanOptions)`, func() { version := "testString" - deleteShareMountTargetPath := "/shares/testString/mount_targets/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(deleteShareMountTargetPath)) - Expect(req.Method).To(Equal("DELETE")) + 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 @@ -62819,11 +62690,11 @@ var _ = Describe(`VpcV1`, func() { // Set mock response res.Header().Set("Content-type", "application/json") - res.WriteHeader(202) - fmt.Fprintf(res, "%s", `{"access_control_mode": "security_group", "created_at": "2019-01-01T12:00:00.000Z", "href": "https://us-south.iaas.cloud.ibm.com/v1/shares/0fe9e5d8-0a4d-4818-96ec-e99708644a58/mount_targets/4cf9171a-0043-4434-8727-15b53dbc374c", "id": "4cf9171a-0043-4434-8727-15b53dbc374c", "lifecycle_state": "stable", "mount_path": "10.240.1.23:/nxg_s_voll_mz7121_58e7e963_8f4b_4a0c_b71a_8ba8d9cd1e2e", "name": "my-share-mount-target", "primary_ip": {"address": "192.168.3.4", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e/reserved_ips/6d353a0f-aeb1-4ae1-832e-1110d10981bb", "id": "6d353a0f-aeb1-4ae1-832e-1110d10981bb", "name": "my-reserved-ip", "resource_type": "subnet_reserved_ip"}, "resource_type": "share_mount_target", "subnet": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "id": "7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "name": "my-subnet", "resource_type": "subnet"}, "transit_encryption": "none", "virtual_network_interface": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::virtual-network-interface:0767-fa41aecb-4f21-423d-8082-630bfba1e1d9", "href": "https://us-south.iaas.cloud.ibm.com/v1/virtual_network_interfaces/0767-fa41aecb-4f21-423d-8082-630bfba1e1d9", "id": "0767-fa41aecb-4f21-423d-8082-630bfba1e1d9", "name": "my-virtual-network-interface", "resource_type": "virtual_network_interface"}, "vpc": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::vpc:4727d842-f94f-4a2d-824a-9bc9b02c523b", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/vpcs/4727d842-f94f-4a2d-824a-9bc9b02c523b", "id": "4727d842-f94f-4a2d-824a-9bc9b02c523b", "name": "my-vpc", "resource_type": "vpc"}}`) + res.WriteHeader(200) + fmt.Fprintf(res, "%s", `{"active": true, "attach_user_tags": ["AttachUserTags"], "clone_policy": {"max_snapshots": 1, "zones": [{"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south/zones/us-south-1", "name": "us-south-1"}]}, "copy_user_tags": true, "created_at": "2019-01-01T12:00:00.000Z", "cron_spec": "30 */2 * * 1-5", "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", "remote_region_policies": [{"delete_over_count": 1, "encryption_key": {"crn": "crn:v1:bluemix:public:kms:us-south:a/123456:e4a29d1a-2ef0-42a6-8fd2-350deb1c647e:key:5437653b-c4b1-447f-9646-b2a2a4cd6179"}, "region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}], "resource_type": "backup_policy_plan"}`) })) }) - It(`Invoke DeleteShareMountTarget successfully with retries`, func() { + It(`Invoke UpdateBackupPolicyPlan successfully with retries`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -62833,22 +62704,65 @@ var _ = Describe(`VpcV1`, func() { Expect(vpcService).ToNot(BeNil()) vpcService.EnableRetries(0, 0) - // Construct an instance of the DeleteShareMountTargetOptions model - deleteShareMountTargetOptionsModel := new(vpcv1.DeleteShareMountTargetOptions) - deleteShareMountTargetOptionsModel.ShareID = core.StringPtr("testString") - deleteShareMountTargetOptionsModel.ID = core.StringPtr("testString") - deleteShareMountTargetOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the ZoneIdentityByName model + zoneIdentityModel := new(vpcv1.ZoneIdentityByName) + zoneIdentityModel.Name = core.StringPtr("us-south-1") + + // Construct an instance of the BackupPolicyPlanClonePolicyPatch model + backupPolicyPlanClonePolicyPatchModel := new(vpcv1.BackupPolicyPlanClonePolicyPatch) + backupPolicyPlanClonePolicyPatchModel.MaxSnapshots = core.Int64Ptr(int64(1)) + backupPolicyPlanClonePolicyPatchModel.Zones = []vpcv1.ZoneIdentityIntf{zoneIdentityModel} + + // Construct an instance of the BackupPolicyPlanDeletionTriggerPatch model + backupPolicyPlanDeletionTriggerPatchModel := new(vpcv1.BackupPolicyPlanDeletionTriggerPatch) + backupPolicyPlanDeletionTriggerPatchModel.DeleteAfter = core.Int64Ptr(int64(20)) + backupPolicyPlanDeletionTriggerPatchModel.DeleteOverCount = core.Int64Ptr(int64(1)) + + // Construct an instance of the EncryptionKeyIdentityByCRN model + encryptionKeyIdentityModel := new(vpcv1.EncryptionKeyIdentityByCRN) + encryptionKeyIdentityModel.CRN = core.StringPtr("crn:v1:bluemix:public:kms:us-south:a/123456:e4a29d1a-2ef0-42a6-8fd2-350deb1c647e:key:5437653b-c4b1-447f-9646-b2a2a4cd6179") + + // Construct an instance of the RegionIdentityByName model + regionIdentityModel := new(vpcv1.RegionIdentityByName) + regionIdentityModel.Name = core.StringPtr("us-south") + + // Construct an instance of the BackupPolicyPlanRemoteRegionPolicyPrototype model + backupPolicyPlanRemoteRegionPolicyPrototypeModel := new(vpcv1.BackupPolicyPlanRemoteRegionPolicyPrototype) + backupPolicyPlanRemoteRegionPolicyPrototypeModel.DeleteOverCount = core.Int64Ptr(int64(5)) + backupPolicyPlanRemoteRegionPolicyPrototypeModel.EncryptionKey = encryptionKeyIdentityModel + backupPolicyPlanRemoteRegionPolicyPrototypeModel.Region = regionIdentityModel + + // Construct an instance of the BackupPolicyPlanPatch model + backupPolicyPlanPatchModel := new(vpcv1.BackupPolicyPlanPatch) + backupPolicyPlanPatchModel.Active = core.BoolPtr(true) + backupPolicyPlanPatchModel.AttachUserTags = []string{"my-daily-backup-plan"} + backupPolicyPlanPatchModel.ClonePolicy = backupPolicyPlanClonePolicyPatchModel + backupPolicyPlanPatchModel.CopyUserTags = core.BoolPtr(true) + backupPolicyPlanPatchModel.CronSpec = core.StringPtr("30 */2 * * 1-5") + backupPolicyPlanPatchModel.DeletionTrigger = backupPolicyPlanDeletionTriggerPatchModel + backupPolicyPlanPatchModel.Name = core.StringPtr("my-policy-plan") + backupPolicyPlanPatchModel.RemoteRegionPolicies = []vpcv1.BackupPolicyPlanRemoteRegionPolicyPrototype{*backupPolicyPlanRemoteRegionPolicyPrototypeModel} + 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.DeleteShareMountTargetWithContext(ctx, deleteShareMountTargetOptionsModel) + _, _, 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.DeleteShareMountTarget(deleteShareMountTargetOptionsModel) + result, response, operationErr := vpcService.UpdateBackupPolicyPlan(updateBackupPolicyPlanOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) @@ -62856,7 +62770,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.DeleteShareMountTargetWithContext(ctx, deleteShareMountTargetOptionsModel) + _, _, operationErr = vpcService.UpdateBackupPolicyPlanWithContext(ctx, updateBackupPolicyPlanOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) }) @@ -62870,18 +62784,36 @@ var _ = Describe(`VpcV1`, func() { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(deleteShareMountTargetPath)) - Expect(req.Method).To(Equal("DELETE")) + 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(202) - fmt.Fprintf(res, "%s", `{"access_control_mode": "security_group", "created_at": "2019-01-01T12:00:00.000Z", "href": "https://us-south.iaas.cloud.ibm.com/v1/shares/0fe9e5d8-0a4d-4818-96ec-e99708644a58/mount_targets/4cf9171a-0043-4434-8727-15b53dbc374c", "id": "4cf9171a-0043-4434-8727-15b53dbc374c", "lifecycle_state": "stable", "mount_path": "10.240.1.23:/nxg_s_voll_mz7121_58e7e963_8f4b_4a0c_b71a_8ba8d9cd1e2e", "name": "my-share-mount-target", "primary_ip": {"address": "192.168.3.4", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e/reserved_ips/6d353a0f-aeb1-4ae1-832e-1110d10981bb", "id": "6d353a0f-aeb1-4ae1-832e-1110d10981bb", "name": "my-reserved-ip", "resource_type": "subnet_reserved_ip"}, "resource_type": "share_mount_target", "subnet": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "id": "7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "name": "my-subnet", "resource_type": "subnet"}, "transit_encryption": "none", "virtual_network_interface": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::virtual-network-interface:0767-fa41aecb-4f21-423d-8082-630bfba1e1d9", "href": "https://us-south.iaas.cloud.ibm.com/v1/virtual_network_interfaces/0767-fa41aecb-4f21-423d-8082-630bfba1e1d9", "id": "0767-fa41aecb-4f21-423d-8082-630bfba1e1d9", "name": "my-virtual-network-interface", "resource_type": "virtual_network_interface"}, "vpc": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::vpc:4727d842-f94f-4a2d-824a-9bc9b02c523b", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/vpcs/4727d842-f94f-4a2d-824a-9bc9b02c523b", "id": "4727d842-f94f-4a2d-824a-9bc9b02c523b", "name": "my-vpc", "resource_type": "vpc"}}`) + res.WriteHeader(200) + fmt.Fprintf(res, "%s", `{"active": true, "attach_user_tags": ["AttachUserTags"], "clone_policy": {"max_snapshots": 1, "zones": [{"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south/zones/us-south-1", "name": "us-south-1"}]}, "copy_user_tags": true, "created_at": "2019-01-01T12:00:00.000Z", "cron_spec": "30 */2 * * 1-5", "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", "remote_region_policies": [{"delete_over_count": 1, "encryption_key": {"crn": "crn:v1:bluemix:public:kms:us-south:a/123456:e4a29d1a-2ef0-42a6-8fd2-350deb1c647e:key:5437653b-c4b1-447f-9646-b2a2a4cd6179"}, "region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}], "resource_type": "backup_policy_plan"}`) })) }) - It(`Invoke DeleteShareMountTarget successfully`, func() { + It(`Invoke UpdateBackupPolicyPlan successfully`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -62891,25 +62823,68 @@ var _ = Describe(`VpcV1`, func() { Expect(vpcService).ToNot(BeNil()) // Invoke operation with nil options model (negative test) - result, response, operationErr := vpcService.DeleteShareMountTarget(nil) + result, response, operationErr := vpcService.UpdateBackupPolicyPlan(nil) Expect(operationErr).NotTo(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) - // Construct an instance of the DeleteShareMountTargetOptions model - deleteShareMountTargetOptionsModel := new(vpcv1.DeleteShareMountTargetOptions) - deleteShareMountTargetOptionsModel.ShareID = core.StringPtr("testString") - deleteShareMountTargetOptionsModel.ID = core.StringPtr("testString") - deleteShareMountTargetOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the ZoneIdentityByName model + zoneIdentityModel := new(vpcv1.ZoneIdentityByName) + zoneIdentityModel.Name = core.StringPtr("us-south-1") + + // Construct an instance of the BackupPolicyPlanClonePolicyPatch model + backupPolicyPlanClonePolicyPatchModel := new(vpcv1.BackupPolicyPlanClonePolicyPatch) + backupPolicyPlanClonePolicyPatchModel.MaxSnapshots = core.Int64Ptr(int64(1)) + backupPolicyPlanClonePolicyPatchModel.Zones = []vpcv1.ZoneIdentityIntf{zoneIdentityModel} + + // Construct an instance of the BackupPolicyPlanDeletionTriggerPatch model + backupPolicyPlanDeletionTriggerPatchModel := new(vpcv1.BackupPolicyPlanDeletionTriggerPatch) + backupPolicyPlanDeletionTriggerPatchModel.DeleteAfter = core.Int64Ptr(int64(20)) + backupPolicyPlanDeletionTriggerPatchModel.DeleteOverCount = core.Int64Ptr(int64(1)) + + // Construct an instance of the EncryptionKeyIdentityByCRN model + encryptionKeyIdentityModel := new(vpcv1.EncryptionKeyIdentityByCRN) + encryptionKeyIdentityModel.CRN = core.StringPtr("crn:v1:bluemix:public:kms:us-south:a/123456:e4a29d1a-2ef0-42a6-8fd2-350deb1c647e:key:5437653b-c4b1-447f-9646-b2a2a4cd6179") + + // Construct an instance of the RegionIdentityByName model + regionIdentityModel := new(vpcv1.RegionIdentityByName) + regionIdentityModel.Name = core.StringPtr("us-south") + + // Construct an instance of the BackupPolicyPlanRemoteRegionPolicyPrototype model + backupPolicyPlanRemoteRegionPolicyPrototypeModel := new(vpcv1.BackupPolicyPlanRemoteRegionPolicyPrototype) + backupPolicyPlanRemoteRegionPolicyPrototypeModel.DeleteOverCount = core.Int64Ptr(int64(5)) + backupPolicyPlanRemoteRegionPolicyPrototypeModel.EncryptionKey = encryptionKeyIdentityModel + backupPolicyPlanRemoteRegionPolicyPrototypeModel.Region = regionIdentityModel + + // Construct an instance of the BackupPolicyPlanPatch model + backupPolicyPlanPatchModel := new(vpcv1.BackupPolicyPlanPatch) + backupPolicyPlanPatchModel.Active = core.BoolPtr(true) + backupPolicyPlanPatchModel.AttachUserTags = []string{"my-daily-backup-plan"} + backupPolicyPlanPatchModel.ClonePolicy = backupPolicyPlanClonePolicyPatchModel + backupPolicyPlanPatchModel.CopyUserTags = core.BoolPtr(true) + backupPolicyPlanPatchModel.CronSpec = core.StringPtr("30 */2 * * 1-5") + backupPolicyPlanPatchModel.DeletionTrigger = backupPolicyPlanDeletionTriggerPatchModel + backupPolicyPlanPatchModel.Name = core.StringPtr("my-policy-plan") + backupPolicyPlanPatchModel.RemoteRegionPolicies = []vpcv1.BackupPolicyPlanRemoteRegionPolicyPrototype{*backupPolicyPlanRemoteRegionPolicyPrototypeModel} + 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.DeleteShareMountTarget(deleteShareMountTargetOptionsModel) + result, response, operationErr = vpcService.UpdateBackupPolicyPlan(updateBackupPolicyPlanOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) }) - It(`Invoke DeleteShareMountTarget with error: Operation validation and request error`, func() { + It(`Invoke UpdateBackupPolicyPlan with error: Operation validation and request error`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -62918,23 +62893,66 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the DeleteShareMountTargetOptions model - deleteShareMountTargetOptionsModel := new(vpcv1.DeleteShareMountTargetOptions) - deleteShareMountTargetOptionsModel.ShareID = core.StringPtr("testString") - deleteShareMountTargetOptionsModel.ID = core.StringPtr("testString") - deleteShareMountTargetOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the ZoneIdentityByName model + zoneIdentityModel := new(vpcv1.ZoneIdentityByName) + zoneIdentityModel.Name = core.StringPtr("us-south-1") + + // Construct an instance of the BackupPolicyPlanClonePolicyPatch model + backupPolicyPlanClonePolicyPatchModel := new(vpcv1.BackupPolicyPlanClonePolicyPatch) + backupPolicyPlanClonePolicyPatchModel.MaxSnapshots = core.Int64Ptr(int64(1)) + backupPolicyPlanClonePolicyPatchModel.Zones = []vpcv1.ZoneIdentityIntf{zoneIdentityModel} + + // Construct an instance of the BackupPolicyPlanDeletionTriggerPatch model + backupPolicyPlanDeletionTriggerPatchModel := new(vpcv1.BackupPolicyPlanDeletionTriggerPatch) + backupPolicyPlanDeletionTriggerPatchModel.DeleteAfter = core.Int64Ptr(int64(20)) + backupPolicyPlanDeletionTriggerPatchModel.DeleteOverCount = core.Int64Ptr(int64(1)) + + // Construct an instance of the EncryptionKeyIdentityByCRN model + encryptionKeyIdentityModel := new(vpcv1.EncryptionKeyIdentityByCRN) + encryptionKeyIdentityModel.CRN = core.StringPtr("crn:v1:bluemix:public:kms:us-south:a/123456:e4a29d1a-2ef0-42a6-8fd2-350deb1c647e:key:5437653b-c4b1-447f-9646-b2a2a4cd6179") + + // Construct an instance of the RegionIdentityByName model + regionIdentityModel := new(vpcv1.RegionIdentityByName) + regionIdentityModel.Name = core.StringPtr("us-south") + + // Construct an instance of the BackupPolicyPlanRemoteRegionPolicyPrototype model + backupPolicyPlanRemoteRegionPolicyPrototypeModel := new(vpcv1.BackupPolicyPlanRemoteRegionPolicyPrototype) + backupPolicyPlanRemoteRegionPolicyPrototypeModel.DeleteOverCount = core.Int64Ptr(int64(5)) + backupPolicyPlanRemoteRegionPolicyPrototypeModel.EncryptionKey = encryptionKeyIdentityModel + backupPolicyPlanRemoteRegionPolicyPrototypeModel.Region = regionIdentityModel + + // Construct an instance of the BackupPolicyPlanPatch model + backupPolicyPlanPatchModel := new(vpcv1.BackupPolicyPlanPatch) + backupPolicyPlanPatchModel.Active = core.BoolPtr(true) + backupPolicyPlanPatchModel.AttachUserTags = []string{"my-daily-backup-plan"} + backupPolicyPlanPatchModel.ClonePolicy = backupPolicyPlanClonePolicyPatchModel + backupPolicyPlanPatchModel.CopyUserTags = core.BoolPtr(true) + backupPolicyPlanPatchModel.CronSpec = core.StringPtr("30 */2 * * 1-5") + backupPolicyPlanPatchModel.DeletionTrigger = backupPolicyPlanDeletionTriggerPatchModel + backupPolicyPlanPatchModel.Name = core.StringPtr("my-policy-plan") + backupPolicyPlanPatchModel.RemoteRegionPolicies = []vpcv1.BackupPolicyPlanRemoteRegionPolicyPrototype{*backupPolicyPlanRemoteRegionPolicyPrototypeModel} + 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.DeleteShareMountTarget(deleteShareMountTargetOptionsModel) + 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 DeleteShareMountTargetOptions model with no property values - deleteShareMountTargetOptionsModelNew := new(vpcv1.DeleteShareMountTargetOptions) + // 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.DeleteShareMountTarget(deleteShareMountTargetOptionsModelNew) + result, response, operationErr = vpcService.UpdateBackupPolicyPlan(updateBackupPolicyPlanOptionsModelNew) Expect(operationErr).ToNot(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) @@ -62949,10 +62967,10 @@ var _ = Describe(`VpcV1`, func() { defer GinkgoRecover() // Set success status code with no respoonse body - res.WriteHeader(202) + res.WriteHeader(200) })) }) - It(`Invoke DeleteShareMountTarget successfully`, func() { + It(`Invoke UpdateBackupPolicyPlan successfully`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -62961,14 +62979,57 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the DeleteShareMountTargetOptions model - deleteShareMountTargetOptionsModel := new(vpcv1.DeleteShareMountTargetOptions) - deleteShareMountTargetOptionsModel.ShareID = core.StringPtr("testString") - deleteShareMountTargetOptionsModel.ID = core.StringPtr("testString") - deleteShareMountTargetOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the ZoneIdentityByName model + zoneIdentityModel := new(vpcv1.ZoneIdentityByName) + zoneIdentityModel.Name = core.StringPtr("us-south-1") + + // Construct an instance of the BackupPolicyPlanClonePolicyPatch model + backupPolicyPlanClonePolicyPatchModel := new(vpcv1.BackupPolicyPlanClonePolicyPatch) + backupPolicyPlanClonePolicyPatchModel.MaxSnapshots = core.Int64Ptr(int64(1)) + backupPolicyPlanClonePolicyPatchModel.Zones = []vpcv1.ZoneIdentityIntf{zoneIdentityModel} + + // Construct an instance of the BackupPolicyPlanDeletionTriggerPatch model + backupPolicyPlanDeletionTriggerPatchModel := new(vpcv1.BackupPolicyPlanDeletionTriggerPatch) + backupPolicyPlanDeletionTriggerPatchModel.DeleteAfter = core.Int64Ptr(int64(20)) + backupPolicyPlanDeletionTriggerPatchModel.DeleteOverCount = core.Int64Ptr(int64(1)) + + // Construct an instance of the EncryptionKeyIdentityByCRN model + encryptionKeyIdentityModel := new(vpcv1.EncryptionKeyIdentityByCRN) + encryptionKeyIdentityModel.CRN = core.StringPtr("crn:v1:bluemix:public:kms:us-south:a/123456:e4a29d1a-2ef0-42a6-8fd2-350deb1c647e:key:5437653b-c4b1-447f-9646-b2a2a4cd6179") + + // Construct an instance of the RegionIdentityByName model + regionIdentityModel := new(vpcv1.RegionIdentityByName) + regionIdentityModel.Name = core.StringPtr("us-south") + + // Construct an instance of the BackupPolicyPlanRemoteRegionPolicyPrototype model + backupPolicyPlanRemoteRegionPolicyPrototypeModel := new(vpcv1.BackupPolicyPlanRemoteRegionPolicyPrototype) + backupPolicyPlanRemoteRegionPolicyPrototypeModel.DeleteOverCount = core.Int64Ptr(int64(5)) + backupPolicyPlanRemoteRegionPolicyPrototypeModel.EncryptionKey = encryptionKeyIdentityModel + backupPolicyPlanRemoteRegionPolicyPrototypeModel.Region = regionIdentityModel + + // Construct an instance of the BackupPolicyPlanPatch model + backupPolicyPlanPatchModel := new(vpcv1.BackupPolicyPlanPatch) + backupPolicyPlanPatchModel.Active = core.BoolPtr(true) + backupPolicyPlanPatchModel.AttachUserTags = []string{"my-daily-backup-plan"} + backupPolicyPlanPatchModel.ClonePolicy = backupPolicyPlanClonePolicyPatchModel + backupPolicyPlanPatchModel.CopyUserTags = core.BoolPtr(true) + backupPolicyPlanPatchModel.CronSpec = core.StringPtr("30 */2 * * 1-5") + backupPolicyPlanPatchModel.DeletionTrigger = backupPolicyPlanDeletionTriggerPatchModel + backupPolicyPlanPatchModel.Name = core.StringPtr("my-policy-plan") + backupPolicyPlanPatchModel.RemoteRegionPolicies = []vpcv1.BackupPolicyPlanRemoteRegionPolicyPrototype{*backupPolicyPlanRemoteRegionPolicyPrototypeModel} + 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.DeleteShareMountTarget(deleteShareMountTargetOptionsModel) + result, response, operationErr := vpcService.UpdateBackupPolicyPlan(updateBackupPolicyPlanOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) @@ -62980,25 +63041,27 @@ var _ = Describe(`VpcV1`, func() { }) }) }) - Describe(`GetShareMountTarget(getShareMountTargetOptions *GetShareMountTargetOptions) - Operation response error`, func() { + Describe(`DeleteBackupPolicy(deleteBackupPolicyOptions *DeleteBackupPolicyOptions) - Operation response error`, func() { version := "testString" - getShareMountTargetPath := "/shares/testString/mount_targets/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(getShareMountTargetPath)) - Expect(req.Method).To(Equal("GET")) + 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(200) + res.WriteHeader(202) fmt.Fprint(res, `} this is not valid json {`) })) }) - It(`Invoke GetShareMountTarget with error: Operation response processing error`, func() { + It(`Invoke DeleteBackupPolicy with error: Operation response processing error`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -63007,20 +63070,20 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the GetShareMountTargetOptions model - getShareMountTargetOptionsModel := new(vpcv1.GetShareMountTargetOptions) - getShareMountTargetOptionsModel.ShareID = core.StringPtr("testString") - getShareMountTargetOptionsModel.ID = core.StringPtr("testString") - getShareMountTargetOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // 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.GetShareMountTarget(getShareMountTargetOptionsModel) + 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.GetShareMountTarget(getShareMountTargetOptionsModel) + result, response, operationErr = vpcService.DeleteBackupPolicy(deleteBackupPolicyOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).To(BeNil()) @@ -63030,18 +63093,20 @@ var _ = Describe(`VpcV1`, func() { }) }) }) - Describe(`GetShareMountTarget(getShareMountTargetOptions *GetShareMountTargetOptions)`, func() { + Describe(`DeleteBackupPolicy(deleteBackupPolicyOptions *DeleteBackupPolicyOptions)`, func() { version := "testString" - getShareMountTargetPath := "/shares/testString/mount_targets/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(getShareMountTargetPath)) - Expect(req.Method).To(Equal("GET")) + 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 @@ -63049,11 +63114,11 @@ var _ = Describe(`VpcV1`, func() { // Set mock response res.Header().Set("Content-type", "application/json") - res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"access_control_mode": "security_group", "created_at": "2019-01-01T12:00:00.000Z", "href": "https://us-south.iaas.cloud.ibm.com/v1/shares/0fe9e5d8-0a4d-4818-96ec-e99708644a58/mount_targets/4cf9171a-0043-4434-8727-15b53dbc374c", "id": "4cf9171a-0043-4434-8727-15b53dbc374c", "lifecycle_state": "stable", "mount_path": "10.240.1.23:/nxg_s_voll_mz7121_58e7e963_8f4b_4a0c_b71a_8ba8d9cd1e2e", "name": "my-share-mount-target", "primary_ip": {"address": "192.168.3.4", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e/reserved_ips/6d353a0f-aeb1-4ae1-832e-1110d10981bb", "id": "6d353a0f-aeb1-4ae1-832e-1110d10981bb", "name": "my-reserved-ip", "resource_type": "subnet_reserved_ip"}, "resource_type": "share_mount_target", "subnet": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "id": "7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "name": "my-subnet", "resource_type": "subnet"}, "transit_encryption": "none", "virtual_network_interface": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::virtual-network-interface:0767-fa41aecb-4f21-423d-8082-630bfba1e1d9", "href": "https://us-south.iaas.cloud.ibm.com/v1/virtual_network_interfaces/0767-fa41aecb-4f21-423d-8082-630bfba1e1d9", "id": "0767-fa41aecb-4f21-423d-8082-630bfba1e1d9", "name": "my-virtual-network-interface", "resource_type": "virtual_network_interface"}, "vpc": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::vpc:4727d842-f94f-4a2d-824a-9bc9b02c523b", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/vpcs/4727d842-f94f-4a2d-824a-9bc9b02c523b", "id": "4727d842-f94f-4a2d-824a-9bc9b02c523b", "name": "my-vpc", "resource_type": "vpc"}}`) + res.WriteHeader(202) + fmt.Fprintf(res, "%s", `{"created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south:a/123456::backup-policy:r134-076191ba-49c2-4763-94fd-c70de73ee2e6", "health_reasons": [{"code": "missing_service_authorization_policies", "message": "One or more accounts are missing service authorization policies", "more_info": "https://cloud.ibm.com/docs/vpc?topic=vpc-backup-service-about&interface=ui"}], "health_state": "ok", "href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6", "id": "r134-076191ba-49c2-4763-94fd-c70de73ee2e6", "last_job_completed_at": "2019-01-01T12:00:00.000Z", "lifecycle_state": "stable", "match_user_tags": ["MatchUserTags"], "name": "my-backup-policy", "plans": [{"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6/plans/r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "id": "r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "name": "my-policy-plan", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "backup_policy_plan"}], "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "resource_type": "backup_policy", "scope": {"crn": "crn:v1:bluemix:public:enterprise::a/123456::enterprise:ebc2b430240943458b9e91e1432cfcce", "id": "fee82deba12e4c0fb69c3b09d1f12345", "resource_type": "enterprise"}, "included_content": ["data_volumes"], "match_resource_type": "instance"}`) })) }) - It(`Invoke GetShareMountTarget successfully with retries`, func() { + It(`Invoke DeleteBackupPolicy successfully with retries`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -63063,22 +63128,22 @@ var _ = Describe(`VpcV1`, func() { Expect(vpcService).ToNot(BeNil()) vpcService.EnableRetries(0, 0) - // Construct an instance of the GetShareMountTargetOptions model - getShareMountTargetOptionsModel := new(vpcv1.GetShareMountTargetOptions) - getShareMountTargetOptionsModel.ShareID = core.StringPtr("testString") - getShareMountTargetOptionsModel.ID = core.StringPtr("testString") - getShareMountTargetOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // 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.GetShareMountTargetWithContext(ctx, getShareMountTargetOptionsModel) + _, _, 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.GetShareMountTarget(getShareMountTargetOptionsModel) + result, response, operationErr := vpcService.DeleteBackupPolicy(deleteBackupPolicyOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) @@ -63086,7 +63151,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.GetShareMountTargetWithContext(ctx, getShareMountTargetOptionsModel) + _, _, operationErr = vpcService.DeleteBackupPolicyWithContext(ctx, deleteBackupPolicyOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) }) @@ -63100,18 +63165,20 @@ var _ = Describe(`VpcV1`, func() { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(getShareMountTargetPath)) - Expect(req.Method).To(Equal("GET")) + 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(200) - fmt.Fprintf(res, "%s", `{"access_control_mode": "security_group", "created_at": "2019-01-01T12:00:00.000Z", "href": "https://us-south.iaas.cloud.ibm.com/v1/shares/0fe9e5d8-0a4d-4818-96ec-e99708644a58/mount_targets/4cf9171a-0043-4434-8727-15b53dbc374c", "id": "4cf9171a-0043-4434-8727-15b53dbc374c", "lifecycle_state": "stable", "mount_path": "10.240.1.23:/nxg_s_voll_mz7121_58e7e963_8f4b_4a0c_b71a_8ba8d9cd1e2e", "name": "my-share-mount-target", "primary_ip": {"address": "192.168.3.4", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e/reserved_ips/6d353a0f-aeb1-4ae1-832e-1110d10981bb", "id": "6d353a0f-aeb1-4ae1-832e-1110d10981bb", "name": "my-reserved-ip", "resource_type": "subnet_reserved_ip"}, "resource_type": "share_mount_target", "subnet": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "id": "7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "name": "my-subnet", "resource_type": "subnet"}, "transit_encryption": "none", "virtual_network_interface": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::virtual-network-interface:0767-fa41aecb-4f21-423d-8082-630bfba1e1d9", "href": "https://us-south.iaas.cloud.ibm.com/v1/virtual_network_interfaces/0767-fa41aecb-4f21-423d-8082-630bfba1e1d9", "id": "0767-fa41aecb-4f21-423d-8082-630bfba1e1d9", "name": "my-virtual-network-interface", "resource_type": "virtual_network_interface"}, "vpc": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::vpc:4727d842-f94f-4a2d-824a-9bc9b02c523b", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/vpcs/4727d842-f94f-4a2d-824a-9bc9b02c523b", "id": "4727d842-f94f-4a2d-824a-9bc9b02c523b", "name": "my-vpc", "resource_type": "vpc"}}`) + res.WriteHeader(202) + fmt.Fprintf(res, "%s", `{"created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south:a/123456::backup-policy:r134-076191ba-49c2-4763-94fd-c70de73ee2e6", "health_reasons": [{"code": "missing_service_authorization_policies", "message": "One or more accounts are missing service authorization policies", "more_info": "https://cloud.ibm.com/docs/vpc?topic=vpc-backup-service-about&interface=ui"}], "health_state": "ok", "href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6", "id": "r134-076191ba-49c2-4763-94fd-c70de73ee2e6", "last_job_completed_at": "2019-01-01T12:00:00.000Z", "lifecycle_state": "stable", "match_user_tags": ["MatchUserTags"], "name": "my-backup-policy", "plans": [{"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6/plans/r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "id": "r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "name": "my-policy-plan", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "backup_policy_plan"}], "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "resource_type": "backup_policy", "scope": {"crn": "crn:v1:bluemix:public:enterprise::a/123456::enterprise:ebc2b430240943458b9e91e1432cfcce", "id": "fee82deba12e4c0fb69c3b09d1f12345", "resource_type": "enterprise"}, "included_content": ["data_volumes"], "match_resource_type": "instance"}`) })) }) - It(`Invoke GetShareMountTarget successfully`, func() { + It(`Invoke DeleteBackupPolicy successfully`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -63121,25 +63188,25 @@ var _ = Describe(`VpcV1`, func() { Expect(vpcService).ToNot(BeNil()) // Invoke operation with nil options model (negative test) - result, response, operationErr := vpcService.GetShareMountTarget(nil) + result, response, operationErr := vpcService.DeleteBackupPolicy(nil) Expect(operationErr).NotTo(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) - // Construct an instance of the GetShareMountTargetOptions model - getShareMountTargetOptionsModel := new(vpcv1.GetShareMountTargetOptions) - getShareMountTargetOptionsModel.ShareID = core.StringPtr("testString") - getShareMountTargetOptionsModel.ID = core.StringPtr("testString") - getShareMountTargetOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // 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.GetShareMountTarget(getShareMountTargetOptionsModel) + result, response, operationErr = vpcService.DeleteBackupPolicy(deleteBackupPolicyOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) }) - It(`Invoke GetShareMountTarget with error: Operation validation and request error`, func() { + It(`Invoke DeleteBackupPolicy with error: Operation validation and request error`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -63148,23 +63215,23 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the GetShareMountTargetOptions model - getShareMountTargetOptionsModel := new(vpcv1.GetShareMountTargetOptions) - getShareMountTargetOptionsModel.ShareID = core.StringPtr("testString") - getShareMountTargetOptionsModel.ID = core.StringPtr("testString") - getShareMountTargetOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // 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.GetShareMountTarget(getShareMountTargetOptionsModel) + 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 GetShareMountTargetOptions model with no property values - getShareMountTargetOptionsModelNew := new(vpcv1.GetShareMountTargetOptions) + // 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.GetShareMountTarget(getShareMountTargetOptionsModelNew) + result, response, operationErr = vpcService.DeleteBackupPolicy(deleteBackupPolicyOptionsModelNew) Expect(operationErr).ToNot(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) @@ -63179,10 +63246,10 @@ var _ = Describe(`VpcV1`, func() { defer GinkgoRecover() // Set success status code with no respoonse body - res.WriteHeader(200) + res.WriteHeader(202) })) }) - It(`Invoke GetShareMountTarget successfully`, func() { + It(`Invoke DeleteBackupPolicy successfully`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -63191,14 +63258,14 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the GetShareMountTargetOptions model - getShareMountTargetOptionsModel := new(vpcv1.GetShareMountTargetOptions) - getShareMountTargetOptionsModel.ShareID = core.StringPtr("testString") - getShareMountTargetOptionsModel.ID = core.StringPtr("testString") - getShareMountTargetOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // 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.GetShareMountTarget(getShareMountTargetOptionsModel) + result, response, operationErr := vpcService.DeleteBackupPolicy(deleteBackupPolicyOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) @@ -63210,17 +63277,17 @@ var _ = Describe(`VpcV1`, func() { }) }) }) - Describe(`UpdateShareMountTarget(updateShareMountTargetOptions *UpdateShareMountTargetOptions) - Operation response error`, func() { + Describe(`GetBackupPolicy(getBackupPolicyOptions *GetBackupPolicyOptions) - Operation response error`, func() { version := "testString" - updateShareMountTargetPath := "/shares/testString/mount_targets/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(updateShareMountTargetPath)) - Expect(req.Method).To(Equal("PATCH")) + 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") @@ -63228,7 +63295,7 @@ var _ = Describe(`VpcV1`, func() { fmt.Fprint(res, `} this is not valid json {`) })) }) - It(`Invoke UpdateShareMountTarget with error: Operation response processing error`, func() { + It(`Invoke GetBackupPolicy with error: Operation response processing error`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -63237,27 +63304,19 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the ShareMountTargetPatch model - shareMountTargetPatchModel := new(vpcv1.ShareMountTargetPatch) - shareMountTargetPatchModel.Name = core.StringPtr("my-share-mount-target") - shareMountTargetPatchModelAsPatch, asPatchErr := shareMountTargetPatchModel.AsPatch() - Expect(asPatchErr).To(BeNil()) - - // Construct an instance of the UpdateShareMountTargetOptions model - updateShareMountTargetOptionsModel := new(vpcv1.UpdateShareMountTargetOptions) - updateShareMountTargetOptionsModel.ShareID = core.StringPtr("testString") - updateShareMountTargetOptionsModel.ID = core.StringPtr("testString") - updateShareMountTargetOptionsModel.ShareMountTargetPatch = shareMountTargetPatchModelAsPatch - updateShareMountTargetOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // 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.UpdateShareMountTarget(updateShareMountTargetOptionsModel) + 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.UpdateShareMountTarget(updateShareMountTargetOptionsModel) + result, response, operationErr = vpcService.GetBackupPolicy(getBackupPolicyOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).To(BeNil()) @@ -63267,33 +63326,17 @@ var _ = Describe(`VpcV1`, func() { }) }) }) - Describe(`UpdateShareMountTarget(updateShareMountTargetOptions *UpdateShareMountTargetOptions)`, func() { + Describe(`GetBackupPolicy(getBackupPolicyOptions *GetBackupPolicyOptions)`, func() { version := "testString" - updateShareMountTargetPath := "/shares/testString/mount_targets/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(updateShareMountTargetPath)) - 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.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))})) @@ -63303,10 +63346,10 @@ var _ = Describe(`VpcV1`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"access_control_mode": "security_group", "created_at": "2019-01-01T12:00:00.000Z", "href": "https://us-south.iaas.cloud.ibm.com/v1/shares/0fe9e5d8-0a4d-4818-96ec-e99708644a58/mount_targets/4cf9171a-0043-4434-8727-15b53dbc374c", "id": "4cf9171a-0043-4434-8727-15b53dbc374c", "lifecycle_state": "stable", "mount_path": "10.240.1.23:/nxg_s_voll_mz7121_58e7e963_8f4b_4a0c_b71a_8ba8d9cd1e2e", "name": "my-share-mount-target", "primary_ip": {"address": "192.168.3.4", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e/reserved_ips/6d353a0f-aeb1-4ae1-832e-1110d10981bb", "id": "6d353a0f-aeb1-4ae1-832e-1110d10981bb", "name": "my-reserved-ip", "resource_type": "subnet_reserved_ip"}, "resource_type": "share_mount_target", "subnet": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "id": "7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "name": "my-subnet", "resource_type": "subnet"}, "transit_encryption": "none", "virtual_network_interface": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::virtual-network-interface:0767-fa41aecb-4f21-423d-8082-630bfba1e1d9", "href": "https://us-south.iaas.cloud.ibm.com/v1/virtual_network_interfaces/0767-fa41aecb-4f21-423d-8082-630bfba1e1d9", "id": "0767-fa41aecb-4f21-423d-8082-630bfba1e1d9", "name": "my-virtual-network-interface", "resource_type": "virtual_network_interface"}, "vpc": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::vpc:4727d842-f94f-4a2d-824a-9bc9b02c523b", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/vpcs/4727d842-f94f-4a2d-824a-9bc9b02c523b", "id": "4727d842-f94f-4a2d-824a-9bc9b02c523b", "name": "my-vpc", "resource_type": "vpc"}}`) + fmt.Fprintf(res, "%s", `{"created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south:a/123456::backup-policy:r134-076191ba-49c2-4763-94fd-c70de73ee2e6", "health_reasons": [{"code": "missing_service_authorization_policies", "message": "One or more accounts are missing service authorization policies", "more_info": "https://cloud.ibm.com/docs/vpc?topic=vpc-backup-service-about&interface=ui"}], "health_state": "ok", "href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6", "id": "r134-076191ba-49c2-4763-94fd-c70de73ee2e6", "last_job_completed_at": "2019-01-01T12:00:00.000Z", "lifecycle_state": "stable", "match_user_tags": ["MatchUserTags"], "name": "my-backup-policy", "plans": [{"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6/plans/r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "id": "r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "name": "my-policy-plan", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "backup_policy_plan"}], "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "resource_type": "backup_policy", "scope": {"crn": "crn:v1:bluemix:public:enterprise::a/123456::enterprise:ebc2b430240943458b9e91e1432cfcce", "id": "fee82deba12e4c0fb69c3b09d1f12345", "resource_type": "enterprise"}, "included_content": ["data_volumes"], "match_resource_type": "instance"}`) })) }) - It(`Invoke UpdateShareMountTarget successfully with retries`, func() { + It(`Invoke GetBackupPolicy successfully with retries`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -63316,29 +63359,21 @@ var _ = Describe(`VpcV1`, func() { Expect(vpcService).ToNot(BeNil()) vpcService.EnableRetries(0, 0) - // Construct an instance of the ShareMountTargetPatch model - shareMountTargetPatchModel := new(vpcv1.ShareMountTargetPatch) - shareMountTargetPatchModel.Name = core.StringPtr("my-share-mount-target") - shareMountTargetPatchModelAsPatch, asPatchErr := shareMountTargetPatchModel.AsPatch() - Expect(asPatchErr).To(BeNil()) - - // Construct an instance of the UpdateShareMountTargetOptions model - updateShareMountTargetOptionsModel := new(vpcv1.UpdateShareMountTargetOptions) - updateShareMountTargetOptionsModel.ShareID = core.StringPtr("testString") - updateShareMountTargetOptionsModel.ID = core.StringPtr("testString") - updateShareMountTargetOptionsModel.ShareMountTargetPatch = shareMountTargetPatchModelAsPatch - updateShareMountTargetOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // 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.UpdateShareMountTargetWithContext(ctx, updateShareMountTargetOptionsModel) + _, _, 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.UpdateShareMountTarget(updateShareMountTargetOptionsModel) + result, response, operationErr := vpcService.GetBackupPolicy(getBackupPolicyOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) @@ -63346,7 +63381,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.UpdateShareMountTargetWithContext(ctx, updateShareMountTargetOptionsModel) + _, _, operationErr = vpcService.GetBackupPolicyWithContext(ctx, getBackupPolicyOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) }) @@ -63360,34 +63395,18 @@ var _ = Describe(`VpcV1`, func() { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(updateShareMountTargetPath)) - 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.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", `{"access_control_mode": "security_group", "created_at": "2019-01-01T12:00:00.000Z", "href": "https://us-south.iaas.cloud.ibm.com/v1/shares/0fe9e5d8-0a4d-4818-96ec-e99708644a58/mount_targets/4cf9171a-0043-4434-8727-15b53dbc374c", "id": "4cf9171a-0043-4434-8727-15b53dbc374c", "lifecycle_state": "stable", "mount_path": "10.240.1.23:/nxg_s_voll_mz7121_58e7e963_8f4b_4a0c_b71a_8ba8d9cd1e2e", "name": "my-share-mount-target", "primary_ip": {"address": "192.168.3.4", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e/reserved_ips/6d353a0f-aeb1-4ae1-832e-1110d10981bb", "id": "6d353a0f-aeb1-4ae1-832e-1110d10981bb", "name": "my-reserved-ip", "resource_type": "subnet_reserved_ip"}, "resource_type": "share_mount_target", "subnet": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::subnet:7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "id": "7ec86020-1c6e-4889-b3f0-a15f2e50f87e", "name": "my-subnet", "resource_type": "subnet"}, "transit_encryption": "none", "virtual_network_interface": {"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::virtual-network-interface:0767-fa41aecb-4f21-423d-8082-630bfba1e1d9", "href": "https://us-south.iaas.cloud.ibm.com/v1/virtual_network_interfaces/0767-fa41aecb-4f21-423d-8082-630bfba1e1d9", "id": "0767-fa41aecb-4f21-423d-8082-630bfba1e1d9", "name": "my-virtual-network-interface", "resource_type": "virtual_network_interface"}, "vpc": {"crn": "crn:v1:bluemix:public:is:us-south:a/123456::vpc:4727d842-f94f-4a2d-824a-9bc9b02c523b", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/vpcs/4727d842-f94f-4a2d-824a-9bc9b02c523b", "id": "4727d842-f94f-4a2d-824a-9bc9b02c523b", "name": "my-vpc", "resource_type": "vpc"}}`) + fmt.Fprintf(res, "%s", `{"created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south:a/123456::backup-policy:r134-076191ba-49c2-4763-94fd-c70de73ee2e6", "health_reasons": [{"code": "missing_service_authorization_policies", "message": "One or more accounts are missing service authorization policies", "more_info": "https://cloud.ibm.com/docs/vpc?topic=vpc-backup-service-about&interface=ui"}], "health_state": "ok", "href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6", "id": "r134-076191ba-49c2-4763-94fd-c70de73ee2e6", "last_job_completed_at": "2019-01-01T12:00:00.000Z", "lifecycle_state": "stable", "match_user_tags": ["MatchUserTags"], "name": "my-backup-policy", "plans": [{"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6/plans/r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "id": "r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "name": "my-policy-plan", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "backup_policy_plan"}], "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "resource_type": "backup_policy", "scope": {"crn": "crn:v1:bluemix:public:enterprise::a/123456::enterprise:ebc2b430240943458b9e91e1432cfcce", "id": "fee82deba12e4c0fb69c3b09d1f12345", "resource_type": "enterprise"}, "included_content": ["data_volumes"], "match_resource_type": "instance"}`) })) }) - It(`Invoke UpdateShareMountTarget successfully`, func() { + It(`Invoke GetBackupPolicy successfully`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -63397,32 +63416,24 @@ var _ = Describe(`VpcV1`, func() { Expect(vpcService).ToNot(BeNil()) // Invoke operation with nil options model (negative test) - result, response, operationErr := vpcService.UpdateShareMountTarget(nil) + result, response, operationErr := vpcService.GetBackupPolicy(nil) Expect(operationErr).NotTo(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) - // Construct an instance of the ShareMountTargetPatch model - shareMountTargetPatchModel := new(vpcv1.ShareMountTargetPatch) - shareMountTargetPatchModel.Name = core.StringPtr("my-share-mount-target") - shareMountTargetPatchModelAsPatch, asPatchErr := shareMountTargetPatchModel.AsPatch() - Expect(asPatchErr).To(BeNil()) - - // Construct an instance of the UpdateShareMountTargetOptions model - updateShareMountTargetOptionsModel := new(vpcv1.UpdateShareMountTargetOptions) - updateShareMountTargetOptionsModel.ShareID = core.StringPtr("testString") - updateShareMountTargetOptionsModel.ID = core.StringPtr("testString") - updateShareMountTargetOptionsModel.ShareMountTargetPatch = shareMountTargetPatchModelAsPatch - updateShareMountTargetOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // 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.UpdateShareMountTarget(updateShareMountTargetOptionsModel) + result, response, operationErr = vpcService.GetBackupPolicy(getBackupPolicyOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) }) - It(`Invoke UpdateShareMountTarget with error: Operation validation and request error`, func() { + It(`Invoke GetBackupPolicy with error: Operation validation and request error`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -63431,30 +63442,22 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the ShareMountTargetPatch model - shareMountTargetPatchModel := new(vpcv1.ShareMountTargetPatch) - shareMountTargetPatchModel.Name = core.StringPtr("my-share-mount-target") - shareMountTargetPatchModelAsPatch, asPatchErr := shareMountTargetPatchModel.AsPatch() - Expect(asPatchErr).To(BeNil()) - - // Construct an instance of the UpdateShareMountTargetOptions model - updateShareMountTargetOptionsModel := new(vpcv1.UpdateShareMountTargetOptions) - updateShareMountTargetOptionsModel.ShareID = core.StringPtr("testString") - updateShareMountTargetOptionsModel.ID = core.StringPtr("testString") - updateShareMountTargetOptionsModel.ShareMountTargetPatch = shareMountTargetPatchModelAsPatch - updateShareMountTargetOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // 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.UpdateShareMountTarget(updateShareMountTargetOptionsModel) + 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 UpdateShareMountTargetOptions model with no property values - updateShareMountTargetOptionsModelNew := new(vpcv1.UpdateShareMountTargetOptions) + // 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.UpdateShareMountTarget(updateShareMountTargetOptionsModelNew) + result, response, operationErr = vpcService.GetBackupPolicy(getBackupPolicyOptionsModelNew) Expect(operationErr).ToNot(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) @@ -63472,7 +63475,7 @@ var _ = Describe(`VpcV1`, func() { res.WriteHeader(200) })) }) - It(`Invoke UpdateShareMountTarget successfully`, func() { + It(`Invoke GetBackupPolicy successfully`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -63481,21 +63484,13 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the ShareMountTargetPatch model - shareMountTargetPatchModel := new(vpcv1.ShareMountTargetPatch) - shareMountTargetPatchModel.Name = core.StringPtr("my-share-mount-target") - shareMountTargetPatchModelAsPatch, asPatchErr := shareMountTargetPatchModel.AsPatch() - Expect(asPatchErr).To(BeNil()) - - // Construct an instance of the UpdateShareMountTargetOptions model - updateShareMountTargetOptionsModel := new(vpcv1.UpdateShareMountTargetOptions) - updateShareMountTargetOptionsModel.ShareID = core.StringPtr("testString") - updateShareMountTargetOptionsModel.ID = core.StringPtr("testString") - updateShareMountTargetOptionsModel.ShareMountTargetPatch = shareMountTargetPatchModelAsPatch - updateShareMountTargetOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // 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.UpdateShareMountTarget(updateShareMountTargetOptionsModel) + result, response, operationErr := vpcService.GetBackupPolicy(getBackupPolicyOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) @@ -63507,90 +63502,19 @@ var _ = Describe(`VpcV1`, func() { }) }) }) - Describe(`DeleteShareSource(deleteShareSourceOptions *DeleteShareSourceOptions)`, func() { - version := "testString" - deleteShareSourcePath := "/shares/testString/source" - 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(deleteShareSourcePath)) - 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 DeleteShareSource 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.DeleteShareSource(nil) - Expect(operationErr).NotTo(BeNil()) - Expect(response).To(BeNil()) - - // Construct an instance of the DeleteShareSourceOptions model - deleteShareSourceOptionsModel := new(vpcv1.DeleteShareSourceOptions) - deleteShareSourceOptionsModel.ShareID = core.StringPtr("testString") - deleteShareSourceOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} - - // Invoke operation with valid options model (positive test) - response, operationErr = vpcService.DeleteShareSource(deleteShareSourceOptionsModel) - Expect(operationErr).To(BeNil()) - Expect(response).ToNot(BeNil()) - }) - It(`Invoke DeleteShareSource 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 DeleteShareSourceOptions model - deleteShareSourceOptionsModel := new(vpcv1.DeleteShareSourceOptions) - deleteShareSourceOptionsModel.ShareID = core.StringPtr("testString") - deleteShareSourceOptionsModel.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.DeleteShareSource(deleteShareSourceOptionsModel) - Expect(operationErr).ToNot(BeNil()) - Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING)) - Expect(response).To(BeNil()) - // Construct a second instance of the DeleteShareSourceOptions model with no property values - deleteShareSourceOptionsModelNew := new(vpcv1.DeleteShareSourceOptions) - // Invoke operation with invalid model (negative test) - response, operationErr = vpcService.DeleteShareSource(deleteShareSourceOptionsModelNew) - Expect(operationErr).ToNot(BeNil()) - Expect(response).To(BeNil()) - }) - AfterEach(func() { - testServer.Close() - }) - }) - }) - Describe(`GetShareSource(getShareSourceOptions *GetShareSourceOptions) - Operation response error`, func() { + Describe(`UpdateBackupPolicy(updateBackupPolicyOptions *UpdateBackupPolicyOptions) - Operation response error`, func() { version := "testString" - getShareSourcePath := "/shares/testString/source" + 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(getShareSourcePath)) - Expect(req.Method).To(Equal("GET")) + 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") @@ -63598,7 +63522,7 @@ var _ = Describe(`VpcV1`, func() { fmt.Fprint(res, `} this is not valid json {`) })) }) - It(`Invoke GetShareSource with error: Operation response processing error`, func() { + It(`Invoke UpdateBackupPolicy with error: Operation response processing error`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -63607,19 +63531,29 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the GetShareSourceOptions model - getShareSourceOptionsModel := new(vpcv1.GetShareSourceOptions) - getShareSourceOptionsModel.ShareID = core.StringPtr("testString") - getShareSourceOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the BackupPolicyPatch model + backupPolicyPatchModel := new(vpcv1.BackupPolicyPatch) + backupPolicyPatchModel.IncludedContent = []string{"data_volumes"} + backupPolicyPatchModel.MatchUserTags = []string{"my-daily-backup-policy"} + backupPolicyPatchModel.Name = core.StringPtr("my-backup-policy") + backupPolicyPatchModelAsPatch, asPatchErr := backupPolicyPatchModel.AsPatch() + 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.GetShareSource(getShareSourceOptionsModel) + 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.GetShareSource(getShareSourceOptionsModel) + result, response, operationErr = vpcService.UpdateBackupPolicy(updateBackupPolicyOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).To(BeNil()) @@ -63629,18 +63563,36 @@ var _ = Describe(`VpcV1`, func() { }) }) }) - Describe(`GetShareSource(getShareSourceOptions *GetShareSourceOptions)`, func() { + Describe(`UpdateBackupPolicy(updateBackupPolicyOptions *UpdateBackupPolicyOptions)`, func() { version := "testString" - getShareSourcePath := "/shares/testString/source" + 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(getShareSourcePath)) - Expect(req.Method).To(Equal("GET")) + 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 @@ -63649,10 +63601,10 @@ var _ = Describe(`VpcV1`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::share:0fe9e5d8-0a4d-4818-96ec-e99708644a58", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/shares/0fe9e5d8-0a4d-4818-96ec-e99708644a58", "id": "0fe9e5d8-0a4d-4818-96ec-e99708644a58", "name": "my-share", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "share"}`) + fmt.Fprintf(res, "%s", `{"created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south:a/123456::backup-policy:r134-076191ba-49c2-4763-94fd-c70de73ee2e6", "health_reasons": [{"code": "missing_service_authorization_policies", "message": "One or more accounts are missing service authorization policies", "more_info": "https://cloud.ibm.com/docs/vpc?topic=vpc-backup-service-about&interface=ui"}], "health_state": "ok", "href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6", "id": "r134-076191ba-49c2-4763-94fd-c70de73ee2e6", "last_job_completed_at": "2019-01-01T12:00:00.000Z", "lifecycle_state": "stable", "match_user_tags": ["MatchUserTags"], "name": "my-backup-policy", "plans": [{"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6/plans/r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "id": "r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "name": "my-policy-plan", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "backup_policy_plan"}], "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "resource_type": "backup_policy", "scope": {"crn": "crn:v1:bluemix:public:enterprise::a/123456::enterprise:ebc2b430240943458b9e91e1432cfcce", "id": "fee82deba12e4c0fb69c3b09d1f12345", "resource_type": "enterprise"}, "included_content": ["data_volumes"], "match_resource_type": "instance"}`) })) }) - It(`Invoke GetShareSource successfully with retries`, func() { + It(`Invoke UpdateBackupPolicy successfully with retries`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -63662,21 +63614,31 @@ var _ = Describe(`VpcV1`, func() { Expect(vpcService).ToNot(BeNil()) vpcService.EnableRetries(0, 0) - // Construct an instance of the GetShareSourceOptions model - getShareSourceOptionsModel := new(vpcv1.GetShareSourceOptions) - getShareSourceOptionsModel.ShareID = core.StringPtr("testString") - getShareSourceOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the BackupPolicyPatch model + backupPolicyPatchModel := new(vpcv1.BackupPolicyPatch) + backupPolicyPatchModel.IncludedContent = []string{"data_volumes"} + backupPolicyPatchModel.MatchUserTags = []string{"my-daily-backup-policy"} + backupPolicyPatchModel.Name = core.StringPtr("my-backup-policy") + backupPolicyPatchModelAsPatch, asPatchErr := backupPolicyPatchModel.AsPatch() + 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.GetShareSourceWithContext(ctx, getShareSourceOptionsModel) + _, _, 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.GetShareSource(getShareSourceOptionsModel) + result, response, operationErr := vpcService.UpdateBackupPolicy(updateBackupPolicyOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) @@ -63684,7 +63646,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.GetShareSourceWithContext(ctx, getShareSourceOptionsModel) + _, _, operationErr = vpcService.UpdateBackupPolicyWithContext(ctx, updateBackupPolicyOptionsModel) Expect(operationErr).ToNot(BeNil()) Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) }) @@ -63698,18 +63660,36 @@ var _ = Describe(`VpcV1`, func() { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.EscapedPath()).To(Equal(getShareSourcePath)) - Expect(req.Method).To(Equal("GET")) + 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", `{"crn": "crn:v1:bluemix:public:is:us-south-1:a/123456::share:0fe9e5d8-0a4d-4818-96ec-e99708644a58", "deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/shares/0fe9e5d8-0a4d-4818-96ec-e99708644a58", "id": "0fe9e5d8-0a4d-4818-96ec-e99708644a58", "name": "my-share", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "share"}`) + fmt.Fprintf(res, "%s", `{"created_at": "2019-01-01T12:00:00.000Z", "crn": "crn:v1:bluemix:public:is:us-south:a/123456::backup-policy:r134-076191ba-49c2-4763-94fd-c70de73ee2e6", "health_reasons": [{"code": "missing_service_authorization_policies", "message": "One or more accounts are missing service authorization policies", "more_info": "https://cloud.ibm.com/docs/vpc?topic=vpc-backup-service-about&interface=ui"}], "health_state": "ok", "href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6", "id": "r134-076191ba-49c2-4763-94fd-c70de73ee2e6", "last_job_completed_at": "2019-01-01T12:00:00.000Z", "lifecycle_state": "stable", "match_user_tags": ["MatchUserTags"], "name": "my-backup-policy", "plans": [{"deleted": {"more_info": "https://cloud.ibm.com/apidocs/vpc#deleted-resources"}, "href": "https://us-south.iaas.cloud.ibm.com/v1/backup_policies/r134-076191ba-49c2-4763-94fd-c70de73ee2e6/plans/r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "id": "r134-6da51cfe-6f7b-4638-a6ba-00e9c327b178", "name": "my-policy-plan", "remote": {"region": {"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south", "name": "us-south"}}, "resource_type": "backup_policy_plan"}], "resource_group": {"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/fee82deba12e4c0fb69c3b09d1f12345", "id": "fee82deba12e4c0fb69c3b09d1f12345", "name": "my-resource-group"}, "resource_type": "backup_policy", "scope": {"crn": "crn:v1:bluemix:public:enterprise::a/123456::enterprise:ebc2b430240943458b9e91e1432cfcce", "id": "fee82deba12e4c0fb69c3b09d1f12345", "resource_type": "enterprise"}, "included_content": ["data_volumes"], "match_resource_type": "instance"}`) })) }) - It(`Invoke GetShareSource successfully`, func() { + It(`Invoke UpdateBackupPolicy successfully`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -63719,24 +63699,34 @@ var _ = Describe(`VpcV1`, func() { Expect(vpcService).ToNot(BeNil()) // Invoke operation with nil options model (negative test) - result, response, operationErr := vpcService.GetShareSource(nil) + result, response, operationErr := vpcService.UpdateBackupPolicy(nil) Expect(operationErr).NotTo(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) - // Construct an instance of the GetShareSourceOptions model - getShareSourceOptionsModel := new(vpcv1.GetShareSourceOptions) - getShareSourceOptionsModel.ShareID = core.StringPtr("testString") - getShareSourceOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the BackupPolicyPatch model + backupPolicyPatchModel := new(vpcv1.BackupPolicyPatch) + backupPolicyPatchModel.IncludedContent = []string{"data_volumes"} + backupPolicyPatchModel.MatchUserTags = []string{"my-daily-backup-policy"} + backupPolicyPatchModel.Name = core.StringPtr("my-backup-policy") + backupPolicyPatchModelAsPatch, asPatchErr := backupPolicyPatchModel.AsPatch() + 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.GetShareSource(getShareSourceOptionsModel) + result, response, operationErr = vpcService.UpdateBackupPolicy(updateBackupPolicyOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) }) - It(`Invoke GetShareSource with error: Operation validation and request error`, func() { + It(`Invoke UpdateBackupPolicy with error: Operation validation and request error`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -63745,22 +63735,32 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the GetShareSourceOptions model - getShareSourceOptionsModel := new(vpcv1.GetShareSourceOptions) - getShareSourceOptionsModel.ShareID = core.StringPtr("testString") - getShareSourceOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the BackupPolicyPatch model + backupPolicyPatchModel := new(vpcv1.BackupPolicyPatch) + backupPolicyPatchModel.IncludedContent = []string{"data_volumes"} + backupPolicyPatchModel.MatchUserTags = []string{"my-daily-backup-policy"} + backupPolicyPatchModel.Name = core.StringPtr("my-backup-policy") + backupPolicyPatchModelAsPatch, asPatchErr := backupPolicyPatchModel.AsPatch() + 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.GetShareSource(getShareSourceOptionsModel) + 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 GetShareSourceOptions model with no property values - getShareSourceOptionsModelNew := new(vpcv1.GetShareSourceOptions) + // 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.GetShareSource(getShareSourceOptionsModelNew) + result, response, operationErr = vpcService.UpdateBackupPolicy(updateBackupPolicyOptionsModelNew) Expect(operationErr).ToNot(BeNil()) Expect(response).To(BeNil()) Expect(result).To(BeNil()) @@ -63778,7 +63778,7 @@ var _ = Describe(`VpcV1`, func() { res.WriteHeader(200) })) }) - It(`Invoke GetShareSource successfully`, func() { + It(`Invoke UpdateBackupPolicy successfully`, func() { vpcService, serviceErr := vpcv1.NewVpcV1(&vpcv1.VpcV1Options{ URL: testServer.URL, Authenticator: &core.NoAuthAuthenticator{}, @@ -63787,13 +63787,23 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the GetShareSourceOptions model - getShareSourceOptionsModel := new(vpcv1.GetShareSourceOptions) - getShareSourceOptionsModel.ShareID = core.StringPtr("testString") - getShareSourceOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Construct an instance of the BackupPolicyPatch model + backupPolicyPatchModel := new(vpcv1.BackupPolicyPatch) + backupPolicyPatchModel.IncludedContent = []string{"data_volumes"} + backupPolicyPatchModel.MatchUserTags = []string{"my-daily-backup-policy"} + backupPolicyPatchModel.Name = core.StringPtr("my-backup-policy") + backupPolicyPatchModelAsPatch, asPatchErr := backupPolicyPatchModel.AsPatch() + 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.GetShareSource(getShareSourceOptionsModel) + result, response, operationErr := vpcService.UpdateBackupPolicy(updateBackupPolicyOptionsModel) Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) @@ -65065,17 +65075,13 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the VirtualNetworkInterfaceIPPrototypeReservedIPPrototypeVirtualNetworkInterfaceIPsContext model - virtualNetworkInterfaceIPPrototypeModel := new(vpcv1.VirtualNetworkInterfaceIPPrototypeReservedIPPrototypeVirtualNetworkInterfaceIPsContext) - virtualNetworkInterfaceIPPrototypeModel.Address = core.StringPtr("10.0.0.5") - virtualNetworkInterfaceIPPrototypeModel.AutoDelete = core.BoolPtr(false) - virtualNetworkInterfaceIPPrototypeModel.Name = core.StringPtr("my-reserved-ip") + // Construct an instance of the VirtualNetworkInterfaceIPPrototypeReservedIPIdentityVirtualNetworkInterfaceIPsContextByID model + virtualNetworkInterfaceIPPrototypeModel := new(vpcv1.VirtualNetworkInterfaceIPPrototypeReservedIPIdentityVirtualNetworkInterfaceIPsContextByID) + virtualNetworkInterfaceIPPrototypeModel.ID = core.StringPtr("6d353a0f-aeb1-4ae1-832e-1110d10981bb") - // Construct an instance of the VirtualNetworkInterfacePrimaryIPPrototypeReservedIPPrototypeVirtualNetworkInterfacePrimaryIPContext model - virtualNetworkInterfacePrimaryIPPrototypeModel := new(vpcv1.VirtualNetworkInterfacePrimaryIPPrototypeReservedIPPrototypeVirtualNetworkInterfacePrimaryIPContext) - virtualNetworkInterfacePrimaryIPPrototypeModel.Address = core.StringPtr("10.0.0.5") - virtualNetworkInterfacePrimaryIPPrototypeModel.AutoDelete = core.BoolPtr(false) - virtualNetworkInterfacePrimaryIPPrototypeModel.Name = core.StringPtr("my-reserved-ip") + // Construct an instance of the VirtualNetworkInterfacePrimaryIPPrototypeReservedIPIdentityVirtualNetworkInterfacePrimaryIPContextByID model + virtualNetworkInterfacePrimaryIPPrototypeModel := new(vpcv1.VirtualNetworkInterfacePrimaryIPPrototypeReservedIPIdentityVirtualNetworkInterfacePrimaryIPContextByID) + virtualNetworkInterfacePrimaryIPPrototypeModel.ID = core.StringPtr("6d353a0f-aeb1-4ae1-832e-1110d10981bb") // Construct an instance of the ResourceGroupIdentityByID model resourceGroupIdentityModel := new(vpcv1.ResourceGroupIdentityByID) @@ -65087,11 +65093,11 @@ var _ = Describe(`VpcV1`, func() { // Construct an instance of the SubnetIdentityByID model subnetIdentityModel := new(vpcv1.SubnetIdentityByID) - subnetIdentityModel.ID = core.StringPtr("7ec86020-1c6e-4889-b3f0-a15f2e50f87e") + subnetIdentityModel.ID = core.StringPtr("69e55145-cc7d-4d8e-9e1f-cc3fb60b1793") // Construct an instance of the CreateVirtualNetworkInterfaceOptions model createVirtualNetworkInterfaceOptionsModel := new(vpcv1.CreateVirtualNetworkInterfaceOptions) - createVirtualNetworkInterfaceOptionsModel.AllowIPSpoofing = core.BoolPtr(true) + createVirtualNetworkInterfaceOptionsModel.AllowIPSpoofing = core.BoolPtr(false) createVirtualNetworkInterfaceOptionsModel.AutoDelete = core.BoolPtr(false) createVirtualNetworkInterfaceOptionsModel.EnableInfrastructureNat = core.BoolPtr(true) createVirtualNetworkInterfaceOptionsModel.Ips = []vpcv1.VirtualNetworkInterfaceIPPrototypeIntf{virtualNetworkInterfaceIPPrototypeModel} @@ -65168,17 +65174,13 @@ var _ = Describe(`VpcV1`, func() { Expect(vpcService).ToNot(BeNil()) vpcService.EnableRetries(0, 0) - // Construct an instance of the VirtualNetworkInterfaceIPPrototypeReservedIPPrototypeVirtualNetworkInterfaceIPsContext model - virtualNetworkInterfaceIPPrototypeModel := new(vpcv1.VirtualNetworkInterfaceIPPrototypeReservedIPPrototypeVirtualNetworkInterfaceIPsContext) - virtualNetworkInterfaceIPPrototypeModel.Address = core.StringPtr("10.0.0.5") - virtualNetworkInterfaceIPPrototypeModel.AutoDelete = core.BoolPtr(false) - virtualNetworkInterfaceIPPrototypeModel.Name = core.StringPtr("my-reserved-ip") + // Construct an instance of the VirtualNetworkInterfaceIPPrototypeReservedIPIdentityVirtualNetworkInterfaceIPsContextByID model + virtualNetworkInterfaceIPPrototypeModel := new(vpcv1.VirtualNetworkInterfaceIPPrototypeReservedIPIdentityVirtualNetworkInterfaceIPsContextByID) + virtualNetworkInterfaceIPPrototypeModel.ID = core.StringPtr("6d353a0f-aeb1-4ae1-832e-1110d10981bb") - // Construct an instance of the VirtualNetworkInterfacePrimaryIPPrototypeReservedIPPrototypeVirtualNetworkInterfacePrimaryIPContext model - virtualNetworkInterfacePrimaryIPPrototypeModel := new(vpcv1.VirtualNetworkInterfacePrimaryIPPrototypeReservedIPPrototypeVirtualNetworkInterfacePrimaryIPContext) - virtualNetworkInterfacePrimaryIPPrototypeModel.Address = core.StringPtr("10.0.0.5") - virtualNetworkInterfacePrimaryIPPrototypeModel.AutoDelete = core.BoolPtr(false) - virtualNetworkInterfacePrimaryIPPrototypeModel.Name = core.StringPtr("my-reserved-ip") + // Construct an instance of the VirtualNetworkInterfacePrimaryIPPrototypeReservedIPIdentityVirtualNetworkInterfacePrimaryIPContextByID model + virtualNetworkInterfacePrimaryIPPrototypeModel := new(vpcv1.VirtualNetworkInterfacePrimaryIPPrototypeReservedIPIdentityVirtualNetworkInterfacePrimaryIPContextByID) + virtualNetworkInterfacePrimaryIPPrototypeModel.ID = core.StringPtr("6d353a0f-aeb1-4ae1-832e-1110d10981bb") // Construct an instance of the ResourceGroupIdentityByID model resourceGroupIdentityModel := new(vpcv1.ResourceGroupIdentityByID) @@ -65190,11 +65192,11 @@ var _ = Describe(`VpcV1`, func() { // Construct an instance of the SubnetIdentityByID model subnetIdentityModel := new(vpcv1.SubnetIdentityByID) - subnetIdentityModel.ID = core.StringPtr("7ec86020-1c6e-4889-b3f0-a15f2e50f87e") + subnetIdentityModel.ID = core.StringPtr("69e55145-cc7d-4d8e-9e1f-cc3fb60b1793") // Construct an instance of the CreateVirtualNetworkInterfaceOptions model createVirtualNetworkInterfaceOptionsModel := new(vpcv1.CreateVirtualNetworkInterfaceOptions) - createVirtualNetworkInterfaceOptionsModel.AllowIPSpoofing = core.BoolPtr(true) + createVirtualNetworkInterfaceOptionsModel.AllowIPSpoofing = core.BoolPtr(false) createVirtualNetworkInterfaceOptionsModel.AutoDelete = core.BoolPtr(false) createVirtualNetworkInterfaceOptionsModel.EnableInfrastructureNat = core.BoolPtr(true) createVirtualNetworkInterfaceOptionsModel.Ips = []vpcv1.VirtualNetworkInterfaceIPPrototypeIntf{virtualNetworkInterfaceIPPrototypeModel} @@ -65278,17 +65280,13 @@ var _ = Describe(`VpcV1`, func() { Expect(response).To(BeNil()) Expect(result).To(BeNil()) - // Construct an instance of the VirtualNetworkInterfaceIPPrototypeReservedIPPrototypeVirtualNetworkInterfaceIPsContext model - virtualNetworkInterfaceIPPrototypeModel := new(vpcv1.VirtualNetworkInterfaceIPPrototypeReservedIPPrototypeVirtualNetworkInterfaceIPsContext) - virtualNetworkInterfaceIPPrototypeModel.Address = core.StringPtr("10.0.0.5") - virtualNetworkInterfaceIPPrototypeModel.AutoDelete = core.BoolPtr(false) - virtualNetworkInterfaceIPPrototypeModel.Name = core.StringPtr("my-reserved-ip") + // Construct an instance of the VirtualNetworkInterfaceIPPrototypeReservedIPIdentityVirtualNetworkInterfaceIPsContextByID model + virtualNetworkInterfaceIPPrototypeModel := new(vpcv1.VirtualNetworkInterfaceIPPrototypeReservedIPIdentityVirtualNetworkInterfaceIPsContextByID) + virtualNetworkInterfaceIPPrototypeModel.ID = core.StringPtr("6d353a0f-aeb1-4ae1-832e-1110d10981bb") - // Construct an instance of the VirtualNetworkInterfacePrimaryIPPrototypeReservedIPPrototypeVirtualNetworkInterfacePrimaryIPContext model - virtualNetworkInterfacePrimaryIPPrototypeModel := new(vpcv1.VirtualNetworkInterfacePrimaryIPPrototypeReservedIPPrototypeVirtualNetworkInterfacePrimaryIPContext) - virtualNetworkInterfacePrimaryIPPrototypeModel.Address = core.StringPtr("10.0.0.5") - virtualNetworkInterfacePrimaryIPPrototypeModel.AutoDelete = core.BoolPtr(false) - virtualNetworkInterfacePrimaryIPPrototypeModel.Name = core.StringPtr("my-reserved-ip") + // Construct an instance of the VirtualNetworkInterfacePrimaryIPPrototypeReservedIPIdentityVirtualNetworkInterfacePrimaryIPContextByID model + virtualNetworkInterfacePrimaryIPPrototypeModel := new(vpcv1.VirtualNetworkInterfacePrimaryIPPrototypeReservedIPIdentityVirtualNetworkInterfacePrimaryIPContextByID) + virtualNetworkInterfacePrimaryIPPrototypeModel.ID = core.StringPtr("6d353a0f-aeb1-4ae1-832e-1110d10981bb") // Construct an instance of the ResourceGroupIdentityByID model resourceGroupIdentityModel := new(vpcv1.ResourceGroupIdentityByID) @@ -65300,11 +65298,11 @@ var _ = Describe(`VpcV1`, func() { // Construct an instance of the SubnetIdentityByID model subnetIdentityModel := new(vpcv1.SubnetIdentityByID) - subnetIdentityModel.ID = core.StringPtr("7ec86020-1c6e-4889-b3f0-a15f2e50f87e") + subnetIdentityModel.ID = core.StringPtr("69e55145-cc7d-4d8e-9e1f-cc3fb60b1793") // Construct an instance of the CreateVirtualNetworkInterfaceOptions model createVirtualNetworkInterfaceOptionsModel := new(vpcv1.CreateVirtualNetworkInterfaceOptions) - createVirtualNetworkInterfaceOptionsModel.AllowIPSpoofing = core.BoolPtr(true) + createVirtualNetworkInterfaceOptionsModel.AllowIPSpoofing = core.BoolPtr(false) createVirtualNetworkInterfaceOptionsModel.AutoDelete = core.BoolPtr(false) createVirtualNetworkInterfaceOptionsModel.EnableInfrastructureNat = core.BoolPtr(true) createVirtualNetworkInterfaceOptionsModel.Ips = []vpcv1.VirtualNetworkInterfaceIPPrototypeIntf{virtualNetworkInterfaceIPPrototypeModel} @@ -65331,17 +65329,13 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the VirtualNetworkInterfaceIPPrototypeReservedIPPrototypeVirtualNetworkInterfaceIPsContext model - virtualNetworkInterfaceIPPrototypeModel := new(vpcv1.VirtualNetworkInterfaceIPPrototypeReservedIPPrototypeVirtualNetworkInterfaceIPsContext) - virtualNetworkInterfaceIPPrototypeModel.Address = core.StringPtr("10.0.0.5") - virtualNetworkInterfaceIPPrototypeModel.AutoDelete = core.BoolPtr(false) - virtualNetworkInterfaceIPPrototypeModel.Name = core.StringPtr("my-reserved-ip") + // Construct an instance of the VirtualNetworkInterfaceIPPrototypeReservedIPIdentityVirtualNetworkInterfaceIPsContextByID model + virtualNetworkInterfaceIPPrototypeModel := new(vpcv1.VirtualNetworkInterfaceIPPrototypeReservedIPIdentityVirtualNetworkInterfaceIPsContextByID) + virtualNetworkInterfaceIPPrototypeModel.ID = core.StringPtr("6d353a0f-aeb1-4ae1-832e-1110d10981bb") - // Construct an instance of the VirtualNetworkInterfacePrimaryIPPrototypeReservedIPPrototypeVirtualNetworkInterfacePrimaryIPContext model - virtualNetworkInterfacePrimaryIPPrototypeModel := new(vpcv1.VirtualNetworkInterfacePrimaryIPPrototypeReservedIPPrototypeVirtualNetworkInterfacePrimaryIPContext) - virtualNetworkInterfacePrimaryIPPrototypeModel.Address = core.StringPtr("10.0.0.5") - virtualNetworkInterfacePrimaryIPPrototypeModel.AutoDelete = core.BoolPtr(false) - virtualNetworkInterfacePrimaryIPPrototypeModel.Name = core.StringPtr("my-reserved-ip") + // Construct an instance of the VirtualNetworkInterfacePrimaryIPPrototypeReservedIPIdentityVirtualNetworkInterfacePrimaryIPContextByID model + virtualNetworkInterfacePrimaryIPPrototypeModel := new(vpcv1.VirtualNetworkInterfacePrimaryIPPrototypeReservedIPIdentityVirtualNetworkInterfacePrimaryIPContextByID) + virtualNetworkInterfacePrimaryIPPrototypeModel.ID = core.StringPtr("6d353a0f-aeb1-4ae1-832e-1110d10981bb") // Construct an instance of the ResourceGroupIdentityByID model resourceGroupIdentityModel := new(vpcv1.ResourceGroupIdentityByID) @@ -65353,11 +65347,11 @@ var _ = Describe(`VpcV1`, func() { // Construct an instance of the SubnetIdentityByID model subnetIdentityModel := new(vpcv1.SubnetIdentityByID) - subnetIdentityModel.ID = core.StringPtr("7ec86020-1c6e-4889-b3f0-a15f2e50f87e") + subnetIdentityModel.ID = core.StringPtr("69e55145-cc7d-4d8e-9e1f-cc3fb60b1793") // Construct an instance of the CreateVirtualNetworkInterfaceOptions model createVirtualNetworkInterfaceOptionsModel := new(vpcv1.CreateVirtualNetworkInterfaceOptions) - createVirtualNetworkInterfaceOptionsModel.AllowIPSpoofing = core.BoolPtr(true) + createVirtualNetworkInterfaceOptionsModel.AllowIPSpoofing = core.BoolPtr(false) createVirtualNetworkInterfaceOptionsModel.AutoDelete = core.BoolPtr(false) createVirtualNetworkInterfaceOptionsModel.EnableInfrastructureNat = core.BoolPtr(true) createVirtualNetworkInterfaceOptionsModel.Ips = []vpcv1.VirtualNetworkInterfaceIPPrototypeIntf{virtualNetworkInterfaceIPPrototypeModel} @@ -65398,17 +65392,13 @@ var _ = Describe(`VpcV1`, func() { Expect(serviceErr).To(BeNil()) Expect(vpcService).ToNot(BeNil()) - // Construct an instance of the VirtualNetworkInterfaceIPPrototypeReservedIPPrototypeVirtualNetworkInterfaceIPsContext model - virtualNetworkInterfaceIPPrototypeModel := new(vpcv1.VirtualNetworkInterfaceIPPrototypeReservedIPPrototypeVirtualNetworkInterfaceIPsContext) - virtualNetworkInterfaceIPPrototypeModel.Address = core.StringPtr("10.0.0.5") - virtualNetworkInterfaceIPPrototypeModel.AutoDelete = core.BoolPtr(false) - virtualNetworkInterfaceIPPrototypeModel.Name = core.StringPtr("my-reserved-ip") + // Construct an instance of the VirtualNetworkInterfaceIPPrototypeReservedIPIdentityVirtualNetworkInterfaceIPsContextByID model + virtualNetworkInterfaceIPPrototypeModel := new(vpcv1.VirtualNetworkInterfaceIPPrototypeReservedIPIdentityVirtualNetworkInterfaceIPsContextByID) + virtualNetworkInterfaceIPPrototypeModel.ID = core.StringPtr("6d353a0f-aeb1-4ae1-832e-1110d10981bb") - // Construct an instance of the VirtualNetworkInterfacePrimaryIPPrototypeReservedIPPrototypeVirtualNetworkInterfacePrimaryIPContext model - virtualNetworkInterfacePrimaryIPPrototypeModel := new(vpcv1.VirtualNetworkInterfacePrimaryIPPrototypeReservedIPPrototypeVirtualNetworkInterfacePrimaryIPContext) - virtualNetworkInterfacePrimaryIPPrototypeModel.Address = core.StringPtr("10.0.0.5") - virtualNetworkInterfacePrimaryIPPrototypeModel.AutoDelete = core.BoolPtr(false) - virtualNetworkInterfacePrimaryIPPrototypeModel.Name = core.StringPtr("my-reserved-ip") + // Construct an instance of the VirtualNetworkInterfacePrimaryIPPrototypeReservedIPIdentityVirtualNetworkInterfacePrimaryIPContextByID model + virtualNetworkInterfacePrimaryIPPrototypeModel := new(vpcv1.VirtualNetworkInterfacePrimaryIPPrototypeReservedIPIdentityVirtualNetworkInterfacePrimaryIPContextByID) + virtualNetworkInterfacePrimaryIPPrototypeModel.ID = core.StringPtr("6d353a0f-aeb1-4ae1-832e-1110d10981bb") // Construct an instance of the ResourceGroupIdentityByID model resourceGroupIdentityModel := new(vpcv1.ResourceGroupIdentityByID) @@ -65420,11 +65410,11 @@ var _ = Describe(`VpcV1`, func() { // Construct an instance of the SubnetIdentityByID model subnetIdentityModel := new(vpcv1.SubnetIdentityByID) - subnetIdentityModel.ID = core.StringPtr("7ec86020-1c6e-4889-b3f0-a15f2e50f87e") + subnetIdentityModel.ID = core.StringPtr("69e55145-cc7d-4d8e-9e1f-cc3fb60b1793") // Construct an instance of the CreateVirtualNetworkInterfaceOptions model createVirtualNetworkInterfaceOptionsModel := new(vpcv1.CreateVirtualNetworkInterfaceOptions) - createVirtualNetworkInterfaceOptionsModel.AllowIPSpoofing = core.BoolPtr(true) + createVirtualNetworkInterfaceOptionsModel.AllowIPSpoofing = core.BoolPtr(false) createVirtualNetworkInterfaceOptionsModel.AutoDelete = core.BoolPtr(false) createVirtualNetworkInterfaceOptionsModel.EnableInfrastructureNat = core.BoolPtr(true) createVirtualNetworkInterfaceOptionsModel.Ips = []vpcv1.VirtualNetworkInterfaceIPPrototypeIntf{virtualNetworkInterfaceIPPrototypeModel} @@ -83892,7 +83882,7 @@ var _ = Describe(`VpcV1`, func() { 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.Header["If-Match"][0]).To(Equal(fmt.Sprintf("%v", "W/\"96d225c4-56bd-43d9-98fc-d7148e5c5028\""))) Expect(req.URL.Query()["version"]).To(Equal([]string{"testString"})) Expect(req.URL.Query()["generation"]).To(Equal([]string{fmt.Sprint(int64(2))})) res.WriteHeader(202) @@ -83915,7 +83905,7 @@ var _ = Describe(`VpcV1`, func() { // Construct an instance of the DeleteVPNServerOptions model deleteVPNServerOptionsModel := new(vpcv1.DeleteVPNServerOptions) deleteVPNServerOptionsModel.ID = core.StringPtr("testString") - deleteVPNServerOptionsModel.IfMatch = core.StringPtr(`W/"96d225c4-56bd-43d9-98fc-d7148e5c5028"`) + deleteVPNServerOptionsModel.IfMatch = core.StringPtr("W/\"96d225c4-56bd-43d9-98fc-d7148e5c5028\"") deleteVPNServerOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with valid options model (positive test) @@ -83935,7 +83925,7 @@ var _ = Describe(`VpcV1`, func() { // Construct an instance of the DeleteVPNServerOptions model deleteVPNServerOptionsModel := new(vpcv1.DeleteVPNServerOptions) deleteVPNServerOptionsModel.ID = core.StringPtr("testString") - deleteVPNServerOptionsModel.IfMatch = core.StringPtr(`W/"96d225c4-56bd-43d9-98fc-d7148e5c5028"`) + deleteVPNServerOptionsModel.IfMatch = core.StringPtr("W/\"96d225c4-56bd-43d9-98fc-d7148e5c5028\"") deleteVPNServerOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with empty URL (negative test) err := vpcService.SetServiceURL("") @@ -84193,7 +84183,7 @@ var _ = Describe(`VpcV1`, func() { Expect(req.URL.EscapedPath()).To(Equal(updateVPNServerPath)) 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.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") @@ -84250,7 +84240,7 @@ var _ = Describe(`VpcV1`, func() { updateVPNServerOptionsModel := new(vpcv1.UpdateVPNServerOptions) updateVPNServerOptionsModel.ID = core.StringPtr("testString") updateVPNServerOptionsModel.VPNServerPatch = vpnServerPatchModelAsPatch - updateVPNServerOptionsModel.IfMatch = core.StringPtr(`W/"96d225c4-56bd-43d9-98fc-d7148e5c5028"`) + updateVPNServerOptionsModel.IfMatch = core.StringPtr("W/\"96d225c4-56bd-43d9-98fc-d7148e5c5028\"") updateVPNServerOptionsModel.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.UpdateVPNServer(updateVPNServerOptionsModel) @@ -84299,7 +84289,7 @@ var _ = Describe(`VpcV1`, func() { 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.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 @@ -84361,7 +84351,7 @@ var _ = Describe(`VpcV1`, func() { updateVPNServerOptionsModel := new(vpcv1.UpdateVPNServerOptions) updateVPNServerOptionsModel.ID = core.StringPtr("testString") updateVPNServerOptionsModel.VPNServerPatch = vpnServerPatchModelAsPatch - updateVPNServerOptionsModel.IfMatch = core.StringPtr(`W/"96d225c4-56bd-43d9-98fc-d7148e5c5028"`) + updateVPNServerOptionsModel.IfMatch = core.StringPtr("W/\"96d225c4-56bd-43d9-98fc-d7148e5c5028\"") updateVPNServerOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with a Context to test a timeout error @@ -84415,7 +84405,7 @@ var _ = Describe(`VpcV1`, func() { 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.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 @@ -84479,7 +84469,7 @@ var _ = Describe(`VpcV1`, func() { updateVPNServerOptionsModel := new(vpcv1.UpdateVPNServerOptions) updateVPNServerOptionsModel.ID = core.StringPtr("testString") updateVPNServerOptionsModel.VPNServerPatch = vpnServerPatchModelAsPatch - updateVPNServerOptionsModel.IfMatch = core.StringPtr(`W/"96d225c4-56bd-43d9-98fc-d7148e5c5028"`) + updateVPNServerOptionsModel.IfMatch = core.StringPtr("W/\"96d225c4-56bd-43d9-98fc-d7148e5c5028\"") updateVPNServerOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with valid options model (positive test) @@ -84538,7 +84528,7 @@ var _ = Describe(`VpcV1`, func() { updateVPNServerOptionsModel := new(vpcv1.UpdateVPNServerOptions) updateVPNServerOptionsModel.ID = core.StringPtr("testString") updateVPNServerOptionsModel.VPNServerPatch = vpnServerPatchModelAsPatch - updateVPNServerOptionsModel.IfMatch = core.StringPtr(`W/"96d225c4-56bd-43d9-98fc-d7148e5c5028"`) + updateVPNServerOptionsModel.IfMatch = core.StringPtr("W/\"96d225c4-56bd-43d9-98fc-d7148e5c5028\"") updateVPNServerOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with empty URL (negative test) err := vpcService.SetServiceURL("") @@ -84618,7 +84608,7 @@ var _ = Describe(`VpcV1`, func() { updateVPNServerOptionsModel := new(vpcv1.UpdateVPNServerOptions) updateVPNServerOptionsModel.ID = core.StringPtr("testString") updateVPNServerOptionsModel.VPNServerPatch = vpnServerPatchModelAsPatch - updateVPNServerOptionsModel.IfMatch = core.StringPtr(`W/"96d225c4-56bd-43d9-98fc-d7148e5c5028"`) + updateVPNServerOptionsModel.IfMatch = core.StringPtr("W/\"96d225c4-56bd-43d9-98fc-d7148e5c5028\"") updateVPNServerOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation @@ -88487,7 +88477,7 @@ var _ = Describe(`VpcV1`, func() { 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.Header["If-Match"][0]).To(Equal(fmt.Sprintf("%v", "W/\"96d225c4-56bd-43d9-98fc-d7148e5c5028\""))) Expect(req.URL.Query()["version"]).To(Equal([]string{"testString"})) Expect(req.URL.Query()["generation"]).To(Equal([]string{fmt.Sprint(int64(2))})) res.WriteHeader(202) @@ -88510,7 +88500,7 @@ var _ = Describe(`VpcV1`, func() { // Construct an instance of the DeleteLoadBalancerOptions model deleteLoadBalancerOptionsModel := new(vpcv1.DeleteLoadBalancerOptions) deleteLoadBalancerOptionsModel.ID = core.StringPtr("testString") - deleteLoadBalancerOptionsModel.IfMatch = core.StringPtr(`W/"96d225c4-56bd-43d9-98fc-d7148e5c5028"`) + deleteLoadBalancerOptionsModel.IfMatch = core.StringPtr("W/\"96d225c4-56bd-43d9-98fc-d7148e5c5028\"") deleteLoadBalancerOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with valid options model (positive test) @@ -88530,7 +88520,7 @@ var _ = Describe(`VpcV1`, func() { // Construct an instance of the DeleteLoadBalancerOptions model deleteLoadBalancerOptionsModel := new(vpcv1.DeleteLoadBalancerOptions) deleteLoadBalancerOptionsModel.ID = core.StringPtr("testString") - deleteLoadBalancerOptionsModel.IfMatch = core.StringPtr(`W/"96d225c4-56bd-43d9-98fc-d7148e5c5028"`) + deleteLoadBalancerOptionsModel.IfMatch = core.StringPtr("W/\"96d225c4-56bd-43d9-98fc-d7148e5c5028\"") deleteLoadBalancerOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with empty URL (negative test) err := vpcService.SetServiceURL("") @@ -88788,7 +88778,7 @@ var _ = Describe(`VpcV1`, func() { Expect(req.URL.EscapedPath()).To(Equal(updateLoadBalancerPath)) 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.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") @@ -88843,7 +88833,7 @@ var _ = Describe(`VpcV1`, func() { updateLoadBalancerOptionsModel := new(vpcv1.UpdateLoadBalancerOptions) updateLoadBalancerOptionsModel.ID = core.StringPtr("testString") updateLoadBalancerOptionsModel.LoadBalancerPatch = loadBalancerPatchModelAsPatch - updateLoadBalancerOptionsModel.IfMatch = core.StringPtr(`W/"96d225c4-56bd-43d9-98fc-d7148e5c5028"`) + updateLoadBalancerOptionsModel.IfMatch = core.StringPtr("W/\"96d225c4-56bd-43d9-98fc-d7148e5c5028\"") updateLoadBalancerOptionsModel.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.UpdateLoadBalancer(updateLoadBalancerOptionsModel) @@ -88892,7 +88882,7 @@ var _ = Describe(`VpcV1`, func() { 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.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 @@ -88952,7 +88942,7 @@ var _ = Describe(`VpcV1`, func() { updateLoadBalancerOptionsModel := new(vpcv1.UpdateLoadBalancerOptions) updateLoadBalancerOptionsModel.ID = core.StringPtr("testString") updateLoadBalancerOptionsModel.LoadBalancerPatch = loadBalancerPatchModelAsPatch - updateLoadBalancerOptionsModel.IfMatch = core.StringPtr(`W/"96d225c4-56bd-43d9-98fc-d7148e5c5028"`) + updateLoadBalancerOptionsModel.IfMatch = core.StringPtr("W/\"96d225c4-56bd-43d9-98fc-d7148e5c5028\"") updateLoadBalancerOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with a Context to test a timeout error @@ -89006,7 +88996,7 @@ var _ = Describe(`VpcV1`, func() { 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.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 @@ -89068,7 +89058,7 @@ var _ = Describe(`VpcV1`, func() { updateLoadBalancerOptionsModel := new(vpcv1.UpdateLoadBalancerOptions) updateLoadBalancerOptionsModel.ID = core.StringPtr("testString") updateLoadBalancerOptionsModel.LoadBalancerPatch = loadBalancerPatchModelAsPatch - updateLoadBalancerOptionsModel.IfMatch = core.StringPtr(`W/"96d225c4-56bd-43d9-98fc-d7148e5c5028"`) + updateLoadBalancerOptionsModel.IfMatch = core.StringPtr("W/\"96d225c4-56bd-43d9-98fc-d7148e5c5028\"") updateLoadBalancerOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with valid options model (positive test) @@ -89125,7 +89115,7 @@ var _ = Describe(`VpcV1`, func() { updateLoadBalancerOptionsModel := new(vpcv1.UpdateLoadBalancerOptions) updateLoadBalancerOptionsModel.ID = core.StringPtr("testString") updateLoadBalancerOptionsModel.LoadBalancerPatch = loadBalancerPatchModelAsPatch - updateLoadBalancerOptionsModel.IfMatch = core.StringPtr(`W/"96d225c4-56bd-43d9-98fc-d7148e5c5028"`) + updateLoadBalancerOptionsModel.IfMatch = core.StringPtr("W/\"96d225c4-56bd-43d9-98fc-d7148e5c5028\"") updateLoadBalancerOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with empty URL (negative test) err := vpcService.SetServiceURL("") @@ -89203,7 +89193,7 @@ var _ = Describe(`VpcV1`, func() { updateLoadBalancerOptionsModel := new(vpcv1.UpdateLoadBalancerOptions) updateLoadBalancerOptionsModel.ID = core.StringPtr("testString") updateLoadBalancerOptionsModel.LoadBalancerPatch = loadBalancerPatchModelAsPatch - updateLoadBalancerOptionsModel.IfMatch = core.StringPtr(`W/"96d225c4-56bd-43d9-98fc-d7148e5c5028"`) + updateLoadBalancerOptionsModel.IfMatch = core.StringPtr("W/\"96d225c4-56bd-43d9-98fc-d7148e5c5028\"") updateLoadBalancerOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation @@ -102116,9 +102106,9 @@ var _ = Describe(`VpcV1`, func() { Expect(networkACLRulePrototypeModel.SourcePortMin).To(Equal(core.Int64Ptr(int64(49152)))) // Construct an instance of the CreateNetworkACLRuleOptions model - networkACLID := "testString" + networkAclid := "testString" var networkACLRulePrototype vpcv1.NetworkACLRulePrototypeIntf = nil - createNetworkACLRuleOptionsModel := vpcService.NewCreateNetworkACLRuleOptions(networkACLID, networkACLRulePrototype) + createNetworkACLRuleOptionsModel := vpcService.NewCreateNetworkACLRuleOptions(networkAclid, networkACLRulePrototype) createNetworkACLRuleOptionsModel.SetNetworkACLID("testString") createNetworkACLRuleOptionsModel.SetNetworkACLRulePrototype(networkACLRulePrototypeModel) createNetworkACLRuleOptionsModel.SetHeaders(map[string]string{"foo": "bar"}) @@ -102461,360 +102451,352 @@ var _ = Describe(`VpcV1`, func() { subnetIdentityModel.ID = core.StringPtr("7ec86020-1c6e-4889-b3f0-a15f2e50f87e") Expect(subnetIdentityModel.ID).To(Equal(core.StringPtr("7ec86020-1c6e-4889-b3f0-a15f2e50f87e"))) - // Construct an instance of the ShareMountTargetVirtualNetworkInterfacePrototypeVirtualNetworkInterfacePrototypeShareMountTargetContext model - shareMountTargetVirtualNetworkInterfacePrototypeModel := new(vpcv1.ShareMountTargetVirtualNetworkInterfacePrototypeVirtualNetworkInterfacePrototypeShareMountTargetContext) - Expect(shareMountTargetVirtualNetworkInterfacePrototypeModel).ToNot(BeNil()) - shareMountTargetVirtualNetworkInterfacePrototypeModel.AllowIPSpoofing = core.BoolPtr(true) - shareMountTargetVirtualNetworkInterfacePrototypeModel.AutoDelete = core.BoolPtr(false) - shareMountTargetVirtualNetworkInterfacePrototypeModel.EnableInfrastructureNat = core.BoolPtr(true) - shareMountTargetVirtualNetworkInterfacePrototypeModel.Ips = []vpcv1.VirtualNetworkInterfaceIPPrototypeIntf{virtualNetworkInterfaceIPPrototypeModel} - shareMountTargetVirtualNetworkInterfacePrototypeModel.Name = core.StringPtr("my-virtual-network-interface") - shareMountTargetVirtualNetworkInterfacePrototypeModel.PrimaryIP = virtualNetworkInterfacePrimaryIPPrototypeModel - shareMountTargetVirtualNetworkInterfacePrototypeModel.ResourceGroup = resourceGroupIdentityModel - shareMountTargetVirtualNetworkInterfacePrototypeModel.SecurityGroups = []vpcv1.SecurityGroupIdentityIntf{securityGroupIdentityModel} - shareMountTargetVirtualNetworkInterfacePrototypeModel.Subnet = subnetIdentityModel - Expect(shareMountTargetVirtualNetworkInterfacePrototypeModel.AllowIPSpoofing).To(Equal(core.BoolPtr(true))) - Expect(shareMountTargetVirtualNetworkInterfacePrototypeModel.AutoDelete).To(Equal(core.BoolPtr(false))) - Expect(shareMountTargetVirtualNetworkInterfacePrototypeModel.EnableInfrastructureNat).To(Equal(core.BoolPtr(true))) - Expect(shareMountTargetVirtualNetworkInterfacePrototypeModel.Ips).To(Equal([]vpcv1.VirtualNetworkInterfaceIPPrototypeIntf{virtualNetworkInterfaceIPPrototypeModel})) - Expect(shareMountTargetVirtualNetworkInterfacePrototypeModel.Name).To(Equal(core.StringPtr("my-virtual-network-interface"))) - Expect(shareMountTargetVirtualNetworkInterfacePrototypeModel.PrimaryIP).To(Equal(virtualNetworkInterfacePrimaryIPPrototypeModel)) - Expect(shareMountTargetVirtualNetworkInterfacePrototypeModel.ResourceGroup).To(Equal(resourceGroupIdentityModel)) - Expect(shareMountTargetVirtualNetworkInterfacePrototypeModel.SecurityGroups).To(Equal([]vpcv1.SecurityGroupIdentityIntf{securityGroupIdentityModel})) - Expect(shareMountTargetVirtualNetworkInterfacePrototypeModel.Subnet).To(Equal(subnetIdentityModel)) - - // Construct an instance of the ShareMountTargetPrototypeShareMountTargetByAccessControlModeSecurityGroup model - shareMountTargetPrototypeModel := new(vpcv1.ShareMountTargetPrototypeShareMountTargetByAccessControlModeSecurityGroup) - Expect(shareMountTargetPrototypeModel).ToNot(BeNil()) - shareMountTargetPrototypeModel.Name = core.StringPtr("my-share-mount-target") - shareMountTargetPrototypeModel.TransitEncryption = core.StringPtr("none") - shareMountTargetPrototypeModel.VirtualNetworkInterface = shareMountTargetVirtualNetworkInterfacePrototypeModel - Expect(shareMountTargetPrototypeModel.Name).To(Equal(core.StringPtr("my-share-mount-target"))) - Expect(shareMountTargetPrototypeModel.TransitEncryption).To(Equal(core.StringPtr("none"))) - Expect(shareMountTargetPrototypeModel.VirtualNetworkInterface).To(Equal(shareMountTargetVirtualNetworkInterfacePrototypeModel)) - - // Construct an instance of the ShareProfileIdentityByName model - shareProfileIdentityModel := new(vpcv1.ShareProfileIdentityByName) - Expect(shareProfileIdentityModel).ToNot(BeNil()) - shareProfileIdentityModel.Name = core.StringPtr("tier-3iops") - Expect(shareProfileIdentityModel.Name).To(Equal(core.StringPtr("tier-3iops"))) - - // Construct an instance of the ZoneIdentityByName model - zoneIdentityModel := new(vpcv1.ZoneIdentityByName) - Expect(zoneIdentityModel).ToNot(BeNil()) - zoneIdentityModel.Name = core.StringPtr("us-south-1") - Expect(zoneIdentityModel.Name).To(Equal(core.StringPtr("us-south-1"))) - - // Construct an instance of the SharePrototypeShareContext model - sharePrototypeShareContextModel := new(vpcv1.SharePrototypeShareContext) - Expect(sharePrototypeShareContextModel).ToNot(BeNil()) - sharePrototypeShareContextModel.Iops = core.Int64Ptr(int64(100)) - sharePrototypeShareContextModel.MountTargets = []vpcv1.ShareMountTargetPrototypeIntf{shareMountTargetPrototypeModel} - sharePrototypeShareContextModel.Name = core.StringPtr("my-share") - sharePrototypeShareContextModel.Profile = shareProfileIdentityModel - sharePrototypeShareContextModel.ReplicationCronSpec = core.StringPtr("0 */5 * * *") - sharePrototypeShareContextModel.ResourceGroup = resourceGroupIdentityModel - sharePrototypeShareContextModel.UserTags = []string{} - sharePrototypeShareContextModel.Zone = zoneIdentityModel - Expect(sharePrototypeShareContextModel.Iops).To(Equal(core.Int64Ptr(int64(100)))) - Expect(sharePrototypeShareContextModel.MountTargets).To(Equal([]vpcv1.ShareMountTargetPrototypeIntf{shareMountTargetPrototypeModel})) - Expect(sharePrototypeShareContextModel.Name).To(Equal(core.StringPtr("my-share"))) - Expect(sharePrototypeShareContextModel.Profile).To(Equal(shareProfileIdentityModel)) - Expect(sharePrototypeShareContextModel.ReplicationCronSpec).To(Equal(core.StringPtr("0 */5 * * *"))) - Expect(sharePrototypeShareContextModel.ResourceGroup).To(Equal(resourceGroupIdentityModel)) - Expect(sharePrototypeShareContextModel.UserTags).To(Equal([]string{})) - Expect(sharePrototypeShareContextModel.Zone).To(Equal(zoneIdentityModel)) - - // Construct an instance of the EncryptionKeyIdentityByCRN model - encryptionKeyIdentityModel := new(vpcv1.EncryptionKeyIdentityByCRN) - Expect(encryptionKeyIdentityModel).ToNot(BeNil()) - encryptionKeyIdentityModel.CRN = core.StringPtr("crn:v1:bluemix:public:kms:us-south:a/123456:e4a29d1a-2ef0-42a6-8fd2-350deb1c647e:key:5437653b-c4b1-447f-9646-b2a2a4cd6179") - Expect(encryptionKeyIdentityModel.CRN).To(Equal(core.StringPtr("crn:v1:bluemix:public:kms:us-south:a/123456:e4a29d1a-2ef0-42a6-8fd2-350deb1c647e:key:5437653b-c4b1-447f-9646-b2a2a4cd6179"))) - - // Construct an instance of the ShareInitialOwner model - shareInitialOwnerModel := new(vpcv1.ShareInitialOwner) - Expect(shareInitialOwnerModel).ToNot(BeNil()) - shareInitialOwnerModel.Gid = core.Int64Ptr(int64(50)) - shareInitialOwnerModel.Uid = core.Int64Ptr(int64(50)) - Expect(shareInitialOwnerModel.Gid).To(Equal(core.Int64Ptr(int64(50)))) - Expect(shareInitialOwnerModel.Uid).To(Equal(core.Int64Ptr(int64(50)))) - - // Construct an instance of the SharePrototypeShareBySize model - sharePrototypeModel := new(vpcv1.SharePrototypeShareBySize) - Expect(sharePrototypeModel).ToNot(BeNil()) - sharePrototypeModel.Iops = core.Int64Ptr(int64(100)) - sharePrototypeModel.MountTargets = []vpcv1.ShareMountTargetPrototypeIntf{shareMountTargetPrototypeModel} - sharePrototypeModel.Name = core.StringPtr("my-share") - sharePrototypeModel.Profile = shareProfileIdentityModel - sharePrototypeModel.ReplicaShare = sharePrototypeShareContextModel - sharePrototypeModel.UserTags = []string{} - sharePrototypeModel.Zone = zoneIdentityModel - sharePrototypeModel.AccessControlMode = core.StringPtr("security_group") - sharePrototypeModel.EncryptionKey = encryptionKeyIdentityModel - sharePrototypeModel.InitialOwner = shareInitialOwnerModel - sharePrototypeModel.ResourceGroup = resourceGroupIdentityModel - sharePrototypeModel.Size = core.Int64Ptr(int64(200)) - Expect(sharePrototypeModel.Iops).To(Equal(core.Int64Ptr(int64(100)))) - Expect(sharePrototypeModel.MountTargets).To(Equal([]vpcv1.ShareMountTargetPrototypeIntf{shareMountTargetPrototypeModel})) - Expect(sharePrototypeModel.Name).To(Equal(core.StringPtr("my-share"))) - Expect(sharePrototypeModel.Profile).To(Equal(shareProfileIdentityModel)) - Expect(sharePrototypeModel.ReplicaShare).To(Equal(sharePrototypeShareContextModel)) - Expect(sharePrototypeModel.UserTags).To(Equal([]string{})) - Expect(sharePrototypeModel.Zone).To(Equal(zoneIdentityModel)) - Expect(sharePrototypeModel.AccessControlMode).To(Equal(core.StringPtr("security_group"))) - Expect(sharePrototypeModel.EncryptionKey).To(Equal(encryptionKeyIdentityModel)) - Expect(sharePrototypeModel.InitialOwner).To(Equal(shareInitialOwnerModel)) - Expect(sharePrototypeModel.ResourceGroup).To(Equal(resourceGroupIdentityModel)) - Expect(sharePrototypeModel.Size).To(Equal(core.Int64Ptr(int64(200)))) - - // Construct an instance of the CreateShareOptions model - var sharePrototype vpcv1.SharePrototypeIntf = nil - createShareOptionsModel := vpcService.NewCreateShareOptions(sharePrototype) - createShareOptionsModel.SetSharePrototype(sharePrototypeModel) - createShareOptionsModel.SetHeaders(map[string]string{"foo": "bar"}) - Expect(createShareOptionsModel).ToNot(BeNil()) - Expect(createShareOptionsModel.SharePrototype).To(Equal(sharePrototypeModel)) - Expect(createShareOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) - }) - It(`Invoke NewCreateSnapshotCloneOptions successfully`, func() { - // Construct an instance of the CreateSnapshotCloneOptions model - id := "testString" - zoneName := "testString" - createSnapshotCloneOptionsModel := vpcService.NewCreateSnapshotCloneOptions(id, zoneName) - createSnapshotCloneOptionsModel.SetID("testString") - createSnapshotCloneOptionsModel.SetZoneName("testString") - createSnapshotCloneOptionsModel.SetHeaders(map[string]string{"foo": "bar"}) - Expect(createSnapshotCloneOptionsModel).ToNot(BeNil()) - Expect(createSnapshotCloneOptionsModel.ID).To(Equal(core.StringPtr("testString"))) - Expect(createSnapshotCloneOptionsModel.ZoneName).To(Equal(core.StringPtr("testString"))) - Expect(createSnapshotCloneOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) - }) - It(`Invoke NewCreateSnapshotConsistencyGroupOptions successfully`, func() { - // Construct an instance of the ResourceGroupIdentityByID model - resourceGroupIdentityModel := new(vpcv1.ResourceGroupIdentityByID) - Expect(resourceGroupIdentityModel).ToNot(BeNil()) - resourceGroupIdentityModel.ID = core.StringPtr("fee82deba12e4c0fb69c3b09d1f12345") - Expect(resourceGroupIdentityModel.ID).To(Equal(core.StringPtr("fee82deba12e4c0fb69c3b09d1f12345"))) - - // Construct an instance of the VolumeIdentityByID model - volumeIdentityModel := new(vpcv1.VolumeIdentityByID) - Expect(volumeIdentityModel).ToNot(BeNil()) - volumeIdentityModel.ID = core.StringPtr("1a6b7274-678d-4dfb-8981-c71dd9d4daa5") - Expect(volumeIdentityModel.ID).To(Equal(core.StringPtr("1a6b7274-678d-4dfb-8981-c71dd9d4daa5"))) - - // Construct an instance of the SnapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshotsSnapshotsItem model - snapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshotsSnapshotsItemModel := new(vpcv1.SnapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshotsSnapshotsItem) - Expect(snapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshotsSnapshotsItemModel).ToNot(BeNil()) - snapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshotsSnapshotsItemModel.Name = core.StringPtr("my-snapshot") - snapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshotsSnapshotsItemModel.SourceVolume = volumeIdentityModel - snapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshotsSnapshotsItemModel.UserTags = []string{"testString"} - Expect(snapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshotsSnapshotsItemModel.Name).To(Equal(core.StringPtr("my-snapshot"))) - Expect(snapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshotsSnapshotsItemModel.SourceVolume).To(Equal(volumeIdentityModel)) - Expect(snapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshotsSnapshotsItemModel.UserTags).To(Equal([]string{"testString"})) - - // Construct an instance of the SnapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshots model - snapshotConsistencyGroupPrototypeModel := new(vpcv1.SnapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshots) - Expect(snapshotConsistencyGroupPrototypeModel).ToNot(BeNil()) - snapshotConsistencyGroupPrototypeModel.DeleteSnapshotsOnDelete = core.BoolPtr(true) - snapshotConsistencyGroupPrototypeModel.Name = core.StringPtr("my-snapshot-consistency-group") - snapshotConsistencyGroupPrototypeModel.ResourceGroup = resourceGroupIdentityModel - snapshotConsistencyGroupPrototypeModel.Snapshots = []vpcv1.SnapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshotsSnapshotsItem{*snapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshotsSnapshotsItemModel} - Expect(snapshotConsistencyGroupPrototypeModel.DeleteSnapshotsOnDelete).To(Equal(core.BoolPtr(true))) - Expect(snapshotConsistencyGroupPrototypeModel.Name).To(Equal(core.StringPtr("my-snapshot-consistency-group"))) - Expect(snapshotConsistencyGroupPrototypeModel.ResourceGroup).To(Equal(resourceGroupIdentityModel)) - Expect(snapshotConsistencyGroupPrototypeModel.Snapshots).To(Equal([]vpcv1.SnapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshotsSnapshotsItem{*snapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshotsSnapshotsItemModel})) - - // Construct an instance of the CreateSnapshotConsistencyGroupOptions model - var snapshotConsistencyGroupPrototype vpcv1.SnapshotConsistencyGroupPrototypeIntf = nil - createSnapshotConsistencyGroupOptionsModel := vpcService.NewCreateSnapshotConsistencyGroupOptions(snapshotConsistencyGroupPrototype) - createSnapshotConsistencyGroupOptionsModel.SetSnapshotConsistencyGroupPrototype(snapshotConsistencyGroupPrototypeModel) - createSnapshotConsistencyGroupOptionsModel.SetHeaders(map[string]string{"foo": "bar"}) - Expect(createSnapshotConsistencyGroupOptionsModel).ToNot(BeNil()) - Expect(createSnapshotConsistencyGroupOptionsModel.SnapshotConsistencyGroupPrototype).To(Equal(snapshotConsistencyGroupPrototypeModel)) - Expect(createSnapshotConsistencyGroupOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) - }) - It(`Invoke NewCreateSnapshotOptions successfully`, func() { - // Construct an instance of the ZoneIdentityByName model - zoneIdentityModel := new(vpcv1.ZoneIdentityByName) - Expect(zoneIdentityModel).ToNot(BeNil()) - zoneIdentityModel.Name = core.StringPtr("us-south-1") - Expect(zoneIdentityModel.Name).To(Equal(core.StringPtr("us-south-1"))) - - // Construct an instance of the SnapshotClonePrototype model - snapshotClonePrototypeModel := new(vpcv1.SnapshotClonePrototype) - Expect(snapshotClonePrototypeModel).ToNot(BeNil()) - snapshotClonePrototypeModel.Zone = zoneIdentityModel - Expect(snapshotClonePrototypeModel.Zone).To(Equal(zoneIdentityModel)) - - // Construct an instance of the ResourceGroupIdentityByID model - resourceGroupIdentityModel := new(vpcv1.ResourceGroupIdentityByID) - Expect(resourceGroupIdentityModel).ToNot(BeNil()) - resourceGroupIdentityModel.ID = core.StringPtr("fee82deba12e4c0fb69c3b09d1f12345") - Expect(resourceGroupIdentityModel.ID).To(Equal(core.StringPtr("fee82deba12e4c0fb69c3b09d1f12345"))) - - // Construct an instance of the VolumeIdentityByID model - volumeIdentityModel := new(vpcv1.VolumeIdentityByID) - Expect(volumeIdentityModel).ToNot(BeNil()) - volumeIdentityModel.ID = core.StringPtr("1a6b7274-678d-4dfb-8981-c71dd9d4daa5") - Expect(volumeIdentityModel.ID).To(Equal(core.StringPtr("1a6b7274-678d-4dfb-8981-c71dd9d4daa5"))) - - // Construct an instance of the SnapshotPrototypeSnapshotBySourceVolume model - snapshotPrototypeModel := new(vpcv1.SnapshotPrototypeSnapshotBySourceVolume) - Expect(snapshotPrototypeModel).ToNot(BeNil()) - snapshotPrototypeModel.Clones = []vpcv1.SnapshotClonePrototype{*snapshotClonePrototypeModel} - snapshotPrototypeModel.Name = core.StringPtr("my-snapshot") - snapshotPrototypeModel.ResourceGroup = resourceGroupIdentityModel - snapshotPrototypeModel.UserTags = []string{} - snapshotPrototypeModel.SourceVolume = volumeIdentityModel - Expect(snapshotPrototypeModel.Clones).To(Equal([]vpcv1.SnapshotClonePrototype{*snapshotClonePrototypeModel})) - Expect(snapshotPrototypeModel.Name).To(Equal(core.StringPtr("my-snapshot"))) - Expect(snapshotPrototypeModel.ResourceGroup).To(Equal(resourceGroupIdentityModel)) - Expect(snapshotPrototypeModel.UserTags).To(Equal([]string{})) - Expect(snapshotPrototypeModel.SourceVolume).To(Equal(volumeIdentityModel)) - - // Construct an instance of the CreateSnapshotOptions model - var snapshotPrototype vpcv1.SnapshotPrototypeIntf = nil - createSnapshotOptionsModel := vpcService.NewCreateSnapshotOptions(snapshotPrototype) - createSnapshotOptionsModel.SetSnapshotPrototype(snapshotPrototypeModel) - createSnapshotOptionsModel.SetHeaders(map[string]string{"foo": "bar"}) - Expect(createSnapshotOptionsModel).ToNot(BeNil()) - Expect(createSnapshotOptionsModel.SnapshotPrototype).To(Equal(snapshotPrototypeModel)) - Expect(createSnapshotOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) - }) - It(`Invoke NewCreateSubnetOptions successfully`, func() { - // Construct an instance of the NetworkACLIdentityByID model - networkACLIdentityModel := new(vpcv1.NetworkACLIdentityByID) - Expect(networkACLIdentityModel).ToNot(BeNil()) - networkACLIdentityModel.ID = core.StringPtr("a4e28308-8ee7-46ab-8108-9f881f22bdbf") - Expect(networkACLIdentityModel.ID).To(Equal(core.StringPtr("a4e28308-8ee7-46ab-8108-9f881f22bdbf"))) - - // Construct an instance of the PublicGatewayIdentityPublicGatewayIdentityByID model - publicGatewayIdentityModel := new(vpcv1.PublicGatewayIdentityPublicGatewayIdentityByID) - Expect(publicGatewayIdentityModel).ToNot(BeNil()) - publicGatewayIdentityModel.ID = core.StringPtr("dc5431ef-1fc6-4861-adc9-a59d077d1241") - Expect(publicGatewayIdentityModel.ID).To(Equal(core.StringPtr("dc5431ef-1fc6-4861-adc9-a59d077d1241"))) - - // 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 RoutingTableIdentityByID model - routingTableIdentityModel := new(vpcv1.RoutingTableIdentityByID) - Expect(routingTableIdentityModel).ToNot(BeNil()) - routingTableIdentityModel.ID = core.StringPtr("6885e83f-03b2-4603-8a86-db2a0f55c840") - Expect(routingTableIdentityModel.ID).To(Equal(core.StringPtr("6885e83f-03b2-4603-8a86-db2a0f55c840"))) - - // Construct an instance of the VPCIdentityByID model - vpcIdentityModel := new(vpcv1.VPCIdentityByID) - Expect(vpcIdentityModel).ToNot(BeNil()) - vpcIdentityModel.ID = core.StringPtr("4727d842-f94f-4a2d-824a-9bc9b02c523b") - Expect(vpcIdentityModel.ID).To(Equal(core.StringPtr("4727d842-f94f-4a2d-824a-9bc9b02c523b"))) - - // Construct an instance of the ZoneIdentityByName model - zoneIdentityModel := new(vpcv1.ZoneIdentityByName) - Expect(zoneIdentityModel).ToNot(BeNil()) - zoneIdentityModel.Name = core.StringPtr("us-south-1") - Expect(zoneIdentityModel.Name).To(Equal(core.StringPtr("us-south-1"))) - - // Construct an instance of the SubnetPrototypeSubnetByTotalCount model - subnetPrototypeModel := new(vpcv1.SubnetPrototypeSubnetByTotalCount) - Expect(subnetPrototypeModel).ToNot(BeNil()) - subnetPrototypeModel.IPVersion = core.StringPtr("ipv4") - subnetPrototypeModel.Name = core.StringPtr("my-subnet") - subnetPrototypeModel.NetworkACL = networkACLIdentityModel - subnetPrototypeModel.PublicGateway = publicGatewayIdentityModel - subnetPrototypeModel.ResourceGroup = resourceGroupIdentityModel - subnetPrototypeModel.RoutingTable = routingTableIdentityModel - subnetPrototypeModel.VPC = vpcIdentityModel - subnetPrototypeModel.TotalIpv4AddressCount = core.Int64Ptr(int64(256)) - subnetPrototypeModel.Zone = zoneIdentityModel - Expect(subnetPrototypeModel.IPVersion).To(Equal(core.StringPtr("ipv4"))) - Expect(subnetPrototypeModel.Name).To(Equal(core.StringPtr("my-subnet"))) - Expect(subnetPrototypeModel.NetworkACL).To(Equal(networkACLIdentityModel)) - Expect(subnetPrototypeModel.PublicGateway).To(Equal(publicGatewayIdentityModel)) - Expect(subnetPrototypeModel.ResourceGroup).To(Equal(resourceGroupIdentityModel)) - Expect(subnetPrototypeModel.RoutingTable).To(Equal(routingTableIdentityModel)) - Expect(subnetPrototypeModel.VPC).To(Equal(vpcIdentityModel)) - Expect(subnetPrototypeModel.TotalIpv4AddressCount).To(Equal(core.Int64Ptr(int64(256)))) - Expect(subnetPrototypeModel.Zone).To(Equal(zoneIdentityModel)) - - // Construct an instance of the CreateSubnetOptions model - var subnetPrototype vpcv1.SubnetPrototypeIntf = nil - createSubnetOptionsModel := vpcService.NewCreateSubnetOptions(subnetPrototype) - createSubnetOptionsModel.SetSubnetPrototype(subnetPrototypeModel) - createSubnetOptionsModel.SetHeaders(map[string]string{"foo": "bar"}) - Expect(createSubnetOptionsModel).ToNot(BeNil()) - Expect(createSubnetOptionsModel.SubnetPrototype).To(Equal(subnetPrototypeModel)) - Expect(createSubnetOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) - }) - It(`Invoke NewCreateSubnetReservedIPOptions successfully`, func() { - // Construct an instance of the ReservedIPTargetPrototypeEndpointGatewayIdentityEndpointGatewayIdentityByID model - reservedIPTargetPrototypeModel := new(vpcv1.ReservedIPTargetPrototypeEndpointGatewayIdentityEndpointGatewayIdentityByID) - Expect(reservedIPTargetPrototypeModel).ToNot(BeNil()) - reservedIPTargetPrototypeModel.ID = core.StringPtr("r134-d7cc5196-9864-48c4-82d8-3f30da41fcc5") - Expect(reservedIPTargetPrototypeModel.ID).To(Equal(core.StringPtr("r134-d7cc5196-9864-48c4-82d8-3f30da41fcc5"))) - - // Construct an instance of the CreateSubnetReservedIPOptions model - subnetID := "testString" - createSubnetReservedIPOptionsModel := vpcService.NewCreateSubnetReservedIPOptions(subnetID) - createSubnetReservedIPOptionsModel.SetSubnetID("testString") - createSubnetReservedIPOptionsModel.SetAddress("192.168.3.4") - createSubnetReservedIPOptionsModel.SetAutoDelete(false) - createSubnetReservedIPOptionsModel.SetName("my-reserved-ip") - createSubnetReservedIPOptionsModel.SetTarget(reservedIPTargetPrototypeModel) - createSubnetReservedIPOptionsModel.SetHeaders(map[string]string{"foo": "bar"}) - Expect(createSubnetReservedIPOptionsModel).ToNot(BeNil()) - Expect(createSubnetReservedIPOptionsModel.SubnetID).To(Equal(core.StringPtr("testString"))) - Expect(createSubnetReservedIPOptionsModel.Address).To(Equal(core.StringPtr("192.168.3.4"))) - Expect(createSubnetReservedIPOptionsModel.AutoDelete).To(Equal(core.BoolPtr(false))) - Expect(createSubnetReservedIPOptionsModel.Name).To(Equal(core.StringPtr("my-reserved-ip"))) - Expect(createSubnetReservedIPOptionsModel.Target).To(Equal(reservedIPTargetPrototypeModel)) - Expect(createSubnetReservedIPOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) - }) - It(`Invoke NewCreateVirtualNetworkInterfaceOptions successfully`, func() { - // Construct an instance of the VirtualNetworkInterfaceIPPrototypeReservedIPPrototypeVirtualNetworkInterfaceIPsContext model - virtualNetworkInterfaceIPPrototypeModel := new(vpcv1.VirtualNetworkInterfaceIPPrototypeReservedIPPrototypeVirtualNetworkInterfaceIPsContext) - Expect(virtualNetworkInterfaceIPPrototypeModel).ToNot(BeNil()) - virtualNetworkInterfaceIPPrototypeModel.Address = core.StringPtr("10.0.0.5") - virtualNetworkInterfaceIPPrototypeModel.AutoDelete = core.BoolPtr(false) - virtualNetworkInterfaceIPPrototypeModel.Name = core.StringPtr("my-reserved-ip") - Expect(virtualNetworkInterfaceIPPrototypeModel.Address).To(Equal(core.StringPtr("10.0.0.5"))) - Expect(virtualNetworkInterfaceIPPrototypeModel.AutoDelete).To(Equal(core.BoolPtr(false))) - Expect(virtualNetworkInterfaceIPPrototypeModel.Name).To(Equal(core.StringPtr("my-reserved-ip"))) - - // Construct an instance of the VirtualNetworkInterfacePrimaryIPPrototypeReservedIPPrototypeVirtualNetworkInterfacePrimaryIPContext model - virtualNetworkInterfacePrimaryIPPrototypeModel := new(vpcv1.VirtualNetworkInterfacePrimaryIPPrototypeReservedIPPrototypeVirtualNetworkInterfacePrimaryIPContext) - Expect(virtualNetworkInterfacePrimaryIPPrototypeModel).ToNot(BeNil()) - virtualNetworkInterfacePrimaryIPPrototypeModel.Address = core.StringPtr("10.0.0.5") - virtualNetworkInterfacePrimaryIPPrototypeModel.AutoDelete = core.BoolPtr(false) - virtualNetworkInterfacePrimaryIPPrototypeModel.Name = core.StringPtr("my-reserved-ip") - Expect(virtualNetworkInterfacePrimaryIPPrototypeModel.Address).To(Equal(core.StringPtr("10.0.0.5"))) - Expect(virtualNetworkInterfacePrimaryIPPrototypeModel.AutoDelete).To(Equal(core.BoolPtr(false))) - Expect(virtualNetworkInterfacePrimaryIPPrototypeModel.Name).To(Equal(core.StringPtr("my-reserved-ip"))) - - // 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 SecurityGroupIdentityByID model - securityGroupIdentityModel := new(vpcv1.SecurityGroupIdentityByID) - Expect(securityGroupIdentityModel).ToNot(BeNil()) - securityGroupIdentityModel.ID = core.StringPtr("be5df5ca-12a0-494b-907e-aa6ec2bfa271") - Expect(securityGroupIdentityModel.ID).To(Equal(core.StringPtr("be5df5ca-12a0-494b-907e-aa6ec2bfa271"))) - - // Construct an instance of the SubnetIdentityByID model - subnetIdentityModel := new(vpcv1.SubnetIdentityByID) - Expect(subnetIdentityModel).ToNot(BeNil()) - subnetIdentityModel.ID = core.StringPtr("7ec86020-1c6e-4889-b3f0-a15f2e50f87e") - Expect(subnetIdentityModel.ID).To(Equal(core.StringPtr("7ec86020-1c6e-4889-b3f0-a15f2e50f87e"))) - + // Construct an instance of the ShareMountTargetVirtualNetworkInterfacePrototypeVirtualNetworkInterfacePrototypeShareMountTargetContext model + shareMountTargetVirtualNetworkInterfacePrototypeModel := new(vpcv1.ShareMountTargetVirtualNetworkInterfacePrototypeVirtualNetworkInterfacePrototypeShareMountTargetContext) + Expect(shareMountTargetVirtualNetworkInterfacePrototypeModel).ToNot(BeNil()) + shareMountTargetVirtualNetworkInterfacePrototypeModel.AllowIPSpoofing = core.BoolPtr(true) + shareMountTargetVirtualNetworkInterfacePrototypeModel.AutoDelete = core.BoolPtr(false) + shareMountTargetVirtualNetworkInterfacePrototypeModel.EnableInfrastructureNat = core.BoolPtr(true) + shareMountTargetVirtualNetworkInterfacePrototypeModel.Ips = []vpcv1.VirtualNetworkInterfaceIPPrototypeIntf{virtualNetworkInterfaceIPPrototypeModel} + shareMountTargetVirtualNetworkInterfacePrototypeModel.Name = core.StringPtr("my-virtual-network-interface") + shareMountTargetVirtualNetworkInterfacePrototypeModel.PrimaryIP = virtualNetworkInterfacePrimaryIPPrototypeModel + shareMountTargetVirtualNetworkInterfacePrototypeModel.ResourceGroup = resourceGroupIdentityModel + shareMountTargetVirtualNetworkInterfacePrototypeModel.SecurityGroups = []vpcv1.SecurityGroupIdentityIntf{securityGroupIdentityModel} + shareMountTargetVirtualNetworkInterfacePrototypeModel.Subnet = subnetIdentityModel + Expect(shareMountTargetVirtualNetworkInterfacePrototypeModel.AllowIPSpoofing).To(Equal(core.BoolPtr(true))) + Expect(shareMountTargetVirtualNetworkInterfacePrototypeModel.AutoDelete).To(Equal(core.BoolPtr(false))) + Expect(shareMountTargetVirtualNetworkInterfacePrototypeModel.EnableInfrastructureNat).To(Equal(core.BoolPtr(true))) + Expect(shareMountTargetVirtualNetworkInterfacePrototypeModel.Ips).To(Equal([]vpcv1.VirtualNetworkInterfaceIPPrototypeIntf{virtualNetworkInterfaceIPPrototypeModel})) + Expect(shareMountTargetVirtualNetworkInterfacePrototypeModel.Name).To(Equal(core.StringPtr("my-virtual-network-interface"))) + Expect(shareMountTargetVirtualNetworkInterfacePrototypeModel.PrimaryIP).To(Equal(virtualNetworkInterfacePrimaryIPPrototypeModel)) + Expect(shareMountTargetVirtualNetworkInterfacePrototypeModel.ResourceGroup).To(Equal(resourceGroupIdentityModel)) + Expect(shareMountTargetVirtualNetworkInterfacePrototypeModel.SecurityGroups).To(Equal([]vpcv1.SecurityGroupIdentityIntf{securityGroupIdentityModel})) + Expect(shareMountTargetVirtualNetworkInterfacePrototypeModel.Subnet).To(Equal(subnetIdentityModel)) + + // Construct an instance of the ShareMountTargetPrototypeShareMountTargetByAccessControlModeSecurityGroup model + shareMountTargetPrototypeModel := new(vpcv1.ShareMountTargetPrototypeShareMountTargetByAccessControlModeSecurityGroup) + Expect(shareMountTargetPrototypeModel).ToNot(BeNil()) + shareMountTargetPrototypeModel.Name = core.StringPtr("my-share-mount-target") + shareMountTargetPrototypeModel.TransitEncryption = core.StringPtr("none") + shareMountTargetPrototypeModel.VirtualNetworkInterface = shareMountTargetVirtualNetworkInterfacePrototypeModel + Expect(shareMountTargetPrototypeModel.Name).To(Equal(core.StringPtr("my-share-mount-target"))) + Expect(shareMountTargetPrototypeModel.TransitEncryption).To(Equal(core.StringPtr("none"))) + Expect(shareMountTargetPrototypeModel.VirtualNetworkInterface).To(Equal(shareMountTargetVirtualNetworkInterfacePrototypeModel)) + + // Construct an instance of the ShareProfileIdentityByName model + shareProfileIdentityModel := new(vpcv1.ShareProfileIdentityByName) + Expect(shareProfileIdentityModel).ToNot(BeNil()) + shareProfileIdentityModel.Name = core.StringPtr("tier-3iops") + Expect(shareProfileIdentityModel.Name).To(Equal(core.StringPtr("tier-3iops"))) + + // Construct an instance of the ZoneIdentityByName model + zoneIdentityModel := new(vpcv1.ZoneIdentityByName) + Expect(zoneIdentityModel).ToNot(BeNil()) + zoneIdentityModel.Name = core.StringPtr("us-south-1") + Expect(zoneIdentityModel.Name).To(Equal(core.StringPtr("us-south-1"))) + + // Construct an instance of the SharePrototypeShareContext model + sharePrototypeShareContextModel := new(vpcv1.SharePrototypeShareContext) + Expect(sharePrototypeShareContextModel).ToNot(BeNil()) + sharePrototypeShareContextModel.Iops = core.Int64Ptr(int64(100)) + sharePrototypeShareContextModel.MountTargets = []vpcv1.ShareMountTargetPrototypeIntf{shareMountTargetPrototypeModel} + sharePrototypeShareContextModel.Name = core.StringPtr("my-share") + sharePrototypeShareContextModel.Profile = shareProfileIdentityModel + sharePrototypeShareContextModel.ReplicationCronSpec = core.StringPtr("0 */5 * * *") + sharePrototypeShareContextModel.ResourceGroup = resourceGroupIdentityModel + sharePrototypeShareContextModel.UserTags = []string{} + sharePrototypeShareContextModel.Zone = zoneIdentityModel + Expect(sharePrototypeShareContextModel.Iops).To(Equal(core.Int64Ptr(int64(100)))) + Expect(sharePrototypeShareContextModel.MountTargets).To(Equal([]vpcv1.ShareMountTargetPrototypeIntf{shareMountTargetPrototypeModel})) + Expect(sharePrototypeShareContextModel.Name).To(Equal(core.StringPtr("my-share"))) + Expect(sharePrototypeShareContextModel.Profile).To(Equal(shareProfileIdentityModel)) + Expect(sharePrototypeShareContextModel.ReplicationCronSpec).To(Equal(core.StringPtr("0 */5 * * *"))) + Expect(sharePrototypeShareContextModel.ResourceGroup).To(Equal(resourceGroupIdentityModel)) + Expect(sharePrototypeShareContextModel.UserTags).To(Equal([]string{})) + Expect(sharePrototypeShareContextModel.Zone).To(Equal(zoneIdentityModel)) + + // Construct an instance of the EncryptionKeyIdentityByCRN model + encryptionKeyIdentityModel := new(vpcv1.EncryptionKeyIdentityByCRN) + Expect(encryptionKeyIdentityModel).ToNot(BeNil()) + encryptionKeyIdentityModel.CRN = core.StringPtr("crn:v1:bluemix:public:kms:us-south:a/123456:e4a29d1a-2ef0-42a6-8fd2-350deb1c647e:key:5437653b-c4b1-447f-9646-b2a2a4cd6179") + Expect(encryptionKeyIdentityModel.CRN).To(Equal(core.StringPtr("crn:v1:bluemix:public:kms:us-south:a/123456:e4a29d1a-2ef0-42a6-8fd2-350deb1c647e:key:5437653b-c4b1-447f-9646-b2a2a4cd6179"))) + + // Construct an instance of the ShareInitialOwner model + shareInitialOwnerModel := new(vpcv1.ShareInitialOwner) + Expect(shareInitialOwnerModel).ToNot(BeNil()) + shareInitialOwnerModel.Gid = core.Int64Ptr(int64(50)) + shareInitialOwnerModel.Uid = core.Int64Ptr(int64(50)) + Expect(shareInitialOwnerModel.Gid).To(Equal(core.Int64Ptr(int64(50)))) + Expect(shareInitialOwnerModel.Uid).To(Equal(core.Int64Ptr(int64(50)))) + + // Construct an instance of the SharePrototypeShareBySize model + sharePrototypeModel := new(vpcv1.SharePrototypeShareBySize) + Expect(sharePrototypeModel).ToNot(BeNil()) + sharePrototypeModel.Iops = core.Int64Ptr(int64(100)) + sharePrototypeModel.MountTargets = []vpcv1.ShareMountTargetPrototypeIntf{shareMountTargetPrototypeModel} + sharePrototypeModel.Name = core.StringPtr("my-share") + sharePrototypeModel.Profile = shareProfileIdentityModel + sharePrototypeModel.ReplicaShare = sharePrototypeShareContextModel + sharePrototypeModel.UserTags = []string{} + sharePrototypeModel.Zone = zoneIdentityModel + sharePrototypeModel.AccessControlMode = core.StringPtr("security_group") + sharePrototypeModel.EncryptionKey = encryptionKeyIdentityModel + sharePrototypeModel.InitialOwner = shareInitialOwnerModel + sharePrototypeModel.ResourceGroup = resourceGroupIdentityModel + sharePrototypeModel.Size = core.Int64Ptr(int64(200)) + Expect(sharePrototypeModel.Iops).To(Equal(core.Int64Ptr(int64(100)))) + Expect(sharePrototypeModel.MountTargets).To(Equal([]vpcv1.ShareMountTargetPrototypeIntf{shareMountTargetPrototypeModel})) + Expect(sharePrototypeModel.Name).To(Equal(core.StringPtr("my-share"))) + Expect(sharePrototypeModel.Profile).To(Equal(shareProfileIdentityModel)) + Expect(sharePrototypeModel.ReplicaShare).To(Equal(sharePrototypeShareContextModel)) + Expect(sharePrototypeModel.UserTags).To(Equal([]string{})) + Expect(sharePrototypeModel.Zone).To(Equal(zoneIdentityModel)) + Expect(sharePrototypeModel.AccessControlMode).To(Equal(core.StringPtr("security_group"))) + Expect(sharePrototypeModel.EncryptionKey).To(Equal(encryptionKeyIdentityModel)) + Expect(sharePrototypeModel.InitialOwner).To(Equal(shareInitialOwnerModel)) + Expect(sharePrototypeModel.ResourceGroup).To(Equal(resourceGroupIdentityModel)) + Expect(sharePrototypeModel.Size).To(Equal(core.Int64Ptr(int64(200)))) + + // Construct an instance of the CreateShareOptions model + var sharePrototype vpcv1.SharePrototypeIntf = nil + createShareOptionsModel := vpcService.NewCreateShareOptions(sharePrototype) + createShareOptionsModel.SetSharePrototype(sharePrototypeModel) + createShareOptionsModel.SetHeaders(map[string]string{"foo": "bar"}) + Expect(createShareOptionsModel).ToNot(BeNil()) + Expect(createShareOptionsModel.SharePrototype).To(Equal(sharePrototypeModel)) + Expect(createShareOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) + }) + It(`Invoke NewCreateSnapshotCloneOptions successfully`, func() { + // Construct an instance of the CreateSnapshotCloneOptions model + id := "testString" + zoneName := "testString" + createSnapshotCloneOptionsModel := vpcService.NewCreateSnapshotCloneOptions(id, zoneName) + createSnapshotCloneOptionsModel.SetID("testString") + createSnapshotCloneOptionsModel.SetZoneName("testString") + createSnapshotCloneOptionsModel.SetHeaders(map[string]string{"foo": "bar"}) + Expect(createSnapshotCloneOptionsModel).ToNot(BeNil()) + Expect(createSnapshotCloneOptionsModel.ID).To(Equal(core.StringPtr("testString"))) + Expect(createSnapshotCloneOptionsModel.ZoneName).To(Equal(core.StringPtr("testString"))) + Expect(createSnapshotCloneOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) + }) + It(`Invoke NewCreateSnapshotConsistencyGroupOptions successfully`, func() { + // Construct an instance of the ResourceGroupIdentityByID model + resourceGroupIdentityModel := new(vpcv1.ResourceGroupIdentityByID) + Expect(resourceGroupIdentityModel).ToNot(BeNil()) + resourceGroupIdentityModel.ID = core.StringPtr("fee82deba12e4c0fb69c3b09d1f12345") + Expect(resourceGroupIdentityModel.ID).To(Equal(core.StringPtr("fee82deba12e4c0fb69c3b09d1f12345"))) + + // Construct an instance of the VolumeIdentityByID model + volumeIdentityModel := new(vpcv1.VolumeIdentityByID) + Expect(volumeIdentityModel).ToNot(BeNil()) + volumeIdentityModel.ID = core.StringPtr("1a6b7274-678d-4dfb-8981-c71dd9d4daa5") + Expect(volumeIdentityModel.ID).To(Equal(core.StringPtr("1a6b7274-678d-4dfb-8981-c71dd9d4daa5"))) + + // Construct an instance of the SnapshotPrototypeSnapshotConsistencyGroupContext model + snapshotPrototypeSnapshotConsistencyGroupContextModel := new(vpcv1.SnapshotPrototypeSnapshotConsistencyGroupContext) + Expect(snapshotPrototypeSnapshotConsistencyGroupContextModel).ToNot(BeNil()) + snapshotPrototypeSnapshotConsistencyGroupContextModel.Name = core.StringPtr("my-snapshot") + snapshotPrototypeSnapshotConsistencyGroupContextModel.SourceVolume = volumeIdentityModel + snapshotPrototypeSnapshotConsistencyGroupContextModel.UserTags = []string{"testString"} + Expect(snapshotPrototypeSnapshotConsistencyGroupContextModel.Name).To(Equal(core.StringPtr("my-snapshot"))) + Expect(snapshotPrototypeSnapshotConsistencyGroupContextModel.SourceVolume).To(Equal(volumeIdentityModel)) + Expect(snapshotPrototypeSnapshotConsistencyGroupContextModel.UserTags).To(Equal([]string{"testString"})) + + // Construct an instance of the SnapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshots model + snapshotConsistencyGroupPrototypeModel := new(vpcv1.SnapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshots) + Expect(snapshotConsistencyGroupPrototypeModel).ToNot(BeNil()) + snapshotConsistencyGroupPrototypeModel.DeleteSnapshotsOnDelete = core.BoolPtr(true) + snapshotConsistencyGroupPrototypeModel.Name = core.StringPtr("my-snapshot-consistency-group") + snapshotConsistencyGroupPrototypeModel.ResourceGroup = resourceGroupIdentityModel + snapshotConsistencyGroupPrototypeModel.Snapshots = []vpcv1.SnapshotPrototypeSnapshotConsistencyGroupContext{*snapshotPrototypeSnapshotConsistencyGroupContextModel} + Expect(snapshotConsistencyGroupPrototypeModel.DeleteSnapshotsOnDelete).To(Equal(core.BoolPtr(true))) + Expect(snapshotConsistencyGroupPrototypeModel.Name).To(Equal(core.StringPtr("my-snapshot-consistency-group"))) + Expect(snapshotConsistencyGroupPrototypeModel.ResourceGroup).To(Equal(resourceGroupIdentityModel)) + Expect(snapshotConsistencyGroupPrototypeModel.Snapshots).To(Equal([]vpcv1.SnapshotPrototypeSnapshotConsistencyGroupContext{*snapshotPrototypeSnapshotConsistencyGroupContextModel})) + + // Construct an instance of the CreateSnapshotConsistencyGroupOptions model + var snapshotConsistencyGroupPrototype vpcv1.SnapshotConsistencyGroupPrototypeIntf = nil + createSnapshotConsistencyGroupOptionsModel := vpcService.NewCreateSnapshotConsistencyGroupOptions(snapshotConsistencyGroupPrototype) + createSnapshotConsistencyGroupOptionsModel.SetSnapshotConsistencyGroupPrototype(snapshotConsistencyGroupPrototypeModel) + createSnapshotConsistencyGroupOptionsModel.SetHeaders(map[string]string{"foo": "bar"}) + Expect(createSnapshotConsistencyGroupOptionsModel).ToNot(BeNil()) + Expect(createSnapshotConsistencyGroupOptionsModel.SnapshotConsistencyGroupPrototype).To(Equal(snapshotConsistencyGroupPrototypeModel)) + Expect(createSnapshotConsistencyGroupOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) + }) + It(`Invoke NewCreateSnapshotOptions successfully`, func() { + // Construct an instance of the ZoneIdentityByName model + zoneIdentityModel := new(vpcv1.ZoneIdentityByName) + Expect(zoneIdentityModel).ToNot(BeNil()) + zoneIdentityModel.Name = core.StringPtr("us-south-1") + Expect(zoneIdentityModel.Name).To(Equal(core.StringPtr("us-south-1"))) + + // Construct an instance of the SnapshotClonePrototype model + snapshotClonePrototypeModel := new(vpcv1.SnapshotClonePrototype) + Expect(snapshotClonePrototypeModel).ToNot(BeNil()) + snapshotClonePrototypeModel.Zone = zoneIdentityModel + Expect(snapshotClonePrototypeModel.Zone).To(Equal(zoneIdentityModel)) + + // Construct an instance of the ResourceGroupIdentityByID model + resourceGroupIdentityModel := new(vpcv1.ResourceGroupIdentityByID) + Expect(resourceGroupIdentityModel).ToNot(BeNil()) + resourceGroupIdentityModel.ID = core.StringPtr("fee82deba12e4c0fb69c3b09d1f12345") + Expect(resourceGroupIdentityModel.ID).To(Equal(core.StringPtr("fee82deba12e4c0fb69c3b09d1f12345"))) + + // Construct an instance of the VolumeIdentityByID model + volumeIdentityModel := new(vpcv1.VolumeIdentityByID) + Expect(volumeIdentityModel).ToNot(BeNil()) + volumeIdentityModel.ID = core.StringPtr("1a6b7274-678d-4dfb-8981-c71dd9d4daa5") + Expect(volumeIdentityModel.ID).To(Equal(core.StringPtr("1a6b7274-678d-4dfb-8981-c71dd9d4daa5"))) + + // Construct an instance of the SnapshotPrototypeSnapshotBySourceVolume model + snapshotPrototypeModel := new(vpcv1.SnapshotPrototypeSnapshotBySourceVolume) + Expect(snapshotPrototypeModel).ToNot(BeNil()) + snapshotPrototypeModel.Clones = []vpcv1.SnapshotClonePrototype{*snapshotClonePrototypeModel} + snapshotPrototypeModel.Name = core.StringPtr("my-snapshot") + snapshotPrototypeModel.ResourceGroup = resourceGroupIdentityModel + snapshotPrototypeModel.UserTags = []string{} + snapshotPrototypeModel.SourceVolume = volumeIdentityModel + Expect(snapshotPrototypeModel.Clones).To(Equal([]vpcv1.SnapshotClonePrototype{*snapshotClonePrototypeModel})) + Expect(snapshotPrototypeModel.Name).To(Equal(core.StringPtr("my-snapshot"))) + Expect(snapshotPrototypeModel.ResourceGroup).To(Equal(resourceGroupIdentityModel)) + Expect(snapshotPrototypeModel.UserTags).To(Equal([]string{})) + Expect(snapshotPrototypeModel.SourceVolume).To(Equal(volumeIdentityModel)) + + // Construct an instance of the CreateSnapshotOptions model + var snapshotPrototype vpcv1.SnapshotPrototypeIntf = nil + createSnapshotOptionsModel := vpcService.NewCreateSnapshotOptions(snapshotPrototype) + createSnapshotOptionsModel.SetSnapshotPrototype(snapshotPrototypeModel) + createSnapshotOptionsModel.SetHeaders(map[string]string{"foo": "bar"}) + Expect(createSnapshotOptionsModel).ToNot(BeNil()) + Expect(createSnapshotOptionsModel.SnapshotPrototype).To(Equal(snapshotPrototypeModel)) + Expect(createSnapshotOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) + }) + It(`Invoke NewCreateSubnetOptions successfully`, func() { + // Construct an instance of the NetworkACLIdentityByID model + networkACLIdentityModel := new(vpcv1.NetworkACLIdentityByID) + Expect(networkACLIdentityModel).ToNot(BeNil()) + networkACLIdentityModel.ID = core.StringPtr("a4e28308-8ee7-46ab-8108-9f881f22bdbf") + Expect(networkACLIdentityModel.ID).To(Equal(core.StringPtr("a4e28308-8ee7-46ab-8108-9f881f22bdbf"))) + + // Construct an instance of the PublicGatewayIdentityPublicGatewayIdentityByID model + publicGatewayIdentityModel := new(vpcv1.PublicGatewayIdentityPublicGatewayIdentityByID) + Expect(publicGatewayIdentityModel).ToNot(BeNil()) + publicGatewayIdentityModel.ID = core.StringPtr("dc5431ef-1fc6-4861-adc9-a59d077d1241") + Expect(publicGatewayIdentityModel.ID).To(Equal(core.StringPtr("dc5431ef-1fc6-4861-adc9-a59d077d1241"))) + + // 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 RoutingTableIdentityByID model + routingTableIdentityModel := new(vpcv1.RoutingTableIdentityByID) + Expect(routingTableIdentityModel).ToNot(BeNil()) + routingTableIdentityModel.ID = core.StringPtr("6885e83f-03b2-4603-8a86-db2a0f55c840") + Expect(routingTableIdentityModel.ID).To(Equal(core.StringPtr("6885e83f-03b2-4603-8a86-db2a0f55c840"))) + + // Construct an instance of the VPCIdentityByID model + vpcIdentityModel := new(vpcv1.VPCIdentityByID) + Expect(vpcIdentityModel).ToNot(BeNil()) + vpcIdentityModel.ID = core.StringPtr("4727d842-f94f-4a2d-824a-9bc9b02c523b") + Expect(vpcIdentityModel.ID).To(Equal(core.StringPtr("4727d842-f94f-4a2d-824a-9bc9b02c523b"))) + + // Construct an instance of the ZoneIdentityByName model + zoneIdentityModel := new(vpcv1.ZoneIdentityByName) + Expect(zoneIdentityModel).ToNot(BeNil()) + zoneIdentityModel.Name = core.StringPtr("us-south-1") + Expect(zoneIdentityModel.Name).To(Equal(core.StringPtr("us-south-1"))) + + // Construct an instance of the SubnetPrototypeSubnetByTotalCount model + subnetPrototypeModel := new(vpcv1.SubnetPrototypeSubnetByTotalCount) + Expect(subnetPrototypeModel).ToNot(BeNil()) + subnetPrototypeModel.IPVersion = core.StringPtr("ipv4") + subnetPrototypeModel.Name = core.StringPtr("my-subnet") + subnetPrototypeModel.NetworkACL = networkACLIdentityModel + subnetPrototypeModel.PublicGateway = publicGatewayIdentityModel + subnetPrototypeModel.ResourceGroup = resourceGroupIdentityModel + subnetPrototypeModel.RoutingTable = routingTableIdentityModel + subnetPrototypeModel.VPC = vpcIdentityModel + subnetPrototypeModel.TotalIpv4AddressCount = core.Int64Ptr(int64(256)) + subnetPrototypeModel.Zone = zoneIdentityModel + Expect(subnetPrototypeModel.IPVersion).To(Equal(core.StringPtr("ipv4"))) + Expect(subnetPrototypeModel.Name).To(Equal(core.StringPtr("my-subnet"))) + Expect(subnetPrototypeModel.NetworkACL).To(Equal(networkACLIdentityModel)) + Expect(subnetPrototypeModel.PublicGateway).To(Equal(publicGatewayIdentityModel)) + Expect(subnetPrototypeModel.ResourceGroup).To(Equal(resourceGroupIdentityModel)) + Expect(subnetPrototypeModel.RoutingTable).To(Equal(routingTableIdentityModel)) + Expect(subnetPrototypeModel.VPC).To(Equal(vpcIdentityModel)) + Expect(subnetPrototypeModel.TotalIpv4AddressCount).To(Equal(core.Int64Ptr(int64(256)))) + Expect(subnetPrototypeModel.Zone).To(Equal(zoneIdentityModel)) + + // Construct an instance of the CreateSubnetOptions model + var subnetPrototype vpcv1.SubnetPrototypeIntf = nil + createSubnetOptionsModel := vpcService.NewCreateSubnetOptions(subnetPrototype) + createSubnetOptionsModel.SetSubnetPrototype(subnetPrototypeModel) + createSubnetOptionsModel.SetHeaders(map[string]string{"foo": "bar"}) + Expect(createSubnetOptionsModel).ToNot(BeNil()) + Expect(createSubnetOptionsModel.SubnetPrototype).To(Equal(subnetPrototypeModel)) + Expect(createSubnetOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) + }) + It(`Invoke NewCreateSubnetReservedIPOptions successfully`, func() { + // Construct an instance of the ReservedIPTargetPrototypeEndpointGatewayIdentityEndpointGatewayIdentityByID model + reservedIPTargetPrototypeModel := new(vpcv1.ReservedIPTargetPrototypeEndpointGatewayIdentityEndpointGatewayIdentityByID) + Expect(reservedIPTargetPrototypeModel).ToNot(BeNil()) + reservedIPTargetPrototypeModel.ID = core.StringPtr("r134-d7cc5196-9864-48c4-82d8-3f30da41fcc5") + Expect(reservedIPTargetPrototypeModel.ID).To(Equal(core.StringPtr("r134-d7cc5196-9864-48c4-82d8-3f30da41fcc5"))) + + // Construct an instance of the CreateSubnetReservedIPOptions model + subnetID := "testString" + createSubnetReservedIPOptionsModel := vpcService.NewCreateSubnetReservedIPOptions(subnetID) + createSubnetReservedIPOptionsModel.SetSubnetID("testString") + createSubnetReservedIPOptionsModel.SetAddress("192.168.3.4") + createSubnetReservedIPOptionsModel.SetAutoDelete(false) + createSubnetReservedIPOptionsModel.SetName("my-reserved-ip") + createSubnetReservedIPOptionsModel.SetTarget(reservedIPTargetPrototypeModel) + createSubnetReservedIPOptionsModel.SetHeaders(map[string]string{"foo": "bar"}) + Expect(createSubnetReservedIPOptionsModel).ToNot(BeNil()) + Expect(createSubnetReservedIPOptionsModel.SubnetID).To(Equal(core.StringPtr("testString"))) + Expect(createSubnetReservedIPOptionsModel.Address).To(Equal(core.StringPtr("192.168.3.4"))) + Expect(createSubnetReservedIPOptionsModel.AutoDelete).To(Equal(core.BoolPtr(false))) + Expect(createSubnetReservedIPOptionsModel.Name).To(Equal(core.StringPtr("my-reserved-ip"))) + Expect(createSubnetReservedIPOptionsModel.Target).To(Equal(reservedIPTargetPrototypeModel)) + Expect(createSubnetReservedIPOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) + }) + It(`Invoke NewCreateVirtualNetworkInterfaceOptions successfully`, func() { + // Construct an instance of the VirtualNetworkInterfaceIPPrototypeReservedIPIdentityVirtualNetworkInterfaceIPsContextByID model + virtualNetworkInterfaceIPPrototypeModel := new(vpcv1.VirtualNetworkInterfaceIPPrototypeReservedIPIdentityVirtualNetworkInterfaceIPsContextByID) + Expect(virtualNetworkInterfaceIPPrototypeModel).ToNot(BeNil()) + virtualNetworkInterfaceIPPrototypeModel.ID = core.StringPtr("6d353a0f-aeb1-4ae1-832e-1110d10981bb") + Expect(virtualNetworkInterfaceIPPrototypeModel.ID).To(Equal(core.StringPtr("6d353a0f-aeb1-4ae1-832e-1110d10981bb"))) + + // Construct an instance of the VirtualNetworkInterfacePrimaryIPPrototypeReservedIPIdentityVirtualNetworkInterfacePrimaryIPContextByID model + virtualNetworkInterfacePrimaryIPPrototypeModel := new(vpcv1.VirtualNetworkInterfacePrimaryIPPrototypeReservedIPIdentityVirtualNetworkInterfacePrimaryIPContextByID) + Expect(virtualNetworkInterfacePrimaryIPPrototypeModel).ToNot(BeNil()) + virtualNetworkInterfacePrimaryIPPrototypeModel.ID = core.StringPtr("6d353a0f-aeb1-4ae1-832e-1110d10981bb") + Expect(virtualNetworkInterfacePrimaryIPPrototypeModel.ID).To(Equal(core.StringPtr("6d353a0f-aeb1-4ae1-832e-1110d10981bb"))) + + // 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 SecurityGroupIdentityByID model + securityGroupIdentityModel := new(vpcv1.SecurityGroupIdentityByID) + Expect(securityGroupIdentityModel).ToNot(BeNil()) + securityGroupIdentityModel.ID = core.StringPtr("be5df5ca-12a0-494b-907e-aa6ec2bfa271") + Expect(securityGroupIdentityModel.ID).To(Equal(core.StringPtr("be5df5ca-12a0-494b-907e-aa6ec2bfa271"))) + + // Construct an instance of the SubnetIdentityByID model + subnetIdentityModel := new(vpcv1.SubnetIdentityByID) + Expect(subnetIdentityModel).ToNot(BeNil()) + subnetIdentityModel.ID = core.StringPtr("69e55145-cc7d-4d8e-9e1f-cc3fb60b1793") + Expect(subnetIdentityModel.ID).To(Equal(core.StringPtr("69e55145-cc7d-4d8e-9e1f-cc3fb60b1793"))) + // Construct an instance of the CreateVirtualNetworkInterfaceOptions model createVirtualNetworkInterfaceOptionsModel := vpcService.NewCreateVirtualNetworkInterfaceOptions() - createVirtualNetworkInterfaceOptionsModel.SetAllowIPSpoofing(true) + createVirtualNetworkInterfaceOptionsModel.SetAllowIPSpoofing(false) createVirtualNetworkInterfaceOptionsModel.SetAutoDelete(false) createVirtualNetworkInterfaceOptionsModel.SetEnableInfrastructureNat(true) createVirtualNetworkInterfaceOptionsModel.SetIps([]vpcv1.VirtualNetworkInterfaceIPPrototypeIntf{virtualNetworkInterfaceIPPrototypeModel}) @@ -102825,7 +102807,7 @@ var _ = Describe(`VpcV1`, func() { createVirtualNetworkInterfaceOptionsModel.SetSubnet(subnetIdentityModel) createVirtualNetworkInterfaceOptionsModel.SetHeaders(map[string]string{"foo": "bar"}) Expect(createVirtualNetworkInterfaceOptionsModel).ToNot(BeNil()) - Expect(createVirtualNetworkInterfaceOptionsModel.AllowIPSpoofing).To(Equal(core.BoolPtr(true))) + Expect(createVirtualNetworkInterfaceOptionsModel.AllowIPSpoofing).To(Equal(core.BoolPtr(false))) Expect(createVirtualNetworkInterfaceOptionsModel.AutoDelete).To(Equal(core.BoolPtr(false))) Expect(createVirtualNetworkInterfaceOptionsModel.EnableInfrastructureNat).To(Equal(core.BoolPtr(true))) Expect(createVirtualNetworkInterfaceOptionsModel.Ips).To(Equal([]vpcv1.VirtualNetworkInterfaceIPPrototypeIntf{virtualNetworkInterfaceIPPrototypeModel})) @@ -103327,11 +103309,11 @@ var _ = Describe(`VpcV1`, func() { id := "testString" deleteBackupPolicyOptionsModel := vpcService.NewDeleteBackupPolicyOptions(id) deleteBackupPolicyOptionsModel.SetID("testString") - deleteBackupPolicyOptionsModel.SetIfMatch(`W/"96d225c4-56bd-43d9-98fc-d7148e5c5028"`) + 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.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() { @@ -103341,12 +103323,12 @@ var _ = Describe(`VpcV1`, func() { deleteBackupPolicyPlanOptionsModel := vpcService.NewDeleteBackupPolicyPlanOptions(backupPolicyID, id) deleteBackupPolicyPlanOptionsModel.SetBackupPolicyID("testString") deleteBackupPolicyPlanOptionsModel.SetID("testString") - deleteBackupPolicyPlanOptionsModel.SetIfMatch(`W/"96d225c4-56bd-43d9-98fc-d7148e5c5028"`) + 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.IfMatch).To(Equal(core.StringPtr("W/\"96d225c4-56bd-43d9-98fc-d7148e5c5028\""))) Expect(deleteBackupPolicyPlanOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) }) It(`Invoke NewDeleteBareMetalServerNetworkAttachmentOptions successfully`, func() { @@ -103587,11 +103569,11 @@ var _ = Describe(`VpcV1`, func() { id := "testString" deleteInstanceOptionsModel := vpcService.NewDeleteInstanceOptions(id) deleteInstanceOptionsModel.SetID("testString") - deleteInstanceOptionsModel.SetIfMatch(`W/"96d225c4-56bd-43d9-98fc-d7148e5c5028"`) + deleteInstanceOptionsModel.SetIfMatch("W/\"96d225c4-56bd-43d9-98fc-d7148e5c5028\"") deleteInstanceOptionsModel.SetHeaders(map[string]string{"foo": "bar"}) Expect(deleteInstanceOptionsModel).ToNot(BeNil()) Expect(deleteInstanceOptionsModel.ID).To(Equal(core.StringPtr("testString"))) - Expect(deleteInstanceOptionsModel.IfMatch).To(Equal(core.StringPtr(`W/"96d225c4-56bd-43d9-98fc-d7148e5c5028"`))) + Expect(deleteInstanceOptionsModel.IfMatch).To(Equal(core.StringPtr("W/\"96d225c4-56bd-43d9-98fc-d7148e5c5028\""))) Expect(deleteInstanceOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) }) It(`Invoke NewDeleteInstanceTemplateOptions successfully`, func() { @@ -103690,11 +103672,11 @@ var _ = Describe(`VpcV1`, func() { id := "testString" deleteLoadBalancerOptionsModel := vpcService.NewDeleteLoadBalancerOptions(id) deleteLoadBalancerOptionsModel.SetID("testString") - deleteLoadBalancerOptionsModel.SetIfMatch(`W/"96d225c4-56bd-43d9-98fc-d7148e5c5028"`) + deleteLoadBalancerOptionsModel.SetIfMatch("W/\"96d225c4-56bd-43d9-98fc-d7148e5c5028\"") deleteLoadBalancerOptionsModel.SetHeaders(map[string]string{"foo": "bar"}) Expect(deleteLoadBalancerOptionsModel).ToNot(BeNil()) Expect(deleteLoadBalancerOptionsModel.ID).To(Equal(core.StringPtr("testString"))) - Expect(deleteLoadBalancerOptionsModel.IfMatch).To(Equal(core.StringPtr(`W/"96d225c4-56bd-43d9-98fc-d7148e5c5028"`))) + Expect(deleteLoadBalancerOptionsModel.IfMatch).To(Equal(core.StringPtr("W/\"96d225c4-56bd-43d9-98fc-d7148e5c5028\""))) Expect(deleteLoadBalancerOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) }) It(`Invoke NewDeleteLoadBalancerPoolMemberOptions successfully`, func() { @@ -103738,9 +103720,9 @@ var _ = Describe(`VpcV1`, func() { }) It(`Invoke NewDeleteNetworkACLRuleOptions successfully`, func() { // Construct an instance of the DeleteNetworkACLRuleOptions model - networkACLID := "testString" + networkAclid := "testString" id := "testString" - deleteNetworkACLRuleOptionsModel := vpcService.NewDeleteNetworkACLRuleOptions(networkACLID, id) + deleteNetworkACLRuleOptionsModel := vpcService.NewDeleteNetworkACLRuleOptions(networkAclid, id) deleteNetworkACLRuleOptionsModel.SetNetworkACLID("testString") deleteNetworkACLRuleOptionsModel.SetID("testString") deleteNetworkACLRuleOptionsModel.SetHeaders(map[string]string{"foo": "bar"}) @@ -103833,11 +103815,11 @@ var _ = Describe(`VpcV1`, func() { id := "testString" deleteShareOptionsModel := vpcService.NewDeleteShareOptions(id) deleteShareOptionsModel.SetID("testString") - deleteShareOptionsModel.SetIfMatch(`W/"96d225c4-56bd-43d9-98fc-d7148e5c5028"`) + deleteShareOptionsModel.SetIfMatch("W/\"96d225c4-56bd-43d9-98fc-d7148e5c5028\"") deleteShareOptionsModel.SetHeaders(map[string]string{"foo": "bar"}) Expect(deleteShareOptionsModel).ToNot(BeNil()) Expect(deleteShareOptionsModel.ID).To(Equal(core.StringPtr("testString"))) - Expect(deleteShareOptionsModel.IfMatch).To(Equal(core.StringPtr(`W/"96d225c4-56bd-43d9-98fc-d7148e5c5028"`))) + Expect(deleteShareOptionsModel.IfMatch).To(Equal(core.StringPtr("W/\"96d225c4-56bd-43d9-98fc-d7148e5c5028\""))) Expect(deleteShareOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) }) It(`Invoke NewDeleteShareSourceOptions successfully`, func() { @@ -103878,11 +103860,11 @@ var _ = Describe(`VpcV1`, func() { id := "testString" deleteSnapshotOptionsModel := vpcService.NewDeleteSnapshotOptions(id) deleteSnapshotOptionsModel.SetID("testString") - deleteSnapshotOptionsModel.SetIfMatch(`W/"96d225c4-56bd-43d9-98fc-d7148e5c5028"`) + deleteSnapshotOptionsModel.SetIfMatch("W/\"96d225c4-56bd-43d9-98fc-d7148e5c5028\"") deleteSnapshotOptionsModel.SetHeaders(map[string]string{"foo": "bar"}) Expect(deleteSnapshotOptionsModel).ToNot(BeNil()) Expect(deleteSnapshotOptionsModel.ID).To(Equal(core.StringPtr("testString"))) - Expect(deleteSnapshotOptionsModel.IfMatch).To(Equal(core.StringPtr(`W/"96d225c4-56bd-43d9-98fc-d7148e5c5028"`))) + Expect(deleteSnapshotOptionsModel.IfMatch).To(Equal(core.StringPtr("W/\"96d225c4-56bd-43d9-98fc-d7148e5c5028\""))) Expect(deleteSnapshotOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) }) It(`Invoke NewDeleteSnapshotsOptions successfully`, func() { @@ -103933,11 +103915,11 @@ var _ = Describe(`VpcV1`, func() { id := "testString" deleteVolumeOptionsModel := vpcService.NewDeleteVolumeOptions(id) deleteVolumeOptionsModel.SetID("testString") - deleteVolumeOptionsModel.SetIfMatch(`W/"96d225c4-56bd-43d9-98fc-d7148e5c5028"`) + deleteVolumeOptionsModel.SetIfMatch("W/\"96d225c4-56bd-43d9-98fc-d7148e5c5028\"") deleteVolumeOptionsModel.SetHeaders(map[string]string{"foo": "bar"}) Expect(deleteVolumeOptionsModel).ToNot(BeNil()) Expect(deleteVolumeOptionsModel.ID).To(Equal(core.StringPtr("testString"))) - Expect(deleteVolumeOptionsModel.IfMatch).To(Equal(core.StringPtr(`W/"96d225c4-56bd-43d9-98fc-d7148e5c5028"`))) + Expect(deleteVolumeOptionsModel.IfMatch).To(Equal(core.StringPtr("W/\"96d225c4-56bd-43d9-98fc-d7148e5c5028\""))) Expect(deleteVolumeOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) }) It(`Invoke NewDeleteVPCAddressPrefixOptions successfully`, func() { @@ -103971,11 +103953,11 @@ var _ = Describe(`VpcV1`, func() { id := "testString" deleteVPCOptionsModel := vpcService.NewDeleteVPCOptions(id) deleteVPCOptionsModel.SetID("testString") - deleteVPCOptionsModel.SetIfMatch(`W/"96d225c4-56bd-43d9-98fc-d7148e5c5028"`) + deleteVPCOptionsModel.SetIfMatch("W/\"96d225c4-56bd-43d9-98fc-d7148e5c5028\"") deleteVPCOptionsModel.SetHeaders(map[string]string{"foo": "bar"}) Expect(deleteVPCOptionsModel).ToNot(BeNil()) Expect(deleteVPCOptionsModel.ID).To(Equal(core.StringPtr("testString"))) - Expect(deleteVPCOptionsModel.IfMatch).To(Equal(core.StringPtr(`W/"96d225c4-56bd-43d9-98fc-d7148e5c5028"`))) + Expect(deleteVPCOptionsModel.IfMatch).To(Equal(core.StringPtr("W/\"96d225c4-56bd-43d9-98fc-d7148e5c5028\""))) Expect(deleteVPCOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) }) It(`Invoke NewDeleteVPCRouteOptions successfully`, func() { @@ -103998,12 +103980,12 @@ var _ = Describe(`VpcV1`, func() { deleteVPCRoutingTableOptionsModel := vpcService.NewDeleteVPCRoutingTableOptions(vpcID, id) deleteVPCRoutingTableOptionsModel.SetVPCID("testString") deleteVPCRoutingTableOptionsModel.SetID("testString") - deleteVPCRoutingTableOptionsModel.SetIfMatch(`W/"96d225c4-56bd-43d9-98fc-d7148e5c5028"`) + deleteVPCRoutingTableOptionsModel.SetIfMatch("W/\"96d225c4-56bd-43d9-98fc-d7148e5c5028\"") deleteVPCRoutingTableOptionsModel.SetHeaders(map[string]string{"foo": "bar"}) Expect(deleteVPCRoutingTableOptionsModel).ToNot(BeNil()) Expect(deleteVPCRoutingTableOptionsModel.VPCID).To(Equal(core.StringPtr("testString"))) Expect(deleteVPCRoutingTableOptionsModel.ID).To(Equal(core.StringPtr("testString"))) - Expect(deleteVPCRoutingTableOptionsModel.IfMatch).To(Equal(core.StringPtr(`W/"96d225c4-56bd-43d9-98fc-d7148e5c5028"`))) + Expect(deleteVPCRoutingTableOptionsModel.IfMatch).To(Equal(core.StringPtr("W/\"96d225c4-56bd-43d9-98fc-d7148e5c5028\""))) Expect(deleteVPCRoutingTableOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) }) It(`Invoke NewDeleteVPCRoutingTableRouteOptions successfully`, func() { @@ -104063,11 +104045,11 @@ var _ = Describe(`VpcV1`, func() { id := "testString" deleteVPNServerOptionsModel := vpcService.NewDeleteVPNServerOptions(id) deleteVPNServerOptionsModel.SetID("testString") - deleteVPNServerOptionsModel.SetIfMatch(`W/"96d225c4-56bd-43d9-98fc-d7148e5c5028"`) + deleteVPNServerOptionsModel.SetIfMatch("W/\"96d225c4-56bd-43d9-98fc-d7148e5c5028\"") deleteVPNServerOptionsModel.SetHeaders(map[string]string{"foo": "bar"}) Expect(deleteVPNServerOptionsModel).ToNot(BeNil()) Expect(deleteVPNServerOptionsModel.ID).To(Equal(core.StringPtr("testString"))) - Expect(deleteVPNServerOptionsModel.IfMatch).To(Equal(core.StringPtr(`W/"96d225c4-56bd-43d9-98fc-d7148e5c5028"`))) + Expect(deleteVPNServerOptionsModel.IfMatch).To(Equal(core.StringPtr("W/\"96d225c4-56bd-43d9-98fc-d7148e5c5028\""))) Expect(deleteVPNServerOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) }) It(`Invoke NewDeleteVPNServerRouteOptions successfully`, func() { @@ -104707,9 +104689,9 @@ var _ = Describe(`VpcV1`, func() { }) It(`Invoke NewGetNetworkACLRuleOptions successfully`, func() { // Construct an instance of the GetNetworkACLRuleOptions model - networkACLID := "testString" + networkAclid := "testString" id := "testString" - getNetworkACLRuleOptionsModel := vpcService.NewGetNetworkACLRuleOptions(networkACLID, id) + getNetworkACLRuleOptionsModel := vpcService.NewGetNetworkACLRuleOptions(networkAclid, id) getNetworkACLRuleOptionsModel.SetNetworkACLID("testString") getNetworkACLRuleOptionsModel.SetID("testString") getNetworkACLRuleOptionsModel.SetHeaders(map[string]string{"foo": "bar"}) @@ -105868,8 +105850,8 @@ var _ = Describe(`VpcV1`, func() { }) It(`Invoke NewListNetworkACLRulesOptions successfully`, func() { // Construct an instance of the ListNetworkACLRulesOptions model - networkACLID := "testString" - listNetworkACLRulesOptionsModel := vpcService.NewListNetworkACLRulesOptions(networkACLID) + networkAclid := "testString" + listNetworkACLRulesOptionsModel := vpcService.NewListNetworkACLRulesOptions(networkAclid) listNetworkACLRulesOptionsModel.SetNetworkACLID("testString") listNetworkACLRulesOptionsModel.SetStart("testString") listNetworkACLRulesOptionsModel.SetLimit(int64(10)) @@ -106251,6 +106233,7 @@ var _ = Describe(`VpcV1`, func() { listVolumesOptionsModel.SetOperatingSystemFamily("Ubuntu Server") listVolumesOptionsModel.SetOperatingSystemArchitecture("amd64") listVolumesOptionsModel.SetZoneName("us-south-1") + listVolumesOptionsModel.SetTag("testString") listVolumesOptionsModel.SetHeaders(map[string]string{"foo": "bar"}) Expect(listVolumesOptionsModel).ToNot(BeNil()) Expect(listVolumesOptionsModel.Start).To(Equal(core.StringPtr("testString"))) @@ -106261,6 +106244,7 @@ var _ = Describe(`VpcV1`, func() { Expect(listVolumesOptionsModel.OperatingSystemFamily).To(Equal(core.StringPtr("Ubuntu Server"))) Expect(listVolumesOptionsModel.OperatingSystemArchitecture).To(Equal(core.StringPtr("amd64"))) Expect(listVolumesOptionsModel.ZoneName).To(Equal(core.StringPtr("us-south-1"))) + Expect(listVolumesOptionsModel.Tag).To(Equal(core.StringPtr("testString"))) Expect(listVolumesOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) }) It(`Invoke NewListVPCAddressPrefixesOptions successfully`, func() { @@ -106805,14 +106789,9 @@ var _ = Describe(`VpcV1`, func() { _, err := vpcService.NewSnapshotClonePrototype(zone) Expect(err).ToNot(BeNil()) }) - It(`Invoke NewSnapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshotsSnapshotsItem successfully`, func() { - var sourceVolume vpcv1.VolumeIdentityIntf = nil - _, err := vpcService.NewSnapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshotsSnapshotsItem(sourceVolume) - Expect(err).ToNot(BeNil()) - }) - It(`Invoke NewSnapshotConsistencyGroupPrototypeSnapshotsItem successfully`, func() { + It(`Invoke NewSnapshotPrototypeSnapshotConsistencyGroupContext successfully`, func() { var sourceVolume vpcv1.VolumeIdentityIntf = nil - _, err := vpcService.NewSnapshotConsistencyGroupPrototypeSnapshotsItem(sourceVolume) + _, err := vpcService.NewSnapshotPrototypeSnapshotConsistencyGroupContext(sourceVolume) Expect(err).ToNot(BeNil()) }) It(`Invoke NewStartBareMetalServerOptions successfully`, func() { @@ -106855,12 +106834,12 @@ var _ = Describe(`VpcV1`, func() { updateBackupPolicyOptionsModel := vpcService.NewUpdateBackupPolicyOptions(id, backupPolicyPatch) updateBackupPolicyOptionsModel.SetID("testString") updateBackupPolicyOptionsModel.SetBackupPolicyPatch(map[string]interface{}{"anyKey": "anyValue"}) - updateBackupPolicyOptionsModel.SetIfMatch(`W/"96d225c4-56bd-43d9-98fc-d7148e5c5028"`) + 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(map[string]interface{}{"anyKey": "anyValue"})) - Expect(updateBackupPolicyOptionsModel.IfMatch).To(Equal(core.StringPtr(`W/"96d225c4-56bd-43d9-98fc-d7148e5c5028"`))) + 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() { @@ -106872,13 +106851,13 @@ var _ = Describe(`VpcV1`, func() { updateBackupPolicyPlanOptionsModel.SetBackupPolicyID("testString") updateBackupPolicyPlanOptionsModel.SetID("testString") updateBackupPolicyPlanOptionsModel.SetBackupPolicyPlanPatch(map[string]interface{}{"anyKey": "anyValue"}) - updateBackupPolicyPlanOptionsModel.SetIfMatch(`W/"96d225c4-56bd-43d9-98fc-d7148e5c5028"`) + 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(map[string]interface{}{"anyKey": "anyValue"})) - Expect(updateBackupPolicyPlanOptionsModel.IfMatch).To(Equal(core.StringPtr(`W/"96d225c4-56bd-43d9-98fc-d7148e5c5028"`))) + 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() { @@ -107203,12 +107182,12 @@ var _ = Describe(`VpcV1`, func() { updateInstanceOptionsModel := vpcService.NewUpdateInstanceOptions(id, instancePatch) updateInstanceOptionsModel.SetID("testString") updateInstanceOptionsModel.SetInstancePatch(map[string]interface{}{"anyKey": "anyValue"}) - updateInstanceOptionsModel.SetIfMatch(`W/"96d225c4-56bd-43d9-98fc-d7148e5c5028"`) + updateInstanceOptionsModel.SetIfMatch("W/\"96d225c4-56bd-43d9-98fc-d7148e5c5028\"") updateInstanceOptionsModel.SetHeaders(map[string]string{"foo": "bar"}) Expect(updateInstanceOptionsModel).ToNot(BeNil()) Expect(updateInstanceOptionsModel.ID).To(Equal(core.StringPtr("testString"))) Expect(updateInstanceOptionsModel.InstancePatch).To(Equal(map[string]interface{}{"anyKey": "anyValue"})) - Expect(updateInstanceOptionsModel.IfMatch).To(Equal(core.StringPtr(`W/"96d225c4-56bd-43d9-98fc-d7148e5c5028"`))) + Expect(updateInstanceOptionsModel.IfMatch).To(Equal(core.StringPtr("W/\"96d225c4-56bd-43d9-98fc-d7148e5c5028\""))) Expect(updateInstanceOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) }) It(`Invoke NewUpdateInstanceTemplateOptions successfully`, func() { @@ -107330,12 +107309,12 @@ var _ = Describe(`VpcV1`, func() { updateLoadBalancerOptionsModel := vpcService.NewUpdateLoadBalancerOptions(id, loadBalancerPatch) updateLoadBalancerOptionsModel.SetID("testString") updateLoadBalancerOptionsModel.SetLoadBalancerPatch(map[string]interface{}{"anyKey": "anyValue"}) - updateLoadBalancerOptionsModel.SetIfMatch(`W/"96d225c4-56bd-43d9-98fc-d7148e5c5028"`) + updateLoadBalancerOptionsModel.SetIfMatch("W/\"96d225c4-56bd-43d9-98fc-d7148e5c5028\"") updateLoadBalancerOptionsModel.SetHeaders(map[string]string{"foo": "bar"}) Expect(updateLoadBalancerOptionsModel).ToNot(BeNil()) Expect(updateLoadBalancerOptionsModel.ID).To(Equal(core.StringPtr("testString"))) Expect(updateLoadBalancerOptionsModel.LoadBalancerPatch).To(Equal(map[string]interface{}{"anyKey": "anyValue"})) - Expect(updateLoadBalancerOptionsModel.IfMatch).To(Equal(core.StringPtr(`W/"96d225c4-56bd-43d9-98fc-d7148e5c5028"`))) + Expect(updateLoadBalancerOptionsModel.IfMatch).To(Equal(core.StringPtr("W/\"96d225c4-56bd-43d9-98fc-d7148e5c5028\""))) Expect(updateLoadBalancerOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) }) It(`Invoke NewUpdateLoadBalancerPoolMemberOptions successfully`, func() { @@ -107388,10 +107367,10 @@ var _ = Describe(`VpcV1`, func() { }) It(`Invoke NewUpdateNetworkACLRuleOptions successfully`, func() { // Construct an instance of the UpdateNetworkACLRuleOptions model - networkACLID := "testString" + networkAclid := "testString" id := "testString" networkACLRulePatch := map[string]interface{}{"anyKey": "anyValue"} - updateNetworkACLRuleOptionsModel := vpcService.NewUpdateNetworkACLRuleOptions(networkACLID, id, networkACLRulePatch) + updateNetworkACLRuleOptionsModel := vpcService.NewUpdateNetworkACLRuleOptions(networkAclid, id, networkACLRulePatch) updateNetworkACLRuleOptionsModel.SetNetworkACLID("testString") updateNetworkACLRuleOptionsModel.SetID("testString") updateNetworkACLRuleOptionsModel.SetNetworkACLRulePatch(map[string]interface{}{"anyKey": "anyValue"}) @@ -107493,12 +107472,12 @@ var _ = Describe(`VpcV1`, func() { updateShareOptionsModel := vpcService.NewUpdateShareOptions(id, sharePatch) updateShareOptionsModel.SetID("testString") updateShareOptionsModel.SetSharePatch(map[string]interface{}{"anyKey": "anyValue"}) - updateShareOptionsModel.SetIfMatch(`W/"96d225c4-56bd-43d9-98fc-d7148e5c5028"`) + updateShareOptionsModel.SetIfMatch("W/\"96d225c4-56bd-43d9-98fc-d7148e5c5028\"") updateShareOptionsModel.SetHeaders(map[string]string{"foo": "bar"}) Expect(updateShareOptionsModel).ToNot(BeNil()) Expect(updateShareOptionsModel.ID).To(Equal(core.StringPtr("testString"))) Expect(updateShareOptionsModel.SharePatch).To(Equal(map[string]interface{}{"anyKey": "anyValue"})) - Expect(updateShareOptionsModel.IfMatch).To(Equal(core.StringPtr(`W/"96d225c4-56bd-43d9-98fc-d7148e5c5028"`))) + Expect(updateShareOptionsModel.IfMatch).To(Equal(core.StringPtr("W/\"96d225c4-56bd-43d9-98fc-d7148e5c5028\""))) Expect(updateShareOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) }) It(`Invoke NewUpdateSnapshotConsistencyGroupOptions successfully`, func() { @@ -107508,12 +107487,12 @@ var _ = Describe(`VpcV1`, func() { updateSnapshotConsistencyGroupOptionsModel := vpcService.NewUpdateSnapshotConsistencyGroupOptions(id, snapshotConsistencyGroupPatch) updateSnapshotConsistencyGroupOptionsModel.SetID("testString") updateSnapshotConsistencyGroupOptionsModel.SetSnapshotConsistencyGroupPatch(map[string]interface{}{"anyKey": "anyValue"}) - updateSnapshotConsistencyGroupOptionsModel.SetIfMatch(`W/"96d225c4-56bd-43d9-98fc-d7148e5c5028"`) + updateSnapshotConsistencyGroupOptionsModel.SetIfMatch("W/\"96d225c4-56bd-43d9-98fc-d7148e5c5028\"") updateSnapshotConsistencyGroupOptionsModel.SetHeaders(map[string]string{"foo": "bar"}) Expect(updateSnapshotConsistencyGroupOptionsModel).ToNot(BeNil()) Expect(updateSnapshotConsistencyGroupOptionsModel.ID).To(Equal(core.StringPtr("testString"))) Expect(updateSnapshotConsistencyGroupOptionsModel.SnapshotConsistencyGroupPatch).To(Equal(map[string]interface{}{"anyKey": "anyValue"})) - Expect(updateSnapshotConsistencyGroupOptionsModel.IfMatch).To(Equal(core.StringPtr(`W/"96d225c4-56bd-43d9-98fc-d7148e5c5028"`))) + Expect(updateSnapshotConsistencyGroupOptionsModel.IfMatch).To(Equal(core.StringPtr("W/\"96d225c4-56bd-43d9-98fc-d7148e5c5028\""))) Expect(updateSnapshotConsistencyGroupOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) }) It(`Invoke NewUpdateSnapshotOptions successfully`, func() { @@ -107523,12 +107502,12 @@ var _ = Describe(`VpcV1`, func() { updateSnapshotOptionsModel := vpcService.NewUpdateSnapshotOptions(id, snapshotPatch) updateSnapshotOptionsModel.SetID("testString") updateSnapshotOptionsModel.SetSnapshotPatch(map[string]interface{}{"anyKey": "anyValue"}) - updateSnapshotOptionsModel.SetIfMatch(`W/"96d225c4-56bd-43d9-98fc-d7148e5c5028"`) + updateSnapshotOptionsModel.SetIfMatch("W/\"96d225c4-56bd-43d9-98fc-d7148e5c5028\"") updateSnapshotOptionsModel.SetHeaders(map[string]string{"foo": "bar"}) Expect(updateSnapshotOptionsModel).ToNot(BeNil()) Expect(updateSnapshotOptionsModel.ID).To(Equal(core.StringPtr("testString"))) Expect(updateSnapshotOptionsModel.SnapshotPatch).To(Equal(map[string]interface{}{"anyKey": "anyValue"})) - Expect(updateSnapshotOptionsModel.IfMatch).To(Equal(core.StringPtr(`W/"96d225c4-56bd-43d9-98fc-d7148e5c5028"`))) + Expect(updateSnapshotOptionsModel.IfMatch).To(Equal(core.StringPtr("W/\"96d225c4-56bd-43d9-98fc-d7148e5c5028\""))) Expect(updateSnapshotOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) }) It(`Invoke NewUpdateSubnetOptions successfully`, func() { @@ -107580,12 +107559,12 @@ var _ = Describe(`VpcV1`, func() { updateVolumeOptionsModel := vpcService.NewUpdateVolumeOptions(id, volumePatch) updateVolumeOptionsModel.SetID("testString") updateVolumeOptionsModel.SetVolumePatch(map[string]interface{}{"anyKey": "anyValue"}) - updateVolumeOptionsModel.SetIfMatch(`W/"96d225c4-56bd-43d9-98fc-d7148e5c5028"`) + updateVolumeOptionsModel.SetIfMatch("W/\"96d225c4-56bd-43d9-98fc-d7148e5c5028\"") updateVolumeOptionsModel.SetHeaders(map[string]string{"foo": "bar"}) Expect(updateVolumeOptionsModel).ToNot(BeNil()) Expect(updateVolumeOptionsModel.ID).To(Equal(core.StringPtr("testString"))) Expect(updateVolumeOptionsModel.VolumePatch).To(Equal(map[string]interface{}{"anyKey": "anyValue"})) - Expect(updateVolumeOptionsModel.IfMatch).To(Equal(core.StringPtr(`W/"96d225c4-56bd-43d9-98fc-d7148e5c5028"`))) + Expect(updateVolumeOptionsModel.IfMatch).To(Equal(core.StringPtr("W/\"96d225c4-56bd-43d9-98fc-d7148e5c5028\""))) Expect(updateVolumeOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) }) It(`Invoke NewUpdateVPCAddressPrefixOptions successfully`, func() { @@ -107627,12 +107606,12 @@ var _ = Describe(`VpcV1`, func() { updateVPCOptionsModel := vpcService.NewUpdateVPCOptions(id, vpcPatch) updateVPCOptionsModel.SetID("testString") updateVPCOptionsModel.SetVPCPatch(map[string]interface{}{"anyKey": "anyValue"}) - updateVPCOptionsModel.SetIfMatch(`W/"96d225c4-56bd-43d9-98fc-d7148e5c5028"`) + updateVPCOptionsModel.SetIfMatch("W/\"96d225c4-56bd-43d9-98fc-d7148e5c5028\"") updateVPCOptionsModel.SetHeaders(map[string]string{"foo": "bar"}) Expect(updateVPCOptionsModel).ToNot(BeNil()) Expect(updateVPCOptionsModel.ID).To(Equal(core.StringPtr("testString"))) Expect(updateVPCOptionsModel.VPCPatch).To(Equal(map[string]interface{}{"anyKey": "anyValue"})) - Expect(updateVPCOptionsModel.IfMatch).To(Equal(core.StringPtr(`W/"96d225c4-56bd-43d9-98fc-d7148e5c5028"`))) + Expect(updateVPCOptionsModel.IfMatch).To(Equal(core.StringPtr("W/\"96d225c4-56bd-43d9-98fc-d7148e5c5028\""))) Expect(updateVPCOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) }) It(`Invoke NewUpdateVPCRouteOptions successfully`, func() { @@ -107660,13 +107639,13 @@ var _ = Describe(`VpcV1`, func() { updateVPCRoutingTableOptionsModel.SetVPCID("testString") updateVPCRoutingTableOptionsModel.SetID("testString") updateVPCRoutingTableOptionsModel.SetRoutingTablePatch(map[string]interface{}{"anyKey": "anyValue"}) - updateVPCRoutingTableOptionsModel.SetIfMatch(`W/"96d225c4-56bd-43d9-98fc-d7148e5c5028"`) + updateVPCRoutingTableOptionsModel.SetIfMatch("W/\"96d225c4-56bd-43d9-98fc-d7148e5c5028\"") updateVPCRoutingTableOptionsModel.SetHeaders(map[string]string{"foo": "bar"}) Expect(updateVPCRoutingTableOptionsModel).ToNot(BeNil()) Expect(updateVPCRoutingTableOptionsModel.VPCID).To(Equal(core.StringPtr("testString"))) Expect(updateVPCRoutingTableOptionsModel.ID).To(Equal(core.StringPtr("testString"))) Expect(updateVPCRoutingTableOptionsModel.RoutingTablePatch).To(Equal(map[string]interface{}{"anyKey": "anyValue"})) - Expect(updateVPCRoutingTableOptionsModel.IfMatch).To(Equal(core.StringPtr(`W/"96d225c4-56bd-43d9-98fc-d7148e5c5028"`))) + Expect(updateVPCRoutingTableOptionsModel.IfMatch).To(Equal(core.StringPtr("W/\"96d225c4-56bd-43d9-98fc-d7148e5c5028\""))) Expect(updateVPCRoutingTableOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) }) It(`Invoke NewUpdateVPCRoutingTableRouteOptions successfully`, func() { @@ -107724,12 +107703,12 @@ var _ = Describe(`VpcV1`, func() { updateVPNServerOptionsModel := vpcService.NewUpdateVPNServerOptions(id, vpnServerPatch) updateVPNServerOptionsModel.SetID("testString") updateVPNServerOptionsModel.SetVPNServerPatch(map[string]interface{}{"anyKey": "anyValue"}) - updateVPNServerOptionsModel.SetIfMatch(`W/"96d225c4-56bd-43d9-98fc-d7148e5c5028"`) + updateVPNServerOptionsModel.SetIfMatch("W/\"96d225c4-56bd-43d9-98fc-d7148e5c5028\"") updateVPNServerOptionsModel.SetHeaders(map[string]string{"foo": "bar"}) Expect(updateVPNServerOptionsModel).ToNot(BeNil()) Expect(updateVPNServerOptionsModel.ID).To(Equal(core.StringPtr("testString"))) Expect(updateVPNServerOptionsModel.VPNServerPatch).To(Equal(map[string]interface{}{"anyKey": "anyValue"})) - Expect(updateVPNServerOptionsModel.IfMatch).To(Equal(core.StringPtr(`W/"96d225c4-56bd-43d9-98fc-d7148e5c5028"`))) + Expect(updateVPNServerOptionsModel.IfMatch).To(Equal(core.StringPtr("W/\"96d225c4-56bd-43d9-98fc-d7148e5c5028\""))) Expect(updateVPNServerOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) }) It(`Invoke NewUpdateVPNServerRouteOptions successfully`, func() { @@ -108143,7 +108122,7 @@ var _ = Describe(`VpcV1`, func() { }) It(`Invoke NewLoadBalancerListenerPolicyTargetPrototypeLoadBalancerListenerPolicyRedirectURLPrototype successfully`, func() { httpStatusCode := int64(301) - url := "https://www.redirect.com" + url := "https://www.example.com" _model, err := vpcService.NewLoadBalancerListenerPolicyTargetPrototypeLoadBalancerListenerPolicyRedirectURLPrototype(httpStatusCode, url) Expect(_model).ToNot(BeNil()) Expect(err).To(BeNil()) @@ -108488,7 +108467,7 @@ var _ = Describe(`VpcV1`, func() { Expect(err).ToNot(BeNil()) }) It(`Invoke NewSnapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshots successfully`, func() { - snapshots := []vpcv1.SnapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshotsSnapshotsItem{} + snapshots := []vpcv1.SnapshotPrototypeSnapshotConsistencyGroupContext{} _model, err := vpcService.NewSnapshotConsistencyGroupPrototypeSnapshotConsistencyGroupBySnapshots(snapshots) Expect(_model).ToNot(BeNil()) Expect(err).To(BeNil())